melodies_monet.util.read_util
Functions
|
Function to read netcdf4 files containing an object within an attribute of a part of the analysis class (models, obs, paired). |
|
Function to read a pickle file containing part of the analysis class (models, obs, paired) |
|
Read previously saved dict containing melodies-monet data ( |
|
Remake dict containing driver class instances from dict of xarray datasets. |
- melodies_monet.util.read_util.read_analysis_ncf(filenames, xr_kws={})
Function to read netcdf4 files containing an object within an attribute of a part of the analysis class (models, obs, paired). For example, a single model/obs pairing or a single model. If the object is saved in multiple files, the function will merge the files.
- Parameters
filenames (
str
oriterable
) – Description of parameter filename.xr_kws (optional) – Additional keyword arguments for xr.open_dataset()
- Returns
ds_out (
type
) – Xarray dataset containing merged files.
- melodies_monet.util.read_util.read_pkl(filename)
Function to read a pickle file containing part of the analysis class (models, obs, paired)
- Parameters
filename (
type
) – Description of parameter filename.- Returns
obj (
type
) – Description of returned object.
- melodies_monet.util.read_util.read_saved_data(analysis, filenames, method, attr, xr_kws={})
Read previously saved dict containing melodies-monet data (
paired
,models
, orobs
) from pickle file or netcdf file, populating thepaired
,models
, orobs
dict.- Parameters
analysis (
melodies_monet.driver.analysis
) – Instance of the analysis class from driver script.filenames (
str
oriterable
) – str or list for reading in pkl. For netCDF, must be dict with format {group1:str or iterable of filenames, group2:…}method (
str
) – One of either ‘pkl’ or ‘netcdf’.attr (
str
) – The analysis attribute that will be populated with the saved data. One of either ‘paired’ or ‘models’ or ‘obs’.**kwargs (optional) – Additional keyword arguments for xr.open_dataset()
- Returns
None
- melodies_monet.util.read_util.xarray_to_class(class_type, group_ds)
Remake dict containing driver class instances from dict of xarray datasets. Dict of xarray datasets must contain global attribute that contains json formatted class attributes.
- Parameters
class_type (
str
) – One of ‘model’, ‘pair’ or ‘observation’group_ds (
dict
) – dict containing xarray datasets from read_grouped_ncf.
- Returns
class_dict