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.

Prominently document that UT1, not UTC, is most appropriate for ancient dates

See original GitHub issue

I am getting very strange results for sunset, the older the date, it seems to be out by a few hours, (Expected value from Starry Night software)

Got 2020-06-01T16:05:01Z, expected 2020-06-01T16:05:00Z, diff mins 0, alt -0.83
Got 1800-06-01T16:03:42Z, expected 1800-06-01T16:04:00Z, diff mins 0, alt -0.83
Got 1000-06-01T16:31:04Z, expected 1000-06-01T16:05:00Z, diff mins 26, alt -0.83
Got 0200-06-01T18:23:57Z, expected 0200-06-01T16:00:00Z, diff mins 143, alt -0.83
Got -400-06-01T20:14:49Z, expected -400-06-01T15:56:00Z, diff mins 258, alt -0.83
Got -800-06-01T21:59:03Z, expected -800-06-01T15:53:00Z, diff mins 366, alt -0.83

To reproduce:

load = Loader(path.as_posix())
ts = load.timescale()
ts.julian_calendar_cutoff = GREGORIAN_START
eph = load('de431t.bsp')
babylon = Topos("32.55 N", "44.42 E")

def altitude_of_sun(t0):
    b = eph['earth'] + babylon
    apparent = b.at(t0).observe(eph['sun']).apparent()
    alt, az, distance = apparent.altaz()
    return alt

def sunset_for_day(t0, expected):
    t1 = ts.tt_jd(t0.tt + 1)
    t, y = almanac.find_discrete(t0, t1, almanac.sunrise_sunset(eph, babylon))
    for ti, yi in zip(t, y):
        if yi == 0:
            diff_mins = int(abs(ti.tt - expected.tt) * 60 * 24)
            print("Got {}, expected {}, diff mins {}, alt {:.2f}"
                  .format(ti.utc_iso(), expected.utc_iso(), diff_mins, altitude_of_sun(ti).degrees))

if __name__ == "__main__":
    sunset_for_day(ts.utc(2020, 6, 1), ts.utc(2020, 6, 1, 16, 5))
    sunset_for_day(ts.utc(1800, 6, 1), ts.utc(1800, 6, 1, 16, 4))
    sunset_for_day(ts.utc(1000, 6, 1), ts.utc(1000, 6, 1, 16, 5))
    sunset_for_day(ts.utc(200, 6, 1), ts.utc(200, 6, 1, 16, 0))
    sunset_for_day(ts.utc(-400, 6, 1), ts.utc(-400, 6, 1, 15, 56))
    sunset_for_day(ts.utc(-800, 6, 1), ts.utc(-800, 6, 1, 15, 53))

Am I doing something wrong? I’m guessing its something to do with the timescale? I’m on version 1.34

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
brandon-rhodescommented, Dec 25, 2020

Great, I’m glad it helped! If you don’t mind, I’m going to re-open this with a different title to remind myself to highlight this difference more in the documentation.

1reaction
brandon-rhodescommented, Dec 25, 2020

(Merry Christmas!) The UTC timescale uses leap seconds to keep up with the Earth’s actual rotation, but leap seconds are only specified from 1972 forwards — there are no leap seconds going backwards that would keep it in sync in past centuries with the length of the day, or at least with our retrospective guesses about how long the day was in past centuries. We currently use the sparse ancient records of eclipses to try to guess where the Earth was pointed during the day in ancient times, and those guesses guide the UT1 timescale that follows the Sun rather than an artificial scheme of leap seconds. I’d first try UT1 and see whether that gives you closer values to the ones you expect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Brief Note on Time Systems - OSU Astronomy
UT1 is effectively the same as Greenwich Mean Time (GMT) as it was defined before 1961. Older scientific papers will often refer to...
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 >
two thirds of all charts and maps as their Prime Meridian39 Among ...
SystemDescription UT1UTCTTTAIGPSUT1Mean Solar TimeUT1UTC = UT1 – DUT1TT = UT1 + ... One of the most important systems ofperiodization is the geologic time ......
Read more >
Probing a southern hemisphere VLBI Intensive baseline ...
Keywords: Very Long Baseline Interferometry (VLBI), UT1−UTC, ... satellite-based techniques are not suited for the direct estimation of ...
Read more >
Future of Leap Seconds - UC Observatories
Whenever a date is used in connection with Coordinated Universal Time (UTC), this date shall be that of the prime meridian at the...
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