BaseCoordinateFrame¶
-
class
astropy.coordinates.BaseCoordinateFrame(*args, **kwargs)[source] [edit on github]¶ Bases:
objectThe base class for coordinate frames.
This class is intended to be subclassed to create instances of specific systems. Subclasses can implement the following attributes:
default_representationA subclass of
BaseRepresentationthat will be treated as the default representation of this frame. This is the representation assumed by default when the frame is created.
FrameAttributeclass attributesFrame attributes such as
FK4.equinoxorFK4.obstimeare defined using a descriptor class. See the narrative documentation or built-in classes code for details.
frame_specific_representation_infoA dictionary mapping the name or class of a representation to a list of
RepresentationMappingobjects that tell what names and default units should be used on this frame for the components of that representation.
Attributes Summary
cartesianShorthand for a cartesian representation of the coordinates in this object. dataThe coordinate data for this object. default_representationframe_attributesframe_specific_representation_infohas_dataTrue if this frame has data, False otherwise.isscalarnamerepresentationThe representation of the data in this frame, as a class that is subclassed from BaseRepresentation.representation_component_namesrepresentation_component_unitsrepresentation_infoA dictionary with the information of what attribute names for this frame apply to particular representations. shapesphericalShorthand for a spherical representation of the coordinates in this object. Methods Summary
get_frame_attr_names()is_equivalent_frame(other)Checks if this object is the same frame as the otherobject.is_frame_attr_default(attrnm)Determine whether or not a frame attribute has its value because it’s the default value, or because this frame was created with that value explicitly requested. is_transformable_to(new_frame)Determines if this coordinate frame can be transformed to another given frame. realize_frame(representation)Generates a new frame with new data from another frame (which may or may not have data). represent_as(new_representation[, ...])Generate and return a new representation of this frame’s dataas a Representation object.separation(other)Computes on-sky separation between this coordinate and another. separation_3d(other)Computes three dimensional separation between this coordinate and another. transform_to(new_frame)Transform this object’s coordinate data to a new frame. Attributes Documentation
-
cartesian¶ Shorthand for a cartesian representation of the coordinates in this object.
-
data¶ The coordinate data for this object. If this frame has no data, an
ValueErrorwill be raised. Usehas_datato check if data is present on this frame object.
-
default_representation¶
-
frame_attributes= OrderedDict()¶
-
frame_specific_representation_info¶
-
isscalar¶
-
name= 'basecoordinateframe'¶
-
representation¶ The representation of the data in this frame, as a class that is subclassed from
BaseRepresentation. Can also be set using the string name of the representation.
-
representation_component_names¶
-
representation_component_units¶
-
representation_info¶ A dictionary with the information of what attribute names for this frame apply to particular representations.
-
shape¶
-
spherical¶ Shorthand for a spherical representation of the coordinates in this object.
Methods Documentation
-
classmethod
get_frame_attr_names()[source] [edit on github]¶
-
is_equivalent_frame(other)[source] [edit on github]¶ Checks if this object is the same frame as the
otherobject.To be the same frame, two objects must be the same frame class and have the same frame attributes. Note that it does not matter what, if any, data either object has.
Parameters: other : BaseCoordinateFrame
the other frame to check
Returns: isequiv : bool
True if the frames are the same, False if not.
Raises: TypeError
If
otherisn’t aBaseCoordinateFrameor subclass.
-
is_frame_attr_default(attrnm)[source] [edit on github]¶ Determine whether or not a frame attribute has its value because it’s the default value, or because this frame was created with that value explicitly requested.
Parameters: attrnm : str
The name of the attribute to check.
Returns: isdefault : bool
True if the attribute
attrnmhas its value by default, False if it was specified at creation of this frame.
-
is_transformable_to(new_frame)[source] [edit on github]¶ Determines if this coordinate frame can be transformed to another given frame.
Parameters: new_frame : class or frame object
The proposed frame to transform into.
Returns: transformable : bool or str
Trueif this can be transformed tonew_frame,Falseif not, or the string ‘same’ ifnew_frameis the same system as this object but no transformation is defined.Notes
A return value of ‘same’ means the transformation will work, but it will just give back a copy of this object. The intended usage is:
if coord.is_transformable_to(some_unknown_frame): coord2 = coord.transform_to(some_unknown_frame)
This will work even if
some_unknown_frameturns out to be the same frame class ascoord. This is intended for cases where the frame is the same regardless of the frame attributes (e.g. ICRS), but be aware that it might also indicate that someone forgot to define the transformation between two objects of the same frame class but with different attributes.
-
realize_frame(representation)[source] [edit on github]¶ Generates a new frame with new data from another frame (which may or may not have data).
Parameters: representation : BaseRepresentation
The representation to use as the data for the new frame.
Returns: frameobj : same as this frame
A new object with the same frame attributes as this one, but with the
representationas the data.
-
represent_as(new_representation, in_frame_units=False)[source] [edit on github]¶ Generate and return a new representation of this frame’s
dataas a Representation object.Note: In order to make an in-place change of the representation of a Frame or SkyCoord object, set the
representationattribute of that object to the desired new representation.Parameters: new_representation : subclass of BaseRepresentation or string
The type of representation to generate. May be a class (not an instance), or the string name of the representation class.
in_frame_units : bool
Force the representation units to match the specified units particular to this frame
Returns: newrep : BaseRepresentation-derived object
A new representation object of this frame’s
data.Raises: AttributeError
If this object had no
dataExamples
>>> from astropy import units as u >>> from astropy.coordinates import SkyCoord, CartesianRepresentation >>> coord = SkyCoord(0*u.deg, 0*u.deg) >>> coord.represent_as(CartesianRepresentation) <CartesianRepresentation (x, y, z) [dimensionless] (1.0, 0.0, 0.0)>
>>> coord.representation = CartesianRepresentation >>> coord <SkyCoord (ICRS): (x, y, z) [dimensionless] (1.0, 0.0, 0.0)>
-
separation(other)[source] [edit on github]¶ Computes on-sky separation between this coordinate and another.
Parameters: other :
BaseCoordinateFrameThe coordinate to get the separation to.
Returns: sep :
AngleThe on-sky separation between this and the
othercoordinate.Notes
The separation is calculated using the Vincenty formula, which is stable at all locations, including poles and antipodes [R2].
[R2] http://en.wikipedia.org/wiki/Great-circle_distance
-
separation_3d(other)[source] [edit on github]¶ Computes three dimensional separation between this coordinate and another.
Parameters: other :
BaseCoordinateFrameThe coordinate system to get the distance to.
Returns: sep :
DistanceThe real-space distance between these two coordinates.
Raises: ValueError
If this or the other coordinate do not have distances.
-
transform_to(new_frame)[source] [edit on github]¶ Transform this object’s coordinate data to a new frame.
Parameters: new_frame : class or frame object or SkyCoord object
The frame to transform this coordinate frame into.
Returns: transframe
A new object with the coordinate data represented in the
newframesystem.Raises: ValueError
If there is no possible transformation route.