lib.adf_diag ============ .. py:module:: lib.adf_diag .. autoapi-nested-parse:: Location of the "AdfDiag" object, which is used to store all relevant data and info needed for generating CAM/ADF diagnostics, including info on the averaging, regridding, and plotting methods themselves. Attributes ---------- .. autoapisummary:: lib.adf_diag._LOCAL_PATH lib.adf_diag._DIAG_SCRIPTS_PATH lib.adf_diag.ermsg Classes ------- .. autoapisummary:: lib.adf_diag.AdfDiag Functions --------- .. autoapisummary:: lib.adf_diag.construct_index_info lib.adf_diag._load_dataset Module Contents --------------- .. py:data:: _LOCAL_PATH .. py:data:: _DIAG_SCRIPTS_PATH .. py:data:: ermsg :value: "'Uninferable' directory not found. Has 'AdfDiag.py' been moved?" .. py:function:: construct_index_info(page_dict, fnam, opf) Helper function for generating web pages. d : dictionary for the index page information fnam : the image filename, img.stem --> then decompose the img file's parts. opf: outputfile for the image .. py:class:: AdfDiag(config_file, debug=False) Bases: :py:obj:`lib.adf_web.AdfWeb` Main ADF diagnostics object. This object is initalized using an ADF diagnostics configure (YAML) file, which specifies various user inputs, including CAM history file names and locations, years being analyzed, types of averaging, regridding, and other post-processing options being used, and the type of plots that will be created. This object also contains various methods used to actually generate the plots and post-processed data. .. py:attribute:: __time_averaging_scripts .. py:attribute:: __regridding_scripts .. py:attribute:: __analysis_scripts .. py:attribute:: __plotting_scripts .. py:attribute:: data .. py:property:: plotting_scripts Return a copy of the '__plotting_scripts' string list to user if requested. .. py:method:: __diag_scripts_caller(scripts_dir: str, func_names: list, default_kwargs: Optional[dict] = None, log_section: Optional[str] = None) Parse a list of scripts as provided by the config file, and call them as functions while passing in the correct inputs. scripts_dir : string, sub-directory under "scripts" where scripts are located func_names : list of function/scripts (either string or dictionary): default_kwargs : optional list of default keyword arguments for the scripts if none are specified by the config file log_section : optional variable that specifies where the log entries are coming from. Note: Is it better to just make a child log instead? .. py:method:: __function_caller(func_name: str, func_kwargs: Optional[dict] = None, module_name=None) Call a function with given arguments. func_name : string, name of the function to call func_kwargs : [optional] dict, the keyword arguments to pass to the function module_name : [optional] string, the name of the module where func_name is defined; if not provided, assume func_name.py return : the output of func_name(self, **func_kwargs) .. py:method:: create_time_series(baseline=False) Generate time series versions of the CAM history file data. .. py:method:: create_climo() Temporally average CAM time series data in order to generate CAM climatologies. The actual averaging is done using the scripts listed under "time_averaging_scripts" as specified in the config file. This is done so that the user can specify the precise kinds of averaging that are done (e.g. weighted vs. non-weighted averaging). .. py:method:: regrid_climo() Re-grid CAM climatology files to observations or baseline climatologies, in order to allow for direct comparisons. The actual regridding is done using the scripts listed under "regridding_scripts" as specified in the config file. This is done so that the user can specify the precise kinds of re-gridding that are done (e.g. bilinear vs. nearest-neighbor regridding). .. py:method:: perform_analyses() Performs statistical and other analyses as specified by the user. This currently only includes the AMWG table generation. This method also assumes that the analysis scripts require model inputs in a time series format. .. py:method:: create_plots() Generate ADF diagnostic plots. The actual plotting is done using the scripts listed under "plotting_scripts" as specified in the config file. This is done so that the user can add their own plotting script(s) without having to modify the main ADF diagnostics routines. .. py:method:: setup_run_cvdp() Create CVDP directory tree, generate namelist file and edit driver.ncl needed to run CVDP. Submit CVDP diagnostics. .. py:method:: derive_variables(res=None, hist_str=None, vars_to_derive=None, ts_dir=None, constit_dict=None, overwrite=None) Derive variables acccording to steps given here. Since derivations will depend on the variable, each variable to derive will need its own set of steps below. Caution: this method assumes that there will be one time series file per variable If the file for the derived variable exists, the kwarg `overwrite` determines whether to overwrite the file (true) or exit with a warning message. .. py:method:: setup_run_mdtf() Create MDTF directory tree, generate input settings jsonc file Submit MDTF diagnostics. Returns mdtf_proc for sub-process control (waits for it to finish in run_adf_diag) .. py:method:: move_tsfiles_for_mdtf(verbose) Move ts files to the directory structure and names required by MDTF Should change with data catalogues .. py:function:: _load_dataset(fils) This method exists to get an xarray Dataset from input file information that can be passed into the plotting methods. :param fils: strings or paths to input file(s) :type fils: list :rtype: xr.Dataset .. rubric:: Notes When just one entry is provided, use `open_dataset`, otherwise `open_mfdatset`