numba_healpy
Numba JIT re-implementations of HEALPix helper functions.
These are drop-in replacements for the equivalent healpy functions,
inlined into the Numba nopython kernels to eliminate Python-level dispatch
overhead in the hot tile loop. All functions operate in RING ordering only.
Numba JIT replacements for HEALPix RING-scheme helper routines.
These functions mirror the HEALPix C++ internals and are designed to be called from within parallel Numba kernels.
_ring_above_jit — scalar ring_above helper (nopython, no parallel). _ring_info_jit — scalar ring layout helper: (n_pix, first_pix, phi0, dphi). _ring_z_jit — scalar ring centre z = cos(theta) helper. _get_interp_weights_jit — parallel (prange over N) replacement for
hp.get_interp_weights; mirrors the HEALPix C++ get_interpol algorithm exactly.
get_interp_weights_numba— public wrapper; drop-in replacement for hp.get_interp_weights.
- _ring_interp_single_jit — bilinear neighbour lookup for one unit-vector query;
acos-free for the normal case (sin weight formula).
- _ring_interp_with_angles_jit — same as _ring_interp_single_jit but also returns
(z_n, phi_n) of each of the 4 neighbours for callers that need the neighbour sky positions (e.g. the spin-2 Q/U frame-rotation kernel).
_pix2ang_ring_jit — scalar (theta, phi) from RING pixel index (nopython). _pix2ang_ring_batch — parallel batch kernel over an array of pixel indices. pix2ang_numba — public wrapper; drop-in for hp.pix2ang(nest=False).
- _query_disc_jit — nopython query_disc: returns int64 array of RING pixel
indices within a disc, callable from inside JIT kernels.
query_disc_numba — public wrapper; drop-in for hp.query_disc(nest=False).
- _gather_ring_stencil_jit — fast Keys/Catmull-Rom stencil gather via ring walk.
Replaces _query_disc_into_jit in the bicubic hot loop, eliminating the ~9 acos calls per (b,s) element.
- numba_healpy.get_interp_weights_numba(nside, theta, phi)[source]
Drop-in Numba replacement for
hp.get_interp_weights(nside, theta, phi).Returns
(pixels, weights)with shapes(4, N)and dtypesint64/float64, identical to the healpy convention. Input arrays are automatically cast to float64 and ravelled.
- numba_healpy.pix2ang_numba(nside, pix, nest=False)[source]
Drop-in Numba replacement for
hp.pix2ang(nside, pix, nest=False).Returns
(theta, phi)float64 arrays of shape(N,). Only RING scheme (nest=False) is supported.
- numba_healpy.query_disc_numba(nside, vec, radius_rad, inclusive=True, nest=False)[source]
Drop-in Numba replacement for
hp.query_disc(nside, vec, radius, ...).Parameters
nside : int vec : array-like, shape (3,) unit vector pointing to disc centre radius_rad : float disc radius [rad] inclusive : bool if True, pixels that partially overlap are included
(default True, same as healpy’s default)
nest : bool only nest=False (RING) is supported
Returns
pix : (M,) int64 RING pixel indices inside the disc (order not guaranteed)