nsrdb.data_model.variable_factory.VarFactory
- class VarFactory[source]
Bases:
object
Factory pattern to retrieve ancillary variable helper objects.
Methods
get_base_handler
(*args, **kwargs)Get the base ancillary variable handler to parse var meta.
get_class
(var_name, **kwargs)Get the Class that is used to process the target variable
get_cloud_handler
(fpath[, dsets])Get a cloud data file handler object.
get_dset_attrs
(dset[, var_meta])Use the variable factory to get output attributes for a single dset.
get_dsets_attrs
(dsets[, var_meta])Use the variable factory to get output attributes for list of dsets.
get_instance
(var_name, *args, **kwargs)Get a processing variable instance for the given var name.
Attributes
HANDLER_NAMES
MAPPING
- classmethod get_instance(var_name, *args, **kwargs)[source]
Get a processing variable instance for the given var name.
- Parameters:
var_name (str) – NSRDB variable name.
*args (list) – List of positional args for instantiation of ancillary var.
**kwargs (dict) – List of keyword args for instantiation of ancillary var. Can also include “handler” which specifies the handler name explicitly.
- Returns:
instance (ancillary object) – Instantiated ancillary variable helper object (AsymVar, MerraVar).
- classmethod get_class(var_name, **kwargs)[source]
Get the Class that is used to process the target variable
- Parameters:
var_name (str) – NSRDB variable name.
**kwargs (dict) – List of keyword args for instantiation of ancillary var. Can also include “handler” which specifies the handler name explicitly.
- Returns:
HandlerClass (ancillary class) – Uninstantiated ancillary class (AsymVar, MerraVar).
- static get_base_handler(*args, **kwargs)[source]
Get the base ancillary variable handler to parse var meta.
- Parameters:
*args (list) – List of positional args for instantiation of ancillary var.
**kwargs (dict) – List of keyword args for instantiation of ancillary var.
- Returns:
instance (AncillaryVarHandler) – Instantiated base ancillary variable helper object.
- classmethod get_dset_attrs(dset, var_meta=None)[source]
Use the variable factory to get output attributes for a single dset.
- Parameters:
dset (str) – Single dataset / variable name.
var_meta (str | pd.DataFrame | None) – CSV file or dataframe containing meta data for all NSRDB variables. Defaults to the NSRDB var meta csv in git repo.
- Returns:
attrs (dict) – Dictionary of dataset attributes.
chunks (tuple) – Chunk shape tuple.
dtype (dict) – Numpy datatype.
- classmethod get_dsets_attrs(dsets, var_meta=None)[source]
Use the variable factory to get output attributes for list of dsets.
- Parameters:
dsets (list) – List of dataset / variable names.
var_meta (str | pd.DataFrame | None) – CSV file or dataframe containing meta data for all NSRDB variables. Defaults to the NSRDB var meta csv in git repo.
- Returns:
attrs (dict) – Dictionary of dataset attributes keyed by dset name.
chunks (dict) – Dictionary of chunk tuples keyed by dset name.
dtypes (dict) – dictionary of numpy datatypes keyed by dset name.
- static get_cloud_handler(fpath, dsets=None, **kwargs)[source]
Get a cloud data file handler object.
- Parameters:
fpath (str) – Full file path to cloud data file, must be either a .h5 or .nc
dsets (NoneType | list | tuple) – Datasets of interest from cloud data file. None means only the grid data is of itnerest.
- Returns:
out (CloudVarSingleH5/NC) – Instantiated CloudVarSingle object appropraite for the .h5 or .nc fpath.