EphemerisCache#
- class EphemerisCache(body_coeffs, body_ids, center_ids)#
Bases:
objectChebyshev ephemeris for a set of bodies, read out of the loaded SPK kernel or kernels. Positions only. Build it with
scarabaeus.utils.EphemerisCache.build_ephemeris_cache.A record covers \([t_{mid} - t_{rad},\ t_{mid} + t_{rad}]\). With \(\tau = (t - t_{mid})/t_{rad} \in [-1, 1]\) and \(c_k\) the coefficients of one axis, the coordinate is the Chebyshev series
\[x(t) = \sum_{k=0}^{N} c_k\, T_k(\tau),\]summed by Clenshaw’s recurrence [1]:
\[b_k = c_k + 2\tau\, b_{k+1} - b_{k+2}, \quad b_{N+1} = b_{N+2} = 0, \qquad x(t) = c_0 + \tau\, b_1 - b_2.\]A body is chained through its centers down to the solar-system barycenter, \(\mathbf{r}_b = \mathbf{r}_{b/c(b)} + \mathbf{r}_{c(b)}\), and a relative position is the difference of two such positions, \(\mathbf{r}_{t/o} = \mathbf{r}_t - \mathbf{r}_o\).
- Parameters:
- body_coeffslist of list of tuple
Chebyshev records
(t_mid, t_rad, x, y, z)for each body across the cached interval, wherex,yandzare coefficient lists.- body_idslist of int
SPICE IDs in the same order as
body_coeffs.- center_idslist of int
SPICE IDs of each body’s center. Necessary for chaining between frames for bodies that are not the primary, e.g. Phobos.
Methods
get_relative_position(target_id, observer_id, t)Position of
target_idrelative toobserver_idatt, in km, in the SPK native frame (J2000).get_relative_positions(target_ids, ...)Positions of
target_idsrelative toobserver_idatt, in km, in the SPK native frame (J2000), as an(n, 3)array with one row per target.References
[1]C. W. Clenshaw, “A note on the summation of Chebyshev series,” Mathematical Tables and Other Aids to Computation, vol. 9, no. 51, pp. 118-120, 1955.
- get_relative_position(target_id: int, observer_id: int, t: float) List[float]#
Position of
target_idrelative toobserver_idatt, in km, in the SPK native frame (J2000). Both bodies must be in the cache.
Building a cache#
- build_ephemeris_cache(body_ids, t0: float, tf: float)#
Build a Rust
EphemerisCacheforbody_idsover[t0, tf].- Parameters:
- body_idslist of int
SPICE IDs to cache. The FIRST entry is the primary/observer body.
- t0, tffloat
Interval to cache, in ephemeris seconds past J2000 (TDB). Callers should include any epoch buffer they need.
- Returns:
- EphemerisCache
Cache covering
body_idsplus any center bodies required for chaining, appended after them (seeEphemerisCache.ids).
- Raises:
- NoLoadedSPKError
If no SPK kernel is loaded.
- ValueError
If a requested body has no segment in any loaded SPK.
- RuntimeError
If a segment has an unsupported SPK type (only types 2 and 3 are readable as Chebyshev position records).