-
Notifications
You must be signed in to change notification settings - Fork 492
Open
Labels
? - Needs TriageNeed team to review and classifyNeed team to review and classifybugSomething isn't workingSomething isn't workingexternalIssues/PR filed by people outside the teamIssues/PR filed by people outside the team
Description
Version
main
On which installation method(s) does this occur?
No response
Describe the issue
As @azrael417 noted, the cos zenith implementation in physicsnemo does not account for leap seconds.
The reason is that unix timestamps are not correctly being converted into the number of actual seconds elapsed since 2000 Jan 1. This is not simply the difference of the unix timestamps since unix timestamps don't account for leap seconds. So for later times, the result is shifted in lon by about 10 seconds = 10 / 86400 * 360 = 0.0625 degrees. This is small for many applications, but worth fixing.
Here is a fix proposed by chat GPT, though we may want to verify the list of leap seconds.
import torch
# Leap second insertion times as torch tensor
leap_seconds_unix = torch.tensor([
78796800, 94694400, 126230400, 157766400, 189302400, 220924800,
252460800, 283996800, 315532800, 362793600, 394329600, 425865600,
489024000, 567993600, 631152000, 662688000, 709948800, 741484800,
773020800, 820454400, 867715200, 915148800, 1136073600, 1230768000,
1341100800, 1435708800, 1483228800
], dtype=torch.int64)
EPOCH_2000 = 946684800 # 2000-01-01 00:00:00 UTC
leap_before_2000 = torch.bucketize(
torch.tensor([EPOCH_2000]), leap_seconds_unix, right=True
)[0]
def seconds_since_2000_with_leap_vectorized(unix_ts_tensor):
# unix_ts_tensor: 1D or ND tensor of int64 Unix timestamps
leap_counts = torch.bucketize(unix_ts_tensor, leap_seconds_unix, right=True)
leap_deltas = leap_counts - leap_before_2000
return (unix_ts_tensor - EPOCH_2000) + leap_deltas
Minimum reproducible example
Relevant log output
Environment details
Metadata
Metadata
Assignees
Labels
? - Needs TriageNeed team to review and classifyNeed team to review and classifybugSomething isn't workingSomething isn't workingexternalIssues/PR filed by people outside the teamIssues/PR filed by people outside the team