Body#
- class Body(name: str, spice_id: int | str = None, mass: ArrayWUnits | SCBPolynomial = None, mass_poly_deg: int = 1)#
Bases:
objectDefines 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:
- namestr
The unique name of the body.
- spice_idint or str, optional
The NAIF ID code of the object. May be given as an integer ID or as a string. Defaults to
None.- massArrayWUnits 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:ArrayWUnits- static mass definition.SCBPolynomial- time variant mass definition, must be a function of time.
- mass_poly_degint, optional
The degree of the polynomial used to fit the mass profile. Defaults to
3.
- Attributes:
mass_profileStored constant or polynomial mass profile.
nameThe name of the Body object.
spice_idThe 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.
Restore the mass the body was built with and forget fitted profiles.
set_mass_profile(poly, units)Sets the mass profile of the body using a polynomial function and associated units.
See also
scarabaeus.SpiceManagerProvides 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
nameis supplied without aspice_id, Scarabaeus queries the loaded kernel pool vianame_to_ID(). If found, the ID is assigned automatically. For new bodies not yet registered in any kernel, aspice_idmust be supplied explicitly and the body is added to the pool viadef_new_body().References
- 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_arraynumpy.ndarray
Time values in seconds (ephemeris time).
- m_arraynumpy.ndarray
Corresponding mass values.
- degint
Degree of the polynomial.
- domaintuple
Domain [t0, tf] for the polynomial conversion.
- unitsArrayWUnits
Units to assign to the mass profile. If None, uses existing mass profile units.
- Returns:
- None
- get_mass(t: EpochArray) ArrayWUnits#
Evaluates the time-varying mass profile at specified epochs.
- Parameters:
- tEpochArray
Time(s) in ephemeris seconds (TDB).
- Returns:
- massArrayWUnits
Evaluated mass at each input epoch.
- 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_0EpochArray
The epoch times for which the state is to be computed.
- reference_framestr
The reference frame in which the state is desired. Defaults to ‘J2000’.
- originstr
The origin body relative to which the state is computed. Defaults to
'EARTH'.
- Returns:
- state_vectorArrayWFrame
The state vector of the body relative to the origin.
- 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:
- tEpochArray, float, or np.ndarray, optional
Time(s) in ephemeris seconds (TDB) at which to evaluate the mass. Or None for constant mass.
- Returns:
- ArrayWUnits
Mass at time t or constant mass.
- reset_mass_history() None#
Restore the mass the body was built with and forget fitted profiles.
Every propagated leg appends the profile it fitted, and the next leg starts from the last one. Propagating the same mission again (a filter re-linearizing its reference, say) would otherwise start the first leg from the mass the previous run ended with, and
get_mass()would return profiles from earlier runs that cover the same epochs.The profile lists are cleared in place: force-model copies of this body share them by reference.
- Returns:
- None
- set_mass_profile(poly: SCBPolynomial, units: Units) None#
Sets the mass profile of the body using a polynomial function and associated units.
- Parameters:
- polySCBPolynomial
A polynomial object representing the mass profile.
- unitsUnits
The units associated with the mass profile.
- Returns:
- None
- property mass_profile: ArrayWUnits | SCBPolynomial#
Stored constant or polynomial mass profile.