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.

Leap second day utc2tai interpolation

See original GitHub issue

Hi astropy developers,

I am from North American pulsar time group(Nanograv). When I am processing some data taken in a leap second day(more exactly mjd 56109 ), I realize in that day, the leap second is interpolated. Here is a test I made.

>>> from astropy.time import Time
>>> test_leap = np.linspace(56107,56110,500)
>>> test_time = Time(test_leap, format='mjd', scale='utc')
>>> plt.plot(test_time.mjd, (test_time.tai.mjd - test_time.mjd)*86400.0)

And I have the plot. astopy_tai

My question what is the reason to do an interpolation, and is there any way to shut the interpolation off.

Thank you.

-Luo Jing

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
taldcroftcommented, Oct 3, 2016

In theory we can add a warning when anyone uses the jd or mjd attributes of a UTC time object. I’m not generally a huge fan of warnings, but this does seems like a good case of “you are doing something that is likely to get you into trouble because there is a subtle implementation detail you might not be aware of.”

0reactions
mwcraigcommented, Oct 3, 2016

In theory we can add a warning when anyone uses the jd or mjd attributes of a UTC time object.

This seems like a good compromise, especially since there is a correct way to calculate time differences in astropy given UTC input (difference the Time objects not the julian dates):

# A time one second before a leap second
pre_leap_second = Time("1994-06-30T23:59:59", scale='utc', format='isot')

# A time one second after the same leap second:
post_leap_second = Time("1994-07-01T00:00:00", scale='utc', format='isot')

# The Wrong Way to get the difference:
bad_interval = post_leap_second.jd - pre_leap_second.jd
print(bad_interval * 86400)
# Prints 1.9999891519546509, which is not 2.

# The Right Way:
good_interval = post_leap_second - pre_leap_second
print(good_interval.jd * 86400)

#prints 1.9999999999939178, which is 2 to machine precision
Read more comments on GitHub >

github_iconTop Results From Across the Web

Leap-second considerations in distributed computer systems
the UTS clock is reduced by 0.1% from 23:43:21 to 24:00:00. → On a day with a negative UTC leap second, the last...
Read more >
Leap second - Wikipedia
A leap second is a one-second adjustment that is occasionally applied to Coordinated Universal Time (UTC), to accommodate the difference between precise ...
Read more >
NTP Leap Second and how they are handled by Meinberg ...
Insertion of a leap second is always scheduled for UTC midnight at the end of the last day of a month, preferably for...
Read more >
It's time to leave the leap second in the past - Hacker News
The process most astronomy programs go through is to get the UTC from the user, convert the Gregorian date to a Julian day...
Read more >
It's time to leave the leap second in the past
To visualize angular velocity change, think of a spinning figure skater. So far, only positive leap seconds have been added. In the early...
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