healpix_geo.lonlat_to_cartesian#

healpix_geo.lonlat_to_cartesian(longitude, latitude, ellipsoid='sphere', num_threads=0)#

Convert geographic coordinates to cartesian coordinates.

Parameters:
  • longitude, latitude (numpy.ndarray) – The geographic coordinates in degrees. All arrays must have the exactly same shape (no broadcasting).

  • ellipsoid (ellipsoid-like, default: "sphere") – The ellipsoid to evaluate the coordinates on.

  • 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:

x, y, z (numpy.ndarray) – The equivalent cartesian coordinates.

Examples

>>> from healpix_geo import lonlat_to_cartesian
>>> import numpy as np
>>> lon = np.array([5.625, 50.625, 28.125])
>>> lat = np.array([41.93785391, 19.55202227, 19.55202227])
>>> x, y, z = lonlat_to_cartesian(lon, lat, ellipsoid="WGS84")
>>> x
array([4728734.69012279, 3814362.85054704, 5302653.4041462 ])
>>> y
array([ 465739.7157339 , 4647814.58126337, 2834327.29460352])
>>> z
array([4240471.60204581, 2121029.8965948 , 2121029.8965948 ])