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:
- lon
astropy.coordinates.Longitude
The longitudes of the sky coordinates.
- lat
astropy.coordinates.Latitude
The latitudes of the sky coordinates.
- nside
numpy.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
anddy
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)
- lon
- Returns:
- ipix
numpy.ndarray
A numpy array containing all the HEALPix cell indexes stored as
np.uint64
.
- ipix
- 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, :])