pyresample.future.resamplers.resampler module

Base resampler class made for subclassing.

class pyresample.future.resamplers.resampler.Resampler(source_geo_def, target_geo_def, cache=None)

Bases: object

Base abstract resampler class.

Initialize resampler with geolocation information.

Parameters:
__init__(source_geo_def, target_geo_def, cache=None)

Initialize resampler with geolocation information.

Parameters:
precompute(**kwargs)

Do the precomputation.

This is an optional step if the subclass wants to implement more complex features like caching or can share some calculations between multiple datasets to be processed.

resample(data)

Resample input data from the source geometry to the target geometry.

Parameters:

data (ArrayLike) – Data to be resampled

Returns (ArrayLike): Data resampled to the target area

abstract property version: str

Get version number string of the current resampler for hashing and caching.

In cases where a resampler has changed enough that past cached files are not usable then this version number will be incremented to distinguish between the cache entries.

pyresample.future.resamplers.resampler.add_crs_xy_coords(data_arr, area)

Add pyproj.crs.CRS and x/y or lons/lats to coordinates.

For SwathDefinition or GridDefinition areas this will add a crs coordinate and coordinates for the 2D arrays of lons and lats.

For AreaDefinition areas this will add a crs coordinate and the 1-dimensional x and y coordinate variables.

Parameters:
pyresample.future.resamplers.resampler.add_xy_coords(data_arr, area, crs=None)

Assign x/y coordinates to DataArray from provided area.

If ‘x’ and ‘y’ coordinates already exist then they will not be added.

Parameters:
  • data_arr (xarray.DataArray) – data object to add x/y coordinates to

  • area (pyresample.geometry.AreaDefinition) – area providing the coordinate data.

  • crs (pyproj.crs.CRS or None) – CRS providing additional information about the area’s coordinate reference system if available. Requires pyproj 2.0+.

Returns (xarray.DataArray): Updated DataArray object

pyresample.future.resamplers.resampler.hash_dict(the_dict, existing_hash=None)

Calculate a hash for a dictionary and optionally update an existing hash.

pyresample.future.resamplers.resampler.hash_resampler_geometries(source_geo_def, target_geo_def, **kwargs)

Get hash for the geometries used by a resampler with extra kwargs.

Return type:

str

pyresample.future.resamplers.resampler.update_resampled_coords(old_data, new_data, new_area)

Add coordinate information to newly resampled DataArray.

Parameters:
  • old_data (xarray.DataArray) – Old data before resampling.

  • new_data (xarray.DataArray) – New data after resampling.

  • new_area (pyresample.geometry.BaseDefinition) – Area definition for the newly resampled data.