Astropy HEALPix

1.1.3 · active · verified Thu Apr 16

astropy-healpix provides HEALPix (Hierarchical Equal Area isolations of the Sphere) functionality, including coordinate transformations, pixelization, and query methods, tightly integrated with the Astropy ecosystem. It is currently at version 1.1.3 and maintains an active development status, with releases often coordinated with major Astropy versions or for bug fixes as needed.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `HEALPix` object, convert HEALPix pixel indices to sky coordinates, and convert sky coordinates back to pixel indices. It uses common Astropy coordinate and unit objects for integration.

from astropy_healpix import HEALPix
from astropy.coordinates import ICRS, SkyCoord
from astropy import units as u
import numpy as np

# Create a HEALPix object with nside=32, 'nested' order, and ICRS frame
hp = HEALPix(nside=32, order='nested', frame=ICRS())

# Convert HEALPix pixel indices to SkyCoord objects
pixel_indices = np.array([0, 100, 20000])
sky_coords = hp.healpix_to_skycoord(pixel_indices)

print(f"Sky Coordinates for pixels {pixel_indices}:\n{sky_coords}")

# Convert SkyCoord objects to HEALPix pixel indices
ra = np.array([0, 10, 20]) * u.deg
dec = np.array([0, 5, 10]) * u.deg
coords_to_convert = SkyCoord(ra, dec, frame='icrs')
pix_at_coords = hp.skycoord_to_healpix(coords_to_convert)

print(f"HEALPix pixels for coordinates {coords_to_convert}: {pix_at_coords}")

view raw JSON →