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, verbose: bool = False)[source]#

Bases: BaseExoRasterizer

Rasterizer 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_bound of 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 BaseExoRasterizer name 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

ExoRasterizer

Type 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).

get_distance_upper_bound()

Maximum distance (float) to map high-resolution data from source_files to the low-resolution file_paths input.

Attributes

STATIC_FEATURES

cache_dir

cache_file

Get cache file name

chunks

coords

Get coords dictionary for initializing xr.Dataset.

data

Get a raster of source values corresponding to the high-resolution grid (the file_paths input grid * s_enhance * t_enhance).

distance_upper_bound

feature

file_paths

fill_nans

hr_lat_lon

Lat lon grid for data in format (spatial_1, spatial_2, 2) Lat/Lon array with same ordering in last dimension.

hr_shape

Get the high-resolution spatiotemporal shape

hr_time_index

Get the full time index for aggregated source data

input_handler_kwargs

input_handler_name

lr_shape

Get the low-resolution spatiotemporal shape

max_workers

nn

Get the nearest neighbor indices.

s_enhance

scale_factor

source_data

Get the flattened observation data from the source_files

source_files

source_handler

Get the Loader object that handles the exogenous data file.

source_handler_kwargs

source_lat_lon

Get the 2D array (n, 2) of lat, lon data from the source_files

t_enhance

tree

Get the KDTree built on the target lat lon data from the file_paths input with s_enhance

verbose

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 Cacher and loaded with Loader

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)

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

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