astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v1.1.1 »
- Astronomical Coordinate Systems (`astropy.coordinates`) »
- FrameAttribute

# FrameAttribute

class `astropy.coordinates.``FrameAttribute`(default=None, secondary_attribute=u'')

  Bases: `astropy.utils.misc.OrderedDescriptor`

  A non-mutable data descriptor to hold a frame attribute.

  This class must be used to define frame attributes (e.g. `equinox` or `obstime`) that are included in a frame class definition.

  Parameters:

  default : object

  > Default value for the attribute if not provided

  secondary_attribute : str

  > Name of a secondary instance attribute which supplies the value if `default is None` and no value was supplied during initialization.

  Examples

  The `FK4` class uses the following class attributes:

      class FK4(BaseCoordinateFrame):
          equinox = TimeFrameAttribute(default=_EQUINOX_B1950)
          obstime = TimeFrameAttribute(default=None,
                                       secondary_attribute='equinox')

  This means that `equinox` and `obstime` are available to be set as keyword arguments when creating an `FK4` class instance and are then accessible as instance attributes. The instance value for the attribute must be stored in `'_' + <attribute_name>` by the frame `__init__` method.

  Note in this example that `equinox` and `obstime` are time attributes and use the `TimeAttributeFrame` class. This subclass overrides the `convert_input` method to validate and convert inputs into a `Time` object.

  Attributes Summary

  `name` |

  Methods Summary

  `convert_input`(value) | Validate the input `value` and convert to expected attribute class.

  Attributes Documentation

  `name` = u'<unbound>'

  Methods Documentation

  `convert_input`(value)

    Validate the input `value` and convert to expected attribute class.

    The base method here does nothing, but subclasses can implement this as needed. The method should catch any internal exceptions and raise ValueError with an informative message.

    The method returns the validated input along with a boolean that indicates whether the input value was actually converted. If the input value was already the correct type then the `converted` return value should be `False`.

    Parameters:

    value : object

    > Input value to be converted.

    Returns:

    output_value

    > The `value` converted to the correct type (or just `value` if `converted` is False)

    converted : bool

    > True if the conversion was actually performed, False otherwise.

    Raises:

    ValueError

    > If the input is not valid for this attribute.