Skip to content

Keplerian Elements

Functions for working with Keplerian orbital elements and computing orbital properties.

Orbital Properties

semimajor_axis builtin

semimajor_axis(n: float, angle_format: AngleFormat) -> float

Computes the semi-major axis of an astronomical object from Earth given the object's mean motion.

Parameters:

Name Type Description Default
n float

The mean motion of the astronomical object in radians or degrees.

required
angle_format AngleFormat

Interpret mean motion as AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

The semi-major axis of the astronomical object in meters.

Example
1
2
3
4
5
6
import brahe as bh

# Calculate semi-major axis from mean motion (typical LEO satellite)
n = 0.001027  # radians/second (~15 revolutions/day)
a = bh.semimajor_axis(n, bh.AngleFormat.RADIANS)
print(f"Semi-major axis: {a/1000:.2f} km")

semimajor_axis_general builtin

semimajor_axis_general(n: float, gm: float, angle_format: AngleFormat) -> float

Computes the semi-major axis of an astronomical object from a general body given the object's mean motion.

Parameters:

Name Type Description Default
n float

The mean motion of the astronomical object in radians or degrees.

required
gm float

(keyword-only) The standard gravitational parameter of primary body in m³/s².

required
angle_format AngleFormat

Interpret mean motion as AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

The semi-major axis of the astronomical object in meters.

Example
1
2
3
4
5
6
import brahe as bh

# Calculate semi-major axis for Jupiter orbiter
n = 0.0001  # radians/second
a = bh.semimajor_axis_general(n, bh.GM_JUPITER, bh.AngleFormat.RADIANS)
print(f"Semi-major axis: {a/1000:.2f} km")

semimajor_axis_from_orbital_period builtin

semimajor_axis_from_orbital_period(period: float) -> float

Computes the semi-major axis from orbital period around Earth.

Parameters:

Name Type Description Default
period float

The orbital period in seconds.

required

Returns:

Name Type Description
float float

The semi-major axis in meters.

Example
1
2
3
4
5
6
import brahe as bh

# Calculate semi-major axis for a 90-minute orbit
period = 90 * 60.0  # 90 minutes in seconds
a = bh.semimajor_axis_from_orbital_period(period)
print(f"Semi-major axis: {a/1000:.2f} km")

semimajor_axis_from_orbital_period_general builtin

semimajor_axis_from_orbital_period_general(period: float, gm: float) -> float

Computes the semi-major axis from orbital period for a general body.

Parameters:

Name Type Description Default
period float

The orbital period in seconds.

required
gm float

(keyword-only) The standard gravitational parameter of primary body in m³/s².

required

Returns:

Name Type Description
float float

The semi-major axis in meters.

Example
1
2
3
4
5
6
import brahe as bh

# Calculate semi-major axis for 2-hour Venus orbit
period = 2 * 3600.0  # 2 hours in seconds
a = bh.semimajor_axis_from_orbital_period_general(period, bh.GM_VENUS)
print(f"Semi-major axis: {a/1000:.2f} km")

mean_motion builtin

mean_motion(a_or_oe: Union[float, array], angle_format: AngleFormat) -> float

Computes the mean motion of an astronomical object around Earth.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a will be extracted.

required
angle_format AngleFormat

(keyword-only) Return output in AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

The mean motion of the astronomical object in radians or degrees.

Example
import brahe as bh
import numpy as np

# Using scalar semi-major axis
a = bh.R_EARTH + 35786e3
n = bh.mean_motion(a, bh.AngleFormat.DEGREES)
print(f"Mean motion: {n:.6f} deg/s")

# Using Keplerian elements vector
oe = [bh.R_EARTH + 35786e3, 0.001, np.radians(0), 0, 0, 0]
n = bh.mean_motion(oe, bh.AngleFormat.DEGREES)
print(f"Mean motion: {n:.6f} deg/s")

mean_motion_general builtin

mean_motion_general(a_or_oe: Union[float, array], gm: float, angle_format: AngleFormat) -> float

Computes the mean motion of an astronomical object around a general body given a semi-major axis.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a will be extracted.

required
gm float

(keyword-only) The standard gravitational parameter of primary body in m³/s².

required
angle_format AngleFormat

(keyword-only) Return output in AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

The mean motion of the astronomical object in radians or degrees.

Example
import brahe as bh
import numpy as np

# Using scalar semi-major axis
a = 4000000.0  # 4000 km semi-major axis
n = bh.mean_motion_general(a, bh.GM_MARS, bh.AngleFormat.RADIANS)
print(f"Mean motion: {n:.6f} rad/s")

# Using Keplerian elements vector
oe = [4000000.0, 0.01, np.radians(30), 0, 0, 0]
n = bh.mean_motion_general(oe, bh.GM_MARS, bh.AngleFormat.RADIANS)
print(f"Mean motion: {n:.6f} rad/s")

orbital_period builtin

orbital_period(a_or_oe: Union[float, array]) -> float

Computes the orbital period of an object around Earth.

Uses rastro.constants.GM_EARTH as the standard gravitational parameter for the calculation.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a will be extracted.

required

Returns:

Name Type Description
float float

The orbital period of the astronomical object in seconds.

Example
import brahe as bh
import numpy as np

# Using scalar semi-major axis
a = bh.R_EARTH + 400e3
period = bh.orbital_period(a)
print(f"Orbital period: {period/60:.2f} minutes")

# Using Keplerian elements vector
oe = [bh.R_EARTH + 400e3, 0.001, np.radians(51.6), 0, 0, 0]
period = bh.orbital_period(oe)
print(f"Orbital period: {period/60:.2f} minutes")

orbital_period_general builtin

orbital_period_general(a_or_oe: Union[float, array], gm: float) -> float

Computes the orbital period of an astronomical object around a general body.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a will be extracted.

required
gm float

(keyword-only) The standard gravitational parameter of primary body in m³/s².

required

Returns:

Name Type Description
float float

The orbital period of the astronomical object in seconds.

Example
import brahe as bh
import numpy as np

# Using scalar semi-major axis
a = 1900000.0  # 1900 km semi-major axis
period = bh.orbital_period_general(a, bh.GM_MOON)
print(f"Lunar orbital period: {period/3600:.2f} hours")

# Using Keplerian elements vector
oe = [1900000.0, 0.01, np.radians(45), 0, 0, 0]
period = bh.orbital_period_general(oe, bh.GM_MOON)
print(f"Lunar orbital period: {period/3600:.2f} hours")

periapsis_distance builtin

periapsis_distance(a_or_oe: Union[float, array], e: float = None) -> float

Calculate the distance of an object at its periapsis.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a and e will be extracted.

required
e float

The eccentricity. Required if a_or_oe is a scalar, ignored if vector.

None

Returns:

Name Type Description
float float

The distance of the object at periapsis in meters.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
a = 8000000.0  # 8000 km semi-major axis
e = 0.2  # moderate eccentricity
r_peri = bh.periapsis_distance(a, e)
print(f"Periapsis distance: {r_peri/1000:.2f} km")

# Using Keplerian elements vector
oe = [8000000.0, 0.2, np.radians(45), 0, 0, 0]
r_peri = bh.periapsis_distance(oe)
print(f"Periapsis distance: {r_peri/1000:.2f} km")

apoapsis_distance builtin

apoapsis_distance(a_or_oe: Union[float, array], e: float = None) -> float

Calculate the distance of an object at its apoapsis.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a and e will be extracted.

required
e float

The eccentricity. Required if a_or_oe is a scalar, ignored if vector.

None

Returns:

Name Type Description
float float

The distance of the object at apoapsis in meters.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
a = 8000000.0  # 8000 km semi-major axis
e = 0.2  # moderate eccentricity
r_apo = bh.apoapsis_distance(a, e)
print(f"Apoapsis distance: {r_apo/1000:.2f} km")

# Using Keplerian elements vector
oe = [8000000.0, 0.2, np.radians(45), 0, 0, 0]
r_apo = bh.apoapsis_distance(oe)
print(f"Apoapsis distance: {r_apo/1000:.2f} km")

periapsis_velocity builtin

periapsis_velocity(a_or_oe: Union[float, array], e: float = None, *, gm: float) -> float

Computes the periapsis velocity of an astronomical object around a general body.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a and e will be extracted.

required
e float

The eccentricity. Required if a_or_oe is a scalar, ignored if vector.

None
gm float

(keyword-only) The standard gravitational parameter of primary body in m³/s².

required

Returns:

Name Type Description
float float

The magnitude of velocity of the object at periapsis in m/s.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
a = 5e11  # 5 AU semi-major axis (meters)
e = 0.95  # highly elliptical
v_peri = bh.periapsis_velocity(a, e, bh.GM_SUN)
print(f"Periapsis velocity: {v_peri/1000:.2f} km/s")

# Using Keplerian elements vector
oe = [5e11, 0.95, np.radians(10), 0, 0, 0]
v_peri = bh.periapsis_velocity(oe, gm=bh.GM_SUN)
print(f"Periapsis velocity: {v_peri/1000:.2f} km/s")

apoapsis_velocity builtin

apoapsis_velocity(a_or_oe: Union[float, array], e: float = None, *, gm: float) -> float

Computes the apoapsis velocity of an astronomical object around a general body.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a and e will be extracted.

required
e float

The eccentricity. Required if a_or_oe is a scalar, ignored if vector.

None
gm float

(keyword-only) The standard gravitational parameter of primary body in m³/s².

required

Returns:

Name Type Description
float float

The magnitude of velocity of the object at apoapsis in m/s.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
a = 10000000.0  # 10000 km semi-major axis
e = 0.3
v_apo = bh.apoapsis_velocity(a, e, bh.GM_MARS)
print(f"Apoapsis velocity: {v_apo/1000:.2f} km/s")

# Using Keplerian elements vector
oe = [10000000.0, 0.3, np.radians(30), 0, 0, 0]
v_apo = bh.apoapsis_velocity(oe, gm=bh.GM_MARS)
print(f"Apoapsis velocity: {v_apo/1000:.2f} km/s")

perigee_velocity builtin

perigee_velocity(a_or_oe: Union[float, array], e: float = None) -> float

Computes the perigee velocity of an astronomical object around Earth.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a and e will be extracted.

required
e float

The eccentricity. Required if a_or_oe is a scalar, ignored if vector.

None

Returns:

Name Type Description
float float

The magnitude of velocity of the object at perigee in m/s.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
a = 26554000.0  # meters
e = 0.72  # high eccentricity
v_peri = bh.perigee_velocity(a, e)
print(f"Perigee velocity: {v_peri:.2f} m/s")

# Using Keplerian elements vector
oe = [26554000.0, 0.72, np.radians(63.4), 0, 0, 0]
v_peri = bh.perigee_velocity(oe)
print(f"Perigee velocity: {v_peri:.2f} m/s")

apogee_velocity builtin

apogee_velocity(a_or_oe: Union[float, array], e: float = None) -> float

Computes the apogee velocity of an astronomical object around Earth.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a and e will be extracted.

required
e float

The eccentricity. Required if a_or_oe is a scalar, ignored if vector.

None

Returns:

Name Type Description
float float

The magnitude of velocity of the object at apogee in m/s.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
a = 24400000.0  # meters
e = 0.73  # high eccentricity
v_apo = bh.apogee_velocity(a, e)
print(f"Apogee velocity: {v_apo:.2f} m/s")

# Using Keplerian elements vector
oe = [24400000.0, 0.73, np.radians(7), 0, 0, 0]
v_apo = bh.apogee_velocity(oe)
print(f"Apogee velocity: {v_apo:.2f} m/s")

sun_synchronous_inclination builtin

sun_synchronous_inclination(a_or_oe: Union[float, array], e: float = None, *, angle_format: AngleFormat) -> float

Computes the inclination for a Sun-synchronous orbit around Earth based on the J2 gravitational perturbation.

Parameters:

Name Type Description Default
a_or_oe float or array

Either the semi-major axis in meters, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which a and e will be extracted.

required
e float

The eccentricity. Required if a_or_oe is a scalar, ignored if vector.

None
angle_format AngleFormat

(keyword-only) Return output in AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

Inclination for a Sun synchronous orbit in degrees or radians.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
a = bh.R_EARTH + 600e3
e = 0.001  # nearly circular
inc = bh.sun_synchronous_inclination(a, e, bh.AngleFormat.DEGREES)
print(f"Sun-synchronous inclination: {inc:.2f} degrees")

# Using Keplerian elements vector
oe = [bh.R_EARTH + 600e3, 0.001, np.radians(97.8), 0, 0, 0]
inc = bh.sun_synchronous_inclination(oe, angle_format=bh.AngleFormat.DEGREES)
print(f"Sun-synchronous inclination: {inc:.2f} degrees")

geo_sma builtin

geo_sma() -> float

Returns the geostationary orbit semi-major axis around Earth.

Returns:

Name Type Description
float float

The semi-major axis in meters.

Example
1
2
3
import brahe as bh
a_geo = bh.geo_sma()
print(f"Geostationary semi-major axis: {a_geo/1000:.2f} km")

Anomaly Conversions

anomaly_eccentric_to_mean builtin

anomaly_eccentric_to_mean(anm_ecc_or_oe: Union[float, array], e: float = None, *, angle_format: AngleFormat) -> float

Converts eccentric anomaly into mean anomaly.

Parameters:

Name Type Description Default
anm_ecc_or_oe float or array

Either the eccentric anomaly, or a 6-element Keplerian elements array [a, e, i, Ω, ω, E] from which e and E will be extracted. The anomaly in the vector should match the angle_format.

required
e float

The eccentricity. Required if anm_ecc_or_oe is a scalar, ignored if vector.

None
angle_format AngleFormat

(keyword-only) Interprets input and returns output in AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

Mean anomaly in radians or degrees.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
E = np.pi / 4  # 45 degrees eccentric anomaly
e = 0.1  # eccentricity
M = bh.anomaly_eccentric_to_mean(E, e, bh.AngleFormat.RADIANS)
print(f"Mean anomaly: {M:.4f} radians")

# Using Keplerian elements vector (with eccentric anomaly at index 5)
oe = [bh.R_EARTH + 500e3, 0.1, np.radians(45), 0, 0, np.pi/4]
M = bh.anomaly_eccentric_to_mean(oe, angle_format=bh.AngleFormat.RADIANS)
print(f"Mean anomaly: {M:.4f} radians")

anomaly_eccentric_to_true builtin

anomaly_eccentric_to_true(anm_ecc_or_oe: Union[float, array], e: float = None, *, angle_format: AngleFormat) -> float

Converts eccentric anomaly into true anomaly.

Parameters:

Name Type Description Default
anm_ecc_or_oe float or array

Either the eccentric anomaly, or a 6-element Keplerian elements array [a, e, i, Ω, ω, E] from which e and E will be extracted. The anomaly in the vector should match the angle_format.

required
e float

The eccentricity. Required if anm_ecc_or_oe is a scalar, ignored if vector.

None
angle_format AngleFormat

(keyword-only) Interprets input and returns output in AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

True anomaly in radians or degrees.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
E = np.pi / 4  # 45 degrees eccentric anomaly
e = 0.4  # eccentricity
nu = bh.anomaly_eccentric_to_true(E, e, bh.AngleFormat.RADIANS)
print(f"True anomaly: {nu:.4f} radians")

# Using Keplerian elements vector (with eccentric anomaly at index 5)
oe = [bh.R_EARTH + 500e3, 0.4, np.radians(45), 0, 0, np.pi/4]
nu = bh.anomaly_eccentric_to_true(oe, angle_format=bh.AngleFormat.RADIANS)
print(f"True anomaly: {nu:.4f} radians")

anomaly_mean_to_eccentric builtin

anomaly_mean_to_eccentric(anm_mean_or_oe: Union[float, array], e: float = None, *, angle_format: AngleFormat) -> float

Converts mean anomaly into eccentric anomaly.

Parameters:

Name Type Description Default
anm_mean_or_oe float or array

Either the mean anomaly, or a 6-element Keplerian elements array [a, e, i, Ω, ω, M] from which e and M will be extracted. The anomaly in the vector should match the angle_format.

required
e float

The eccentricity. Required if anm_mean_or_oe is a scalar, ignored if vector.

None
angle_format AngleFormat

(keyword-only) Interprets input and returns output in AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

Eccentric anomaly in radians or degrees.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
M = 1.5  # mean anomaly in radians
e = 0.3  # eccentricity
E = bh.anomaly_mean_to_eccentric(M, e, bh.AngleFormat.RADIANS)
print(f"Eccentric anomaly: {E:.4f} radians")

# Using Keplerian elements vector (with mean anomaly at index 5)
oe = [bh.R_EARTH + 500e3, 0.3, np.radians(45), 0, 0, 1.5]
E = bh.anomaly_mean_to_eccentric(oe, angle_format=bh.AngleFormat.RADIANS)
print(f"Eccentric anomaly: {E:.4f} radians")

anomaly_mean_to_true builtin

anomaly_mean_to_true(anm_mean_or_oe: Union[float, array], e: float = None, *, angle_format: AngleFormat) -> float

Converts mean anomaly into true anomaly.

Parameters:

Name Type Description Default
anm_mean_or_oe float or array

Either the mean anomaly, or a 6-element Keplerian elements array [a, e, i, Ω, ω, M] from which e and M will be extracted. The anomaly in the vector should match the angle_format.

required
e float

The eccentricity. Required if anm_mean_or_oe is a scalar, ignored if vector.

None
angle_format AngleFormat

(keyword-only) Interprets input and returns output in AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

True anomaly in radians or degrees.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
M = 2.0  # mean anomaly in radians
e = 0.25  # eccentricity
nu = bh.anomaly_mean_to_true(M, e, bh.AngleFormat.RADIANS)
print(f"True anomaly: {nu:.4f} radians")

# Using Keplerian elements vector (with mean anomaly at index 5)
oe = [bh.R_EARTH + 500e3, 0.25, np.radians(45), 0, 0, 2.0]
nu = bh.anomaly_mean_to_true(oe, angle_format=bh.AngleFormat.RADIANS)
print(f"True anomaly: {nu:.4f} radians")

anomaly_true_to_eccentric builtin

anomaly_true_to_eccentric(anm_true_or_oe: Union[float, array], e: float = None, *, angle_format: AngleFormat) -> float

Converts true anomaly into eccentric anomaly.

Parameters:

Name Type Description Default
anm_true_or_oe float or array

Either the true anomaly, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which e and ν will be extracted. The anomaly in the vector should match the angle_format.

required
e float

The eccentricity. Required if anm_true_or_oe is a scalar, ignored if vector.

None
angle_format AngleFormat

(keyword-only) Interprets input and returns output in AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

Eccentric anomaly in radians or degrees.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
nu = np.pi / 3  # 60 degrees true anomaly
e = 0.2  # eccentricity
E = bh.anomaly_true_to_eccentric(nu, e, bh.AngleFormat.RADIANS)
print(f"Eccentric anomaly: {E:.4f} radians")

# Using Keplerian elements vector (with true anomaly at index 5)
oe = [bh.R_EARTH + 500e3, 0.2, np.radians(45), 0, 0, np.pi/3]
E = bh.anomaly_true_to_eccentric(oe, angle_format=bh.AngleFormat.RADIANS)
print(f"Eccentric anomaly: {E:.4f} radians")

anomaly_true_to_mean builtin

anomaly_true_to_mean(anm_true_or_oe: Union[float, array], e: float = None, *, angle_format: AngleFormat) -> float

Converts true anomaly into mean anomaly.

Parameters:

Name Type Description Default
anm_true_or_oe float or array

Either the true anomaly, or a 6-element Keplerian elements array [a, e, i, Ω, ω, ν] from which e and ν will be extracted. The anomaly in the vector should match the angle_format.

required
e float

The eccentricity. Required if anm_true_or_oe is a scalar, ignored if vector.

None
angle_format AngleFormat

(keyword-only) Interprets input and returns output in AngleFormat.DEGREES or AngleFormat.RADIANS.

required

Returns:

Name Type Description
float float

Mean anomaly in radians or degrees.

Example
import brahe as bh
import numpy as np

# Using scalar parameters
nu = np.pi / 2  # 90 degrees true anomaly
e = 0.15  # eccentricity
M = bh.anomaly_true_to_mean(nu, e, bh.AngleFormat.RADIANS)
print(f"Mean anomaly: {M:.4f} radians")

# Using Keplerian elements vector (with true anomaly at index 5)
oe = [bh.R_EARTH + 500e3, 0.15, np.radians(45), 0, 0, np.pi/2]
M = bh.anomaly_true_to_mean(oe, angle_format=bh.AngleFormat.RADIANS)
print(f"Mean anomaly: {M:.4f} radians")