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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="480"
height="240"
viewBox="0 0 480 240"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="south-pole_full-moon.svg"
inkscape:export-filename="/home/cpr/Desktop/pyephem/south-pole_full-moon.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.73067701"
inkscape:cx="211.9984"
inkscape:cy="396.29685"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1615"
inkscape:window-height="1026"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-812.36216)">
<rect
style="fill:#0c0b03;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4164"
width="480"
height="240"
x="0"
y="812.36218" />
<path
style="fill:#5b86b3;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 447.58065,952.44282 c -6e-5,50.10648 -97.96392,70.40318 -208.06452,70.40318 -110.1006,0 -200.32253,-24.16768 -200.322587,-74.27415 -4e-6,-50.10648 90.452767,-114.30305 200.322587,-107.17742 134.29419,8.70968 208.06457,60.94191 208.06452,111.04839 z"
id="path4138"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:#43505f;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 455.32259,1005.9105 c 1.5e-4,21.646 -81.99529,26.613 -201.04839,26.613 -119.0531,0 -230.080794,-4.967 -230.080642,-26.613 6.1e-5,-21.64599 96.511562,-39.19353 215.564512,-39.19353 119.05295,0 215.56446,17.54754 215.56452,39.19353 z"
id="path4136"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:#1e2b33;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.2955817px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 302.49893,954.74882 6.74909,-0.31993 13.16766,3.85884 0,2.35819 8.06281,2.78694 0.0477,9.11116 -3.14878,2.51897 -111.06633,5.09153 -32.82373,-0.42876 0.19084,13.29162 -42.93802,5.681 -0.38167,-17.36477 -10.40054,0.10719 -1.33585,-29.15571 11.16389,-2.1438 -0.66708,-25.52092 c 0,0 -0.37108,-0.37898 2.46268,-1.09903 2.83376,-0.72005 9.94079,-2.53577 19.29173,-1.67825 9.35095,0.85753 18.70189,3.00133 20.51483,4.18042 1.81294,1.17909 0.95418,9.21835 0.95418,9.21835 l 11.64097,3.00132 40.21861,-5.4131 z"
id="path4153"
inkscape:connector-curvature="0" />
<path
style="fill:#395362;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 274.35483,999.13635 c 4e-5,9.08595 2.36316,5.80645 -16.20968,5.80645 -18.57283,0 -51.04842,3.2795 -51.04838,-5.80645 0,-9.08597 15.05623,-16.45161 33.62903,-16.45161 18.5728,0 33.62903,7.36564 33.62903,16.45161 z"
id="path4155"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:#495a6a;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 306.29032,995.02344 c 3e-5,6.54726 -1.86913,-0.24191 -17.90323,-0.24191 -16.03409,0 -40.16132,6.78917 -40.16129,0.24191 0,-6.54725 12.99818,-11.85484 29.03226,-11.85484 16.03408,0 29.03226,5.30759 29.03226,11.85484 z"
id="path4160"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<path
style="fill:#3d5061;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 313.54839,1005.4267 c -10e-6,6.4136 -10.05149,2.4194 -27.82258,2.4194 -17.77109,0 -36.53225,3.9942 -36.53226,-2.4194 -10e-6,-6.41363 14.40632,-11.61291 32.17742,-11.61291 17.7711,0 32.17743,5.19928 32.17742,11.61291 z"
id="path4158"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssss" />
<circle
style="fill:#f0dba3;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4168"
cx="330.96774"
cy="891.71698"
r="24.193548" />
<path
style="opacity:1;fill:#ab8139;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.30144665px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 141.3217,837.12569 c -1.56465,-0.0303 -4.04942,1.68082 -4.04942,1.68082 l 2.09951,18.14558 -27.74449,-0.89965 c 0,0 -6.14877,-9e-5 -8.69826,-1.19987 -2.5495,-1.19977 3.44998,4.04942 3.44998,4.04942 l 33.14339,1.7993 c 0,0 -0.14969,5.84891 0.30021,6.59876 0.31814,0.53022 1.94952,1.42494 3.97412,2.51218 2.08904,1.12194 14.92178,5.58685 15.22171,6.33669 0.0451,0.11282 0.0573,0.2402 0.0613,0.37252 -1.36285,1.2996 -3.84058,3.96507 -3.84058,3.96507 0,0 -0.95511,-1.90828 -2.1216,-2.33246 -1.16649,-0.42417 -2.5447,0.5302 -2.65075,1.37859 -0.10604,0.84835 -0.53046,0.84791 -1.16673,1.80231 -0.63627,0.9544 -0.6888,1.59145 -0.6888,1.59145 l -3.76426,0.42372 c 2.01486,1.16651 4.66547,1.90874 5.08964,1.90874 0.42418,0 8.94736,-0.34156 9.79572,-0.65967 0.84836,-0.31817 0.49099,-1.77922 0.49099,-1.77922 0,0 -3.87081,0.10634 -4.45406,-0.74201 -0.53481,-0.77793 3.12907,-2.89412 4.99525,-4.09159 0.27384,0.003 0.58256,-0.006 0.95287,-0.0381 3.44931,-0.29997 2.99934,-0.90025 3.7492,-1.05026 0.4723,-0.0945 5.35393,0.22059 9.36096,0.47191 l 6.74936,3.67188 a 1.9353182,2.8632102 0 0 0 1.68383,1.45993 1.9353182,2.8632102 0 0 0 0.30724,-0.0372 c -1.72039,0.79216 -3.41785,1.56836 -3.41785,1.56836 2.22694,0 9.7123,0.16567 10.24253,0.16567 0.53022,0 5.238,-0.51605 5.45009,-0.78117 0.21209,-0.26511 0.94383,-1.19502 0.94383,-1.51313 0,-0.31817 -4.17991,0.79643 -4.44502,0.58437 -1.03761,-0.35618 -1.70076,-0.55176 -2.30434,-0.72594 a 2.5307443,2.5869831 0 0 0 0.32431,-1.26514 2.5307443,2.5869831 0 0 0 -2.21398,-2.56339 l -0.11647,-1.88364 c 0.4776,-0.10265 1.00736,-0.22094 1.37659,-0.29017 2.49646,-0.46813 3.93785,-1.22994 5.15389,-2.61159 0.85999,-0.97712 0.60936,-4.17929 -0.33536,-5.67903 -0.80333,-1.27524 -2.8146,-3.91884 -3.56445,-4.36871 -0.74986,-0.44993 0.75004,-0.59943 0.75004,-0.59943 0,0 2.8491,1.34912 3.44898,1.49908 0.59988,0.14996 6.10475,0.35461 7.49841,-0.44983 1.30533,-0.75344 0.90065,-2.69914 0.90065,-3.44898 0,-0.74985 -5.1e-4,-0.89965 1.04925,-0.89965 1.04979,0 25.79542,-2.40003 26.69525,-2.69995 0.89981,-0.29997 1.0497,-2.09951 0.44982,-2.09951 -0.59988,0 -27.84088,2.62853 -28.78572,2.08144 -1.28131,-0.74193 -3.92703,-0.96866 -4.80749,-0.88158 -0.89545,0.0886 -6.96703,0.60486 -8.39905,1.05026 -1.35884,0.42263 -2.99917,0.89965 -2.99917,0.89965 l -20.99613,0.75004 -2.24912,-1.19986 -7.64801,0.29921 c 0,0 -0.45085,-0.59928 -2.10052,-1.49908 -1.64967,-0.89985 -7.34779,-0.15061 -7.34779,-0.15061 0,0 -3.65749,-18.43161 -4.49924,-18.5954 -0.0951,-0.0185 -0.19591,-0.0291 -0.30022,-0.0312 z m 45.22638,39.24513 0.17973,1.8013 a 2.5307443,2.5869831 0 0 0 -1.42679,2.32543 2.5307443,2.5869831 0 0 0 0.22592,1.06131 c -0.4338,0.20163 -0.92901,0.43047 -1.43683,0.66469 a 1.9353182,2.8632102 0 0 0 1.10649,-2.58447 1.9353182,2.8632102 0 0 0 -1.27316,-2.6869 c 0.87345,-0.18948 1.76289,-0.38854 2.62464,-0.58136 z m -4.42093,0.95186 a 1.9353182,2.8632102 0 0 0 -0.79421,2.10353 l -3.00921,-1.84548 c 0.70891,0.039 1.29711,0.0673 1.54025,0.0673 0.44894,0 1.28056,-0.13478 2.26317,-0.32532 z"
id="path4200-3"
inkscape:connector-curvature="0" />
</g>
</svg>
@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