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 a from_cartesian class method. By default, transformations are done via the cartesian system, but classes that want to define a smarter transformation path can overload the represent_as method. Furthermore, all classes must define an attr_classes attribute, an OrderedDict which maps component names to the class that creates them. They can also define a recommended_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 the reshape 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 and other to CartesianRepresentation, and converting the result back to the type of representation of self.

Parameters:

other : representation

The representation to take the cross product with.

Returns:

cross_product : representation

With vectors perpendicular to both self and other, in the same type of representation as self.

dot(other)[source] [edit on github]

Dot product of two representations.

The calculation is done by converting both self and other to CartesianRepresentation.

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 and other.

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 that axis is the entry in the shape of the representation, and that the out 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 that axis is the entry in the shape of the representation, and that the out argument cannot be used.

Returns:

sum : representation

Vector sum, in the same representation as that of the input.

to_cartesian()[source] [edit on github]