Utilities Subpackage¶
@authors: Alberto FOSSA’ Giuliana Elena MICELI |
|
@authors: Alberto FOSSA’ Giuliana Elena MICELI |
|
@authors: Alberto FOSSA’ Giuliana Elena MICELI |
|
@authors: Alberto FOSSA’ Giuliana Elena MICELI |
|
@authors: Alberto FOSSA’ Giuliana Elena MICELI |
|
@authors: Alberto FOSSA’ Giuliana Elena MICELI |
Documentation¶
@authors: Alberto FOSSA’ Giuliana Elena MICELI
-
class
latom.utils.keplerian_orbit.TwoDimOrb(gm, **kwargs)[source] Bases:
objectDefines a two-dimensional orbit from its keplerian parameters.
- Parameters
gm (float) – Central body standard gravitational parameter [m^3/s^2]
- Other Parameters
T (float) – Orbital period [s]
a (float) – Semi-major axis [m]
e (float) – Eccentricity [-]
ra (float) – Apoapsis radius [m]
rp (float) – Periapsis radius [m]
- Variables
GM (float, optional) – Central body standard gravitational parameter [m^3/s^2]
T (float) – Orbit period [s]
a (float) – Semi-major axis [m]
e (float) – Eccentricity [-]
ra (float) – Apoapsis radius [m]
rp (float) – Periapsis radius [m]
va (float) – Velocity at the apoapsis [m/s]
vp (float) – Velocity at the periapsis [m/s]
h (float) – Specific angular momentum magnitude [m^2/s]
energy (float) – Specific energy of the orbit in 2BP [m^2/s^2]
-
static
coe2polar(gm, ta, **kwargs)[source] Transforms the classical orbital elements into polar coordinates.
- Parameters
gm (float) – Central body standard gravitational parameter [m^3/s^2]
ta (float or ndarray) – True anomaly [rad]
- Other Parameters
a (float) – Semi-major axis [m]
e (float) – Eccentricity [-]
h (float) – Specific angular momentum magnitude [m^2/s]
- Returns
r (float or ndarray) – Position in polar coordinates [m]
u (float or ndarray) – radial velocity [m/s]
v (float or ndarray) – tangential velocity [m/s]
-
static
polar2coe(gm, r, u, v)[source] Transforms the polar coordinates into classical orbital elements.
- Parameters
gm (float) – Central body standard gravitational parameter [m^3/s^2]
r (float or ndarray) – Position in polar coordinates [m]
u (float or ndarray) – radial velocity [m/s]
v (float or ndarray) – tangential velocity [m/s]
- Returns
a (float) – Orbit semi-major axis [m]
e (float) – Orbit eccentricity [-]
h (float) – Orbit specific angular momentum magnitude [m^2/s]
ta (float or ndarray) – True anomaly [rad]
-
static
polar2energy(gm, r, u, v)[source] Returns the energy given the polar coordinates.
- Parameters
gm (float) – Central body standard gravitational parameter [m^3/s^2]
r (float or ndarray) – Position in polar coordinates [m]
u (float or ndarray) – radial velocity [m/s]
v (float or ndarray) – tangential velocity [m/s]
- Returns
(u**2 + v**2)*0.5 - gm/r – Specific energy of the orbit in 2BP [m^2/s^2]
- Return type
float or ndarray
-
static
propagate(gm, a, e, tai, taf, nb, tp=0.0)[source] Propagates the orbit states in polar coordinates for the orbital period duration.
- Parameters
gm (float) – Central body standard gravitational parameter [m^3/s^2]
a (float) – Orbit semi-major axis [m]
e (float) – Orbit eccentricity [-]
tai (float) – True anomaly initial angle [rad]
taf (float) – True anomaly final angle [rad]
nb (int) – number of point where the True Anomaly is calculated [-]
tp (float) – Time at periapsis passage [s]
- Returns
t (ndarray) – Time vector [s]
states (ndarray) – List of the states values propagated in time [m, m/s, m/s]
-
class
latom.utils.keplerian_orbit.KepOrb(a, e, i, raan, w, ta, gm)[source] Bases:
objectKepOrb defines a Keplerian Orbit.
- Parameters
a (float) – Semi-major axis [m]
e (float) – Eccentricity [-]
i (float) – Inclination [rad]
raan (float) – Right Ascension of the Ascending Node [rad]
w (float) – Argument of Periapsis [rad]
ta (float) – True anomaly [rad]
gm (float) – Central body standard gravitational parameter [m^3/s^2]
- Variables
eps (float) – Smallest number such that
1.0 + eps != 1.0a (float) – Semi-major axis [m]
e (float) – Eccentricity [-]
i (float) – Inclination [rad]
W (float) – Right Ascension of the Ascending Node [rad]
w (float) – Argument of Periapsis [rad]
ta (float) – True anomaly [rad]
GM (float, optional) – Central body standard gravitational parameter [m^3/s^2]
n (float) – Mean motion [rad/s]
R (ndarray) – Position vector [m]
V (ndarray) – Velocity vector [m/s]
H (ndarray) – Specific angular momentum vector [m^2/s]
E (ndarray) – Eccentricity vector [-]
h (float) – Specific angular momentum magnitude [m^2/s]
r (float) – Position vector magnitude [m]
vr (float) – Radial velocity [m/s]
-
set_state_vector(r, v)[source] Set the spacecraft state vector and compute the corresponding COE, H, E.
- Parameters
r (ndarray) – Position vector [m]
v (ndarray) – Velocity vector [m/s]
-
set_classical_orbital_elements(a, e, i, raan, w, ta)[source] Set the spacecraft COE and compute the corresponding state vector, H, E.
- Parameters
a (float) – Semi-major axis [km]
e (float) – Eccentricity [-]
i (float) – Inclination [rad]
raan (float) – Right Ascension of the Ascending Node [rad]
w (float) – Argument of Periapsis [rad]
ta (float) – True anomaly [rad]
-
set_true_anomaly(ta)[source] Set the spacecraft true anomaly and update the corresponding state vector.
- Parameters
ta (float) – True anomaly [rad]
-
compute_mean_motion()[source] Computes the spacecraft mean motion.
-
compute_angular_momentum()[source] Computes the specific angular momentum vector.
-
compute_eccentricity()[source] Compute the spacecraft eccentricity vector.
-
compute_classical_orbital_elements()[source] Computes the spacecraft classical orbital elements, specific angular momentum vector and eccentricity vector from its state vector.
-
compute_state_vector()[source] Computes the spacecraft state vector, specific angular momentum vector and eccentricity vector from its COE.
-
compute_eccentric_anomaly(ta)[source] Compute the eccentric anomaly from a given true anomaly.
- Parameters
ta (float) – True anomaly [rad]
- Returns
ea – Eccentric anomaly [rad]
- Return type
float
-
compute_true_anomaly(ea)[source] Compute the true anomaly from a given eccentric anomaly.
- Parameters
ea (ndarray or float) – Eccentric anomaly [-]
- Returns
ta – True anomaly [rad]
- Return type
ndarray or float
-
compute_periapsis_passage(ta, t)[source] Compute the time at periapsis passage given the current time and true anomaly.
- Parameters
t (float) – Time [s]
ta (float) – True anomaly [rad]
- Returns
tp – Time at periapsis passage [s]
- Return type
float
-
propagate(ta, t_vec, mode)[source] Propagate the orbit forward or backward in time solving the Kepler’s time of flight equation.
- Parameters
ta (float) – Initial true anomaly [rad]
t_vec (ndarray) – Time vector [s]
mode (str) –
fwdfor forward propagation orbackfor backward propagation
- Returns
r_vec (ndarray) – Position vector time series [m]
v_vec (ndarray) – Velocity vector time series [m/s]
-
static
kepler_eqn(ea, e, n, t, tp)[source] Kepler’s Time of Flight equation.
- Parameters
ea (float) – Eccentric anomaly [rad]
e (float) – Eccentricity [-]
n (float) – Mean motion [rad/s]
t (float) – Time [s]
tp (float) – Time at periapsis passage [s]
- Returns
f – Current value of Kepler’s equation written as E - e*sin(E) - Me = 0
- Return type
float
-
static
kepler_eqn_prime(ea, e, n, t, tp)[source] First derivative of Kepler’s time of flight equation wrt eccentric anomaly.
- Parameters
ea (float) – Eccentric anomaly [rad]
e (float) – Eccentricity [-]
n (float) – Mean motion [rad/s]
t (float) – Time [s]
tp (float) – Time at periapsis passage [s]
- Returns
fprime – First derivative of Kepler’s equation wrt eccentric anomaly
- Return type
float
-
static
kepler_eqn_second(ea, e, n, t, tp)[source] Second derivative of Kepler’s time of flight equation wrt eccentric anomaly.
- Parameters
ea (float) – Eccentric anomaly [rad]
e (float) – Eccentricity [-]
n (float) – Mean motion [rad/s]
t (float) – Time [s]
tp (float) – Time at periapsis passage [s]
- Returns
fsecond – Second derivative of Kepler’s equation wrt eccentric anomaly
- Return type
float
@authors: Alberto FOSSA’ Giuliana Elena MICELI
-
class
latom.utils.spacecraft.Spacecraft(isp, twr, throttle_min=0.0, m0=1.0, m_dry=None, g=9.80665)[source] Bases:
objectSpacecraft class defines the spacecraft characteristics.
- Parameters
isp (float) – Specific impulse [s]
twr (float) – Thrust over initial weight ratio [-]
throttle_min (float, optional) – Minimum throttle level [-]. Default is 0.0
m0 (float, optional) – Initial mass [kg]. Default is 1.0
m_dry (float or None, optional) – Dry mass [kg]. Default is
Nonefor which m_dry is set equal tom0/100g (float, optional) – Central body surface gravity [m/s^2]. Default is g0
- Variables
Isp (float) – Specific impulse [s]
twr (float) – Thrust over initial weight ratio [-]
m0 (float) – Initial mass [kg]
m_dry (float) – Dry mass [kg]
w (float) – Exhaust velocity [m/s]
T_max (float) – Maximum thrust [N]
T_min (float) – Minimum thrust [N]
-
update_twr(twr)[source] Updates the boundaries value for the thrust throttle
- Parameters
twr (float) – Thrust over initial weight ratio [-]
-
class
latom.utils.spacecraft.ImpulsiveBurn(sc, dv)[source] Bases:
objectImpulsiveBurn class describes an impulsive burn.
- Parameters
sc (Spacecraft) – Instant of Spacecraft class
dv (float) – Change in velocity corresponding to the impulsive burn [m/s]
- Variables
sc (Spacecraft) – Instant of Spacecraft class
dv (float) – Change in velocity corresponding to the impulsive burn [m/s]
mf (float) – Spacecraft final mass after the impulsive burn [kg]
dm (float) – Propellant mass required for the impulsive burn [kg]
-
static
tsiolkovsky_mf(m0, dv, isp)[source] Computes the final spacecraft mass for a given velocity change using the Tsiolkovsky rocket equation.
- Parameters
m0 (float) – Initial spacecraft mass [kg]
dv (float) – Change in velocity [m/s]
isp (float) – Specific impulse of the spacecraft rocket engine [s]
- Returns
mf – Final spacecraft mass [kg]
- Return type
float
-
static
tsiolkovsky_dv(m0, mf, isp)[source] Computes the velocity change for a given initial and final spacecraft masses using the Tsiolkovsky rocket equation.
- Parameters
m0 (float) – Initial spacecraft mass [kg]
mf (float) – Final spacecraft mass [kg]
isp (float) – Specific impulse of the spacecraft rocket engine [s]
- Returns
dv – Change in velocity [m/s]
- Return type
float
@authors: Alberto FOSSA’ Giuliana Elena MICELI
-
latom.utils.coc.rot1(t)[source] Elementary rotation matrix around X axis.
- Parameters
t (float) – Rotation angle [rad]
- Returns
r – 3x3 rotation matrix around X axis
- Return type
ndarray
-
latom.utils.coc.rot3(t)[source] Elementary rotation matrix around Z axis.
- Parameters
t (float) – Rotation angle [rad]
- Returns
r – 3x3 rotation matrix around Z axis
- Return type
ndarray
-
latom.utils.coc.eq2per(raan, i, w)[source] Rotation matrix from inertial, body-centred equatorial reference frame to perifocal reference frame.
- Parameters
raan (float) – Right Ascension of the Ascending Node [rad]
i (float) – Inclination [rad]
w (float) – Argument of Periapsis [rad]
- Returns
q – 3x3 rotation matrix from equatorial to perifocal reference frames
- Return type
ndarray
-
latom.utils.coc.per2eq(raan, i, w)[source] Rotation matrix from perifocal reference frame to inertial, body-centred equatorial reference frame.
- Parameters
raan (float) – Right Ascension of the Ascending Node [rad]
i (float) – Inclination [rad]
w (float) – Argument of Periapsis [rad]
- Returns
q – 3x3 rotation matrix from perifocal to equatorial reference frames
- Return type
ndarray
-
latom.utils.coc.coe2sv_vec(a, e, i, raan, w, ta, gm)[source] Change of Coordinates from Classical Orbital Elements to State Vector in body-centred inertial reference frame.
- Parameters
a (float) – Semi-major axis [m]
e (float) – Eccentricity [-]
i (float) – Inclination [rad]
raan (float) – Right Ascension of the Ascending Node [rad]
w (float) – Argument of Periapsis [rad]
ta (ndarray) – True anomalies [rad]
gm (float) – Central body standard gravitational parameter [m^3/s^2]
- Returns
r_vec (ndarray) – Position vector [m]
v_vec (ndarray) – Velocity vector [m/s]
-
latom.utils.coc.polar2per_vec(r, theta, u, v)[source] Transformation from polar coordinates to perifocal reference frame.
- Parameters
r (ndarray) – Radius time series [m]
theta (ndarray) – Angle time series [rad]
u (ndarray) – Radial velocity time series [m/s]
v (ndarray) – Tangential velocity time series [m/s]
- Returns
xp (ndarray) – Position along x axis [m]
yp (ndarray) – Position along y axis [m]
vxp (ndarray) – Velocity component along x axis [m/s]
vyp (ndarray) – Velocity component along y axis [m/s]
-
latom.utils.coc.per2eq_vec(xp, yp, vxp, vyp, raan, i, w)[source] Transformation from perifocal reference frame to inertial, body-centred equatorial reference frame.
- Parameters
xp (ndarray) – Position along x axis [m]
yp (ndarray) – Position along y axis [m]
vxp (ndarray) – Velocity component along x axis [m/s]
vyp (ndarray) – Velocity component along y axis [m/s]
raan (float) – Right Ascension of the Ascending Node [rad]
i (float) – Inclination [rad]
w (float) – Argument of Periapsis [rad]
- Returns
r_vec (ndarray) – Position vector [m]
v_vec (ndarray) – Velocity vector [m/s]
-
latom.utils.coc.polar2eq_vec(r, theta, u, v, raan, i, w)[source] Transformation from polar coordinates to inertial, body-centred equatorial reference frame.
- Parameters
r (nd array) – Radius time series [m]
theta (ndarray) – Angle time series [rad]
u (nd array) – Radial velocity time series [m/s]
v (ndarray) – Tangential velocity time series [m/s]
raan (float) – Right Ascension of the Ascending Node [rad]
i (float) – Inclination [rad]
w (float) – Argument of Periapsis [rad]
- Returns
r_vec (ndarray) – Position vector [m]
v_vec (ndarray) – Velocity vector [m/s]
-
latom.utils.coc.lat_long2cartesian(lat, long, r)[source] Transformation from latitude, longitude to cartesian coordinates.
- Parameters
lat (float) – Latitude [deg]
long (float) – Longitude [deg]
r (float) – Planet radius [m]
@authors: Alberto FOSSA’ Giuliana Elena MICELI
Defines the methods to save and load files using the pickle library
-
latom.utils.pickle_utils.save(obj, filename)[source] Save an object.
- Parameters
obj (object) – Object to be serialized
filename (str) – Full path to file where the object is serialized
-
latom.utils.pickle_utils.load(filename)[source] Load an object.
- Parameters
filename (str) – Full path to file where the object is serialized
- Returns
obj – Object to be serialized
- Return type
object
@authors: Alberto FOSSA’ Giuliana Elena MICELI
Defines useful constants
@authors: Alberto FOSSA’ Giuliana Elena MICELI
-
class
latom.utils.primary.Primary(r, gm)[source] Bases:
objectPrimary class defines the characteristic quantities for a given primary body.
- Variables
R (float) – Radius [m]
GM (float) – Standard gravitational parameter [m^3/s^2]
g (float) – Surface gravity [m/s]
tc (float) – Characteristic time [s]
vc (float) – Characteristic speed [m/s]
T_circ (float) – Orbital period in a circular orbit with radius equal to R [s]
-
class
latom.utils.primary.Moon[source] Bases:
latom.utils.primary.PrimaryDefines the Moon