API Reference#

Resamplers#

healpix_resample.NearestResampler(*args[, ...])

Nearest-neighbour HEALPix resampler — no sparse matrices.

healpix_resample.BilinearResampler(*args[, area])

Bilinear (Npt=4, inverse-distance weighted) HEALPix resampler.

healpix_resample.GridBilinearResampler(...)

Bilinear interpolation of lon/lat grids at HEALPix cell centres.

healpix_resample.BicubicResampler(*args[, ...])

Radial cubic-convolution HEALPix resampler.

healpix_resample.CloughTocherResampler(...)

Delaunay triangulation + Clough-Tocher C1 cubic HEALPix resampler.

healpix_resample.PSFResampler(lon_deg, ...)

healpix_resample.CellPointResampler(*args, ...)

Resample input lat-lon points as HEALPix "cell-points".

healpix_resample.GroupByResampler([reduce])

healpix_resample.ConservativeResampler(*args)

Area-weighted, flux-conserving HEALPix resampler.

healpix_resample.OverlapConservativeResampler(...)

First-order overlap-area conservative remapping onto HEALPix.

Conservative remapping#

Three distinct notions of conservation are available and are not interchangeable: ConservativeResampler performs area-weighted hard binning (each sample to its containing cell), OverlapConservativeResampler performs first-order overlap-area remapping from a rectilinear lat/lon grid (each source cell split across the HEALPix cells it intersects, the formulation used by ESMF/xESMF), and PSFResampler with conservative=True solves a PSF-aware inverse problem under a global conservation constraint. See the OverlapConservativeResampler — first-order overlap-area conservative remapping page for the comparison table.

Mask-like / categorical data#

BitmaskResampler and CategoricalResampler wrap an ordinary interpolating resampler (default BilinearResampler) to resample integer bitmasks and mutually-exclusive class labels respectively – see the healpix_resample.mask (mask-like / categorical data) page.

healpix_resample.BitmaskResampler(lon_deg, ...)

Resample an integer bitmask (independent boolean flags) to HEALPix.

healpix_resample.CategoricalResampler(...[, ...])

Resample mutually-exclusive class labels to HEALPix (argmax).

healpix_resample.CategoricalResampleResults(...)

ResampleResults returned by CategoricalResampler.resample().

Large-scale processing#

subset_for_parent_cell() restricts a resampler’s input samples and output cells to one coarse HEALPix parent cell, so a global dataset can be processed one parent cell at a time without ever constructing a resampler over the full input. See the Processing one parent cell at a time (subset_for_parent_cell) page for the workflow.

healpix_resample.subset_for_parent_cell(...)

Restrict processing to one parent cell: which samples, which output cells.

HEALPix to UTM#

HealpixToUTM resamples HEALPix cell data onto a regular raster in a projected (UTM) CRS, by building a resampler on the pixel centers of the target grid and applying its invert(). The operator is built from the geometry alone and reports the HEALPix cells it needs (cell_ids), so that only those are read from the source dataset. Requires the optional dependency pyproj. See the HEALPix → UTM page.

healpix_resample.HealpixToUTM(grid, level, *)

Resample HEALPix cell data onto a UTM raster through invert().

healpix_resample.UTMGrid(crs, x, y)

A regular raster in a projected (typically UTM) CRS.

healpix_resample.healpix_to_utm(cell_data, ...)

Resample an in-memory HEALPix field onto a UTM raster in one call.

healpix_resample.utm_crs_from_lonlat(...)

WGS84 / UTM CRS of the zone containing the centroid of the points.

Base class#

KNeighborsResampler is the base class inherited by all resamplers above. Use it directly only if you need to implement a custom weighting scheme via comp_matrix().

healpix_resample.knn.KNeighborsResampler(...)

GPU-friendly sparse HEALPix regridding via local Gaussian weights + CG deconvolution.

Output#

All resamplers return a ResampleResults dataclass.

healpix_resample.base.ResampleResults(...[, ...])

Proxy to resampling results.

Internals#

These functions are not part of the public API but are documented here for contributors. healpix_weighted_nearest() is called internally by all resamplers to build the sparse operators. conjugate_gradient() and least_squares_cg() are used internally by PSFResampler. bounded_least_squares_cg() is the bounded variant used by PSFResampler when resample() is called with clip. estimate_pixel_area() is used by PSFResampler to auto-estimate per-sample pixel area when area is not supplied.

healpix_resample.knn.healpix_weighted_nearest(...)

healpix_resample.psf.conjugate_gradient(A_mv, b)

Solve A x = b with Conjugate Gradient, using only matvec A_mv(v).

healpix_resample.psf.least_squares_cg(M, MT, ...)

Solve for delta in a damped least-squares problem without forming dense matrices.

healpix_resample.psf.bounded_least_squares_cg(M, ...)

Same damped weighted least-squares problem as least_squares_cg, under the box constraint lower <= delta <= upper (cell by cell).

healpix_resample.base.estimate_pixel_area(...)

Estimate each sample's pixel area from shared-latitude "ring" structure.