healpix-resample
healpix-resample is a lightweight, GPU-friendly Python
package for regridding data from unstructured longitude/latitude samples onto a
HEALPix grid — one sparse linear operator, several interpolation
strategies, and a consistent API across all of them.
Under the hood, every resampler builds a sparse PyTorch operator mapping input
samples to a subset of HEALPix cells at a chosen resolution level, so the same forward/inverse operator
can be reused, batched (B, N), and run on CPU or CUDA. The package manages the HEALPix authalic
definition and the Earth ellipsoid using the WGS84 reference system.
Resamplers at a glance
| Resampler | Strategy | Good for |
|---|---|---|
NearestResampler |
Single nearest sample per cell | Fast, simple, exact point indexing |
BilinearResampler |
4 nearest samples, inverse-distance weights | Smoother than nearest, cheap |
BicubicResampler |
16 nearest samples, Keys' cubic convolution kernel | Sharper on fields with curvature, still non-iterative |
PSFResampler |
Gaussian PSF kernel + damped least-squares (Conjugate Gradient) | Best reconstruction quality, dense or irregular data |
ConservativeResampler |
Direct binning, area-weighted sum | Exact flux/mass conservation |
GroupByResampler |
Direct binning, configurable reduction (mean, sum, prod, amax, amin) |
Aggregating many samples per cell |
CellPointResampler |
Level-29 "cell-point" encoding | Exact point indexing, no interpolation |
BilinearResampler, BicubicResampler, and PSFResampler also support an optional area= +
conservative=True mode that redistributes each sample's value across its cell footprint instead of
just interpolating, so the global total is preserved exactly — combining smooth interpolation with
ConservativeResampler's exact-conservation guarantee. PSFResampler additionally supports
out_cell_ids= to restrict output to a specific cell subset, and healpix_resample.subset_for_parent_cell
lets you process one coarse HEALPix region at a time for datasets too large to load in full.
Every resampler handles NaN-valued samples consistently (excluded from the computation rather than propagated) and accepts both NumPy arrays and PyTorch tensors, returning whichever type you passed in.
Installation
From PyPI
pip install healpix-resample
From source (editable, for development)
git clone https://github.com/GRID4EARTH/healpix-resample.git
cd healpix-resample
pip install -e .
Or, using pixi (the environment this package is developed and tested in):
git clone https://github.com/GRID4EARTH/healpix-resample.git
cd healpix-resample
pixi install
Requirements
- Python 3.10+
- PyTorch (CPU or CUDA)
- NumPy
healpix-geo
Verifying the installation
import healpix_resample
print(healpix_resample.__file__)
Quickstart
from healpix_resample import BilinearResampler
op = BilinearResampler(lon_deg=lon, lat_deg=lat, level=level, device="cuda")
result = op.resample(values)
healpix_values = result.cell_data # (K,) or (B, K)
healpix_cells = result.cell_ids # (K,) HEALPix cell ids, same order as cell_data
Every resampler follows this same resample(val) -> ResampleResults(cell_data, cell_ids) pattern; swap
BilinearResampler for any of the other classes above to change interpolation strategy without changing
the rest of your code. See the full documentation —
in particular the 4resamplers tutorial, which runs every resampler
side by side on the same dataset — for a complete tour, including conservative mode, batched inputs,
out_cell_ids, and large-scale parent-cell processing.
Documentation
Full documentation, including a user guide per resampler, tutorials, and the API reference, is available at grid4earth.eu/healpix-resample.
Development
This project uses pixi to manage environments.
pixi run tests # run the test suite
pixi run -e docs build-docs # build the documentation locally (docs/_build)
Target applications
- Earth observation data remapping (e.g. Sentinel products)
- Oceanographic or atmospheric gridding
- Astronomical sky projections
- Large-scale geospatial data harmonization
License
Apache License 2.0 — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file healpix_resample-2026.7.0.tar.gz.
File metadata
- Download URL: healpix_resample-2026.7.0.tar.gz
- Upload date:
- Size: 8.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3864d5e290b240f0106a34aec7f49cab0a8586580ce0c3f33ab4edd459ec4b47
|
|
| MD5 |
bd07687b357ce718f463e9037e8e63fc
|
|
| BLAKE2b-256 |
d34a528da4cf7bec95bcccb99564ce8d04dfb2a4cb815dfa74a161a791df0460
|
Provenance
The following attestation bundles were made for healpix_resample-2026.7.0.tar.gz:
Publisher:
pypipublish.yml on GRID4EARTH/healpix-resample
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
healpix_resample-2026.7.0.tar.gz -
Subject digest:
3864d5e290b240f0106a34aec7f49cab0a8586580ce0c3f33ab4edd459ec4b47 - Sigstore transparency entry: 2303219675
- Sigstore integration time:
-
Permalink:
GRID4EARTH/healpix-resample@48c15e8743b637afed9c632b74d48579cceb9edd -
Branch / Tag:
refs/tags/v2026.07.0 - Owner: https://github.com/GRID4EARTH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypipublish.yml@48c15e8743b637afed9c632b74d48579cceb9edd -
Trigger Event:
release
-
Statement type:
File details
Details for the file healpix_resample-2026.7.0-py3-none-any.whl.
File metadata
- Download URL: healpix_resample-2026.7.0-py3-none-any.whl
- Upload date:
- Size: 50.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c8921f8fec60ce7f92a0f6e49dfebded3e89816167194202f68049a563470da
|
|
| MD5 |
d4f458bfa9c5bec60fe1181b12ebbf3e
|
|
| BLAKE2b-256 |
d33d353dcd6db2fcb44af0d8fd2a3744c5ded83c7a52c4b7d2571836f0438488
|
Provenance
The following attestation bundles were made for healpix_resample-2026.7.0-py3-none-any.whl:
Publisher:
pypipublish.yml on GRID4EARTH/healpix-resample
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
healpix_resample-2026.7.0-py3-none-any.whl -
Subject digest:
9c8921f8fec60ce7f92a0f6e49dfebded3e89816167194202f68049a563470da - Sigstore transparency entry: 2303219815
- Sigstore integration time:
-
Permalink:
GRID4EARTH/healpix-resample@48c15e8743b637afed9c632b74d48579cceb9edd -
Branch / Tag:
refs/tags/v2026.07.0 - Owner: https://github.com/GRID4EARTH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypipublish.yml@48c15e8743b637afed9c632b74d48579cceb9edd -
Trigger Event:
release
-
Statement type: