Frame#
- class spacekernel.frames.Frame#
Bases:
objectAbstract base class for reference frames and coordinate systems.
Manages frame registration, provides transformation graph utilities, and enables transformation of vectors between frames.
|
Get a registered Frame instance by name. |
|
Return a hash for the Frame instance. |
|
Check if a frame with the given name is registered. |
Frame.name: str Get the registered name of this frame. |
|
|
Find a sequence of frames (route) from source to target frame. |
|
Return the dictionary of direct transforms from this frame. |
|
Transform position and velocity vectors to another frame. |
|
Register a direct transformation from this frame to a target frame. |
|
Remove the direct transformation from this frame to a target frame. |
- classmethod Frame.__class_getitem__(cls, str item: str) Frame#
Get a registered Frame instance by name.
- Parameters:
- itemstr
The name of the frame (case-insensitive).
- Returns:
- Frame
The Frame instance associated with the given name.
- Raises:
- KeyError
If no Frame with the given name is registered.
- classmethod Frame.is_frame(cls, str item: str) bool#
Check if a frame with the given name is registered.
- Parameters:
- itemstr
Name of the frame.
- Returns:
- bool
True if the frame is registered, False otherwise.
- Frame.name()#
Frame.name: str Get the registered name of this frame.
- Returns:
- str
The name of the frame, or ‘Unnamed’ if not registered.
- classmethod Frame.get_route(cls, source: Frame | str, target: Frame | str) list[Frame]#
Find a sequence of frames (route) from source to target frame.
- Parameters:
- sourceFrame or str
The starting frame or its name.
- targetFrame or str
The target frame or its name.
- Returns:
- list of Frame
The list of frames forming the transformation path.
- Raises:
- ValueError
If no route is found between source and target frames.
- Frame.transforms(self) dict[Frame, Callable]#
Return the dictionary of direct transforms from this frame.
- Returns:
- dict of {Frame: Callable}
Keys are adjacent frames; values are functions to transform coordinates from this frame to the adjacent frame.
- Frame.transform_to(self, frame: Frame | str, time: DatetimeLike, r: ndarray[double], v: ndarray[double]) tuple[ndarray, 2]#
Transform position and velocity vectors to another frame.
- Parameters:
- frameFrame or str
Target frame or its name.
- timeDatetimeLike
Time of the transformation.
- rndarray
Position vector(s) in this frame.
- vndarray
Velocity vector(s) in this frame.
- Returns:
- tuple of ndarray, 2
Transformed position and velocity vectors in the target frame.
- Raises:
- ValueError
If no route is found between the frames.
- Frame.register_transform(self, Frame target_frame: Frame, transform: Callable) None#
Register a direct transformation from this frame to a target frame.
- Parameters:
- target_frameFrame
The frame to which the transformation applies.
- transformCallable
The transformation function to convert coordinates from this frame to the target frame. The callable should have the signature (time: Time, position: ndarray[(N, 3)], velocity: ndarray[(N, 3)]).
- Returns:
- None
Notes
Overwrites any existing transformation to the same target frame.
Useful for dynamically adding or replacing frame transformations at runtime.
- Frame.remove_transform(self, Frame target_frame: Frame) None#
Remove the direct transformation from this frame to a target frame.
- Parameters:
- target_frameFrame
The frame whose transformation should be removed.
- Returns:
- None
- Raises:
- KeyError
If no transformation to the target frame exists.
Notes
After removal, transformations to the target frame must be re-registered to be available again.