satpy.resample.kdtree module

Resamplers based on the kdtree algorightm.

class satpy.resample.kdtree.BilinearResampler(source_geo_def, target_geo_def)[source]

Bases: BaseResampler

Resample using bilinear interpolation.

This resampler implements on-disk caching when the cache_dir argument is provided to the resample method. This should provide significant performance improvements on consecutive resampling of geostationary data.

Parameters:
  • cache_dir (str) – Long term storage directory for intermediate results.

  • radius_of_influence (float) – Search radius cut off distance in meters

  • epsilon (float) – Allowed uncertainty in meters. Increasing uncertainty reduces execution time.

  • reduce_data (bool) – Reduce the input data to (roughly) match the target area.

Init BilinearResampler.

__init__(source_geo_def, target_geo_def)[source]

Init BilinearResampler.

compute(data, fill_value=None, **kwargs)[source]

Resample the given data using bilinear interpolation.

load_bil_info(cache_dir, **kwargs)[source]

Load bilinear resampling info from cache directory.

precompute(mask=None, radius_of_influence=50000, epsilon=0, reduce_data=True, cache_dir=False, **kwargs)[source]

Create bilinear coefficients and store them for later use.

save_bil_info(cache_dir, **kwargs)[source]

Save bilinear resampling info to cache directory.

class satpy.resample.kdtree.KDTreeResampler(source_geo_def, target_geo_def)[source]

Bases: BaseResampler

Resample using a KDTree-based nearest neighbor algorithm.

This resampler implements on-disk caching when the cache_dir argument is provided to the resample method. This should provide significant performance improvements on consecutive resampling of geostationary data. It is not recommended to provide cache_dir when the mask keyword argument is provided to precompute which occurs by default for SwathDefinition source areas.

Parameters:
  • cache_dir (str) – Long term storage directory for intermediate results.

  • mask (bool) – Force resampled data’s invalid pixel mask to be used when searching for nearest neighbor pixels. By default this is True for SwathDefinition source areas and False for all other area definition types.

  • radius_of_influence (float) – Search radius cut off distance in meters

  • epsilon (float) – Allowed uncertainty in meters. Increasing uncertainty reduces execution time.

Init KDTreeResampler.

__init__(source_geo_def, target_geo_def)[source]

Init KDTreeResampler.

_adjust_radius_of_influence(radius_of_influence)[source]

Adjust radius of influence.

_apply_cached_index(val, idx_name, persist=False)[source]

Reassign resampler index attributes.

_load_neighbour_info_from_cache(cache_dir, idx_name, mask_name, **kwargs)[source]
_read_resampler_attrs()[source]

Read certain attributes from the resampler for caching.

compute(data, weight_funcs=None, fill_value=nan, with_uncert=False, **kwargs)[source]

Resample data.

load_neighbour_info(cache_dir, mask=None, **kwargs)[source]

Read index arrays from either the in-memory or disk cache.

precompute(mask=None, radius_of_influence=None, epsilon=0, cache_dir=None, **kwargs)[source]

Create a KDTree structure and store it for later use.

Note: The mask keyword should be provided if geolocation may be valid where data points are invalid.

save_neighbour_info(cache_dir, mask=None, **kwargs)[source]

Cache resampler’s index arrays if there is a cache dir.

satpy.resample.kdtree._move_existing_caches(cache_dir, filename)[source]

Move existing cache files out of the way.

satpy.resample.kdtree.get_resampler_classes()[source]

Get resampler classes based on kdtree.