CelestialBody#

class CelestialBody(name: str, mass: ArrayWUnits, mean_radius: ArrayWUnits, grav_param: ArrayWUnits, base_frame: Frame, spice_id: int | str = None, barycenter_id: int | str = None, gs_list: list = [])#

Bases: Body

Defines an astronomical body such as a planet, moon, asteroid, or comet.

Parameters:
  • name (str) – The written name of the CelestialBody.

  • mass (ArrayWUnits) – The mass of the CelestialBody. Recommend expressed in units of kilograms.

  • mean_radius (ArrayWUnits) – The mean radius of the CelestialBody. Recommend expressed in units of kilometers.

  • grav_param (ArrayWUnits) – The gravitational parameter of the CelestialBody. Recommend expressed in units of \(\frac{km^3}{s^2}\).

  • base_frame (Frame) – The body-centered, body-fixed reference frame attached to the CelestialBody.

  • spice_id (int or str, optional) – The NAIF ID code of the object. May be given as an integer ID or as a string. Defaults to None.

  • gs_list (list, optional) – A list containing all of the ground stations on the surface of the CelestialBody. Defaults to [].

See also

scarabaeus.constants

Scarabaeus’ constants library, including planetary constants.

scarabaeus.Frame

Scarabaeus’ representation of reference frames.

Notes

The gravitational parameter \(\mu\) is defined as

\[\mu = GM\]

where \(G = 6.674\times10^{-20}\ \mathrm{km}^3\,\mathrm{kg}^{-1}\,\mathrm{s}^{-2}\) is the universal gravitational constant and \(M\) is the body mass. The circular orbital velocity at distance \(r\) and surface escape velocity are

\[v_{circ} = \sqrt{\frac{\mu}{r}}, \qquad v_{esc} = \sqrt{\frac{2\mu}{R_{mean}}}\]

Use grav_param (\(\mu = GM\)) rather than mass for orbital computations to avoid rounding errors from \(G\).

Examples

Create a CelestialBody object with numerical values that are half that of Jupiter.

>>> import scarabaeus as scb
>>> jov_constants = scb.constants.JUPITER
>>> half_jupiter = scb.CelestialBody(
...     name        = "HALF JUPITER",
...     mass        = jov_constants.mass / 2,
...     mean_radius = jov_constants.mean_radius / 2,
...     grav_param  = jov_constants.GM / 2,
...     base_frame  = jov_constants.ref_frame,
...     spice_id    = 50000,
...     gs_list     = []
... )
Attributes:
base_frame

The reference frame attached to the CelestialBody.

grav_param

The gravitational parameter of the CelestialBody given, by convention, in units of \(\frac{km^3}{s^2}\).

gs_list

All GroundStation objects attached to the surface of the CelestialBody.

mass_profile

Stored constant or polynomial mass profile.

mean_radius

The mean radius of the CelestialBody.

name

The name of the Body object.

spice_id

The SPICE ID of the Body object.

Methods

disp_properties()

Displays all properties of the CelestialBody object in a readable format.

fit_mass_profile_from_data(t_array, m_array, ...)

Fits a polynomial to a mass time history and sets it as the new mass profile.

from_constants(cb_name)

Creates a CelestialBody object from a given name using its respective values as defined in constants.

get_mass(t)

Evaluates the time-varying mass profile at specified epochs.

get_state(epoch_0[, reference_frame, origin])

Retrieves the state of the body relative to a given origin in a specified reference frame.

mass([t])

Returns the mass of the body.

set_mass_profile(poly, units)

Sets the mass profile of the body using a polynomial function and associated units.

classmethod from_constants(cb_name: str) Self#

Creates a CelestialBody object from a given name using its respective values as defined in constants.

Parameters:

cb_name (str) – The name of the desired celestial body to create a Scarabaeus CelestialBody object for.

Returns:

cb_out – A CelestialBody object initialized with all relevant values as defined by the given constant value.

Return type:

CelestialBody

Raises:

not_def_err – Raised when the given cb_name does not match an object in Scarabaeus’ constants library.

See also

scarabaeus.Constants

Scarabaeus’ constants library.

Notes

This method performs the same functionality as manually accessing each of the pertinent constants values and assigning them by normal construction. It is a faster alternative when initalizing CelestialBody objects by values from constants.

disp_properties() None#

Displays all properties of the CelestialBody object in a readable format.

fit_mass_profile_from_data(t_array: ndarray, m_array: ndarray, domain: tuple, units: Units) None#

Fits a polynomial to a mass time history and sets it as the new mass profile.

Parameters:
  • t_array (numpy.ndarray) – Time values in seconds (ephemeris time).

  • m_array (numpy.ndarray) – Corresponding mass values.

  • deg (int) – Degree of the polynomial.

  • domain (tuple) – Domain [t0, tf] for the polynomial conversion.

  • units (ArrayWUnits) – Units to assign to the mass profile. If None, uses existing mass profile units.

Return type:

None

get_mass(t: EpochArray) ArrayWUnits#

Evaluates the time-varying mass profile at specified epochs.

Parameters:

t (EpochArray) – Time(s) in ephemeris seconds (TDB).

Returns:

mass – Evaluated mass at each input epoch.

Return type:

ArrayWUnits

get_state(epoch_0, reference_frame: str = 'J2000', origin: str = 'EARTH') ArrayWFrame#

Retrieves the state of the body relative to a given origin in a specified reference frame.

Parameters:
  • epoch_0 (EpochArray) – The epoch times for which the state is to be computed.

  • reference_frame (str) – The reference frame in which the state is desired. Defaults to ‘J2000’.

  • origin (str) – The origin body relative to which the state is computed. Defaults to 'EARTH'.

Returns:

state_vector – The state vector of the body relative to the origin.

Return type:

ArrayWFrame

mass(t: EpochArray | float | ndarray = None) ArrayWUnits#

Returns the mass of the body. If the mass is time-varying, evaluates it at time t. If the mass is constant, returns the same value regardless of t.

Parameters:

t (EpochArray, float, or np.ndarray, optional) – Time(s) in ephemeris seconds (TDB) at which to evaluate the mass. Or None for constant mass.

Returns:

Mass at time t or constant mass.

Return type:

ArrayWUnits

set_mass_profile(poly: SCBPolynomial, units: Units) None#

Sets the mass profile of the body using a polynomial function and associated units.

Parameters:
  • poly (SCBPolynomial) – A polynomial object representing the mass profile.

  • units (Units) – The units associated with the mass profile.

Return type:

None

property base_frame: Frame#

The reference frame attached to the CelestialBody.

property grav_param: ArrayWUnits#

The gravitational parameter of the CelestialBody given, by convention, in units of \(\frac{km^3}{s^2}\).

property gs_list: list[GroundStation]#

All GroundStation objects attached to the surface of the CelestialBody.

property mass_profile: ArrayWUnits | SCBPolynomial#

Stored constant or polynomial mass profile.

property mean_radius: ArrayWUnits#

The mean radius of the CelestialBody.

property name: str#

The name of the Body object.

property spice_id: int | str#

The SPICE ID of the Body object.