data0.run_functions
Functions
|
Process command line arguments given to run_model.py. |
|
Create the dictionary of metadata for a run to be output to a dictionary. |
|
Prepare the input data for the model. |
Module Contents
- data0.run_functions.process_cmd_args(cmd_args, verbose=True, default_savedir='HPC_runs/test_unet0', default_config='input_config', default_version=1)
Process command line arguments given to run_model.py.
- Parameters:
cmd_args (list) – The list of command line arguments given to run_model.py. Assumes the arguments are: - arg 0: script name (i.e., run_model.py) - arg 1: savedir, the directory in which to save model outputs - arg 2: version, the version of the packages to import (0 or 1)
verbose (bool, optional) – Whether to print the processed command line arguments. Default is True.
default_savedir (str, optional) – The default save directory to use if none is found in cmd_args. Default is ‘HPC_runs/test_unet’.
default_config (str, optional) – The default config file to use if none is found in cmd_args. Default is ‘input_config’.
default_version (int, optional) – The default version to use if none is found in cmd_args. Default is 1.
- Returns:
savedir (str) – The path to the directory in which to save model outputs.
config_dict (dict) – The model configuration dictionary.
config_path (str) – The path to the configuration file used.
version (int) – The version of the packages to use for running the model (0 or 1).
- data0.run_functions.make_output_metadata_dict(savedir, config_path, config_dict, version, model_fmt)
Create the dictionary of metadata for a run to be output to a dictionary.
- Parameters:
savedir (str) – The path to the directory in which the data for this run is saved.
config_path (str) – The path to the configuration JSON file.
config_dict (dict) – The dictionary of the configuration file.
version (int) – The version of the code used in this run (0 or 1).
model_fmt (str) – The format in which to output the trained model for this run. Either ‘h5’, ‘keras’, or ‘both’.
- Returns:
output_metadata – The output metadata dictionary.
- Return type:
dict
- data0.run_functions.prepare_input(uarr, input_config, output_metadata, split_year=2019, stage=1)
Prepare the input data for the model.
Get the training data from the input NetCDF dataset as numpy arrays and concatenate them along the time dimension.
- Parameters:
uarr (unox.uarray) – The dataset of the input NetCDF file.
input_config (str or dict) – Path to the input configuration JSON file or a dictionary containing the configuration.
output_metadata (dict) – The dictionary of metadata describing the output of a model run.
split_year (int, optional) – The year at which to split the training and testing data. Defaults to 2019.
stage (int) – The stage of the data to plot (1 or 2).
- Returns:
xtrain (np.ndarray) – Concatenated training input features.
ytrain (np.ndarray) – Concatenated training target variables.
output_metadata (dict) – The dictionary of metadata describing the output of a model run with values added for train_years and unet_build_shape.