sup3r.preprocessing.data_handlers.exo.ExoDataHandler#
- class ExoDataHandler(feature: str, file_paths: str | list | Path, model: Sup3rGan | MultiStepGan | None = None, steps: list | None = None, **exo_rasterizer_kwargs)[source]#
Bases:
object
Class to rasterize exogenous features for multistep forward passes. e.g. Multiple topography arrays at different resolutions for multiple spatial enhancement steps.
This takes a list of models and uses the different sets of models features to retrieve and rasterize exogenous data according to the requested target coordinate and grid shape, for each model step.
Get list of steps with types of exogenous data needed for retrieval, initialize self.data, and update self.data for each model step with rasterized exo data.
- Parameters:
feature (str) – Exogenous feature to extract from file_paths
file_paths (str | list) – A single source h5 file or netcdf file to extract raster data from. The string can be a unix-style file path which will be passed through glob.glob. This is typically low-res WRF output or GCM netcdf data that is source low-resolution data intended to be sup3r resolved.
model (Sup3rGan | MultiStepGan) – Model used to get exogenous data. If a
MultiStepGan
lr_features
,hr_exo_features
, andhr_out_features
will be checked for each model inmodel.models
and exogenous data will be retrieved based on the resolution required for that type of feature. e.g. If a model has topography as a lr and hr_exo feature, and the model performs 5x spatial enhancement with an input resolution of 30km then topography at 30km and at 6km will be retrieved. Either this or list of steps needs to be provided.steps (list) – List of dictionaries containing info on which models to use for a given step index and what type of exo data the step requires. e.g.:: [{‘model’: 0, ‘combine_type’: ‘input’},
{‘model’: 0, ‘combine_type’: ‘layer’}]
Each step entry can also contain enhancement factors. e.g.:: [{‘model’: 0, ‘combine_type’: ‘input’, ‘s_enhance’: 1, ‘t_enhance’: 1},
{‘model’: 0, ‘combine_type’: ‘layer’, ‘s_enhance’: 3, ‘t_enhance’: 1}]
exo_rasterizer_kwargs (dict) – Keyword arguments passed to the
BaseExoRasterizer
class.
Methods
Get exo data for each model step.
get_exo_rasterizer
(s_enhance, t_enhance)Get exo rasterizer instance for given enhancement factors
get_exo_steps
(feature, models)Get list of steps describing how to use exogenous data for the given feature in the list of given models.
get_single_step_data
(s_enhance, t_enhance)Get exo data for a single model step, with specific enhancement factors.
Attributes
Get exo data cache file for all enhancement factors
- classmethod get_exo_steps(feature, models)[source]#
Get list of steps describing how to use exogenous data for the given feature in the list of given models. This checks the input and exo feature lists for each model step and adds that step if the given feature is found in the list.
- get_exo_rasterizer(s_enhance, t_enhance)[source]#
Get exo rasterizer instance for given enhancement factors
- get_single_step_data(s_enhance, t_enhance)[source]#
Get exo data for a single model step, with specific enhancement factors.
- property cache_files#
Get exo data cache file for all enhancement factors