cdshealpix.ring.lonlat_to_healpix

cdshealpix.ring.lonlat_to_healpix(lon, lat, nside, return_offsets=False, num_threads=0)

Get the HEALPix indexes that contains specific sky coordinates.

The nside of the returned HEALPix cell indexes must be specified. This method is wrapped around the hash method from the cdshealpix Rust crate.

Parameters:
lonastropy.coordinates.Longitude

The longitudes of the sky coordinates.

latastropy.coordinates.Latitude

The latitudes of the sky coordinates.

nsidenumpy.ndarray

The nside of the returned HEALPix cell indexes.

return_offsetsbool, optional

If set to True, returns a tuple made of 3 elements, the HEALPix cell indexes and the dx, dy arrays telling where the (lon, lat) coordinates passed are located on the cells. dx and dy are \(\in [0, 1]\)

num_threadsint, optional

Specifies the number of threads to use for the computation. Default to 0 means it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set), or the number of logical CPUs (otherwise)

Returns:
ipixnumpy.ndarray

A numpy array containing all the HEALPix cell indexes stored as np.uint64.

Raises:
ValueError

When the number of longitudes and latitudes given do not match.

Examples

>>> from cdshealpix.ring import lonlat_to_healpix
>>> from astropy.coordinates import Longitude, Latitude
>>> import astropy.units as u
>>> import numpy as np
>>> lon = Longitude([0, 50, 25], u.deg)
>>> lat = Latitude([6, -12, 45], u.deg)
>>> depth = np.array([12, 14])
>>> nside = 2 ** depth
>>> ipix = lonlat_to_healpix(lon[:, np.newaxis], lat[:, np.newaxis], nside[np.newaxis, :])