melodies_monet.driver
Driver routines.
- 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.
- concat_pairs()
Read and concatenate all observation and model time interval pair data, populating the
paireddict.- Returns:
None
- normalize_obs_gridded_data()
Normalize accumulated grid data by dividing sums by counts.
Creates
obs_gridded_datasetcontaining data and count arrays for each observation/variable combination. Grid cells with zero observations are set to NaN.
- open_models(time_interval=None, load_files=True)
Open all models listed in the input yaml file and create a
modelobject for each of them, populating themodelsdict.- 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
observationinstance for each of them, populating theobsdict.- 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
paireddict.- 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 inpaired.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
analysisinstance attributes.- Parameters:
control (
str) – Input yaml file path. If provided,controlwill 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()
Create a uniform observation grid for accumulating swath data.
Reads
obs_gridconfiguration (start_time, end_time, ntime, nlat, nlon) from the control dictionary and initializes:obs_grid— grid center coordinates (longitude, latitude, time)obs_edges— grid cell edge arraysobs_gridded_data— zero arrays for data accumulationobs_gridded_count— zero arrays for count accumulation
- 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
- update_obs_gridded_data()
Accumulate swath observations onto the uniform grid.
For each observation dataset and time step, extracts lat/lon coordinates and data values, bins observations into grid cells, and accumulates sums and counts using Numba-accelerated
update_data_grid().
- add_logo
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.
- 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
modelinstance 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
observationobject.
- 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
- 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.DataFrameorxarray.Dataset).