Coordinate transformation methods#
Coordinate Frame Class#
- class marsimage.frames.CoordinateFrame(coordinate_system_name, coordinate_system_index, origin_offset_vector, origin_rotation, reference_coordinate_system_name, reference_coordinate_system_index, variant)[source]
Represents a coordinate frame and provides methods for coordinate transformations.
Coordinate frames are defined by an origin offset vector and an origin rotation. A reference coordinate system must be specified with a name and an index.
- Parameters:
coordinate_system_name (str) – The name of the coordinate system.
coordinate_system_index (int) – The index of the coordinate system.
origin_offset_vector (numpy.ndarray) – The offset vector of the origin of the coordinate system.
origin_rotation (scipy.spatial.transform.Rotation) – The rotation of the coordinate system.
reference_coordinate_system_name (str) – The name of the reference coordinate system.
reference_coordinate_system_index (int) – The index of the reference coordinate system.
variant (str) – The variant of the coordinate system (e.g. NED, ENU).
- classmethod from_odl(coord_system_parms)[source]
Create a CoordinateFrame object from an ODL COORD_SYSTEM_PARMS dictionary.
- Parameters:
coord_system_parms (dict) – Dictionary containing coordinate system parameters.
- Returns:
An instance of the CoordinateFrame class.
- Return type:
CoordinateFrame
Note
The dictionary coord_system_parms must contain the following keys:
“COORDINATE_SYSTEM_NAME”
“COORDINATE_SYSTEM_INDEX”
“ORIGIN_OFFSET_VECTOR”
“ORIGIN_ROTATION_QUATERNION”
“REFERENCE_COORD_SYSTEM_NAME”
“REFERENCE_COORD_SYSTEM_INDEX”
- property origin_rotation_quaternion
Convenience function, returns the origin rotation in JPL style quaternion.
- property origin_rotation_matrix
Convenience function, returns the origin rotation as a rotation matrix.
- transform_to(target_system)[source]
Transform the coordinate system to a specified reference system.
Note
The reference system must match the reference system of the coordinate system. The reference system must be a CoordinateFrame object with the same coordinate system variant (e.g. NED, ENU).
- Parameters:
target_system (CoordinateFrame) – The reference system to transform to.
- Returns:
The transformed coordinate system.
- Return type:
CoordinateFrame
- Raises:
If the target system is not a CoordinateFrame object. - If the target system does not have the same reference system name. - If the target system does not have the same reference system index. - If the target system does not have the same variant.
- xyz(variant='NED')[source]
Return the xyz coordinates of the origin of the coordinate system.
- Parameters:
variant (str, optional) – The coordinate system variant, by default “NED”.
- Returns:
The xyz coordinates of the origin of the coordinate system.
- Return type:
- property easting
Return the easting coordinate of the origin of the coordinate system.
- Returns:
The easting coordinate of the origin.
- Return type:
- Raises:
ValueError – If the reference coordinate system is not “ORBITAL” or if the variant is unknown.
- property northing
Returns the northing coordinate of the origin of the coordinate system.
- Returns:
The northing coordinate of the origin.
- Return type:
- Raises:
ValueError – If the reference coordinate system is not “ORBITAL” or if the variant is unknown.
- property elevation
Return the elevation of the origin of the coordinate system.
- Returns:
The elevation coordinate of the origin in the ORBITAL coordinate system.
- Return type:
- Raises:
ValueError – If the reference coordinate system is not “ORBITAL” or if the variant is unknown.
- property ypr
Calculate the YPR (Yaw, Pitch, Roll) from the origin rotation.
This method assumes that the camera is looking down for ypr = (0, 0, 0).
- Returns:
A tuple containing the yaw, pitch, and roll angles.
- Return type:
- property ypr_dji
Calculate the DJI YPR (Yaw, Pitch, Roll) values.
DJI YPR values assume that the camera is looking forward for ypr = (0, 0, 0).
- Returns:
The YPR values as a numpy array.
- Return type:
- property wphik
Calculate the (Omega, Phi, Kappa) angles from the origin rotation.
- Returns:
A tuple containing the omega, phi, and kappa angles.
- Return type:
Camera Model and CAHVORE#
The formulas used in this module are based on [Di and Li, 2004].
- class marsimage.frames.CAHVORE(cm_type: Literal['CAHV', 'CAHVOR', 'CAHVORE'], C: ndarray, A: ndarray, H: ndarray, V: ndarray, coordinate_system_name: str, coordinate_system_index: int, reference_coordinate_system_name: str, reference_coordinate_system_index: int, O: ndarray = None, R: ndarray = None, E: float = None, T: float = None, P: float = None, variant: Literal['NED', 'ENU'] = 'NED')[source]#
Dataclass that holds the parameters of a CAHVOR(E) camera model.
- classmethod from_odl(geometric_camera_model)[source]#
Create a CAHVORE object from an ODL Label GEOMETRIC_CAMERA_MODEL group.
- Parameters:
geometric_camera_model (dict) – The GEOMETRIC_CAMERA_MODEL group from the ODL Label.
Note
The dictionary GEOMETRIC_CAMERA_MODEL must at least contain the following keys:
MODEL_TYPE
MODEL_COMPONENT_1
MODEL_COMPONENT_2
MODEL_COMPONENT_3
MODEL_COMPONENT_4
REFERENCE_COORD_SYSTEM_NAME
REFERENCE_COORD_SYSTEM_INDEX
If the MODEL_TYPE is CAHVOR, the dictionary must also contain the following keys:
MODEL_COMPONENT_5
MODEL_COMPONENT_6
If the MODEL_TYPE is CAHVORE, the dictionary must also contain the following keys:
MODEL_COMPONENT_7
MODEL_COMPONENT_8
MODEL_COMPONENT_9
- Returns:
The CAHVORE object.
- Return type:
- property hs#
The hs parameter.
- property vs#
The vs parameter.
- property hc#
The hc parameter.
- property vc#
The vc parameter.
- property H_n#
The normalized H vector H’.
- property V_n#
The normalized V vector V’.
- class marsimage.frames.CameraModel(width: int, height: int, pixel_size: float, pixel_size_x: float, pixel_size_y: float, f: float, f_mm: float, crop_factor: float, f_35: float, model_type: str, x0: float, y0: float, x0_mm: float, y0_mm: float, cf: CoordinateFrame)[source]#
Camera model class based on the Photogrammetric camera model.
- classmethod from_cahvore(cahvore, width, height, pixel_size)[source]#
Initialize the photogrammetric camera model from a CAHVORE camera model.
Calculations based on ‘CAHVOR camera model and its photogrammetric conversion for planetary applications (https://doi.org/10.1029/2003JE002199)’.
- Parameters:
- Returns:
The CameraModel object.
- Return type:
- transform_to(target_frame)[source]#
Transform the CameraModel to a specified reference system.
- Parameters:
target_frame (CoordinateFrame) – The reference system to transform to.
- Returns:
The transformed CameraModel object.
- Return type:
- property ypr#
Calculate the YPR (Yaw, Pitch, Roll) from the origin rotation.
This method assumes that the camera is looking down for ypr = (0, 0, 0).
- Returns:
A tuple containing the yaw, pitch, and roll angles.
- Return type:
- property ypr_dji#
Calculate the DJI YPR (Yaw, Pitch, Roll) values.
DJI YPR values assume that the camera is looking forward for ypr = (0, 0, 0).
- Returns:
The YPR values as a numpy array.
- Return type:
- property cam_heading#
The compass heading of the camera.
- property planetocentric_latitude#
The planetocentric latitude of the camera.
- property planetodetic_latitude#
The planetodetic latitude of the camera.
- property longitude#
The longitude of the camera.
- property elevation#
The geographic elevation of the camera.
OrbitalCoordinateFrame Class#
- class marsimage.frames.OrbitalCoordinateFrame[source]#
Localization class to parse the Rover localization data from different sources.
- classmethod from_places(mission, site, drive)[source]#
Create a Localization object from the PLACES data.
- Parameters:
- Returns:
The Localization object describing the coordinate frame of the rover at a specific site and drive in the orbital frame.
- Return type:
- property longitude#
The longitude of the rover in degrees.
- property planetocentric_latitude#
The planetocentric latitude of the rover in degrees. I.e. no ellipsoidal correction.
- property planetodetic_latitude#
The planetodetic latitude of the rover in degrees. I.e. with ellipsoidal correction.