Skip to content

Commit 4bcdecb

Browse files
Fix skyfielders#466 by correcting from_satrec() epoch formula
1 parent 9a718e7 commit 4bcdecb

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
Changelog
33
=========
44

5+
1.32 — Future
6+
-------------
7+
8+
* Fix: the ``.epoch`` attribute of Earth satellite objects that were
9+
built using :meth:`~skyfield.sgp4lib.EarthSatellite.from_satrec()`
10+
was, alas, a half-day off.
11+
`#466 <https://github.com/skyfielders/python-skyfield/issues/466>`_
12+
513
1.31 — 2020 October 24
614
----------------------
715

skyfield/documentation/earth-satellites.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ call this special constructor:
740740
.. testoutput::
741741

742742
Satellite number: 5
743-
Epoch: A.D. 2000-Jun-27 06:50:24.0000 UT
743+
Epoch: A.D. 2000-Jun-27 18:50:24.0000 UT
744744

745745
The result should be a satellite object that behaves
746746
exactly as though it had been loaded from TLE lines.

skyfield/sgp4lib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def from_satrec(cls, satrec, ts):
131131
# be unified to always use epochyr and epochdays.
132132
whole, fraction = divmod(satrec.jdsatepoch, 1.0)
133133
year, month, day = compute_calendar_date(whole)
134+
day += 0.5 # convert integer Julian day into Julian date float
134135
self.epoch = ts.utc(year, month, day + fraction + satrec.jdsatepochF)
135136

136137
self._setup(satrec)

0 commit comments

Comments
 (0)