Saturday 7 November 2020

Determining lunar eclipse in skyfield

I am given a list of dates in UTC, all hours cast to 00:00.

I'd like to determine if a (lunar) eclipse occurred in a given day (ie past 24 hours)

Considering the python snippet

from sykfield.api import load
eph = load('de421.bsp')
def eclipticangle(t):

    moon, earth = eph['moon'], eph['earth']
    e = earth.at(t)
    x, y, _ = e.observe(moon).apparent().ecliptic_latlon()

    return x.degrees

I am assuming one is able to determine if an eclipse occurred within 24hrs of a time t by

  1. Checking that the first angle is close enough to 180 (easy)
  2. Checking if the second degree is close enough to 0 (not so essy?)

Now as far as the answer in the comment suggests it is not so trivial to solve the second problem simply by testing if the angle is close to 0.

Therefore, my question is

Can someone provide a function to determine if a lunar eclipse occurred on a given day t?

Edit. This question was edited to reflect the feedback from Brandon Rhodes left in the comments below.



from Determining lunar eclipse in skyfield

No comments:

Post a Comment