BaseRepresentation¶
-
class
astropy.coordinates.
BaseRepresentation
[source] [edit on github]¶ Bases:
astropy.utils.misc.ShapedLikeNDArray
Base Representation object, for representing a point in a 3D coordinate system.
Notes
All representation classes should subclass this base representation class. All subclasses should then define a
to_cartesian
method and afrom_cartesian
class method. By default, transformations are done via the cartesian system, but classes that want to define a smarter transformation path can overload therepresent_as
method. Furthermore, all classes must define anattr_classes
attribute, anOrderedDict
which maps component names to the class that creates them. They can also define arecommended_units
dictionary, which maps component names to the units they are best presented to users in. Note that frame classes may override this with their own preferred units.Attributes Summary
components
A tuple with the in-order names of the coordinate components recommended_units
shape
The shape of the instance and underlying arrays. Methods Summary
cross
(other)Vector cross product of two representations. dot
(other)Dot product of two representations. from_cartesian
()from_representation
(representation)get_name
()mean
(*args, **kwargs)Vector mean. norm
()Vector norm. represent_as
(other_class)sum
(*args, **kwargs)Vector sum. to_cartesian
()Attributes Documentation
-
components
¶ A tuple with the in-order names of the coordinate components
-
recommended_units
= {}¶
-
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 thereshape
method.Raises: 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
-
cross
(other)[source] [edit on github]¶ Vector cross product of two representations.
The calculation is done by converting both
self
andother
toCartesianRepresentation
, and converting the result back to the type of representation ofself
.Parameters: other : representation
The representation to take the cross product with.
Returns: cross_product : representation
With vectors perpendicular to both
self
andother
, in the same type of representation asself
.
-
dot
(other)[source] [edit on github]¶ Dot product of two representations.
The calculation is done by converting both
self
andother
toCartesianRepresentation
.Parameters: other :
BaseRepresentation
The representation to take the dot product with.
Returns: dot_product :
Quantity
The sum of the product of the x, y, and z components of the cartesian representations of
self
andother
.
-
from_cartesian
()[source] [edit on github]¶
-
classmethod
from_representation
(representation)[source] [edit on github]¶
-
classmethod
get_name
()[source] [edit on github]¶
-
mean
(*args, **kwargs)[source] [edit on github]¶ Vector mean.
Averaging is done by converting the representation to cartesian, and taking the mean of the x, y, and z components. The result is converted back to the same representation as the input.
Refer to
mean
for full documentation of the arguments, noting thataxis
is the entry in theshape
of the representation, and that theout
argument cannot be used.Returns: mean : representation
Vector mean, in the same representation as that of the input.
-
norm
()[source] [edit on github]¶ Vector norm.
The norm is the standard Frobenius norm, i.e., the square root of the sum of the squares of all components with non-angular units.
Returns: norm :
astropy.units.Quantity
Vector norm, with the same shape as the representation.
-
represent_as
(other_class)[source] [edit on github]¶
-
sum
(*args, **kwargs)[source] [edit on github]¶ Vector sum.
Adding is done by converting the representation to cartesian, and summing the x, y, and z components. The result is converted back to the same representation as the input.
Refer to
sum
for full documentation of the arguments, noting thataxis
is the entry in theshape
of the representation, and that theout
argument cannot be used.Returns: sum : representation
Vector sum, in the same representation as that of the input.
-
to_cartesian
()[source] [edit on github]¶
-