healpix_geo.ring.lonlat_to_healpix#

healpix_geo.ring.lonlat_to_healpix(longitude, latitude, depth, ellipsoid='sphere', num_threads=0)#

Get the HEALPix indexes that contains specific points.

Parameters:
  • lon (numpy.ndarray) – The longitudes of the input points, in degrees.

  • lat (numpy.ndarray) – The latitudes of the input points, in degrees.

  • depth (int or numpy.ndarray of int) – The HEALPix cell depth given as a np.uint8 numpy array.

  • ellipsoid (str, default: "sphere") – Reference ellipsoid to evaluate healpix on. If "sphere", this will return the same result as cdshealpix.ring.lonlat_to_healpix().

  • num_threads (int, 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:

ipix (numpy.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.

  • ValueError – When the name of the ellipsoid is unknown.

Examples

>>> from healpix_geo.ring import lonlat_to_healpix
>>> import numpy as np
>>> lon = np.array([0, 50, 25], dtype="float64")
>>> lat = np.array([6, -12, 45], dtype="float64")
>>> depth = 3
>>> ipix = lonlat_to_healpix(lon, lat, depth, ellipsoid="WGS84")
>>> ipix
array([336, 436, 114], dtype=uint64)