cdshealpix.nested.skycoord_to_healpix

cdshealpix.nested.skycoord_to_healpix(skycoord, 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:
skycoordastropy.coordinates.SkyCoord

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 in 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 import skycoord_to_healpix
>>> import astropy.units as u
>>> from astropy.coordinates import SkyCoord
>>> import numpy as np
>>> skycoord = SkyCoord([0, 50, 25] * u.deg, [6, -12, 45] * u.deg, frame="icrs")
>>> depth = 12
>>> ipix = skycoord_to_healpix(skycoord, depth)