HEALPixSHT — API reference#
Every public method of HEALPixSHT, and what the transform costs. The guide is
HEALPixSHT — spherical harmonics on the full sky; the conventions are HEALPixSHT — conventions and algorithm.
Methods#
HEALPixSHT(level, lmax, dtype, device, ellipsoid)#
Instantiate the transform and precompute all geometry.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
— |
Grid4Earth/HEALPix level, integer ≥ 0. Internally, |
|
|
|
Maximum multipole ℓ. |
|
|
|
Real dtype for maps. Use |
|
|
auto |
Computation device. Defaults to CUDA when available. |
|
|
|
Geometry model: |
Read-only attributes
Attribute |
Description |
|---|---|
|
HEALPix nside |
|
Maximum multipole |
|
Total pixels: 12·nside² |
|
Number of iso-latitude rings: 4·nside − 1 |
|
Number of alm coefficients: (lmax+1)·(lmax+2)//2 |
sht.map2alm(im, nest=False) → Tensor[..., K]#
Analysis transform: HEALPix map → spherical harmonic coefficients.
a_lm = ∫ f(θ,φ) · Y_lm*(θ,φ) dΩ
Parameter |
Description |
|---|---|
|
|
|
|
Returns a complex Tensor of shape (..., K) where K = (lmax+1)·(lmax+2)//2.
alm layout (same as healpy):
[m=0: l=0..lmax | m=1: l=1..lmax | … | m=lmax: l=lmax]
sht.alm2map(alm, nest=False) → Tensor[..., N]#
Synthesis transform: a_lm → HEALPix map.
f(θ,φ) = Σ_{l,m} a_lm · Y_lm(θ,φ)
Parameter |
Description |
|---|---|
|
|
|
|
Returns a real Tensor of shape (..., N).
sht.map2alm_spin(Q, U, spin, nest=False) → (almE, almB)#
Spin-s analysis: (Q, U) → E-mode and B-mode spherical harmonic coefficients.
|
Physical interpretation |
|---|---|
|
Scalar pair: |
|
Vector field: |
|
CMB polarisation: |
Parameter |
Description |
|---|---|
|
|
|
|
|
|
|
|
Returns (almE, almB), each a complex Tensor of shape (..., K).
Requires
quaternionicandsphericalpackages forspin > 0.
sht.alm2map_spin(almE, almB, spin, nest=False) → (Q, U)#
Spin-s synthesis: adjoint of map2alm_spin.
Parameter |
Description |
|---|---|
|
|
|
|
|
|
|
|
Returns (Q, U), each a real Tensor of shape (..., N).
sht.uv_to_curl_div(u, v, nest=False) → (div, curl)#
One-call Helmholtz–Hodge decomposition of a tangent-plane vector field.
Internally calls map2alm_spin(u, v, spin=1) and
alm2map_spin(almE, almB, spin=1).
Parameter |
Description |
|---|---|
|
|
|
|
|
|
Returns:
Output |
Description |
|---|---|
|
Divergence map ∇·v — sources and sinks of the flow. |
|
Vorticity map ∇×v — rotation intensity of the flow. |
sht.anafast(im, map2=None, spin=0, nest=False) → Tensor#
Angular power spectrum C_ℓ.
Parameter |
Description |
|---|---|
|
|
|
Same shape as |
|
|
|
|
Returns
spin=0→(..., lmax+1)real Tensor.spin>0→(..., 3, lmax+1)real Tensor with[C_l^EE, C_l^BB, C_l^EB].
Formula (spin=0):
C_l = 1/(2l+1) × [ |a_{l0}|² + 2 Σ_{m=1}^{l} |a_{lm}|² ]
Cost and tuning#
Precomputation: the Legendre tables and phase matrix are computed once at
HEALPixSHT(level=...)time. At level=6 (nside=64) this takes ~0.5 s; subsequent calls tomap2alm/alm2mapare fast.Spin harmonics are computed lazily on the first call to
map2alm_spinfor a given spin value and cached for all subsequent calls.dtype: use
torch.float32for speed-critical applications (training, large batches). Usetorch.float64when comparing against healpy or when high numerical accuracy matters.GPU: pass
device="cuda"at construction time. All hot-path operations (fft,einsum) run natively on GPU.Batch size: process many maps at once with a leading batch dimension
im.shape = (B, N)for an effective B× throughput increase on GPU.