3. Frame#
- class Frame(name: str)#
Bases:
object
Contains information about the reference frame attached to a quantity.
The reference frame notation strictly follows SPICE structure.
- Parameters:
name (
str
) – The name of the Frame object.
:raises ValueError(
`'NAME is not in the list of recognized frames. Please create a new frame.'
): | Raised when the frame that want to be used hasn't been defined yet (in SPICE). :raises ValueError(``
’Epoch array must be in TDB (ephemeris time).’:py:class:`): | Raised when the epoch array do not use TBD as query time. :raises ValueError(`
’DCM Rotation Matrix should be a square Matrix.’:py:class:`): | Raised when the Direction Cosine Matrix is not a N x N square matrix. :raises ValueError(`
’DCM Rotation Matrix should be an Orthonormal Matrix.’``:py:class:`): | Raised when the Direction Cosine Matrix is not orhonormal (the column vectors do not form an orthonormal set).See also
References
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/Tutorials/pdf/individual_docs/21_fk.pdf
Examples
# import libraries import scarabaeus as scb import numpy as np # load spice kernels (needed to load SPICE frames) furnshKernelFilename = os.getcwd() + "/data/Kernels/kernels.tm" scb.SpiceManager.load_kernel_from_mkfile(furnshKernelFilename) # Method (1) - generate common frames objects (J2000,ITRF93,ECLIPJ2000,IAUEARTH) = scb.Frame.generate_common_frames() # Method (2) - generate specific frames objects J2000 = scb.Frame("J2000") ITRF93 = scb.Frame("ITRF93") IAUEARTH = scb.Frame("IAU_EARTH") # Print at screen frame object properties J2000.disp_properties() ITRF93.disp_properties() # Print at screen all existing SPICE frames print(scb.SpiceManager.list_all_frames()) # Get frame transformations (DCM and translation) between 'J2000' and 'IAUEARTH' at a given epoch epoch_array = scb.EpochArray(np.array(86400*365*25), 'TDB') # Get rotation and translation components between R = scb.Frame.get_DCM(frame_source = J2000, frame_target = IAUEARTH, epoch = epoch_array) t = scb.Frame.get_translation(frame_source = J2000, frame_target = IAUEARTH, epoch = epoch_array) # Get full (4x4) transformation matrix between 'J2000' and 'IAUEARTH' T = scb.Frame.get_transformation(frame_source = J2000, frame_target = IAUEARTH, epoch = epoch_array)
Attributes
The class ID the SPICE frame (SPICE compatible).
The class of the SPICE frame (SPICE compatible).
The frame ID (SPICE compatible).
The name of the frame.
The origin of the frame (SPICE compatible).
The name of the origin of the frame (SPICE compatible).
Methods
Displays the frame object properties.
Gets a set of common frames.
get_DCM
(source_frame, target_frame, epoch)Gets the Direction Cosine Matrix (DCM) given the source and target frames at a given epoch.
get_transformation
(source_frame, ...)Get 4x4 transformation matrix that combine rotation and translation between source and target frames at a given epoch.
get_translation
(source_frame, target_frame, ...)Get the translation vector between origin of reference frames given the source and target frames at a given epoch.
write_ck_frame
(file_name, frame_name, ...)Generate a CK SPICE frame [1].
write_pck_frame
(file_name, frame_name, ...)Generates a PCK SPICE frame [1].
write_tk_frame
(file_name, frame_name, ...[, ...])Generate a TK SPICE frame [1].
- static generate_common_frames()#
Gets a set of common frames. Generates 4 frames widely used frames.
- Returns:
cmon_frame – A tuple of common frames.
- Return type:
tuple[Frame]
Examples
# initial setup import scarabaeus as scb # get the common frames J2000, ITRF93, ECLIPJ2000, IAUEARTH = scb.Frame.generate_common_frames()
- static get_DCM(source_frame: Self, target_frame: Self, epoch: EpochArray) ndarray #
Gets the Direction Cosine Matrix (DCM) given the source and target frames at a given epoch.
- Parameters:
source_frame (
Frame
) – The source frame which the DCM performs a transformation from.target_frame (
Frame
) – The target frame which the DCM performs a transformation to.epoch (
EpochArray
) – The ephemeris time at which the transformation holds.
- Returns:
DCM – The requested DCM.
- Return type:
- static get_transformation(source_frame: Self, target_frame: Self, epoch: EpochArray) ArrayWUnits #
Get 4x4 transformation matrix that combine rotation and translation between source and target frames at a given epoch. :param source_frame: The source frame which the transformation matrix needs to be computed from. :type source_frame:
Frame
:param target_frame: The target frame which the transformation matrix needs to be computed to. :type target_frame:Frame
:param epoch: The ephemeris time at which the transformation holds. :type epoch:EpochArray
- Returns:
T – The requested (4x4) transformation matrix T.
- Return type:
- static get_translation(source_frame: Self, target_frame: Self, epoch: EpochArray) ArrayWUnits #
Get the translation vector between origin of reference frames given the source and target frames at a given epoch.
- Parameters:
source_frame (
Frame
) – The source frame which the translation vector needs to be computed from.target_frame (
Frame
) – The target frame which the translation vector needs to be computed to.epoch (
EpochArray
) – The ephemeris time at which the transformation holds.
- Returns:
vec – The requested translation vector between origins.
- Return type:
- static write_ck_frame(file_name: str, frame_name: str, frame_id: int, center_id: int, sclk_id: int, spk_id: int) None #
Generate a CK SPICE frame [1].
- Parameters:
file_name (
str
) – The output file name (e.g., “MGS_FRAME_TEST.tf”).frame_name (
str
) – The name of the frame (e.g., “MGS_SPACECRAFT”).frame_id (
int
) – The unique frame ID (e.g., -94000).center_id (
int
) – The body ID at the center of the frame (e.g., -94).sclk_id (
int
) – The spacecraft clock ID associated with the frame (e.g., -94).spk_id (
int
) – The SPK ID associated with the frame (e.g., -94).
- Return type:
References
Examples
# initial setup import scarabaeus as scb import os furnshKernelFilename = os.getcwd() + "/data/Kernels/kernels.tm" scb.SpiceManager.load_kernel_from_mkfile(furnshKernelFilename) scb.Frame.write_ck_frame( file_name="MGS_FRAME_TEST.tf", frame_name="MGS_SPACECRAFT", frame_id=-94000, center_id=-94, sclk_id=-94, spk_id=-94 )
- static write_pck_frame(file_name: str, frame_name: str, frame_class: int, frame_id: int) None #
Generates a PCK SPICE frame [1].
- Parameters:
- Return type:
References
Examples
# initial setup import scarabaeus as scb import os furnshKernelFilename = os.getcwd() + "/data/Kernels/kernels.tm" scb.SpiceManager.load_kernel_from_mkfile(furnshKernelFilename) scb.Frame.write_pck_frame( file_name="EROS_FRAME_TEST.pck", frame_name = "EROS_FIXED", frame_class = 2, frame_id = 2000433)
- static write_tk_frame(file_name: str, frame_name: str, frame_id: int, center_id: int, relative_frame: int, matrix: list = None)#
Generate a TK SPICE frame [1].
- Parameters:
file_name (
str
) – The output file name (e.g., “MARS_FRAME_TEST.tf”).frame_name (
str
) – The name of the frame (e.g., “MARS_FIXED”).frame_id (
int
) – The unique frame ID (e.g., 1400499).center_id (
int
) – The body ID at the center of the frame (e.g., 499).relative_frame (
int
) – The relative reference frame (e.g., “IAU_MARS”).matrix (
list
, optional) – 3x3 transformation matrix. Defaults to the identity matrix.
- Return type:
References
Examples
# initial setup import scarabaeus as scb import os furnshKernelFilename = os.getcwd() + "/data/Kernels/kernels.tm" scb.SpiceManager.load_kernel_from_mkfile(furnshKernelFilename) scb.Frame.write_tk_frame( file_name="MARS_FRAME_TEST.tf", frame_name="MARS_FIXED", frame_id=1400499, center_id=499, relative_frame="IAU_MARS", matrix=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]
)