sup3r.preprocessing.derivers.base.BaseDeriver#
- class BaseDeriver(data: Sup3rX | Sup3rDataset, features, FeatureRegistry=None, interp_kwargs=None)[source]#
Bases:
ContainerContainer subclass with additional methods for transforming / deriving data exposed through an
Rasterizerobject.- Parameters:
data (Union[Sup3rX, Sup3rDataset]) – Data to use for derivations. Usually comes from the .data attribute of a
Rasterizerobject.features (list) – List of feature names to derive from the
Rasterizerdata. TheRasterizerobject contains the features available to use in the derivation. e.g. rasterizer.features = [‘windspeed’, ‘winddirection’] with self.features = [‘U’, ‘V’]FeatureRegistry (Dict) – Optional FeatureRegistry dictionary to use for derivation method lookups. When the
Deriveris asked to derive a feature that is not found in theRasterizerdata it will look for a method to derive the feature in the registry.interp_kwargs (dict | None) – Dictionary of kwargs for level interpolation. Can include “method” and “run_level_check” keys. Method specifies how to perform height interpolation. e.g. Deriving u_20m from u_10m and u_100m. Options are “linear” and “log”. See
sup3r.preprocessing.derivers.Deriver.do_level_interpolation()
Methods
check_registry(feature)Get compute method from the registry if available.
collect_input_attrs(feature[, inputs])Collect attributes from the input features for the given feature.
derive(feature)Routine to derive requested features.
do_level_interpolation(feature[, interp_kwargs])Interpolate over height or pressure to derive the given feature.
get_inputs(feature)Get inputs for the given feature and inputs for those inputs.
get_multi_level_data(feature)Get data stored in multi-level arrays, like u stored on pressure levels.
get_single_level_data(feature)When doing level interpolation we should include the single level data available.
has_interp_variables(feature)Check if the given feature can be interpolated from values at nearby heights or from pressure level data.
map_new_name(feature, pattern)If the search for a derivation method first finds an alternative name for the feature we want to derive, by matching a wildcard pattern, we need to replace the wildcard with the specific height or pressure we want and continue the search for a derivation method with this new name.
no_overlap(feature)Check if any of the nested inputs for 'feature' contain 'feature'
post_init_log([args_dict])Log additional arguments after initialization.
wrap(data)Return a
Sup3rDatasetobject or tuple of such.Attributes
- property data#
Return underlying data.
- Returns:
See also
- check_registry(feature) ndarray | Array | str | None[source]#
Get compute method from the registry if available. Will check for pattern feature match in feature registry. e.g. if u_100m matches a feature registry entry of u_(.*)m
- map_new_name(feature, pattern)[source]#
If the search for a derivation method first finds an alternative name for the feature we want to derive, by matching a wildcard pattern, we need to replace the wildcard with the specific height or pressure we want and continue the search for a derivation method with this new name.
- has_interp_variables(feature)[source]#
Check if the given feature can be interpolated from values at nearby heights or from pressure level data. e.g. If
u_10mandu_50mexist thenu_30mcan be interpolated from these. If a pressure level arrayuis available this can also be used, in conjunction with height data.
- derive(feature) ndarray | Array[source]#
Routine to derive requested features. Employs a little recursion to locate differently named features with a name map in the feature registry. i.e. if FEATURE_REGISTRY contains a key, value pair like “windspeed”: “wind_speed” then requesting “windspeed” will ultimately return a compute method (or fetch from raw data) for “wind_speed
Note
Features are all saved as lower case names and __contains__ checks will use feature.lower()
- get_single_level_data(feature)[source]#
When doing level interpolation we should include the single level data available. e.g. If we have u_100m already and want to interpolate u_40m from multi-level data U we should add u_100m at height 100m before doing interpolation, since 100 could be a closer level to 40m than those available in U.
- get_multi_level_data(feature)[source]#
Get data stored in multi-level arrays, like u stored on pressure levels.
- collect_input_attrs(feature, inputs=None)[source]#
Collect attributes from the input features for the given feature.
- do_level_interpolation(feature, interp_kwargs=None) DataArray[source]#
Interpolate over height or pressure to derive the given feature.
- post_init_log(args_dict=None)#
Log additional arguments after initialization.
- property shape#
Get shape of underlying data.
- wrap(data)#
Return a
Sup3rDatasetobject or tuple of such. This is a tuple when the.dataattribute belongs to aCollectionobject likeBatchHandler. Otherwise this isSup3rDatasetobject, which is either a wrapped 3-tuple, 2-tuple, or 1-tuple (e.g.len(data) == 3,len(data) == 2orlen(data) == 1). This is a 3-tuple when.databelongs to a container object likeDualSamplerWithObs, a 2-tuple when.databelongs to a dual container object likeDualSampler, and a 1-tuple otherwise.