sup3r.preprocessing.rasterizers.exo.ObsRasterizer#
- class ObsRasterizer(feature: str | None = None, file_paths: str | None = None, source_files: str | None = None, source_handler_kwargs: dict | None = None, s_enhance: int = 1, t_enhance: int = 1, input_handler_name: str | None = None, input_handler_kwargs: dict | None = None, cache_dir: str | None = None, chunks: str | dict | None = 'auto', distance_upper_bound: int | None = None, fill_nans: bool = True, scale_factor: float = 1.0, max_workers: int = 1)[source]#
Bases:
BaseExoRasterizerRasterizer for sparse spatiotemporal observation data. This is used in the same way as other rasterizers (provide netcdf or flattened h5 data) but it does not aggregate and leaves NaNs in the output data if there are no observations within the
distance_upper_boundof the target pixel.Note
When setting up a forward pass config file you have to specifiy how to access exogenous features. To automatically select this rasterizer instead of the
BaseExoRasterizername the exogenous feature with an ‘_obs’ suffix. For example, to use this rasterizer with u_10m data, set the feature to ‘u_10m_obs’.See also
ExoRasterizerType agnostic class that returns the correct rasterizer based on the feature name.
Methods
get_data()Get a raster of source values corresponding to the high-resolution grid (the file_paths input grid * s_enhance * t_enhance).
Maximum distance (float) to map high-resolution data from source_files to the low-resolution file_paths input.
query_tree(lat_lon)Query the KDTree for the nearest neighbor indices and distances for the given lat_lon points.
Attributes
STATIC_FEATUREScache_dirGet cache file name
chunksGet coords dictionary for initializing xr.Dataset.
Get a raster of source values corresponding to the high-resolution grid (the file_paths input grid * s_enhance * t_enhance).
distance_upper_boundGet the nearest neighbor indices.
featurefile_pathsfill_nansLat lon grid for data in format (spatial_1, spatial_2, 2) Lat/Lon array with same ordering in last dimension.
Get the high-resolution spatiotemporal shape
Get the full time index for aggregated source data
input_handler_kwargsinput_handler_nameGet the low-resolution spatiotemporal shape
max_workersGet the nearest neighbor indices.
s_enhancescale_factorGet the flattened observation data from the source_files
source_filesGet the Loader object that handles the exogenous data file.
source_handler_kwargsGet the 2D array (n, 2) of lat, lon data from the source_files
t_enhanceGet the KDTree built on the target lat lon data from the file_paths input with s_enhance
- property source_handler#
Get the Loader object that handles the exogenous data file.
- property source_data#
Get the flattened observation data from the source_files
- property cache_file#
Get cache file name
- Returns:
cache_fp (str) – Name of cache file. This is a netcdf file which will be saved with
Cacherand loaded withLoader
- property coords#
Get coords dictionary for initializing xr.Dataset.
- property data#
Get a raster of source values corresponding to the high-resolution grid (the file_paths input grid * s_enhance * t_enhance). The shape is (lats, lons, temporal, 1)
- property dists#
Get the nearest neighbor indices. This uses a single neighbor by default
- get_data()#
Get a raster of source values corresponding to the high-resolution grid (the file_paths input grid * s_enhance * t_enhance). The shape is (lats, lons, temporal)
- get_distance_upper_bound()#
Maximum distance (float) to map high-resolution data from source_files to the low-resolution file_paths input.
- property hr_lat_lon#
Lat lon grid for data in format (spatial_1, spatial_2, 2) Lat/Lon array with same ordering in last dimension. This corresponds to the enhanced meta data from the file_paths input * s_enhance.
- Returns:
ndarray
- property hr_shape#
Get the high-resolution spatiotemporal shape
- property hr_time_index#
Get the full time index for aggregated source data
- property lr_shape#
Get the low-resolution spatiotemporal shape
- property nn#
Get the nearest neighbor indices. This uses a single neighbor by default
- query_tree(lat_lon)#
Query the KDTree for the nearest neighbor indices and distances for the given lat_lon points.
- property source_lat_lon#
Get the 2D array (n, 2) of lat, lon data from the source_files
- property tree#
Get the KDTree built on the target lat lon data from the file_paths input with s_enhance