# pyresample.ewa.dask_ewa module

Dask-friendly implementation of the EWA resampling algorithm.

The DaskEWAResampler class implements the Elliptical Weighted Averaging (EWA) resampling algorithm in a per-chunk processing scheme. This allows common dask configurations (number of workers, chunk size, etc) to control how much data is being worked on at any one time. This limits how much data is being held in memory at any one time. In cases where not all input array chunks will be used this implementation should avoid loading/computing the data for that chunk. In cases where not all output chunks have data in them, this implementation should avoid unnecessary array creation and memory usage until necessary.

class pyresample.ewa.dask_ewa.DaskEWAResampler(source_geo_def, target_geo_def)

  Bases: `BaseResampler`

  Resample using an elliptical weighted averaging algorithm.

  This algorithm does not use caching or any externally provided data mask (unlike the ‘nearest’ resampler).

  This algorithm works under the assumption that the data is observed one scan line at a time. However, good results can still be achieved for non-scan based data provided rows_per_scan is set to the number of rows in the entire swath or by setting it to None.

  Initialize in-memory cache.

  __init__(source_geo_def, target_geo_def)

    Initialize in-memory cache.

  compute(data, cache_id=None, rows_per_scan=None, chunks=None, fill_value=None, weight_count=10000, weight_min=0.01, weight_distance_max=1.0, weight_delta_max=10.0, weight_sum_min=-1.0, maximum_weight_mode=None, **kwargs)

    Resample the data according to the precomputed X/Y coordinates.

  precompute(cache_dir=None, rows_per_scan=None, persist=False, **kwargs)

    Generate row and column arrays and store it for later use.

  resample(data, cache_dir=None, mask_area=None, rows_per_scan=None, persist=False, chunks=None, fill_value=None, weight_count=10000, weight_min=0.01, weight_distance_max=1.0, weight_delta_max=10.0, weight_sum_min=-1.0, maximum_weight_mode=None)

    Resample using an elliptical weighted averaging algorithm.

    This algorithm does not use caching or any externally provided data mask (unlike the ‘nearest’ resampler). See the `DaskEWAResampler` class docstring for more information on how the algorithm works.

    Note

    This sets the default of ‘mask_area’ to False since it is not needed in EWA resampling currently.

    Parameters:

      - data (numpy.ndarray, dask.array.Array, xarray.DataArray) – Raster data to be resampled. Can be a numpy array, dask array, or xarray DataArray backed by a numpy or dask array. If the data is a numpy or dask array then only 2D (y, x) arrays are permitted. DataArray objects may be 2D or 3D where the third dimension is named “bands”. Note that regardless of the input type, data is converted to a dask array for internal processing and converted back to the original data type on return.

      - cache_dir (str, None) – Not used by this resampler.

      - mask_area (bool, None) – Not used by this resampler.

      - rows_per_scan (int, None) – Number of array rows that represent a single scan of the instrument. If `None` (default), then the `.attrs` of the source swath longitude and latitude data is checked for this value if they are DataArray objects. Otherwise, this value must be provided. Decent results may be possible if this value is set to the total number of rows in the array. As a convenience, providing `0` will result in the total number of rows being used.

      - persist (bool) – Whether to persist (as in dask) the computations during precompute or compute them on the fly during compute. Persisting allows the resampler to determine which input chunks will overlap with the target area. This can greatly reduce the number of tasks and checks that will need to be computed in cases where it is known that only a small amount of input data will fall into the output area.

      - chunks (tuple, int, dict, string) – Chunk size of resulting dask array. See `normalize_chunks()` for more information.

      - fill_value (int, float) – Output value when no data is present. Defaults to `numpy.nan` for float types or the maximum value for any integer types.

      - weight_count (int) – number of elements to create in the gaussian weight table. Default is 10000. Must be at least 2

      - weight_min (float) – the minimum value to store in the last position of the weight table. Default is 0.01, which, with a weight_distance_max of 1.0 produces a weight of 0.01 at a grid cell distance of 1.0. Must be greater than 0.

      - weight_distance_max (float) – distance in grid cell units at which to apply a weight of weight_min. Default is 1.0. Must be greater than 0.

      - weight_delta_max (float) – maximum distance in grid cells in each grid dimension over which to distribute a single swath cell. Default is 10.0.

      - weight_sum_min (float) – minimum weight sum value. Cells whose weight sums are less than weight_sum_min are set to the grid fill value. Default is EPSILON.

      - maximum_weight_mode (bool) – If False (default), a weighted average of all swath cells that map to a particular grid cell is used. If True, the swath cell having the maximum weight of all swath cells that map to a particular grid cell is used. This option should be used for coded/category data, i.e. snow cover.