question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GPS time unexpected isot representation

See original GitHub issue

Description

GPS time is correctly defined as 1980-01-06T00:00:19 TAI as its epoch. Many text formats using GPS time, such as RINEX messages, have defined the ISO or ISO-like text datetimes for GPS to be TAI - 19s (leap seconds at the 1980-01-06T00:00:00 UTC epoch). With GPS time being specified via the format argument and not having a GPS scale since it follows TAI, the isot representation is not as expected by these standard formats.

Expected behavior

In [1]: t = Time(0, format='gps')

In [2]: t.isot
Out[2]: '1980-01-06T00:00:00.000'

In [3]: t.tai.isot
Out[3]: '1980-01-06T00:00:19.000'

As below under actual behavior, I would not expect the t.isot and t.tai.isot values to be the same. I’m not sure if this is a similar issue to #11245 or not, but seems like it could be. Not sure if this would need effectively a GPS time scale in addition to the current TAI to make it work. For now, the only work around I’ve found is explicitly removing the 19 leap second offset for the .isot in a wrapper method. Am I missing something key or is this the only way to handle this at the moment, and should this functionality be added? Obviously using t.utc.isot is not the correct answer as that would add all of the leap seconds since the GPS epoch for current datetimes.

In [1]: (Time(0, format='gps') + TimeDelta(-19, format='sec')).isot
Out[1]: '1980-01-06T00:00:00.000'

Actual behavior

In [85]: t = Time(0, format='gps')

In [86]: t.isot
Out[86]: '1980-01-06T00:00:19.000'

In [87]: t.tai.isot
Out[87]: '1980-01-06T00:00:19.000'

In [88]: t.utc.isot
Out[88]: '1980-01-06T00:00:00.000'

In [89]: t.gps
Out[89]: 0.0

In [90]: t.utc
Out[90]: <Time object: scale='utc' format='gps' value=0.0>

System Details

Linux-4.19.0-13-amd64-x86_64-with-debian-10.7 Python 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0] Numpy 1.16.2 astropy 4.0.1.post1 Scipy 1.5.2 Matplotlib 3.0.2

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
taldcroftcommented, Jan 22, 2021

See #11269.

1reaction
taldcroftcommented, Jan 22, 2021

I have a proof-of-concept fix which adds a new time scale gps_scale and gives the expected behavior in limited testing.

In [24]: t = Time('1980-01-06', scale='gps_scale')

In [25]: t.isot
Out[25]: '1980-01-06T00:00:00.000'

In [26]: t.gps  # SI seconds since the GPS epoch time 1980-01-06 00:00:00 UTC
Out[26]: 0.0

In [27]: t.tai.isot
Out[27]: '1980-01-06T00:00:19.000'

In [28]: t = Time('2020-01-01', scale='gps_scale')

In [29]: t.isot
Out[29]: '2020-01-01T00:00:00.000'

In [30]: t.tai.isot
Out[30]: '2020-01-01T00:00:19.000'

In [31]: t.gps
Out[31]: 1261872000.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

Time and Dates (astropy.time) — Astropy v5.2
The Time object maintains an internal representation of time as a pair of double precision numbers expressing Julian days. The sum of the...
Read more >
Time Systems and Dates - GPS Time
It is a time frame based on atomic clocks and aligned with the zero longitude time zone. UTC, plus an offset for time...
Read more >
UTC to GPS Time Correction - Qinsy - QPS Confluence
GPS time was set to match UTC in 1980, but has since diverged. The lack of corrections means that GPS time remains at...
Read more >
Time Distribution of Strong Seismic Events in the Fore ... - MDPI
based on time series of horizontal components of velocity vectors of the GPS stations in the ITRF2008 reference system. [10,16] and expected direction...
Read more >
Untitled
The conduct exhibited during the study does not represent the values of the ... Use aciclovir vencido medicine for the full prescribed length...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found