astro py:docs

- Index
- Modules

### Navigation

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

# BaseRepresentationOrDifferential

class astropy.coordinates.BaseRepresentationOrDifferential(*args, **kwargs)

  Bases: `ShapedLikeNDArray`

  3D coordinate representations and differentials.

  Parameters:
    comp1, comp2, comp3 `Quantity` or subclass

      The components of the 3D point or differential. The names are the keys and the subclasses the values of the `attr_classes` attribute.

    copy bool, optional

      If `True` (default), arrays will be copied; if `False`, they will be broadcast together but not use new memory.

  Attributes Summary

  `components` | A tuple with the in-order names of the coordinate components.
  `info` | Container for meta information like name, description, format.
  `shape` | The shape of the instance and underlying arrays.

  Methods Summary

  `from_cartesian`(other) | Create a representation of this class from a supplied Cartesian one.
  `get_name`() | Name of the representation or differential.
  `to_cartesian`() | Convert the representation to its Cartesian form.

  Attributes Documentation

  components

    A tuple with the in-order names of the coordinate components.

  info

    Container for meta information like name, description, format. This is required when the object is used as a mixin column within a table, but can be used as a general way to store meta information.

  shape

    The shape of the instance and underlying arrays.

    Like `shape`, can be set to a new shape by assigning a tuple. Note that if different instances share some but not all underlying data, setting the shape of one instance can make the other instance unusable. Hence, it is strongly recommended to get new, reshaped instances with the `reshape` method.

    Raises:
      `ValueError`

        If the new shape has the wrong total number of elements.

      `AttributeError`

        If the shape of any of the components cannot be changed without the arrays being copied. For these cases, use the `reshape` method (which copies any arrays that cannot be reshaped in-place).

  Methods Documentation

  abstract classmethod from_cartesian(other)

    Create a representation of this class from a supplied Cartesian one.

    Parameters:
      other `CartesianRepresentation`

        The representation to turn into this class

    Returns:
      representation `BaseRepresentation` subclass instance

        A new representation of this class’s type.

  classmethod get_name()

    Name of the representation or differential.

    In lower case, with any trailing ‘representation’ or ‘differential’ removed. (E.g., ‘spherical’ for `SphericalRepresentation` or `SphericalDifferential`.)

  abstract to_cartesian()

    Convert the representation to its Cartesian form.

    Note that any differentials get dropped. Also note that orientation information at the origin is not preserved by conversions through Cartesian coordinates. For example, transforming an angular position defined at distance=0 through cartesian coordinates and back will lose the original angular coordinates:

        >>> import astropy.units as u
        >>> import astropy.coordinates as coord
        >>> rep = coord.SphericalRepresentation(
        ...     lon=15*u.deg,
        ...     lat=-11*u.deg,
        ...     distance=0*u.pc)
        >>> rep.to_cartesian().represent_as(coord.SphericalRepresentation)
        <SphericalRepresentation (lon, lat, distance) in (rad, rad, pc)
            (0., 0., 0.)>

    Returns:
      cartrepr `CartesianRepresentation`

        The representation in Cartesian form.