The KeplerParameterHolder
class is designed to manage and maintain consistency among parameters of a Keplerian orbit.
This class can calculate missing parameters based on given values, ensuring accurate orbital properties.
Below is a detailed explanation of its structure, methods, and usage.
The KeplerParameterHolder
class is primarily responsible for:
- Holding various orbital parameters (semi-major axis, eccentricity, anomalies, etc.).
- Calculating missing parameters based on input.
- Maintaining consistency between values and checking for any parameter errors.
- a, b: Semi-major and semi-minor axes (must be positive).
- e: Eccentricity (0 ≤ e < 1).
- p: Parameter for orbit calculation (positive).
- e_angle: Eccentricity angle (φ), converted based on units.
- i: Inclination (0 to π radians).
- OMEGA, w: RAAN (Ω) and Argument of Perigee (ω).
- M: Mean anomaly.
- t, t0: Current time and epoch time.
- v, E: True and Eccentric anomalies.
- unit: Angle unit (either
radians
ordegrees
). - tolerance, strict_tolerance: Tolerances for calculations and checks.
This helper function validates a parameter value based on given conditions. If the value does not meet the conditions, it logs an error message.
Converts angles to radians if given in degrees and verifies they fall within an expected range.
Normalizes an angle to the range [0, 2π)
radians.
Calculates any missing parameters based on available values, ensuring consistency. This includes calculating:
- Eccentricity (e) from eccentricity angle (φ) if only
φ
is given. - Semi-minor axis (b) and parameter
p
from eccentricity angle (φ) and semi-major axis (a). - Parameter (p) from semi-major axis (a) and eccentricity (e).
- Eccentricity angle (φ) from eccentricity e or both a and b.
Additionally, it calculates:
- Mean Anomaly (M) if
t
,t0
, anda
are provided. - Eccentric Anomaly (E) from Mean Anomaly (M) and Eccentricity (e).
- True Anomaly (v) from Eccentric Anomaly (E) and Eccentricity (e).
Calculates the radial distance (r
) from the central body. The method uses parameters such as a
, e
, and E
, or
alternatively, p
, e
, and v
.
Calculates the (x, y)
position vector in the orbital plane based on radius (r
) and true anomaly (v
).
Calculates Mean Anomaly (M
) using either Eccentric Anomaly (E
) or mean motion and time difference.
Calculates Eccentric Anomaly (E
) using the Newton-Raphson method, refining the result based on tolerance.
Calculates True Anomaly (v
) from Eccentric Anomaly (E) and Eccentricity (e).
Uses a combination of Brouwer-Clemence series expansion and Newton-Raphson iteration for a refined calculation of E
.
Compares Eccentric Anomaly results from Newton-Raphson and Brouwer-Clemence methods to determine any differences.
Logs and displays all current orbital parameters, showing values in both radians and degrees where applicable.
Returns a string representation of the object, useful for debugging and easy display.
orbit = KeplerParameterHolder(a=7000000, b=234134)
Output:
--- Current Orbital Parameters ---
a = 7000000
b = 234134
e = 0.9994404686668742
p = 7831.247136571428
e_angle = 1.537342 radians | 88.083230 degrees
i = None
Ω = None
ω = None
M = None
t = None
t0 = None
ν = None
E = None
---------------------------------
This example shows the class calculating additional parameters automatically based on the input values for a
and b
.
orbit = KeplerParameterHolder(a=7000000, b=234134, t=5, t0=2)
Output:
--- Current Orbital Parameters ---
a = 7000000
b = 234134
e = 0.9994404686668742
p = 7831.247136571428
e_angle = 1.537342 radians | 88.083230 degrees
i = None
Ω = None
ω = None
M = 0.003234 radians | 0.185296 degrees
t = 5
t0 = 2
ν = 3.283759 radians | 188.145551 degrees
E = 5.821674 radians | 333.557365 degrees
---------------------------------
In this example, additional time parameters t
and t0
enable the calculation of M
, ν
, and E
based on the time difference.
orbit = KeplerParameterHolder(a=7000000, b=234134, M=85, unit='degrees')
Output:
--- Current Orbital Parameters ---
a = 7000000
b = 234134
e = 0.9994404686668742
p = 7831.247136571428
e_angle = 1.537342 radians | 88.083230 degrees
i = None
Ω = None
ω = None
M = 1.483530 radians | 85.000000 degrees
t = None
t0 = None
ν = 3.125745 radians | 179.091996 degrees
E = 2.256849 radians | 129.307942 degrees
---------------------------------
Here, M
is provided in degrees, and the class correctly converts and uses this value, calculating ν
and E
accordingly.