Fix AFSPC gsto: use IAU/gstime polynomial to match Vallado C++ reference#22
Open
neilberkman wants to merge 1 commit into
Open
Fix AFSPC gsto: use IAU/gstime polynomial to match Vallado C++ reference#22neilberkman wants to merge 1 commit into
neilberkman wants to merge 1 commit into
Conversation
Vallado's initl() in SGP4.cpp computes gsto using two formulas: 1. Lines 1261-1270: the AFSPC d₁₉₇₀ polynomial (stored in gsto1) 2. Line 1273: gstime_SGP4(epoch + 2433281.5) — the IAU polynomial The second assignment unconditionally overwrites the first, making the AFSPC sidereal time formula dead code. The reference C++ always uses gstime_SGP4 for gsto regardless of opsmode. This crate's from_elements_afspc_compatibility_mode was passing afspc_epoch_to_sidereal_time which implements the dead-code formula. Changed to iau_epoch_to_sidereal_time which matches gstime_SGP4. The difference is ~1e-10 rad in gsto, which accumulates during long propagations. For a GEO satellite propagated ~1 year (500,000 min), this reduces position error from 3.7 mm to < 1 mm vs the C++ reference. Includes regression test that fails on master and passes with this fix. Updated doc comment to reflect the change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
from_elements_afspc_compatibility_modeusesafspc_epoch_to_sidereal_timefor gsto (Greenwich Sidereal Time at epoch). However, the Vallado C++ reference implementation never actually uses that formula.In
SGP4.cppinitl(), gsto is computed twice:gsto1)gsto = gstime_SGP4(epoch + 2433281.5);The second assignment unconditionally overwrites the first. The AFSPC sidereal time result is dead code —
gstime_SGP4(the IAU polynomial) is always used, regardless of opsmode.This PR changes the sidereal time function passed by
from_elements_afspc_compatibility_modefromafspc_epoch_to_sidereal_timetoiau_epoch_to_sidereal_time, matching the C++ behavior.Impact
The gsto difference is ~1e-10 rad — negligible for short propagations but accumulates over time. For a GEO-resonant satellite propagated ~1 year (500,000 min), the position error drops from ~3.7 mm to < 0.13 mm vs the C++ reference.
Test plan