Attribute#
- class astropy.coordinates.Attribute(default=None, secondary_attribute='', *, doc='A frame attribute')[source]#
Bases:
objectA non-mutable data descriptor to hold a frame attribute.
This class must be used to define frame attributes (e.g.
equinoxorobstime) that are included in a frame class definition.- Parameters:
- default
object Default value for the attribute if not provided
- secondary_attribute
python:str Name of a secondary instance attribute which supplies the value if
default is Noneand no value was supplied during initialization.- doc
python:str Description of the frame attribute for help and documentation. Information on the default value will be appended to this description.
- default
Examples
The
FK4class uses the following class attributes:class FK4(BaseCoordinateFrame): equinox = TimeAttribute(default=_EQUINOX_B1950) obstime = TimeAttribute(default=None, secondary_attribute='equinox')
This means that
equinoxandobstimeare available to be set as keyword arguments when creating anFK4class 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
equinoxandobstimeare time attributes and use theTimeAttributeFrameclass. This subclass overrides theconvert_inputmethod to validate and convert inputs into aTimeobject.Attributes Summary
Methods Summary
convert_input(value)Validate the input
valueand convert to expected attribute class.Attributes Documentation
- name = '<unbound>'#
Methods Documentation
- convert_input(value)[source]#
Validate the input
valueand 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
convertedreturn value should beFalse.- Parameters:
- value
object Input value to be converted.
- value
- Returns:
- output_value
object The
valueconverted to the correct type (or justvalueifconvertedis False)- convertedbool
True if the conversion was actually performed, False otherwise.
- output_value
- Raises:
ValueErrorIf the input is not valid for this attribute.