cdshealpix.nested.lonlat_to_healpix

cdshealpix.nested.lonlat_to_healpix(lon, lat, depth, return_offsets=False, num_threads=0)

Get the HEALPix indexes that contains specific sky coordinates.

The depth 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.

depthnumpy.ndarray

The depth 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. When lon is not of type astropy.coordinates.Longitude. When lat is not of type astropy.coordinates.Latitude.

Examples

>>> from cdshealpix 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([5, 6])
>>> ipix = lonlat_to_healpix(lon[:, np.newaxis], lat[:, np.newaxis], depth[np.newaxis, :])