healpix_resample.HealpixToUTM#
- class healpix_resample.HealpixToUTM(grid, level, *, method='bilinear', nest=True, ellipsoid='WGS84', pad=None, dtype=torch.float64, device=None, verbose=False, **resampler_kwargs)[source]#
Resample HEALPix cell data onto a UTM raster through
invert().The operator is geometry-only: it is built from the target grid and the HEALPix level alone, without any data and without the list of cells available in the source dataset. Construction determines which HEALPix cells the raster needs (cell_ids); only those have to be read from the source, which is what makes the operator usable on a store far larger than memory (e.g. a global, metre-scale Zarr archive):
>>> op = HealpixToUTM(grid, level, method="bilinear") >>> op.cell_ids # (K,) cells to read, sorted >>> data = store.sel(cell_ids=op.cell_ids) # (B, K), read only those >>> img = op.resample(data) # (B, ny, nx)
- Parameters:
grid (
UTMGrid) – Target raster (pixel-centerx,yand CRS of the tile).level (
int) – HEALPix level of the source data.method (
{"bilinear", "nearest", "bicubic", "clough_tocher"}ortype) – Which resampler’sinvert()to use – see the module docstring. A resampler class can be passed directly; it must acceptlon_deg, lat_deg, leveland implementinvert().nest (
bool) – HEALPix indexing scheme of the source cell ids.ellipsoid (
str) – Passed through to the resampler (healpix_geo).pad (
int, optional) – Number of extra pixels added around the grid while building the operator, cropped from the output. Only useful for Clough-Tocher, whose forward construction keeps a cell only if it lies inside the convex hull of the samples (here: the pixel centers): without a margin the cells surrounding the raster would be discarded and the border pixels could not be interpolated. Default: two HEALPix cell widths for"clough_tocher", 0 otherwise.dtype, device, verbose – Passed to the resampler.
**resampler_kwargs – Extra keyword arguments for the resampler constructor (e.g.
Npt,threshold).
- cell_ids#
The HEALPix cells (at level) required to fill the raster, int64, shape
(K,), sorted in ascending order. This is the selection to apply to the source dataset before calling resample().- Type:
- resampler#
The underlying resampler (built on the padded pixel centers).
- valid#
Boolean, shape
(ny, nx): pixels the operator can fill when every cell of cell_ids carries data. Pixels outside it are NaN in every output (only Clough-Tocher can have such pixels: those outside the hull of the cell centers).- Type:
- __init__(grid, level, *, method='bilinear', nest=True, ellipsoid='WGS84', pad=None, dtype=torch.float64, device=None, verbose=False, **resampler_kwargs)[source]#
Methods
__init__(grid, level, *[, method, nest, ...])resample(cell_data[, cell_ids])HEALPix cells -> UTM raster.