lib.adf_diag

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

_LOCAL_PATH

_DIAG_SCRIPTS_PATH

ermsg

Classes

AdfDiag

Main ADF diagnostics object.

Functions

construct_index_info(page_dict, fnam, opf)

Helper function for generating web pages.

_load_dataset(fils)

This method exists to get an xarray Dataset from input file information that

Module Contents

lib.adf_diag._LOCAL_PATH
lib.adf_diag._DIAG_SCRIPTS_PATH
lib.adf_diag.ermsg = "'Uninferable' directory not found. Has 'AdfDiag.py' been moved?"
lib.adf_diag.construct_index_info(page_dict, fnam, opf)[source]

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

class lib.adf_diag.AdfDiag(config_file, debug=False)[source]

Bases: 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.

__time_averaging_scripts
__regridding_scripts
__analysis_scripts
__plotting_scripts
data
property plotting_scripts

Return a copy of the ‘__plotting_scripts’ string list to user if requested.

__diag_scripts_caller(scripts_dir: str, func_names: list, default_kwargs: dict | None = None, log_section: str | None = 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_sectionoptional variable that specifies where the log entries are coming from.

Note: Is it better to just make a child log instead?

__function_caller(func_name: str, func_kwargs: dict | None = 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)

create_time_series(baseline=False)[source]

Generate time series versions of the CAM history file data.

create_climo()[source]

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).

regrid_climo()[source]

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).

perform_analyses()[source]

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.

create_plots()[source]

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.

setup_run_cvdp()[source]

Create CVDP directory tree, generate namelist file and edit driver.ncl needed to run CVDP. Submit CVDP diagnostics.

derive_variables(res=None, hist_str=None, vars_to_derive=None, ts_dir=None, constit_dict=None, overwrite=None)[source]

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.

setup_run_mdtf()[source]

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)

move_tsfiles_for_mdtf(verbose)[source]

Move ts files to the directory structure and names required by MDTF Should change with data catalogues

lib.adf_diag._load_dataset(fils)[source]

This method exists to get an xarray Dataset from input file information that can be passed into the plotting methods.

Parameters:

fils (list) – strings or paths to input file(s)

Return type:

xr.Dataset

Notes

When just one entry is provided, use open_dataset, otherwise open_mfdatset