Skip to content

STrajectory6

STrajectory6

STrajectory6()

Static-dimension 6D trajectory container.

Stores a sequence of 6-dimensional states at specific epochs with support for interpolation and automatic state eviction policies. Dimension is fixed at compile time for performance.

Initialize instance.

__doc__ class-attribute

__doc__ = 'Static-dimension 6D trajectory container.\n\nStores a sequence of 6-dimensional states at specific epochs with support\nfor interpolation and automatic state eviction policies. Dimension is fixed\nat compile time for performance.'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

__module__ class-attribute

__module__ = 'brahe._brahe'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

end_epoch property

end_epoch: Epoch

Get end epoch of trajectory.

Returns:

Type Description
Epoch

Epoch or None: Last epoch if trajectory is not empty, None otherwise

interpolation_method property

interpolation_method: InterpolationMethod

Get interpolation method.

Returns:

Name Type Description
InterpolationMethod InterpolationMethod

Current interpolation method

length property

length: int

Get the number of states in the trajectory.

Returns:

Name Type Description
int int

Number of states in the trajectory

Example
import brahe as bh
import numpy as np

traj = bh.DTrajectory(6)
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc, state)
print(f"Trajectory length: {traj.length}")

start_epoch property

start_epoch: Epoch

Get start epoch of trajectory.

Returns:

Type Description
Epoch

Epoch or None: First epoch if trajectory is not empty, None otherwise

time_span property

time_span: float

Get time span of trajectory in seconds.

Returns:

Type Description
float

float or None: Time span between first and last epochs, or None if less than 2 states

__getitem__ method descriptor

__getitem__(key: str) -> Any

Return self[key].

__iter__ method descriptor

__iter__() -> Any

Implement iter(self).

__len__ method descriptor

__len__() -> int

Return len(self).

__new__ builtin

__new__(*args, **kwargs)

Create and return a new object. See help(type) for accurate signature.

__repr__ method descriptor

__repr__() -> str

Return repr(self).

__str__ method descriptor

__str__() -> str

Return str(self).

add method descriptor

add(epoch: Epoch, state: ndarray) -> Any

Add a state to the trajectory.

Parameters:

Name Type Description Default
epoch Epoch

Time of the state

required
state ndarray

6-element state vector

required

clear method descriptor

clear() -> Any

Clear all states from the trajectory.

dimension method descriptor

dimension() -> int

Get trajectory dimension (always 6).

Returns:

Name Type Description
int int

Dimension of the trajectory (always 6)

epoch_at_idx method descriptor

epoch_at_idx(index: int) -> Epoch

Get epoch at a specific index

Parameters:

Name Type Description Default
index int

Index of the epoch

required

Returns:

Name Type Description
Epoch Epoch

Epoch at index

Example
import brahe as bh
import numpy as np

traj = bh.DTrajectory(6)
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc, state)
retrieved_epc = traj.epoch_at_idx(0)

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc, state)
first_epc, first_state = traj.first()

from_data builtin

from_data(epochs: list[Epoch], states: ndarray, interpolation_method: InterpolationMethod = None) -> STrajectory6

Create a trajectory from existing data.

Parameters:

Name Type Description Default
epochs list[Epoch]

List of time epochs

required
states ndarray

Flattened 1D array of 6D state vectors with total length N*6 where N is the number of epochs

required
interpolation_method InterpolationMethod

Interpolation method (default Linear)

None

Returns:

Name Type Description
STrajectory6 STrajectory6

New 6D trajectory instance populated with data

Example
import brahe as bh
import numpy as np

epc1 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
epc2 = bh.Epoch.from_datetime(2024, 1, 1, 12, 1, 0.0, 0.0, bh.TimeSystem.UTC)
states = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0,
                   bh.R_EARTH + 510e3, 0.0, 0.0, 0.0, 7650.0, 0.0])
traj = bh.STrajectory6.from_data([epc1, epc2], states)

get method descriptor

get(index: int) -> Tuple

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc, state)
ret_epc, ret_state = traj.get(0)

get_eviction_policy method descriptor

get_eviction_policy() -> str

Get current eviction policy.

Returns:

Name Type Description
str str

String representation of eviction policy

Example
import brahe as bh

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
policy = traj.get_eviction_policy()

index_after_epoch method descriptor

index_after_epoch(epoch: Epoch) -> int

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc1 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc1, state)
epc2 = bh.Epoch.from_datetime(2024, 1, 1, 11, 59, 0.0, 0.0, bh.TimeSystem.UTC)
index = traj.index_after_epoch(epc2)

index_before_epoch method descriptor

index_before_epoch(epoch: Epoch) -> int

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc1 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc1, state)
epc2 = bh.Epoch.from_datetime(2024, 1, 1, 12, 1, 0.0, 0.0, bh.TimeSystem.UTC)
index = traj.index_before_epoch(epc2)

interpolate method descriptor

interpolate(epoch: Epoch) -> ndarray

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc1 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state1 = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc1, state1)
epc2 = bh.Epoch.from_datetime(2024, 1, 1, 12, 2, 0.0, 0.0, bh.TimeSystem.UTC)
state2 = np.array([bh.R_EARTH + 510e3, 0.0, 0.0, 0.0, 7650.0, 0.0])
traj.add(epc2, state2)
epc_mid = bh.Epoch.from_datetime(2024, 1, 1, 12, 1, 0.0, 0.0, bh.TimeSystem.UTC)
state_interp = traj.interpolate(epc_mid)

interpolate_linear method descriptor

interpolate_linear(epoch: Epoch) -> ndarray

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc1 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state1 = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc1, state1)
epc2 = bh.Epoch.from_datetime(2024, 1, 1, 12, 2, 0.0, 0.0, bh.TimeSystem.UTC)
state2 = np.array([bh.R_EARTH + 510e3, 0.0, 0.0, 0.0, 7650.0, 0.0])
traj.add(epc2, state2)
epc_mid = bh.Epoch.from_datetime(2024, 1, 1, 12, 1, 0.0, 0.0, bh.TimeSystem.UTC)
state_interp = traj.interpolate_linear(epc_mid)

is_empty method descriptor

is_empty() -> bool

Check if trajectory is empty.

Returns:

Name Type Description
bool bool

True if trajectory contains no states, False otherwise

Example
import brahe as bh

traj = bh.DTrajectory(6)
print(f"Is empty: {traj.is_empty()}")

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc, state)
last_epc, last_state = traj.last()

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

Example
import brahe as bh
import numpy as np

traj = bh.DTrajectory(6)
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc, state)
print(f"Number of states: {traj.len()}")

nearest_state method descriptor

nearest_state(epoch: Epoch) -> Tuple

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc1 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc1, state)
epc2 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 30.0, 0.0, bh.TimeSystem.UTC)
nearest_epc, nearest_state = traj.nearest_state(epc2)

remove method descriptor

remove(index: int) -> Tuple

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc, state)
removed_epc, removed_state = traj.remove(0)

remove_epoch method descriptor

remove_epoch(epoch: Epoch) -> ndarray

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc, state)
removed_state = traj.remove_epoch(epc)

set_eviction_policy_max_age method descriptor

set_eviction_policy_max_age(max_age: float) -> Any

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_eviction_policy_max_size(max_size: int) -> Any

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

Set the interpolation method for the trajectory.

Parameters:

Name Type Description Default
method InterpolationMethod

New interpolation method

required
Example
import brahe as bh

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
traj.set_interpolation_method(bh.InterpolationMethod.LINEAR)

state_after_epoch method descriptor

state_after_epoch(epoch: Epoch) -> Tuple

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc1 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc1, state)
epc2 = bh.Epoch.from_datetime(2024, 1, 1, 11, 59, 0.0, 0.0, bh.TimeSystem.UTC)
ret_epc, ret_state = traj.state_after_epoch(epc2)

state_at_idx method descriptor

state_at_idx(index: int) -> ndarray

Get state at a specific index

Parameters:

Name Type Description Default
index int

Index of the state

required

Returns:

Type Description
ndarray

numpy.ndarray: State vector at index

Example
import brahe as bh
import numpy as np

traj = bh.DTrajectory(6)
epc = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc, state)
retrieved_state = traj.state_at_idx(0)

state_before_epoch method descriptor

state_before_epoch(epoch: Epoch) -> Tuple

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
import brahe as bh
import numpy as np

traj = bh.OrbitTrajectory(bh.OrbitFrame.ECI, bh.OrbitRepresentation.CARTESIAN, None)
epc1 = bh.Epoch.from_datetime(2024, 1, 1, 12, 0, 0.0, 0.0, bh.TimeSystem.UTC)
state = np.array([bh.R_EARTH + 500e3, 0.0, 0.0, 0.0, 7600.0, 0.0])
traj.add(epc1, state)
epc2 = bh.Epoch.from_datetime(2024, 1, 1, 12, 1, 0.0, 0.0, bh.TimeSystem.UTC)
ret_epc, ret_state = traj.state_before_epoch(epc2)

to_matrix method descriptor

to_matrix() -> ndarray

Get all states as a numpy array

with_eviction_policy_max_age method descriptor

with_eviction_policy_max_age(max_age: float) -> STrajectory6

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
STrajectory6 STrajectory6

Self with updated eviction policy

with_eviction_policy_max_size method descriptor

with_eviction_policy_max_size(max_size: int) -> STrajectory6

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
STrajectory6 STrajectory6

Self with updated eviction policy

with_interpolation_method method descriptor

with_interpolation_method(interpolation_method: InterpolationMethod) -> STrajectory6

Set interpolation method using builder pattern

Parameters:

Name Type Description Default
interpolation_method InterpolationMethod

Interpolation method to use

required

Returns:

Name Type Description
STrajectory6 STrajectory6

Self with updated interpolation method

Static 6-dimensional trajectory optimized for orbital state storage.

Overview

STrajectory6 provides compile-time optimized storage for 6-dimensional Cartesian states [x, y, z, vx, vy, vz]. It offers the best performance for standard orbital mechanics applications.

Features

  • Fixed dimension: Always 6D (compile-time optimization)
  • Lower memory overhead: More efficient than DTrajectory
  • Fastest performance: Optimized for Cartesian orbital states
  • Full interpolation: Supports linear, cubic, and Lagrange interpolation
  • Eviction policies: Memory management via automatic state removal

When to Use

Use STrajectory6 when:

  • Storing standard Cartesian orbital states
  • Performance is critical
  • State dimension is always 6
  • Not using orbit-specific features (use OrbitTrajectory for that)

See Also