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#
Cell averages on a grid: each target cell gets the mean of the |
|
How each kind of variable goes from a product onto target with |
|
Nearest-neighbour and (optionally) bilinear resampling from source |
Functions#
|
Radius of influence (m): 1.5 times the coarser of source and target |
|
Bit-flag variables (CF flag_masks, or AC tools' flags variables). |
|
A product's contents on any pyresample target, as a bare Dataset. |
|
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:
- mean(data)[source]#
Float (rows, cols[, bands]) -> cell means in the input’s float dtype.
- Parameters:
data (numpy.ndarray)
- Return type:
- 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:
tree (xarray.DataTree)
method (str)
radius_of_influence (float)
- 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.
- coverage(method)[source]#
True where the target has data from the source with method.
- Parameters:
method (str)
- Return type:
- nearest(data, fill_value=np.nan)[source]#
(rows, cols[, bands]); integer data keeps its dtype (fill 0).
- Parameters:
data (numpy.ndarray)
- Return type:
- 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.
- hypso.grid.resample.is_flag_variable(name, attrs)[source]#
Bit-flag variables (CF flag_masks, or AC tools’ flags variables).
- 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:
tree (xarray.DataTree) – A georeferenced product tree.
target (pyresample.geometry.AreaDefinition or SwathDefinition)
method ({"nearest", "bilinear", "average"}, default "nearest") – Per kind of variable as in
GridOperators;"average"only onto grids coarser than the product.radius_of_influence (float, optional) – In m; default
default_radius().
- Returns:
The cube
(y, x, band)with the source band wavelengths, each derived variable(y, x), each flag as booleanflag_<name>, and the target’s latitude and longitude.- Return type: