[04c391]: ASTRO / ephem-loc-day.py  Maximize  Restore  History

Download this file

50 lines (40 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python
# given the location and time, print various rise/set times (to be
# called by a Perl program later)
# Call as: $0 longitude latitude date(yyyy/mm/dd)
# TODO: add elevation
# TODO: go further back and forward to avoid circumpolarity glitches
import ephem;
from sys import argv;
obs = ephem.Observer();
obs.long,obs.lat,date,obs.pressure=argv[1],argv[2],argv[3],0
obs.date = date;
obs.horizon='-0:34'
for i in ["Sun", "Moon", "Mercury", "Venus", "Mars", "Jupiter", "Saturn"]:
for j in ["previous_rising", "previous_setting", "next_rising", "next_setting", "next_transit", "previous_transit"]:
for k in ["00","12"]:
obs.date = date+" "+k+":00:00"
obj = getattr(ephem,i)()
m = getattr(obs, j)
# thing to print
try:
s = m(obj)
except(ephem.AlwaysUpError):
s = "ALWAYSUP"
except(ephem.NeverUpError):
s = "NEVERUP"
print i,j,s
# Twilights only
for h in ['-6:00', '-12:00', '-18:00']:
obs.horizon = h
for j in ["previous_rising", "previous_setting", "next_rising", "next_setting"]:
for k in ["00","12"]:
obs.date = date+" "+k+":00:00"
m = getattr(obs, j)
try:
s = m(ephem.Sun())
except(ephem.AlwaysUpError):
s = "ALWAYSUP"
except(ephem.NeverUpError):
s = "NEVERUP"
print "Sun"+h,j,s

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks