melodies_monet.driver

Drive the entire analysis package via the analysis class.

Classes

analysis()

The analysis class.

model()

The model class.

observation()

The observation class.

pair()

The pair class.

class melodies_monet.driver.analysis

The analysis class.

The analysis class is the highest level class and stores all information about the analysis. It reads and stores information from the input yaml file and defines overarching analysis information like the start and end time, which models and observations to pair, etc.

__init__()

Initialize an analysis object.

concat_pairs()

Read and concatenate all observation and model time interval pair data, populating the paired dict.

Returns:

None

open_models(time_interval=None, load_files=True)

Open all models listed in the input yaml file and create a model object for each of them, populating the models dict.

Parameters:
  • time_interval (optional, default None) ([pandas.Timestamp, pandas.Timestamp]) – If not None, restrict models to datetime range spanned by time interval [start, end].

  • load_files (optional, default True) (boolean) – If False, only populate :attr: dict with yaml file parameters and do not open model files.

Returns:

None

open_obs(time_interval=None, load_files=True)

Open all observations listed in the input yaml file and create an observation instance for each of them, populating the obs dict.

Parameters:
  • time_interval (optional, default None) ([pandas.Timestamp, pandas.Timestamp]) – If not None, restrict obs to datetime range spanned by time interval [start, end].

  • load_files (optional, default True) (boolean) – If False, only populate :attr: dict with yaml file parameters and do not open obs files.

Returns:

None

pair_data(time_interval=None)

Pair all observations and models in the analysis class (i.e., those listed in the input yaml file) together, populating the paired dict.

Parameters:

time_interval (optional, default None) ([pandas.Timestamp, pandas.Timestamp]) – If not None, restrict pairing to datetime range spanned by time interval [start, end].

Returns:

None

plotting()

Cycle through all the plotting groups (e.g., plot_grp1) listed in the input yaml file and create the plots.

This routine loops over all the domains and model/obs pairs specified in the plotting group (.control_dict['plots']) for all the variables specified in the mapping dictionary listed in paired.

Creates plots stored in the file location specified by output_dir in the analysis section of the yaml file.

Returns:

None

read_analysis()

Read all previously saved analysis attributes listed in analysis section of input yaml file.

Returns:

None

read_control(control=None)

Read the input yaml file, updating various analysis instance attributes.

Parameters:

control (str) – Input yaml file path. If provided, control will be set to this value.

Returns:

type – Reads the contents of the yaml control file into a dictionary associated with the analysis class.

save_analysis()

Save all analysis attributes listed in analysis section of input yaml file.

Returns:

None

setup_obs_grid()

Setup a uniform observation grid.

setup_regridders()

Create an obs xesmf.Regridder from base and target grids specified in the control_dict

Returns:

None

stats()

Calculate statistics specified in the input yaml file.

This routine loops over all the domains and model/obs pairs for all the variables specified in the mapping dictionary listed in paired.

Creates a csv file storing the statistics and optionally a figure visualizing the table.

Returns:

None

Add the MELODIES MONET logo to the plots.

Type:

bool, default=True

models

Models, set by open_models().

Type:

dict

obs

Observations, set by open_obs().

Type:

dict

paired

Paired data, set by pair_data().

Type:

dict

class melodies_monet.driver.model

The model class.

A class with information and data from model results.

__init__()

Initialize a model object.

glob_files()

Convert the model file location string read in by the yaml file into a list of files containing all model data.

Returns:

None

mask_and_scale()

Mask and scale model data including unit conversions.

Returns:

None

open_model_files(time_interval=None, control_dict=None)

Open the model files, store data in model instance attributes, and apply mask and scaling.

Models supported are cmaq, wrfchem, ufs (rrfs is deprecated), and gsdchem. If a model is not supported, MELODIES-MONET will try to open the model data using a generic reader. If you wish to include new models, add the new model option to this module.

Parameters:

time_interval (optional, default None) ([pandas.Timestamp, pandas.Timestamp]) – If not None, restrict models to datetime range spanned by time interval [start, end].

Returns:

None

rename_vars()

Rename any variables in model with rename set.

Returns:

None

sum_variables()

Sum any variables noted that should be summed to create new variables. This occurs after any unit scaling.

Returns:

None

class melodies_monet.driver.observation

The observation class.

A class with information and data from an observational dataset.

__init__()

Initialize an observation object.

add_coordinates_ground()

Add latitude and longitude coordinates to data when the observation type is ground and ground_coordinate is specified

Returns:

None

filter_obs()

Filter observations based on filter_dict.

Returns:

None

mask_and_scale()

Mask and scale observations, including unit conversions and setting detection limits.

Returns:

None

obs_to_df()

Convert and reformat observation object (obj) to dataframe.

Returns:

None

open_obs(time_interval=None, control_dict=None)

Open the observational data, store data in observation pair, and apply mask and scaling.

Parameters:

time_interval (optional, default None) ([pandas.Timestamp, pandas.Timestamp]) – If not None, restrict obs to datetime range spanned by time interval [start, end].

Returns:

None

open_sat_obs(time_interval=None, control_dict=None)

Methods to opens satellite data observations. Uses in-house python code to open and load observations. Alternatively may use the satpy reader. Fills the object class associated with the equivalent label (self.label) with satellite observation dataset read in from the associated file (self.file) by the satellite file reader

Parameters:

time_interval (optional, default None) ([pandas.Timestamp, pandas.Timestamp]) – If not None, restrict obs to datetime range spanned by time interval [start, end].

Returns:

None

rename_vars()

Rename any variables in observation with rename set.

Returns:

None

resample_data()

Resample the obs df based on the value set in the control file.

Returns:

None

sum_variables()

Sum any variables noted that should be summed to create new variables. This occurs after any unit scaling.

Returns:

None

obj

The data object (pandas.DataFrame or xarray.Dataset).

class melodies_monet.driver.pair

The pair class.

The pair class pairs model data directly with observational data along time and space.

__init__()

Initialize a pair object.

fix_paired_xarray(dset)

Reformat the paired dataset.

Parameters:

dset (xarray.Dataset)

Returns:

xarray.Dataset – Reformatted paired dataset.