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
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

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
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
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

The standard gravitational parameter of primary body in m³/s².

required

Returns:

Name Type Description
float float

The semi-major axis in meters.

Example
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: float, angle_format: AngleFormat) -> float

Computes the mean motion of an astronomical object around Earth.

Parameters:

Name Type Description Default
a float

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

required
angle_format AngleFormat

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

# Calculate mean motion for geostationary orbit (35786 km altitude)
a = bh.R_EARTH + 35786e3
n = bh.mean_motion(a, bh.AngleFormat.DEGREES)
print(f"Mean motion: {n:.6f} deg/s")

mean_motion_general builtin

mean_motion_general(a: float, 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 float

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

required
gm float

The standard gravitational parameter of primary body in m³/s².

required
angle_format AngleFormat

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

# Calculate mean motion for a Mars orbiter
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")

orbital_period builtin

orbital_period(a: float) -> Any

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 float

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

required

Returns:

Type Description
float

The orbital period of the astronomical object in seconds.

Example
import brahe as bh

# Calculate orbital period for ISS-like orbit (400 km altitude)
a = bh.R_EARTH + 400e3
period = bh.orbital_period(a)
print(f"Orbital period: {period/60:.2f} minutes")

orbital_period_general builtin

orbital_period_general(a: float, gm: float) -> float

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

Parameters:

Name Type Description Default
a float

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

required
gm float

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

# Calculate orbital period around the Moon
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")

periapsis_distance builtin

periapsis_distance(a: float, e: float) -> float

Calculate the distance of an object at its periapsis.

Parameters:

Name Type Description Default
a float

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

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required

Returns:

Name Type Description
float float

The distance of the object at periapsis in meters.

Example
import brahe as bh

# Calculate periapsis distance for an elliptical orbit
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")

apoapsis_distance builtin

apoapsis_distance(a: float, e: float) -> float

Calculate the distance of an object at its apoapsis.

Parameters:

Name Type Description Default
a float

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

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required

Returns:

Name Type Description
float float

The distance of the object at apoapsis in meters.

Example
import brahe as bh

# Calculate apoapsis distance
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")

periapsis_velocity builtin

periapsis_velocity(a: float, e: float, gm: float) -> float

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

Parameters:

Name Type Description Default
a float

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

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required
gm float

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

# Calculate periapsis velocity for a comet around the Sun
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")

apoapsis_velocity builtin

apoapsis_velocity(a: float, e: float, gm: float) -> float

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

Parameters:

Name Type Description Default
a float

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

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required
gm float

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

# Calculate apoapsis velocity for a Martian satellite
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")

perigee_velocity builtin

perigee_velocity(a: float, e: float) -> float

Computes the perigee velocity of an astronomical object around Earth.

Parameters:

Name Type Description Default
a float

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

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required

Returns:

Name Type Description
float float

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

Example
import brahe as bh

# Calculate perigee velocity for Molniya orbit (highly elliptical)
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")

apogee_velocity builtin

apogee_velocity(a: float, e: float) -> float

Computes the apogee velocity of an astronomical object around Earth.

Parameters:

Name Type Description Default
a float

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

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required

Returns:

Name Type Description
float float

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

Example
import brahe as bh

# Calculate apogee velocity for GTO (Geostationary Transfer Orbit)
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")

sun_synchronous_inclination builtin

sun_synchronous_inclination(a: float, e: float, 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 float

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

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required
angle_format AngleFormat

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

# Calculate sun-synchronous inclination for typical Earth observation satellite (600 km)
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")

Anomaly Conversions

anomaly_eccentric_to_mean builtin

anomaly_eccentric_to_mean(anm_ecc: float, e: float, angle_format: AngleFormat) -> float

Converts eccentric anomaly into mean anomaly.

Parameters:

Name Type Description Default
anm_ecc float

Eccentric anomaly in radians or degrees.

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required
angle_format AngleFormat

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 math

# Convert eccentric to mean anomaly
E = math.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")

anomaly_eccentric_to_true builtin

anomaly_eccentric_to_true(anm_ecc: float, e: float, angle_format: AngleFormat) -> float

Converts eccentric anomaly into true anomaly.

Parameters:

Name Type Description Default
anm_ecc float

Eccentric anomaly in radians or degrees.

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required
angle_format AngleFormat

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 math

# Convert eccentric to true anomaly
E = math.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")

anomaly_mean_to_eccentric builtin

anomaly_mean_to_eccentric(anm_mean: float, e: float, angle_format: AngleFormat) -> float

Converts mean anomaly into eccentric anomaly.

Parameters:

Name Type Description Default
anm_mean float

Mean anomaly in radians or degrees.

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required
angle_format AngleFormat

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

# Convert mean to eccentric anomaly (solves Kepler's equation)
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")

anomaly_mean_to_true builtin

anomaly_mean_to_true(anm_mean: float, e: float, angle_format: AngleFormat) -> float

Converts mean anomaly into true anomaly.

Parameters:

Name Type Description Default
anm_mean float

Mean anomaly in radians or degrees.

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required
angle_format AngleFormat

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

# Convert mean to true anomaly (combines Kepler's equation + eccentric anomaly conversion)
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")

anomaly_true_to_eccentric builtin

anomaly_true_to_eccentric(anm_true: float, e: float, angle_format: AngleFormat) -> float

Converts true anomaly into eccentric anomaly.

Parameters:

Name Type Description Default
anm_true float

True anomaly in radians or degrees.

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required
angle_format AngleFormat

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 math

# Convert true to eccentric anomaly
nu = math.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")

anomaly_true_to_mean builtin

anomaly_true_to_mean(anm_true: float, e: float, angle_format: AngleFormat) -> float

Converts true anomaly into mean anomaly.

Parameters:

Name Type Description Default
anm_true float

True anomaly in radians or degrees.

required
e float

The eccentricity of the astronomical object's orbit (dimensionless).

required
angle_format AngleFormat

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 math

# Convert true to mean anomaly
nu = math.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")