Skip to content

Pyephem doesn't catch moonset in next 13+ hours at 89.5 latitude #32

barrycarter opened this Issue Nov 26, 2013 · 3 comments

2 participants


import ephem
atlanta = ephem.Observer()
atlanta.pressure = 0
atlanta.horizon = '-0:34', atlanta.lon = '89:30', '0' = '2013/11/26 18:37'
print atlanta.next_setting(ephem.Moon())

The code above yields the "ephem.AlwaysUpError: 'Moon' is still above the horizon at 2013/11/26 18:37:06" error.

However, if change the date to "2013/11/26 18:38", you get:

2013/11/27 07:37:20

which is the correct answer.

Shouldn't next_setting() catch settings that occur within 24 hours?

For reference, libnova does the same thing, see for details.


I just realized I have the atlanta.horizon value wrong for the moon. However, changing the date by one minute still shouldn't change the answer so completely?

(the fact that the date in question is today is totally coincidental, BTW)


I have finally had some time to look at your issue, and in the process remind myself how the whole rising-and-setting engine works. Here is an IPython Notebook where I did some graphing and tracing until I figured out what was going on:

The answer to your question is that, no, next_setting() is not designed to find the next setting within 24 hours. Instead, it is designed to find whether the Moon sets on the particular circuit of the sky that it is engaged in. And the two times that you ask about, as you can see from the notebook, fall in different sky-circlings of the Moon.

I will update the Quick Reference and the docstrings for those functions to try to make this distinction clear — I'm sorry that they confused you and wasted some of your time wondering why!


There! Hopefully that will help things. I am planning for a release on Friday, which will make these changes available if you upgrade. Thanks for letting me know that this was frustrating, and feel free to re-open this issue if you have a further suggestion that could make this PyEphem feature even less confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.