3. CelestialBody#

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

Bases: Body

Defines an astronomical body like the Sun, a planet, dwarf 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

List of Scarabaeus-defined planetary constants.

scarabaeus.Frame

Scarabaeus’ representation of reference frames.

Examples

Create a CelestialBody object with numerical values that are half that of Jupiter, from the Constants library.

# initial setup
import scarabaeus as scb

# get planetary values from Constants
jov_constants = scb.Constants.jupiter

# define the celestial body
half_jupiter = scb.CelestialBody(
    name        = "HALF JUPITER",
    mass        = jov_constants["mass"] / 2,
    mean_radius = jov_constants["radius"] / 2,
    grav_param  = jov_constants["mu"] / 2,
    base_frame  = scb.Frame('IAU_JUPITER')
    spice_id    = 5,
    gs_list     = []
)

>>> jupiter.disp_properties()
                            HALF JUPITER
===================================================================
mass                     : 9.490623355393134e+26 kg
mean_radius              : 35746.0 km
gravitational parameter  : 63343267.460900396 mu
reference frame          : IAU_JUPITER (599 - JUPITER)
SPICE ID                 : -599
attached ground stations : []

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

add_ground_station(gs_to_add)

Adds a new GroundStation object to the list of ground stations attached to the CelestialBody object.

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 Scarabaeus' Constants library.

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 Scarabaeus’ Constants library.

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.

add_ground_station(gs_to_add) None#

Adds a new GroundStation object to the list of ground stations attached to the CelestialBody object.

Parameters:

gs_to_add (GroundStation or list of GroundStations) – In the case of adding one ground station: a single GroundStation object. In the case of adding multiple ground stations: a list of GroundStation objects.

Return type:

None

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

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

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

  • m_array (np.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:

Evaluated mass at each input epoch.

Return type:

ArrayWUnits

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

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:

ArrayWUnits

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

Sets the mass profile of the body using a polynomial function and associated units. :param poly: A polynomial object representing the mass profile. :type poly: SCBPolynomial :param units: The units associated with the mass profile. :type units: Units

Returns:

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.