skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.39k stars 209 forks source link

Moon phase seems inconsistent: Getting values over 180 degrees #753

Closed JsBergbau closed 2 years ago

JsBergbau commented 2 years ago

According to https://rhodesmill.org/skyfield/almanac.html#phases-of-the-moon 0 degrees is new moon, 180 degress is full moon.

Trying with this script


from datetime import datetime
from dateutil import tz
from skyfield import almanac

planets = load('de421.bsp')

#Next full moon
ts = load.timescale()
time=datetime(2022,6,14,1,48,tzinfo=tz.tzoffset("DE",7200))
timets=ts.from_datetime(time)
moonphase = almanac.moon_phase(planets,timets)
print("Moonphase: " ,time, ": " , moonphase)

#about one month later
time=datetime(2022,7,18,1,48,tzinfo=tz.tzoffset("DE",7200))
timets=ts.from_datetime(time)
moonphase = almanac.moon_phase(planets,timets)
print("Moonphase: " ,time, ": " , moonphase)

I get

Moonphase:  2022-06-14 01:48:00+02:00 :  172deg 51' 21.5"
Moonphase:  2022-07-18 01:48:00+02:00 :  238deg 03' 32.6"

172 degrees seem reasonable, but why is there 238 degress for about one month later?

brandon-rhodes commented 2 years ago

Because the phase is a number from 0°–359.99° that tells you where the Moon is in its whole journey from New to Full to back to New. I'll expand the description there in the docs you link to, to clarify that the angle keeps growing until the end of the lunar month.

brandon-rhodes commented 2 years ago

There! The documentation should update the next time I do a release of Skyfield. Thanks for pointing out that the description of the function was incomplete.