AttitudeRepresentation
- class erwans3.Telescope_class.AttitudeRepresentation(x: Union[ndarray, Rotation, AttitudeRepresentation], y: Optional[ndarray] = None, z: Optional[ndarray] = None, w: Optional[ndarray] = None, xyzw_axis: int = -1, differentials: Optional[BaseDifferential] = None, copy: bool = True)
Bases:
BaseRepresentationRepresents attitude information in terms of quaternion.
This class inherits from BaseRepresentation and provides functionality to represent attitude information using quaternions or rotations. However, that representation is not a coordinate representation It cannot be converted with cartesian representation which limit its uses.
- Parameters:
x (
ndarrayorRotationorAttitudeRepresentation) – If a single argument is provided, it can be: -AttitudeRepresentation: Initialize from another AttitudeRepresentation instance. -Rotation: Initialize from a Rotation instance. -ndarray: Initialize from a quaternion array or a rotation vector array.y (
ndarray, optional) – Second component of the quaternion (if provided).z (
ndarray, optional) – Third component of the quaternion (if provided).w (
ndarray, optional) – Fourth component of the quaternion (if provided).xyzw_axis (
int, optional) – Axis along which the xyzw components are defined. Default is -1.differentials (
dict, optional) – Dictionary containing differential attributes. Default is None.copy (
bool, optional) – If True, performs a deep copy of input arrays. Default is True.
Notes
AttitudeRepresentationobject main usage is to be encapsulated in a |SatCoord| object Thus it can associated to a frame and frame transformation can be performed.Usage: >>> att = AttitudeRepresentation(0,0,0,1) >>> coord = ICRS(CartesianRepresentation(np.ones(3)*u.m)) >>> sat_icrs = SatCoord(coord, att, obstime=Time.now()) >>> sat_gcrs = sat_icrs.transform_to(GCRS) >>> print(sat_gcrs.att)
Yet, AttitudeRepresentation can be attached to a frame on its own. >>> att = AttitudeRepresentation(0,0,0,1) >>> att_frame = ICRS(att) Frame transformation can be applied as long as no FunctionTransform or FunctionTransformWithFiniteDifference are not involve example: >>> att_hcrs = HCSR(AttitudeRepresentation.make_random(), representation_type=AttitudeRepresentation) >>> att_sg = att_hcrs.transform_to(Supergalactic(representation_type=AttitudeRepresentation)) Frames defined with |Frame_class.CustomFrame| uses Affine transform and thus can be used to transform AttitudeRepresentation
See also
BaseRepresentationBase class for representations.
RotationClass representing rotations in astropy.coordinates.
Attributes Summary
Get the quaternion representation of the AttitudeRepresentation.
Get the Rotation instance from the quaternion representation.
The 'w' component of the points(s).
The 'x' component of the points(s).
The 'y' component of the points(s).
The 'z' component of the points(s).
Methods Summary
from_cartesian(cart)should not be used !
from_matrix(mats)Create an
AttitudeRepresentationinstance from rotation matrices.get_q()Get the quaternion representation of the AttitudeRepresentation.
make_identity(rotshape)Create an identity AttitudeRepresentation instance.
make_random(rotshape)Create a random
AttitudeRepresentationinstance.should not be used !
transform(matrix)Transform the AttitudeRepresentation by a rotation matrix.
Attributes Documentation
- attr_classes = {'w': <class 'astropy.units.quantity.Quantity'>, 'x': <class 'astropy.units.quantity.Quantity'>, 'y': <class 'astropy.units.quantity.Quantity'>, 'z': <class 'astropy.units.quantity.Quantity'>}
- q
Get the quaternion representation of the AttitudeRepresentation.
This property returns the quaternion representation of the AttitudeRepresentation instance. If the internal _q attribute is set, it returns _q. Otherwise, it constructs the quaternion array using the _x, _y, _z, and _w components.
- Returns:
Quaternion representation of the AttitudeRepresentation.
- Return type:
- rot
Get the Rotation instance from the quaternion representation.
This property returns a Rotation instance derived from the quaternion representation of the AttitudeRepresentation instance. It uses the quaternion array _q to construct the Rotation instance.
- Returns:
Rotation instance corresponding to the quaternion representation.
- Return type:
Rotation
Notes
If the quaternion array _q has a dimension less than or equal to 1, it constructs a
Rotation instance using Rotation.from_quat. - If _q has a dimension greater than 1, it constructs a Rotation instance using get_rot_from_quat_vec.
- w
The ‘w’ component of the points(s).
- x
The ‘x’ component of the points(s).
- y
The ‘y’ component of the points(s).
- z
The ‘z’ component of the points(s).
Methods Documentation
- classmethod from_cartesian(cart)
should not be used !
- classmethod from_matrix(mats) AttitudeRepresentation
Create an
AttitudeRepresentationinstance from rotation matrices.This class method creates an AttitudeRepresentation instance from rotation matrices. It extracts quaternion representations from the input rotation matrices mats.
- Parameters:
mats (
ndarray) – Rotation matrices from which to create the AttitudeRepresentation instance.- Returns:
AttitudeRepresentation instance created from the input rotation matrices.
- Return type:
Notes
This class method extracts quaternion representations from rotation matrices to create
an AttitudeRepresentation instance. - The input mats should be compatible with the conversion to quaternions.
Examples
>>> # Assuming `mats` is an array of rotation matrices >>> att_rep = AttitudeRepresentation.from_matrix(mats) >>> print(att_rep) AttitudeRepresentation([x, y, z, w]) # Example output with quaternion components
- get_q() ndarray
Get the quaternion representation of the AttitudeRepresentation.
This property returns the quaternion representation of the AttitudeRepresentation instance. If the internal _q attribute is set, it returns _q. Otherwise, it constructs the quaternion array using the _x, _y, _z, and _w components.
- Returns:
Quaternion representation of the AttitudeRepresentation.
- Return type:
- classmethod make_identity(rotshape) AttitudeRepresentation
Create an identity AttitudeRepresentation instance.
This class method creates an identity AttitudeRepresentation instance with the specified shape based on the input rotshape. The identity representation corresponds to a quaternion array representing no rotation (all components equal to [1, 0, 0, 0]).
- Parameters:
rotshape (
intortuple) – Shape of the identity representation. If an integer is provided, a 1D identity representation is created. If a tuple is provided, it specifies the shape of the identity representation array.- Returns:
Identity AttitudeRepresentation instance with the specified shape.
- Return type:
- Raises:
TypeError – If the input type for rotshape is not supported (should be a tuple or an integer).
Notes
This class method creates an identity AttitudeRepresentation instance with all quaternion components
set to [1, 0, 0, 0], representing no rotation. - The shape of the identity representation determines the size of the identity array.
- classmethod make_random(rotshape) AttitudeRepresentation
Create a random
AttitudeRepresentationinstance.This class method creates a random AttitudeRepresentation instance with the specified shape based on the input rotshape. The random representation corresponds to a quaternion array representing a random rotation.
- Parameters:
rotshape (
intortuple) – Shape of the random representation. If an integer is provided, a 1D random representation is created. If a tuple is provided, it specifies the shape of the random representation array.- Returns:
Random AttitudeRepresentation instance with the specified shape.
- Return type:
Notes
This class method creates a random AttitudeRepresentation instance with quaternion components
representing a random rotation. - The shape of the random representation determines the size of the random array.
- to_cartesian()
should not be used !
returns itself in order to compute some frame transorm
- transform(matrix: ndarray) AttitudeRepresentation
Transform the AttitudeRepresentation by a rotation matrix.
This method transforms the AttitudeRepresentation instance by applying a rotation represented by the input rotation matrix matrix. The transformation is performed by first creating a new AttitudeRepresentation from the rotation matrix, then applying the rotation to the current AttitudeRepresentation.
- Parameters:
matrix (
ndarray) – Rotation matrix representing the transformation.- Returns:
Transformed AttitudeRepresentation instance after applying the rotation.
- Return type:
Notes
The transformation is performed by creating a new AttitudeRepresentation instance from
the rotation matrix and then applying it to the current AttitudeRepresentation. - The order of transformation (whether the input matrix is applied first or last) depends on the specific implementation of the from_matrix method and the multiplication logic.