Skip to content

Fix EarthSatellite.epoch float-day truncation - #1143

Closed
shaneraphel wants to merge 1 commit into
skyfielders:masterfrom
shaneraphel:tle-epoch-seconds-1141
Closed

shaneraphel wants to merge 1 commit into
skyfielders:masterfrom
shaneraphel:tle-epoch-seconds-1141

Conversation

@shaneraphel

@shaneraphel shaneraphel commented Sep 16, 2026 •

Copy link
Copy Markdown

Fixes #1141.

EarthSatellite.epoch is documented as the TLE epoch. The current path packs satrec.epochdays (and the from_satrec Julian-date fraction) into a single float day argument of ts.utc, which truncates the fraction. That offset is up to ~34 µs and moves a LEO evaluated at its own epoch by ~25 cm. from_omm already uses ts._utc_jd and is not rewritten.

Pass the day fraction as seconds:

        whole_days = int(satrec.epochdays)
        seconds = (satrec.epochdays - whole_days) * DAY_S
        self.epoch = ts.utc(year, 1, whole_days, 0, 0, seconds)

and the same on from_satrec. Leap seconds are not rewritten.

Measured on skyfield 1.55 / sgp4 2.27, TLE 55910 23076.01808579, builtin timescale:

constructor float-day offset seconds form
EarthSatellite(line1, line2) −12.35 µs (93.4 mm TEME) ~0 µs (~0 mm)
from_satrec −12.35 µs ~0 µs
ts._utc_jd (OMM control) 0 0

@brandon-rhodes

Copy link
Copy Markdown
Member

Thanks for looking into this, I'll hopefully get the chance to look at this in detail within the next week!

@brandon-rhodes

Copy link
Copy Markdown
Member

Since d618ee9 fixed the underlying issue with a slightly different approach, I'm going to close this PR. But thanks for the work to find a fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EarthSatellite.epoch is off from the TLE epoch by up to 34 microseconds

2 participants