sffjunkie / astral

Python calculations for the position of the sun and moon.
Apache License 2.0
237 stars 47 forks source link

Moon phases are slightly off #57

Open sirex opened 4 years ago

sirex commented 4 years ago

I found, that moon phases are slightly off by several hours. I'm using astral to calculate moon phases, bus since astral gives inaccurate values, sometimes I get moon phase for a wrong date.

Here is my experiment:

import datetime
import ephem
import astral
import matplotlib.pyplot as plt
x = [datetime.datetime(2020, 5, 22) + datetime.timedelta(hours=i*6) for i in range(30*4*2)]
a = astral.Astral()
a = [a.moon_phase(date=d, rtype=float) for d in x]
a = [(28 - p if p > 14 else p) / 14 * 100 for p in a]
e = [ephem.Moon(ephem.Date(d)).phase for d in x]
fig, ax = plt.subplots()
ax.plot(x, a, label="Astral")
ax.plot(x, e, label="Ephem")
ax.legend()
plt.show()

And the result:

Screenshot from 2020-05-23 07-23-52