data0.run_functions =================== .. py:module:: data0.run_functions Functions --------- .. autoapisummary:: data0.run_functions.process_cmd_args data0.run_functions.make_output_metadata_dict data0.run_functions.prepare_input Module Contents --------------- .. py:function:: 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`. :param cmd_args: 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) :type cmd_args: `list` :param verbose: Whether to print the processed command line arguments. Default is True. :type verbose: `bool`, optional :param default_savedir: The default save directory to use if none is found in `cmd_args`. Default is 'HPC_runs/test_unet'. :type default_savedir: `str`, optional :param default_config: The default config file to use if none is found in `cmd_args`. Default is 'input_config'. :type default_config: `str`, optional :param default_version: The default version to use if none is found in `cmd_args`. Default is 1. :type default_version: `int`, optional :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). .. py:function:: 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. :param savedir: The path to the directory in which the data for this run is saved. :type savedir: `str` :param config_path: The path to the configuration JSON file. :type config_path: `str` :param config_dict: The dictionary of the configuration file. :type config_dict: `dict` :param version: The version of the code used in this run (0 or 1). :type version: `int` :param model_fmt: The format in which to output the trained model for this run. Either 'h5', 'keras', or 'both'. :type model_fmt: `str` :returns: **output_metadata** -- The output metadata dictionary. :rtype: `dict` .. py:function:: 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. :param uarr: The dataset of the input NetCDF file. :type uarr: `unox.uarray` :param input_config: Path to the input configuration JSON file or a dictionary containing the configuration. :type input_config: `str` or `dict` :param output_metadata: The dictionary of metadata describing the output of a model run. :type output_metadata: `dict` :param split_year: The year at which to split the training and testing data. Defaults to 2019. :type split_year: `int`, optional :param stage: The stage of the data to plot (1 or 2). :type stage: `int` :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`.