hypso.grid.resample#

Resampling between pyresample geometries: one Resampler per source and target pair (neighbour lookup done once, applied to every variable), an Averager for coarser grids (mean of the source pixels in each cell), and resample_product - a product’s contents on any target, as a bare Dataset.

Classes#

Averager

Cell averages on a grid: each target cell gets the mean of the

GridOperators

How each kind of variable goes from a product onto target with

Resampler

Nearest-neighbour and (optionally) bilinear resampling from source

Functions#

default_radius(source_metres[, target_metres])

Radius of influence (m): 1.5 times the coarser of source and target

is_flag_variable(name, attrs)

Bit-flag variables (CF flag_masks, or AC tools' flags variables).

resample_product(tree, target[, method, ...])

A product's contents on any pyresample target, as a bare Dataset.

target_resolution_metres(target)

Pixel size (m) of an AreaDefinition; 0 for a swath target.

Module Contents#

class hypso.grid.resample.Averager(latitudes, longitudes, target)[source]#

Cell averages on a grid: each target cell gets the mean of the source pixels whose centres fall in it (NaN ignored per band) - an unweighted approximation of area-weighted averaging, close when source pixels are much smaller than the cells. Only for targets coarser than the source; finer ones leave empty cells inside the swath.

bitwise_or(data)[source]#

Integer flags (rows, cols) -> per cell, every flag set in any of its pixels (0 for empty cells).

Parameters:

data (numpy.ndarray)

Return type:

numpy.ndarray

mean(data)[source]#

Float (rows, cols[, bands]) -> cell means in the input’s float dtype.

Parameters:

data (numpy.ndarray)

Return type:

numpy.ndarray

class hypso.grid.resample.GridOperators(tree, target, method, radius_of_influence=None)[source]#

How each kind of variable goes from a product onto target with method, so resample_product and regrid treat variables alike:

  • floats(): the cube and float variables - nearest, bilinear, or cell average; azimuths (by name) through their sine and cosine unless nearest, so 0/360 does not average to 180;

  • integers(): nearest neighbour, except bit flags with “average”, which are OR-ed over the cell;

  • covered(): target pixels that received data.

Parameters:
parameters()[source]#

What was done, for provenance.

Return type:

dict

class hypso.grid.resample.Resampler(source, target, radius_of_influence, bilinear)[source]#

Nearest-neighbour and (optionally) bilinear resampling from source to target; radius_of_influence in metres.

Parameters:
  • radius_of_influence (float)

  • bilinear (bool)

coverage(method)[source]#

True where the target has data from the source with method.

Parameters:

method (str)

Return type:

numpy.ndarray

nearest(data, fill_value=np.nan)[source]#

(rows, cols[, bands]); integer data keeps its dtype (fill 0).

Parameters:

data (numpy.ndarray)

Return type:

numpy.ndarray

hypso.grid.resample.default_radius(source_metres, target_metres=0.0)[source]#

Radius of influence (m): 1.5 times the coarser of source and target pixel size, so every target pixel inside the swath finds neighbours.

Parameters:
Return type:

float

hypso.grid.resample.is_flag_variable(name, attrs)[source]#

Bit-flag variables (CF flag_masks, or AC tools’ flags variables).

Parameters:

name (str)

Return type:

bool

hypso.grid.resample.resample_product(tree, target, method='nearest', radius_of_influence=None)[source]#

A product’s contents on any pyresample target, as a bare Dataset.

Parameters:
Returns:

The cube (y, x, band) with the source band wavelengths, each derived variable (y, x), each flag as boolean flag_<name>, and the target’s latitude and longitude.

Return type:

xarray.Dataset

hypso.grid.resample.target_resolution_metres(target)[source]#

Pixel size (m) of an AreaDefinition; 0 for a swath target.

Return type:

float