EphCore.Ephemeris.Kernels.SPK.DifferenceArray (eph_core v0.1.0)

Copy Markdown View Source

Evaluates an SPK Type 21 (Extended Modified Difference Array) record.

This is a pure-Elixir transliteration of the SPICELIB spke21.f routine (Fred Krogh's DAINT algorithm). The Python reference implementation is whiskie14142/spktype21, which itself was translated from the FORTRAN source.

Algorithm overview

Given a reference epoch TL and query epoch ET, the algorithm evaluates position and velocity by:

  1. Computing delta = ET - TL.
  2. Building the FC (forward-coefficient) and WC (weight-coefficient) arrays from the stepsize vector G.
  3. Seeding W with reciprocals: W[j] = 1/(j+1).
  4. Evolving W via a KS-loop until KS = 1 (position phase).
  5. Performing position interpolation: P = REFPOS + Δ (REFVEL + Δ Σ DT·W).
  6. Evolving W one more step to KS = 0 (velocity phase).
  7. Performing velocity interpolation: V = REFVEL + Δ * Σ DT·W.

All indices below follow Python 0-based convention; the comments show the original Fortran 1-based names for cross-reference.

Summary

Functions

evaluate(record, et)

@spec evaluate(map(), float()) ::
  {:ok, {float(), float(), float(), float(), float(), float()}}
  | {:error, term()}