Function lupnt::InitFrameConversionFromSpice

Function Documentation

void lupnt::InitFrameConversionFromSpice(Real t_start_tdb, Real t_end_tdb, Real segment_length_s = 86400.0, int num_coeffs = 13)

Calibrates LuPNT’s native (non-SPICE) high-accuracy frame conversions — GcrfToItrf / ItrfToGcrf (Earth orientation) and MoonCiToPa / MoonPaToCi (lunar orientation) — to closely reproduce lupnt::spice::ConvertFrameSpice over a given simulation time window.

LuPNT normally computes these rotations from purely-analytic models: IAU 2006/2000A precession-nutation (RotPrecessionNutation) plus EOP-based polar motion and sidereal rotation (RotPolarMotion / RotSideralMotion / RotSideralMotionDot) for Earth, where the EOP (x_pole, y_pole, UT1-UTC, LOD) come from the loaded IERS EOP table (see lupnt/data/eop.h

); and static, pre-extracted DE Chebyshev “lunar mantle

libration” coefficients for the Moon (see GetLunarMantleData). Those can disagree with SPICE’s high-accuracy binary-PCK-based orientation (which

lupnt::spice::LoadSpiceKernel now downloads automatically — see earth_latest_high_prec.bpc / moon_pa_de*.bpc + moon_de*.tf) by a non-negligible amount — in particular when the loaded EOP table does not cover the requested epoch.

This function closes that gap for a known time window:

  • Earth: samples ComputeEopFromSpice(t) &#8212; which derives (x_pole, y_pole, UT1-UTC) from SPICE’s “J2000”<->”ITRF93” rotation &#8212; at the Chebyshev-Gauss nodes spanning [t_start_tdb, t_end_tdb], and fits piecewise Chebyshev polynomials to those 3 EOP parameters (the same Chebyshev representation used internally for the planetary/lunar ephemeris data &#8212; see spice_cheby.h / kernels.cc). Once initialized, RotPolarMotion / RotSideralMotion / RotSideralMotionDot (and hence GcrfToItrf / ItrfToGcrf) transparently use these SPICE-fitted EOP values &#8212; together with the exact analytic time derivative of UT1-UTC, via cheby_eval_ad &#8212; whenever the requested epoch falls within the fitted window, instead of the loaded IERS EOP table.

  • Moon: samples the SPICE “J2000”<->”IAU_MOON” rotation matrix at the same Chebyshev-Gauss nodes, extracts ZXZ Euler angles (phi, theta, psi) for the decomposition R = Rz(psi)*Rx(theta)*Rz(phi), continuously unwraps phi and psi (so the fitted functions are smooth despite the 2*pi-periodic branch cuts), and fits piecewise Chebyshev polynomials to those 3 angles. At evaluation time the angles (and their exact analytic time derivatives, via cheby_eval_ad) are used to reconstruct R = Rz(psi)*Rx(theta)*Rz(phi), which is GUARANTEED exactly orthonormal (to floating-point precision) because products of elementary rotation matrices are always orthonormal &#8212; regardless of the Chebyshev fit residual in the angles. Once initialized, MoonCiToPa / MoonPaToCi automatically use the fitted model whenever the requested epoch falls within the fitted window.

Outside the fitted window(s), the original analytic computation is used as before, so this feature is purely additive/opt-in (nothing changes unless InitFrameConversionFromSpice is explicitly called).

Parameters:
  • t_start_tdb – Start of the time window to fit [s, TDB since J2000]

  • t_end_tdb – End of the time window to fit [s, TDB since J2000]

  • segment_length_s – Length of each Chebyshev fit segment [s] (default: 1 day; shorter segments improve accuracy at the cost of memory/init time)

  • num_coeffs – Number of Chebyshev coefficients (polynomial degree + 1) per fitted quantity and segment (default: 13)