cartesian_to_spherical#

pygaia.astrometry.vectorastrometry.cartesian_to_spherical(x, y, z)#

Convert Cartesian to spherical coordinates. The input can be scalars or 1-dimensional numpy arrays. Note that the angle coordinates follow the astronomical convention of using elevation (declination, latitude) rather than its complement (pi/2-elevation), which is commonly used in the mathematical treatment of spherical coordinates.

Parameters:
  • x (float or float array) – Cartesian vector component along the X-axis

  • y (float or float array) – Cartesian vector component along the Y-axis

  • z (float or float array) – Cartesian vector component along the Z-axis

Returns:

r, phi, theta – The spherical coordinates r=np.sqrt(x*x+y*y+z*z), longitude phi, latitude theta.

Return type:

float or float array

Raises:

ValueError – When one of the input (x,y,z) coordinates correspond to r=0.

Notes

The longitude angle is between 0 and \(+2\pi\).