ADCS.orbits.orbital_state module¶
- class ADCS.orbits.orbital_state.Orbital_State(ephem=None, J2000=None, R=None, V=None, S=None, B=None, rho=None, density_model=None, fast=False, magnetic_model='igrf_numba', environment=None)[source]¶
Bases:
objectComplete dynamical and environmental representation of a spacecraft orbital state.
The state is defined by inertial position and velocity in the ECI/ICRF frame at an epoch expressed in J2000 centuries. The class also stores commonly-used derived quantities and environment vectors, including Earth-fixed coordinates, Sun vector, geomagnetic field vector (IGRF), atmospheric density, and frame transforms.
Notes
The
fastargument is accepted for backward compatibility but is ignored: this implementation always computes real Sun and geomagnetic field vectors and frame transforms.- Parameters:
ephem (Ephemeris) – Ephemeris object used for Earth and Sun position queries. If omitted, the default environment supplies DE421.
J2000 (float) – Epoch in Julian centuries since J2000.
R (numpy.ndarray) – Position vector in ECI frame [km].
V (numpy.ndarray) – Velocity vector in ECI frame [km/s].
S (numpy.ndarray or None) – Optional Sun position vector in ECI frame [km]. If
None, it is computed.B (numpy.ndarray or None) – Optional geomagnetic field vector in ECI frame [T]. If
None, it is computed.rho (float or None) – Optional atmospheric density [kg/m^3]. If
None, it is computed by the atmosphere selected inenvironment.environment (Environment or None) – Environment models used to sample the state. When omitted, defaults are combined with any supplied
ephemormagnetic_model.fast (bool) – Backward-compatible parameter (ignored). Real environment vectors are always computed.
magnetic_model (str)
Osculating Keplerian elements. Every state carries the classical elements of its instantaneous
(R, V), computed on first access:semi_major_axis,semi_minor_axis,semi_parameter,apoapsis,periapsis,eccentricity,eccentricity_vector,inclination,longitude_of_ascending_node,argument_of_periapsis,longitude_of_periapsis,true_anomaly_at_epoch,eccentric_anomaly_at_epoch,mean_anomaly_at_epoch,mean_longitude_at_epoch,true_longitude_at_epoch,argument_of_latitude_at_epoch,mean_argument_of_latitude_at_epoch,mean_motion,orbital_period,time_of_periapsis_passage,epochandmass_of_the_two_bodies, plus thekeplerian_elementsdict of the same values. Units follow the rest of the package: distances in km, angles in radians in[0, 2pi), mean motion in rad/s, period in s, epoch and periapsis passage as TT Julian dates, mass in kg. Undefined elements (radial, parabolic or hyperbolic motion) arenan. These are osculating values and differ from the mean elements in a TLE.The conversion methods
from_keplerian()andto_keplerian()speak degrees by default because orbits are usually typed that way; both takedegrees=Falseto use radians and match the attributes.- classmethod from_TLE(tle, line2=None, J2000=None, *, environment=None)[source]¶
Create a state from a Skyfield EarthSatellite or two TLE lines.
By default, samples the TLE at its epoch.
J2000optionally selects another epoch in Julian centuries since J2000. TLE-derived position and velocity are converted from TEME to the package’s inertial frame using Skyfield’s position representation.- Parameters:
line2 (str | None)
J2000 (float | None)
environment (Environment | None)
- Return type:
- classmethod from_dict(d, ephem=None, density_model=None, fast=True, magnetic_model=None, environment=None)[source]¶
Construct an orbital state from a dictionary.
Notes
The
fastargument is accepted for backward compatibility but is ignored.- Parameters:
d (dict) – Dictionary containing orbital state fields.
ephem (Ephemeris) – Ephemeris object.
density_model (Atmosphere or None) – Deprecated; pass
environment=Environment(atmosphere=...)instead. Still accepted, with aDeprecationWarning.fast (bool) – Backward-compatible parameter (ignored).
magnetic_model (str or None) – Geomagnetic field model. When omitted, the one recorded in
dis used, falling back to the default for dicts written before the field existed.environment (Environment or None) – Models used to reconstruct the state.
- Returns:
Reconstructed orbital state.
- Return type:
- Raises:
ValueError – If both
density_modelandenvironmentare given.
- classmethod from_keplerian(J2000, a, e, i, raan, arg_periapsis, true_anomaly, *, mu=398600.4415, degrees=True, environment=None, ephem=None, magnetic_model='igrf_numba')[source]¶
Create an ECI state from classical Keplerian elements.
ais semi-major axis in km.i,raan,arg_periapsisandtrue_anomalyare in degrees by default; passdegrees=Falseto give them in radians, the unit of the element attributes (inclination,longitude_of_ascending_node, …). The supported conic is an ellipse (a > 0and0 <= e < 1).- Parameters:
J2000 (float)
a (float)
e (float)
i (float)
raan (float)
arg_periapsis (float)
true_anomaly (float)
mu (float)
degrees (bool)
environment (Environment | None)
ephem (DE421 | None)
magnetic_model (str)
- Return type:
- classmethod from_position(J2000, R, V, *, environment=None, ephem=None, magnetic_model='igrf_numba')[source]¶
Create a state from inertial Cartesian position and velocity.
This named constructor is equivalent to calling
Orbital_Statedirectly, and makes the coordinate convention explicit:RandVare ECI/ICRF vectors in km and km/s.- Parameters:
J2000 (float)
R (ndarray)
V (ndarray)
environment (Environment | None)
ephem (DE421 | None)
magnetic_model (str)
- Return type:
- classmethod from_tle(tle, line2=None, J2000=None, *, environment=None)¶
Create a state from a Skyfield EarthSatellite or two TLE lines.
By default, samples the TLE at its epoch.
J2000optionally selects another epoch in Julian centuries since J2000. TLE-derived position and velocity are converted from TEME to the package’s inertial frame using Skyfield’s position representation.- Parameters:
line2 (str | None)
J2000 (float | None)
environment (Environment | None)
- Return type:
- average(orbital_state_2, ratio=0.5, fast=False)[source]¶
Linearly interpolate between two orbital states.
- Parameters:
orbital_state_2 (Orbital_State) – Second orbital state.
ratio (float) – Interpolation ratio in [0, 1].
fast (bool) – Backward-compatible parameter (ignored).
- Returns:
Interpolated orbital state.
- Return type:
- copy()[source]¶
Return a deep copy of the orbital state.
This implementation avoids recomputing environment vectors and frame transforms.
- Returns:
Independent copy of the orbital state.
- Return type:
- ecef_to_eci(vec)[source]¶
Transform a vector from ECEF to ECI coordinates.
- Parameters:
vec (numpy.ndarray) – Vector in ECEF frame.
- Returns:
Vector in ECI frame.
- Return type:
numpy.ndarray
- ecef_to_geocentric(vec)[source]¶
Transform an ECEF vector to local geocentric coordinates.
- Parameters:
vec (numpy.ndarray) – Vector in ECEF frame.
- Returns:
Vector in geocentric basis.
- Return type:
numpy.ndarray
- eci_to_ecef(vec)[source]¶
Transform a vector from ECI to ECEF coordinates.
- Parameters:
vec (numpy.ndarray) – Vector in ECI frame.
- Returns:
Vector in ECEF frame.
- Return type:
numpy.ndarray
- eci_to_enu(vec)[source]¶
Transform a vector from ECI to local ENU frame.
- Parameters:
vec (numpy.ndarray) – Vector in ECI frame.
- Returns:
Vector in ENU frame.
- Return type:
numpy.ndarray
- enu_to_eci(vec)[source]¶
Transform a vector from ENU to ECI frame.
- Parameters:
vec (numpy.ndarray) – Vector in ENU frame.
- Returns:
Vector in ECI frame.
- Return type:
numpy.ndarray
- geocentric_to_ecef(vec)[source]¶
Transform a geocentric vector to ECEF coordinates.
- Parameters:
vec (numpy.ndarray) – Vector in geocentric basis.
- Returns:
Vector in ECEF frame.
- Return type:
numpy.ndarray
- get_b_eci()[source]¶
Compute the geomagnetic field vector in the ECI frame.
- Returns:
Magnetic field vector [Tesla].
- Return type:
numpy.ndarray
- get_state_vector(x)[source]¶
Retrieve cached or updated body-frame vectors.
- Parameters:
x (ADCS.state.State or None) – Current spacecraft state, or
Noneto return initialized cached vectors.- Returns:
Dictionary of vectors and derivatives.
- Return type:
dict[str, numpy.ndarray]
- get_sun_eci()[source]¶
Compute the Sun position vector in the ECI frame.
- Returns:
Sun vector in ECI coordinates [km].
- Return type:
numpy.ndarray
- is_sunlit()[source]¶
Determine whether the spacecraft is illuminated by the Sun.
- Returns:
Trueif sunlit,Falseotherwise.- Return type:
bool
- j2000_to_tai()[source]¶
Convert J2000 centuries to TAI Julian date.
- Returns:
TAI Julian date.
- Return type:
float
- orbit_dynamics(zonal_J=2)[source]¶
Compute translational orbital dynamics at the current state.
- Parameters:
zonal_J (int) – Highest zonal harmonic degree to include.
0disables zonals,2includes only J2, and larger values include every zonal term up to that degree.- Returns:
Time derivatives of position and velocity.
- Return type:
tuple[numpy.ndarray, numpy.ndarray]
- orbit_dynamics_jacobians(zonal_J=2)[source]¶
Compute Jacobians of the translational dynamics.
- Parameters:
zonal_J (int) – Highest zonal harmonic degree to include.
0disables zonals,2includes only J2, and larger values include every zonal term up to that degree.- Returns:
Jacobian matrices of the dynamics.
- Return type:
tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]
- propagate_jacobians(dt, zonal_J=2)[source]¶
Propagate state transition Jacobians using first-order integration.
- Parameters:
dt (float) – Time step in seconds.
zonal_J (int) – Highest zonal harmonic degree to include.
0disables zonals,2includes only J2, and larger values include every zonal term up to that degree.
- Returns:
State transition Jacobian blocks.
- Return type:
tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]
- propagate_jacobians_rk4(dt, zonal_J=2)[source]¶
Propagate state transition Jacobians using RK4 integration.
- Parameters:
dt (float) – Time step in seconds.
zonal_J (int) – Highest zonal harmonic degree to include.
0disables zonals,2includes only J2, and larger values include every zonal term up to that degree.
- Returns:
State transition Jacobian blocks.
- Return type:
tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]
- propagate_orbit(dt, fast=True, zonal_J=2)[source]¶
Propagate the orbital state forward using first-order integration.
- Parameters:
dt (float) – Time step in seconds.
fast (bool) – Backward-compatible parameter (ignored).
zonal_J (int) – Highest zonal harmonic degree to include.
0disables zonals,2includes only J2, and larger values include every zonal term up to that degree.
- Returns:
Propagated orbital state.
- Return type:
- propagate_orbit_rk4(dt, fast=True, zonal_J=2)[source]¶
Propagate the orbital state using fourth-order Runge–Kutta integration.
- Parameters:
dt (float) – Time step in seconds.
fast (bool) – Backward-compatible parameter (ignored).
zonal_J (int) – Highest zonal harmonic degree to include.
0disables zonals,2includes only J2, and larger values include every zonal term up to that degree.
- Returns:
Propagated orbital state.
- Return type:
- to_TLE(*, satellite_number=99999, classification='U')[source]¶
Format the osculating state as an approximate two-line element set.
TLEs store SGP4 mean elements, so these lines are a convenient approximation and are not an SGP4 fit to the state; see
ADCS.orbits.sgp4_orbit.SGP4Orbitfor a fitted set.satellite_numbermust be in the five-digit range supported by traditional TLEs.- Parameters:
satellite_number (int)
classification (str)
- Return type:
Tuple[str, str]
- to_dict()[source]¶
Serialize the orbital state to a dictionary.
- Returns:
Dictionary representation of the orbital state.
- Return type:
dict
- to_keplerian(*, mu=398600.4415, degrees=True)[source]¶
Return classical elliptic elements
(a, e, i, raan, argp, nu).ais in km. Angles are in degrees by default; passdegrees=Falsefor radians, which matches the element attributes (inclination,longitude_of_ascending_node,argument_of_periapsis,true_anomaly_at_epoch). For circular or equatorial orbits, the undefined angular elements are set to zero and the remaining angle is chosen to preserve the state as far as the classical convention allows.- Parameters:
mu (float)
degrees (bool)
- Return type:
Tuple[float, float, float, float, float, float]
- to_position()[source]¶
Return
(J2000, R, V)in Julian centuries, km, and km/s.- Return type:
Tuple[float, ndarray, ndarray]
- update_vecs(x)[source]¶
Update body-frame vectors and their derivatives from a structured state.
- Parameters:
x (ADCS.state.State) – Spacecraft state containing the attitude quaternion.
- Returns:
None- Return type:
None