healpix_resample.NearestResampler#
- class healpix_resample.NearestResampler(*args, Npt=9, **kwargs)[source]#
Nearest-neighbour HEALPix resampler — no sparse matrices.
Uses
NptKNN neighbours (default 9) to robustly find the nearest source for every HEALPix cell, even when the output grid is finer than the input.- Parameters:
Npt (
int) – Number of HEALPix neighbours per source sample used by the KNN. Larger values cover more cells at the cost of more memory during construction. Default 9 is a good trade-off for most use cases.All other parameters are forwarded to ``KNeighborsResampler``.
- __init__(*args, Npt=9, **kwargs)[source]#
Pre-compute sparse operators.
- Parameters:
lon_deg, lat_deg – unstructured sample coordinates in degrees, shape (N,)
Npt – number of nearest HEALPix cells used per sample
level – HEALPix level, nside = 2**level
sigma_m – Gaussian length scale (meters). If None, uses the HEALPix pixel scale sigma = sqrt(4*pi/(12*4**level))*R.
threshold – keep only HEALPix cells whose global weight sum >= threshold
nest – HEALPix indexing scheme
dtype/device – torch dtype/device for all matrices and computations
Methods
__init__(*args[, Npt])Pre-compute sparse operators.
comp_matrix()Build hi_k (K,) — nearest source index per HEALPix cell.
get_cell_ids()invert(hval)HEALPix cells → source samples.
resample(val, **_kwargs)Source samples → HEALPix cells.