mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-03-30 20:34:16 -04:00
Fixed a failure to find a full moon using certain start dates.
In all four versions of Astronomy Engine (C, C#, JavaScript, and Python), starting a search for a full moon near December 19, 2020 would fail. I added a unit test to all four languages and it failed consistently across them all. The root cause: I was too optimistic about how narrow I could make the window around the approximate moon phase time in the SearchMoonPhase functions. Finding the exact moon phase time failed because it was outside this excessively small window around the approximate time. I increased the window from 1.8 days to 3.0 days. This should handle all cases with minimal impact on performance. Now all four of the new unit tests pass.
This commit is contained in:
@@ -4620,11 +4620,11 @@ def SearchMoonPhase(targetLon, startTime, limitDays):
|
||||
# that every lunar phase repeats roughly every 29.5 days.
|
||||
# There is a surprising uncertainty in the quarter timing,
|
||||
# due to the eccentricity of the moon's orbit.
|
||||
# I have seen up to 0.826 days away from the simple prediction.
|
||||
# I have seen more than 0.9 days away from the simple prediction.
|
||||
# To be safe, we take the predicted time of the event and search
|
||||
# +/-0.9 days around it (a 1.8-day wide window).
|
||||
# +/-1.5 days around it (a 3-day wide window).
|
||||
# But we must return None if the final result goes beyond limitDays after startTime.
|
||||
uncertainty = 0.9
|
||||
uncertainty = 1.5
|
||||
ya = _moon_offset(targetLon, startTime)
|
||||
if ya > 0.0:
|
||||
ya -= 360.0 # force searching forward in time, not backward
|
||||
|
||||
Reference in New Issue
Block a user