cartesian_to_spherical¶
-
astropy.coordinates.cartesian_to_spherical(x, y, z)[source] [edit on github]¶ Converts 3D rectangular cartesian coordinates to spherical polar coordinates.
Note that the resulting angles are latitude/longitude or elevation/azimuthal form. I.e., the origin is along the equator rather than at the north pole.
Note
This function simply wraps functionality provided by the
CartesianRepresentationandSphericalRepresentationclasses. In general, for both performance and readability, we suggest using these classes directly. But for situations where a quick one-off conversion makes sense, this function is provided.Parameters: x : scalar, array-like, or
QuantityThe first cartesian coordinate.
y : scalar, array-like, or
QuantityThe second cartesian coordinate.
z : scalar, array-like, or
QuantityThe third cartesian coordinate.
Returns: r :
QuantityThe radial coordinate (in the same units as the inputs).
lat :
QuantityThe latitude in radians
lon :
QuantityThe longitude in radians