sup3r.preprocessing.derivers.base.BaseDeriver#

class BaseDeriver(data: Sup3rX | Sup3rDataset, features, FeatureRegistry=None, interp_kwargs=None)[source]#

Bases: Container

Container subclass with additional methods for transforming / deriving data exposed through an Rasterizer object.

Parameters:
  • data (Union[Sup3rX, Sup3rDataset]) – Data to use for derivations. Usually comes from the .data attribute of a Rasterizer object.

  • features (list) – List of feature names to derive from the Rasterizer data. The Rasterizer object 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 Deriver is asked to derive a feature that is not found in the Rasterizer data 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.

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 Sup3rDataset object or tuple of such.

Attributes

FEATURE_REGISTRY

data

Return underlying data.

shape

Get shape of underlying data.

property data#

Return underlying data.

Returns:

Sup3rDataset

See also

wrap()

get_inputs(feature)[source]#

Get inputs for the given feature and inputs for those inputs.

no_overlap(feature)[source]#

Check if any of the nested inputs for ‘feature’ contain ‘feature’

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_10m and u_50m exist then u_30m can be interpolated from these. If a pressure level array u is 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.

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 Sup3rDataset object or tuple of such. This is a tuple when the .data attribute belongs to a Collection object like BatchHandler. Otherwise this is Sup3rDataset object, which is either a wrapped 2-tuple or 1-tuple (e.g. len(data) == 2 or len(data) == 1). This is a 2-tuple when .data belongs to a dual container object like DualSampler and a 1-tuple otherwise.