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.

The unix_tai time format appears to be off by 8 seconds

See original GitHub issue

Description

The zero point for the new time format unix_tai appears to be off by 8 seconds.

Expected behavior

The new time format unix_tai is defined to match the CLOCK_TAI Linux real-time clock (and I was looking forward to using it, for that reason).

For a current date I expect CLOCK_TAI - CLOCK_UTC = 37 seconds and that is what I observe on a linux system whose leap second table is properly maintained by ntp. When I try the same computation using Astropy I get 29 seconds.

Actual behavior

Astropy.time seems to believe that CLOCK_TAI - CLOCK_UTC is 29 seconds for current dates. That is what is shown as an example in your docs and is coded in the unit test, so you clearly have a reason for this. But I don’t see how it is compatible with CLOCK_TAI.

Steps to Reproduce

1: Find a linux system that has a current leap second table (linux is the only OS I know of that supports the CLOCK_TAI real time clock). 2: Use a reasonably recent Python 3 (I use 3.7) 3: Use AstroPy 4.1 or the current dev version

import time
import astropy.time
clock_tai = getattr(time, "CLOCK_TAI", 11)
now_utc_unix = time.time()
now_tai_unix = time.clock_gettime(clock_tai)
astropy_now_utc = astropy.time.Time(now_utc_unix, format="unix")
print(now_tai_unix - now_utc_unix)
print(astropy_now_utc.unix_tai - now_utc_unix)

System Details

import platform; print(platform.platform()) Linux-3.10.0-1062.12.1.el7.x86_64-x86_64-with-centos-7.7.1908-Core import sys; print(“Python”, sys.version) Python 3.7.8 | packaged by conda-forge | (default, Jul 23 2020, 03:54:19) [GCC 7.5.0] import numpy; print(“Numpy”, numpy.version) Numpy 1.19.1 import astropy; print(“astropy”, astropy.version) astropy 4.3.dev452+gc3132e70a import scipy; print(“Scipy”, scipy.version) Scipy 1.5.2 import matplotlib; print(“Matplotlib”, matplotlib.version) Matplotlib 3.0.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:26 (20 by maintainers)

github_iconTop GitHub Comments

2reactions
mhvkcommented, Jan 13, 2021

In the end, I think we have to match CLOCK_TAI however that is actually implemented in current systems. Hopefully, those are consistent…

I fear we need to go the “advertise as a breaking change route” - having two implementations is just going to be super-confusing.

1reaction
maxnoecommented, Jan 14, 2021

@pllim I just meant which part of the Changelog I will fill in 😉

I am not a maintainer, so @mhvk or you will have to set the milestone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unix time - Wikipedia
Unix time is a date and time representation widely used in computing. It measures time by the number of seconds that have elapsed...
Read more >
Converting a UNIX Timestamp to Formatted Date String
Use date('c',time()) as format to convert to ISO 8601 date (added in PHP 5) ... it out by using the timestamp from my...
Read more >
Date and Time Formats - IBM
Format Specifier Format Example %m/%d/%Y mm/dd/yyyy 02/21/2018 %m/%d/%y mm/dd/yy 02/21/18 %d/%m/%Y dd/mm/yyyy 21/02/2018
Read more >
Time.Format - - The Go Programming Language
4 5 package time 6 7 import "errors" 8 9 // These are predefined layouts for use in ... 36 // The RFC3339Nano...
Read more >
Time and Date Formats (PSPP) - GNU.org
The time formats translate between human-friendly descriptions of time ... Internally, PSPP represents a date as the number of seconds since the epoch, ......
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