Orbital States
Representations of orbital states in Cartesian and Keplerian forms.
Quick Example
import lox_space as lox
# Create a Cartesian state
t = lox.Time("TAI", 2024, 1, 1)
state = lox.State(
time=t,
position=(6678.0, 0.0, 0.0), # km
velocity=(0.0, 7.73, 0.0), # km/s
)
# Convert to Keplerian elements
kep = state.to_keplerian()
print(f"a = {kep.semi_major_axis():.1f} km")
print(f"e = {kep.eccentricity():.6f}")
print(f"i = {kep.inclination():.4f} rad")
# Create from Keplerian elements
kep = lox.Keplerian(
time=t,
semi_major_axis=6678.0,
eccentricity=0.001,
inclination=0.5,
longitude_of_ascending_node=0.0,
argument_of_periapsis=0.0,
true_anomaly=0.0,
)
state = kep.to_cartesian()
# Work with trajectories
trajectory = lox.Trajectory([state1, state2, state3])
interpolated = trajectory.interpolate(t + lox.TimeDelta(100))
State
Represents an orbital state (position and velocity) at a specific time.
Parameters:
-
–timeThe epoch of this state.
-
–positionPosition vector (x, y, z) in km.
-
–velocityVelocity vector (vx, vy, vz) in km/s.
-
–originCentral body (default: Earth).
-
–frameReference frame (default: ICRF).
Examples:
>>> t = lox.Time("TAI", 2024, 1, 1)
>>> state = lox.State(
... t,
... position=(6678.0, 0.0, 0.0),
... velocity=(0.0, 7.73, 0.0),
... )
Methods:
-
origin–Return the central body (origin) of this state.
-
position–Return the position vector as a numpy array [x, y, z] in km.
-
reference_frame–Return the reference frame of this state.
-
rotation_lvlh–Compute the rotation matrix from inertial to LVLH frame.
-
time–Return the epoch of this state.
-
to_frame–Transform this state to a different reference frame.
-
to_ground_location–Convert this state to a ground location.
-
to_keplerian–Convert this Cartesian state to Keplerian orbital elements.
-
to_origin–Transform this state to a different central body.
-
velocity–Return the velocity vector as a numpy array [vx, vy, vz] in km/s.
position
position() -> ndarray
Return the position vector as a numpy array [x, y, z] in km.
rotation_lvlh
rotation_lvlh() -> ndarray
Compute the rotation matrix from inertial to LVLH frame.
to_frame
to_frame(frame: Frame, provider: EOPProvider | None = None) -> Self
Transform this state to a different reference frame.
to_keplerian
to_keplerian() -> Keplerian
Convert this Cartesian state to Keplerian orbital elements.
to_origin
Transform this state to a different central body.
velocity
velocity() -> ndarray
Return the velocity vector as a numpy array [vx, vy, vz] in km/s.
Keplerian
Represents an orbit using Keplerian (classical) orbital elements.
Parameters:
-
–timeEpoch of the elements.
-
–semi_major_axisSemi-major axis in km.
-
–eccentricityOrbital eccentricity (0 = circular, <1 = elliptical).
-
–inclinationInclination in radians.
-
–longitude_of_ascending_nodeRAAN in radians.
-
–argument_of_periapsisArgument of periapsis in radians.
-
–true_anomalyTrue anomaly in radians.
-
–originCentral body (default: Earth).
Examples:
>>> import math
>>> t = lox.Time("TAI", 2024, 1, 1)
>>> orbit = lox.Keplerian(
... t,
... semi_major_axis=6678.0,
... eccentricity=0.001,
... inclination=math.radians(51.6),
... longitude_of_ascending_node=0.0,
... argument_of_periapsis=0.0,
... true_anomaly=0.0,
... )
Methods:
-
argument_of_periapsis–Return the argument of periapsis in radians.
-
eccentricity–Return the orbital eccentricity.
-
inclination–Return the inclination in radians.
-
longitude_of_ascending_node–Return the longitude of the ascending node (RAAN) in radians.
-
orbital_period–Return the orbital period.
-
origin–Return the central body (origin) of this orbit.
-
semi_major_axis–Return the semi-major axis in km.
-
time–Return the epoch of these elements.
-
to_cartesian–Convert these Keplerian elements to a Cartesian state.
-
true_anomaly–Return the true anomaly in radians.
longitude_of_ascending_node
longitude_of_ascending_node() -> float
Return the longitude of the ascending node (RAAN) in radians.
Trajectory
A time-series of orbital states with interpolation support.
Parameters:
-
–statesList of State objects in chronological order.
Examples:
>>> trajectory = propagator.propagate(times)
>>> state = trajectory.interpolate(t)
>>> arr = trajectory.to_numpy()
Methods:
-
find_events–Find events where a function crosses zero.
-
find_windows–Find time windows where a function is positive.
-
from_numpy–Create a Trajectory from a numpy array.
-
interpolate–Interpolate the trajectory at a specific time.
-
origin–Return the central body (origin) of this trajectory.
-
reference_frame–Return the reference frame of this trajectory.
-
states–Return the list of states in this trajectory.
-
to_frame–Transform all states to a different reference frame.
-
to_numpy–Export trajectory to a numpy array.
-
to_origin–Transform all states to a different central body.
find_events
Find events where a function crosses zero.
find_windows
Find time windows where a function is positive.
from_numpy
classmethod
from_numpy(
start_time: Time,
states: ndarray,
origin: Origin | None = None,
frame: Frame | None = None,
) -> Self
Create a Trajectory from a numpy array.
Parameters:
interpolate
Interpolate the trajectory at a specific time.
to_frame
to_frame(frame: Frame, provider: EOPProvider | None = None) -> Self
Transform all states to a different reference frame.
to_numpy
to_numpy() -> ndarray
Export trajectory to a numpy array.
Ensemble
Collection of named trajectories for batch visibility analysis.
Parameters:
-
–ensembleDictionary mapping spacecraft names to their trajectories.
Examples:
>>> ensemble = lox.Ensemble({
... "SC1": trajectory1,
... "SC2": trajectory2,
... })
>>> results = lox.visibility_all(times, ground_stations, ensemble, spk)