healpix_resample.ConservativeResampler#

class healpix_resample.ConservativeResampler(*args, area=None, out_cell_ids=None, **kwargs)[source]#

Area-weighted, flux-conserving HEALPix resampler.

Bins each source sample into its containing HEALPix cell (exact grouping, like GroupByResampler) and accumulates area-weighted sums, so the total integrated quantity is exactly preserved between the sample-space and HEALPix-cell representations. See the module docstring for the extensive-vs-intensive distinction that determines whether area needs to be supplied.

Parameters:
  • area (array-like or None) – Per-sample pixel area/weight, shape (N,). Any consistent unit works since only ratios matter. Defaults to 1.0 for every sample (equal-area pixels / already-extensive quantities).

  • All other parameters are forwarded to ``KNeighborsResampler``

  • (``lon_deg``, ``lat_deg``, ``level``, ``nest``, ``device``, ``dtype``,

  • ``ellipsoid``, ``verbose``, …). ``out_cell_ids`` is not supported.

__init__(*args, area=None, out_cell_ids=None, **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[, area, out_cell_ids])

Pre-compute sparse operators.

comp_matrix()

get_cell_area()

Return the total input area binned into each HEALPix cell (K,).

get_cell_ids()

invert(hval)

HEALPix cells → source samples, mass-conserving redistribution.

resample(val, **_kwargs)

Source samples → HEALPix cells, area-weighted sum.