Healpy

1.19.0 · active · verified Wed Apr 15

Healpy is a Python package, currently at version 1.19.0, designed to handle pixelated data on the sphere. It is based on the Hierarchical Equal Area isoLatitude Pixelization (HEALPix) scheme and bundles the HEALPix C++ library. Primarily used in astrophysics and cosmology, Healpy provides tools for map manipulation, spherical harmonic transforms, and visualization of all-sky data.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a basic HEALPix map using a NumPy array and visualize it with `healpy.mollview()`. It sets up a map at a given `NSIDE` resolution, populates it with pixel indices, and then displays it with coordinate graticules.

import numpy as np
import healpy as hp
import matplotlib.pyplot as plt

# Define the resolution parameter NSIDE (must be a power of 2)
NSIDE = 32

# Calculate the number of pixels
NPIX = hp.nside2npix(NSIDE)
print(f"Number of pixels for NSIDE={NSIDE}: {NPIX}")

# Create a simple map (e.g., an array with pixel indices)
m = np.arange(NPIX, dtype=float)

# Visualize the map using Mollweide projection
hp.mollview(m, title="Simple Healpix Map (RING ordering)")
hp.graticule() # Add meridians and parallels
plt.show()

view raw JSON →