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:
Don Cross
2020-12-18 14:29:41 -05:00
parent c58a59dabf
commit 246ac47d2b
20 changed files with 123 additions and 43 deletions

View File

@@ -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