healpix_resample.PSFResampler#

class healpix_resample.PSFResampler(lon_deg, lat_deg, level, *, out_cell_ids=None, device='cpu', dtype=torch.float32, verbose=False, ellipsoid='WGS84', Npt=9, sigma_m=None, threshold=0.1, area=None, fill_missing_out_cells=False, **kwargs)[source]#
__init__(lon_deg, lat_deg, level, *, out_cell_ids=None, device='cpu', dtype=torch.float32, verbose=False, ellipsoid='WGS84', Npt=9, sigma_m=None, threshold=0.1, area=None, fill_missing_out_cells=False, **kwargs)[source]#

PSF regridding Set.

Parameters:
  • fill_missing_out_cells (bool) – Only relevant when out_cell_ids is supplied. Some requested output cells can end up with too little real kernel support (an empty or near-empty column of M, or – separately – some input samples with too little real link weight in MT) – e.g. when out_cell_ids force-includes cells the KNN search wouldn’t have retained on its own. This originated as a targeted patch for a specific use case (river mouths in ocean models, where an approximate value was preferred over a gap), but the fallback it triggers is expensive: an unvectorized Python loop computing a full distance search per affected cell/sample (comp_matrix’s bad_k handling), which can be very slow for more than a handful of affected cells – exactly the situation you can hit when combining out_cell_ids with subset_for_parent_cell().

    • False (the default): skip that fallback entirely. Output cells that don’t have enough real support are left as nan in resample()’s result rather than filled with an approximate nearest-single-sample value – correct, and fast.

    • True: restore the original fallback-fill behaviour exactly (approximate but non-NaN values for weakly-supported cells). Opt into this only if you specifically need a value rather than a gap for those cells, and can tolerate the extra construction cost when many cells/samples are affected.

  • area (array-like, "auto", or None) – Per-sample pixel area/weight of the native (source) grid, shape (N,). This is baked directly into the source-to-HEALPix operator M (a.k.a. B in the accompanying paper) – larger source pixels contribute proportionally more to a HEALPix cell’s reconstructed value – making the reconstruction a conservative rebinning rather than a plain local average. The HEALPix side needs no such weight since HEALPix cells are equal-area (iso-surface) by construction. This does not by itself guarantee exact global conservation (see resample(..., conservative=True) for that); it removes the local bias a plain unweighted average would otherwise introduce.

    • If omitted (None, the default) or "auto": the area is estimated automatically from the grid’s geometry, assuming samples share latitude “rings” as in regular lat/lon grids or reduced Gaussian grids (e.g. ECMWF’s N-grids – see estimate_pixel_area()). If no such structure is detected (e.g. a grid regular in a different projection such as UTM, or scattered points), silently falls back to a uniform weight of 1.0 per sample – the same as the current, unweighted behaviour.

    • If an explicit array: used as-is (own convention/units; only ratios matter).

Methods

__init__(lon_deg, lat_deg, level, *[, ...])

PSF regridding Set.

comp_matrix()

get_cell_ids()

invert(hval)

Project HEALPix field back to the sample locations.

resample(val, *[, lam, max_iter, tol, x0, ...])

Estimate the HEALPix field from unstructured samples.