forked from saltastro/timDIMM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix_pointing.py
executable file
·76 lines (67 loc) · 2.29 KB
/
fix_pointing.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
import os
import re
import ephem
import timdimm
import datetime
def run(program, *args):
pid = os.fork()
if not pid:
os.execvp(program, (program,) + args)
return pid
def get_stars(site, cat):
good = []
el_limit = 25.0 * ephem.pi / 180.0
az_limit = 181.0 * ephem.pi / 180.0
for key, star in cat.items():
if star.az > az_limit and star.alt > el_limit:
good.append(key)
good.sort(lambda x, y: cmp(cat[x].dec, cat[y].dec))
print good
return good
if __name__ == '__main__':
pid = run("./video_feed")
print "Video PID: %d" % pid
now = datetime.datetime.today()
file = "%4d%02d%02d_west.dat" % (now.year, now.month, now.day)
salt = timdimm.salt_site()
cat = timdimm.hr_catalog(salt)
stars = get_stars(salt, cat)
for s in stars:
salt.date = ephem.now()
star = cat[s]
star.compute(salt)
print "Going to HR %s (%s)" % (s, star.name)
print "RA = %s; Dec = %s" % (star.ra, star.dec)
lst = salt.sidereal_time()
ha = ephem.hours(lst - star.ra)
print "HA = %s; Alt = %s; Az = %s" % (ha, star.alt, star.az)
os.system("./ox_wagon.py open")
os.system("./gto900_hr.rb %s" % s)
while True:
os.system("./ox_wagon.py open")
res = raw_input('---> ')
if re.match('[NESW]', res):
print "Nudge %s" % res.lower()
os.system("./gto900_nudge.rb %s" % res.lower())
elif re.match('[nesw]', res):
print "Tweak %s" % res.lower()
os.system("./gto900_tweak.rb %s" % res.lower())
elif re.match('[kK]', res):
print "Skipping"
break
elif re.match('[aA]', res):
print "Accept"
os.system("./tpoint_gto.rb %s >> %s" % (s, file))
break
elif re.match('[qQxX]', res):
print "Exiting..."
os.system("kill -9 %d" % pid)
exit()
else:
print "\tNESW for big move"
print "\tnesw for little move"
print "\tk to skip"
print "\ta to accept to move on"
print "\tx or q to exit"
os.system("kill -9 %d" % pid)