Skip to content

Instantly share code, notes, and snippets.

@cprima
Created June 20, 2016 19:29
Show Gist options
  • Select an option

  • Save cprima/c295bbb24d00897b73d21f574e862b2e to your computer and use it in GitHub Desktop.

Select an option

Save cprima/c295bbb24d00897b73d21f574e862b2e to your computer and use it in GitHub Desktop.
How long does the moon stay above the horizon at the south pole?
#!/usr/bin/env python
import ephem
sp = ephem.Observer()
sp.lon = 0 * ephem.degree
sp.lat = -89.9 * ephem.degree
sp.elevation = 0
moon = ephem.Moon()
from datetime import timedelta, date
def daterange(start_date, end_date):
for n in range(int ((end_date - start_date).days)):
yield start_date + timedelta(n)
start_date = date(2016, 2, 28)
end_date = date(2016, 9, 30)
for single_date in daterange(start_date, end_date):
sp.date = single_date.strftime("%Y-%m-%d")
try:
risetime = sp.next_setting(moon)
print("rise detected at {0}".format(risetime))
try:
fm = ephem.next_full_moon(sp.date)
print("Next full moon: "+str(fm))
except Exception as f:
print(f)
except Exception as e:
print(e)
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cprima

cprima commented Jun 20, 2016

Copy link
Copy Markdown
Author

'Moon' transits below the horizon at 2016/6/12 18:24:07
rise detected at 2016/6/13 08:05:02
Next full moon: 2016/6/20 11:02:18
'Moon' is still above the horizon at 2016/6/14 07:28:00
'Moon' is still above the horizon at 2016/6/15 08:10:37
'Moon' is still above the horizon at 2016/6/16 08:54:04
'Moon' is still above the horizon at 2016/6/17 09:38:53
'Moon' is still above the horizon at 2016/6/18 10:25:26
'Moon' is still above the horizon at 2016/6/19 11:13:49
'Moon' is still above the horizon at 2016/6/20 12:03:48
'Moon' is still above the horizon at 2016/6/21 12:54:56
'Moon' is still above the horizon at 2016/6/22 13:46:35
'Moon' is still above the horizon at 2016/6/23 14:38:09
'Moon' is still above the horizon at 2016/6/24 15:29:17
'Moon' is still above the horizon at 2016/6/25 16:19:54
'Moon' is still above the horizon at 2016/6/26 17:10:20
'Moon' is still above the horizon at 2016/6/26 17:10:20
'Moon' transits below the horizon at 2016/6/28 06:26:45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment