Skip to main content
`Ctrl`+`K`

# BaseRepresentationOrDifferential

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

  Bases: `MaskableShapedLikeNDArray`

  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.
  `mask` | The combined mask of all components.
  `masked` | Whether or not the instance uses masked values.
  `name` | Name of the representation or differential.
  `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_mask`(*attrs) | Calculate the mask, by combining masks from the given attributes.
  `get_name`() |
  `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.

  mask

    The combined mask of all components.

  masked
  name = 'base'

    Name of the representation or differential.

    When a subclass is defined, by default, the name is the lower-cased name of the class with with any trailing ‘representation’ or ‘differential’ removed. (E.g., ‘spherical’ for `SphericalRepresentation` or `SphericalDifferential`.)

    This can be customized when defining a subclass by setting the class attribute.

  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

  abstractmethod 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.

  get_mask(*attrs)

    Calculate the mask, by combining masks from the given attributes.

    Parameters:
      *attrs `python:str`

        Attributes from which to get the masks to combine. If not given, use all components of the class.

    Returns:
      mask `ndarray` of bool

        The combined, read-only mask. If the instance is not masked, it is an array of `False` with the correct shape.

  classmethod get_name()

    Deprecated since version v7.1: The get_name method is deprecated and may be removed in a future version. Use name instead.

    Name of the representation or differential.

    Returns the `.name` attribute.

  abstractmethod 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.