healpix_geo.ring.cartesian_to_healpix#

healpix_geo.ring.cartesian_to_healpix(x, y, z, depth, ellipsoid='sphere', num_threads=0)#

Get the HEALPix indexes that contain specific points.

Parameters:
  • x (numpy.ndarray) – The x coordinate of the input points, in meters.

  • y (numpy.ndarray) – The y coordinate of the input points, in meters.

  • z (numpy.ndarray) – The z coordinate of the input points, in meters.

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

  • ellipsoid (ellipsoid-like, default: "sphere") – Reference ellipsoid to evaluate healpix on. If the reference ellipsoid is spherical, this will return the same result as cdshealpix.nested.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 cartesian_to_healpix
>>> import numpy as np
>>> x = np.array(
...     [6343428.894701699, 4010777.6054728953, 4094327.79214653], dtype="float64"
... )
>>> y = np.array([0.0, 4779858.620418726, 1909216.4044747741], dtype="float64")
>>> z = np.array(
...     [662257.957592079, -1317402.5312295998, 4487348.408865919], dtype="float64"
... )
>>> depth = 3
>>> ipix = cartesian_to_healpix(x, y, z, depth, ellipsoid="WGS84")
>>> ipix
array([336, 436, 114], dtype=uint64)