astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v5.2.1 »
- Astronomical Coordinate Systems (`astropy.coordinates`) »
- cartesian_to_spherical

# cartesian_to_spherical

astropy.coordinates.cartesian_to_spherical(x, y, z)

  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 `CartesianRepresentation` and `SphericalRepresentation` classes. 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, numpy:array_like, or `Quantity`

      The first Cartesian coordinate.

    y scalar, numpy:array_like, or `Quantity`

      The second Cartesian coordinate.

    z scalar, numpy:array_like, or `Quantity`

      The third Cartesian coordinate.

  Returns:
    r `Quantity`

      The radial coordinate (in the same units as the inputs).

    lat `Quantity` [:ref: ‘angle’]

      The latitude in radians

    lon `Quantity` [:ref: ‘angle’]

      The longitude in radians