Body#

class Body(name: str, spice_id: int | str = None, mass: ArrayWUnits | SCBPolynomial = None, mass_poly_deg: int = 1)#

Bases: object

Defines the simplest form of ephemeris object in Scarabaeus.

From NAIF [1]:

“An ephemeris object is any object that may have ephemeris or trajectory data such as a planet, natural satellite, tracking station, spacecraft, barycenter (the center of mass of a group of bodies), asteroid, or comet. Each body in the solar system is associated with an integer code for use with SPICE.”

Body objects serve to hold information relevant to some ephemeris object that exists within the kernel pool.

Parameters:
  • name (str) – The unique name of the body.

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

  • mass (ArrayWUnits or SCBPolynomial, optional) –

    The mass of the body, supports static and time variant definitions depending on the received input type. Defaults to None. Accepted types are:

  • mass_poly_deg (int, optional) – The degree of the polynomial used to fit the mass profile. Defaults to 3.

See also

scarabaeus.SpiceManager

Provides many useful methods related to SPICE objects.

Notes

Every Body instance corresponds to a NAIF ephemeris object identified by an integer NAIF ID code. When a name is supplied without a spice_id, Scarabaeus queries the loaded kernel pool via name_to_ID(). If found, the ID is assigned automatically. For new bodies not yet registered in any kernel, a spice_id must be supplied explicitly and the body is added to the pool via def_new_body().

References

Attributes:
mass_profile

Stored constant or polynomial mass profile.

name

The name of the Body object.

spice_id

The SPICE ID of the Body object.

Methods

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.

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.

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 mass_profile: ArrayWUnits | SCBPolynomial#

Stored constant or polynomial mass profile.

property name: str#

The name of the Body object.

property spice_id: int | str#

The SPICE ID of the Body object.