Trajectory¶
Dynamic-dimension trajectory container for N-dimensional state data.
Trajectory ¶
Trajectory(dimension: int = 6)
Dynamic-dimension trajectory container.
Stores a sequence of N-dimensional states at specific epochs with support for interpolation and automatic state eviction policies. Dimension is determined at runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension | int | Trajectory dimension (default 6, must be greater than 0) | 6 |
Attributes:
| Name | Type | Description |
|---|---|---|
dimension | int | State vector dimension |
interpolation_method | InterpolationMethod | Current interpolation method |
Example
Initialize instance.
length property ¶
length: int
Get the number of states in the trajectory.
Returns:
| Name | Type | Description |
|---|---|---|
int | int | Number of states in the trajectory |
add method descriptor ¶
add_with_covariance method descriptor ¶
Add a state with its corresponding covariance matrix.
This automatically enables covariance storage if not already enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Time epoch | required |
state | ndarray | State vector (must match trajectory dimension) | required |
covariance | ndarray | Covariance matrix (must be square, dimension x dimension) | required |
Example
covariance_at method descriptor ¶
Get covariance matrix at a specific epoch (with interpolation).
Returns None if covariance storage is not enabled or epoch is out of range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Time epoch to query | required |
Returns:
| Type | Description |
|---|---|
ndarray | numpy.ndarray or None: Covariance matrix at the requested epoch (interpolated if necessary) |
enable_covariance_storage method descriptor ¶
enable_covariance_storage() -> Any
Enable covariance storage for this trajectory.
Initializes the covariance vector with zero matrices for all existing states. After calling this, covariances can be added using add_with_covariance() or set_covariance_at().
epoch_at_idx method descriptor ¶
first method descriptor ¶
first() -> Tuple
Get the first (epoch, state) tuple in the trajectory, if any exists.
Returns:
| Type | Description |
|---|---|
Tuple | tuple or None: Tuple of (Epoch, numpy.ndarray) for first state, or None if empty |
Example
from_data builtin ¶
from_data(epochs: list[Epoch], states: ndarray, interpolation_method: InterpolationMethod = None) -> Trajectory
Create a trajectory from existing data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epochs | list[Epoch] | List of time epochs | required |
states | ndarray | 2D array of states with shape (num_epochs, dimension) where each row is a state vector | required |
interpolation_method | InterpolationMethod | Interpolation method (default Linear) | None |
Returns:
| Name | Type | Description |
|---|---|---|
DTrajectory | Trajectory | New trajectory instance populated with data |
get method descriptor ¶
Get both epoch and state at a specific index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index | int | Index to retrieve | required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple | Tuple | Tuple of (Epoch, numpy.ndarray) for epoch and state at the index |
Example
get_covariance_interpolation_method method descriptor ¶
get_interpolation_method method descriptor ¶
get_interpolation_method() -> InterpolationMethod
Get interpolation method.
Returns:
| Name | Type | Description |
|---|---|---|
InterpolationMethod | InterpolationMethod | Current interpolation method |
index_after_epoch method descriptor ¶
Get the index of the state at or after the given epoch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Target epoch | required |
Returns:
| Name | Type | Description |
|---|---|---|
int | int | Index of the state at or after the target epoch |
Example
index_before_epoch method descriptor ¶
Get the index of the state at or before the given epoch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Target epoch | required |
Returns:
| Name | Type | Description |
|---|---|---|
int | int | Index of the state at or before the target epoch |
Example
interpolate method descriptor ¶
Interpolate state at a given epoch using the configured interpolation method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Target epoch | required |
Returns:
| Type | Description |
|---|---|
ndarray | numpy.ndarray: Interpolated state vector |
Example
interpolate_linear method descriptor ¶
Interpolate state at a given epoch using linear interpolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Target epoch | required |
Returns:
| Type | Description |
|---|---|
ndarray | numpy.ndarray: Linearly interpolated state vector |
Example
last method descriptor ¶
last() -> Tuple
Get the last (epoch, state) tuple in the trajectory, if any exists.
Returns:
| Type | Description |
|---|---|
Tuple | tuple or None: Tuple of (Epoch, numpy.ndarray) for last state, or None if empty |
Example
len method descriptor ¶
len() -> int
Get the number of states in the trajectory (alias for length).
Returns:
| Name | Type | Description |
|---|---|---|
int | int | Number of states in the trajectory |
nearest_state method descriptor ¶
Get the nearest state to a given epoch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Target epoch | required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple | Tuple | Tuple of (Epoch, numpy.ndarray) containing the nearest state |
Example
remove method descriptor ¶
Remove a state at a specific index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index | int | Index of the state to remove | required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple | Tuple | Tuple of (Epoch, numpy.ndarray) for the removed epoch and state |
Example
remove_epoch method descriptor ¶
Remove a state at a specific epoch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Epoch of the state to remove | required |
Returns:
| Type | Description |
|---|---|
ndarray | numpy.ndarray: The removed state vector |
Example
set_covariance_at method descriptor ¶
set_covariance_interpolation_method method descriptor ¶
set_covariance_interpolation_method(method: CovarianceInterpolationMethod) -> Any
Set covariance interpolation method.
Covariance matrices require special interpolation methods to preserve positive semi-definiteness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method | CovarianceInterpolationMethod | Covariance interpolation method to use | required |
set_eviction_policy_max_age method descriptor ¶
Set maximum age for trajectory states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_age | float | Maximum age in seconds relative to most recent state | required |
set_eviction_policy_max_size method descriptor ¶
Set maximum trajectory size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_size | int | Maximum number of states to retain | required |
set_interpolation_method method descriptor ¶
set_interpolation_method(method: InterpolationMethod) -> Any
state_after_epoch method descriptor ¶
Get the state at or after the given epoch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Target epoch | required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple | Tuple | Tuple of (Epoch, numpy.ndarray) containing state at or after the target epoch |
Example
state_at_idx method descriptor ¶
state_before_epoch method descriptor ¶
Get the state at or before the given epoch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epoch | Epoch | Target epoch | required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple | Tuple | Tuple of (Epoch, numpy.ndarray) containing state at or before the target epoch |
Example
with_covariance_interpolation_method method descriptor ¶
Set covariance interpolation method using builder pattern.
Covariance matrices require special interpolation methods to preserve positive semi-definiteness. This method allows setting the interpolation method used when calling covariance_at().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method | CovarianceInterpolationMethod | Covariance interpolation method to use | required |
Returns:
| Name | Type | Description |
|---|---|---|
DTrajectory | DTrajectory | Self with updated covariance interpolation method |
with_eviction_policy_max_age method descriptor ¶
with_eviction_policy_max_age(max_age: float) -> DTrajectory
Set eviction policy to keep states within maximum age using builder pattern
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_age | float | Maximum age of states in seconds | required |
Returns:
| Name | Type | Description |
|---|---|---|
DTrajectory | DTrajectory | Self with updated eviction policy |
with_eviction_policy_max_size method descriptor ¶
with_eviction_policy_max_size(max_size: int) -> DTrajectory
Set eviction policy to keep maximum number of states using builder pattern
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_size | int | Maximum number of states to retain | required |
Returns:
| Name | Type | Description |
|---|---|---|
DTrajectory | DTrajectory | Self with updated eviction policy |
with_interpolation_method method descriptor ¶
with_interpolation_method(interpolation_method: InterpolationMethod) -> DTrajectory
Set interpolation method using builder pattern
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interpolation_method | InterpolationMethod | Interpolation method to use | required |
Returns:
| Name | Type | Description |
|---|---|---|
DTrajectory | DTrajectory | Self with updated interpolation method |
See Also¶
- OrbitTrajectory - Frame-aware orbital trajectory
- InterpolationMethod