wavy.model_module

The main task of this module is to acquire, read, and prepare geophysical variables from model output files for further use.

Attributes

model_dict

variable_def

Classes

model_class

class to read and process model data

Functions

crop_to_period(ds, sd, ed)

Function to crop the dataset to a given period

check_date(filelst, date)

Checks if str in lst according to desired date (sd, ed)

generate_bestguess_leadtime(model, fc_date[, lidx])

fct to return leadtimes for bestguess

read_model_nc_output_lru(filestr, lonsname, latsname, ...)

Module Contents

wavy.model_module.crop_to_period(ds, sd, ed)

Function to crop the dataset to a given period

wavy.model_module.check_date(filelst, date)

Checks if str in lst according to desired date (sd, ed)

return: idx for file

wavy.model_module.generate_bestguess_leadtime(model, fc_date, lidx=None, **kwargs)

fct to return leadtimes for bestguess

wavy.model_module.read_model_nc_output_lru(filestr, lonsname, latsname, timename)
wavy.model_module.model_dict
wavy.model_module.variable_def
class wavy.model_module.model_class(**kwargs)

Bases: wavy.quicklookmod.quicklook_class_sat

class to read and process model data model: e.g. Hs[time,lat,lon], lat[rlat,rlon], lon[rlat,rlon] This class should communicate with the satellite, model, and station classes.

sd
ed
nID
model
varalias
units
stdvarname
distlim
filter
region
leadtime
cfg
crop_to_period(**kwargs)

Function to crop the variable dictionary to a given period

get_item_parent(item, attr)

Offers possibility to explore netcdf meta info. by specifying what you are looking for (item), e.g. part of a string, and in which attribute (attr), e.g. standard_name, this function returns the parent parameter name of the query string.

param:

item - (partial) string e.g. [m] attr - attribute e.g. units

return: list of matching parameter strings

e.g. for satellite_class object sco:

sco.get_item_parent('m','units')
get_item_child(item)

Gets all attributes connected to given parameter name.

param:

item - (partial) string e.g. [m]

return: matching parameter string

e.g. for satellite_class object sco:

sco.get_item_child('time')
_get_model_filedate(fc_date, leadtime, **kwargs)

get init_date for latest model output file and checks if available

param:

fc_date - datetime object leadtime - integer in hours

return:

suitable datetime to create model filename

_make_model_filename(fc_date, leadtime, **kwargs)

creates/returns filename based on fc_date,leadtime

param: fc_date - datetime object leadtime - integer in hours

return:

filename (consists of path + filename)

comment:
  • special characters are escaped by adding “"

  • the escapes need to be removed for certain libraries like xarray and netCDF4

_make_model_filename_wrapper(fc_date, leadtime, **kwargs)

Wrapper function of make_model_filename. Organizes various cases.

param:

model - modelname type(str) fc_date - datetime object leadtime - integer in hours

return:

filename

_make_list_of_model_filenames(fc_dates, lt, **kwargs)
return: flst - list of model files to be opened

dlst - list of dates to be chosen within each file

_get_files(dict_for_sub=None, path=None, wavy_path=None, **kwargs)

Function to retrieve list of files/paths for available locally stored data. This list is used for other functions to query and parsing.

param:

sd - start date (datetime object) ed - end date (datetime object) nID - nID as of model_cfg.yaml dict_for_sub - dictionary for substitution in templates path - a path if defined

return:

pathlst - list of paths filelst - list of files

list_input_files(show=False, **kwargs)
_get_model(**kwargs)

Main function to obtain data from satellite missions. reads files, apply region and temporal filter

return: adjusted dictionary according to spatial and

temporal constraints

_enforce_longitude_format(**kwargs)
_enforce_meteorologic_convention(**kwargs)
_change_varname_to_aliases(**kwargs)
_change_stdvarname_to_cfname(**kwargs)
populate(**kwargs)