/
run_measure_seeing.py
executable file
·122 lines (99 loc) · 3.72 KB
/
run_measure_seeing.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python
import os, shutil
import datetime
import ox_wagon
import pick_star
from find_boxes import find_boxes
from guide_gto900 import guide_gto900
from pygto900 import GTO900, status
from spiral_search_gto900 import spiralsearch
import time
import sys
old_star = None
repeat = 1
niter = 15
spiral_log = '/home/massdimm/spiral.log'
while True:
#kill any existing running camera programs
os.system('pkill ave_frames')
os.system('pkill measure_seeing')
time.sleep(5)
#Make sure the ox wagon is open
try:
ox=ox_wagon.OxWagon()
ox=ox.open()
except Exception,e:
print Exception
print 'Could not give open command to Ox Wagon'
pass
#Display telescope status
#os.system('./pygto900.py status')
#time.sleep(30)
#Warning if telescope is pointing too low
with GTO900() as g:
alt = g.alt()
if alt<=30.0:
print '!!!WARNING: Telescope is at an altitude lower than 30 degrees !!!'
print 'Seeing measurements will not start'
print 'YOU MAY WANT TO CHECK THE TELESCOPE ALIGNMENT AND POINTING BEFORE STARTING MEASUREMENTS'
g.park_mode()
sys.exit()
else:
print 'Telescope position checked'
#pick the star
try:
pick_star.pick_star(g)
except Exception, e:
print Exception
print 'Could not pick new star because %s' % e
print 'WARNING: YOU MAY WANT TO STOP MEASUREMENT AND START AGAIN'
g.park_mode()
exit()
#check to see if the star is available
os.system('./ave_frames 10 \!center.fits')
nstars = find_boxes('center.fits')
if nstars < 2:
nfound, sx, sy = spiralsearch(g,niter=niter)
sout = open(spiral_log, 'a')
sout.write('%s %i %i %i\n' % (datetime.datetime.now(), sx, sy, nfound))
sout.close()
if nfound == -1:
print 'Could not find stars in %i iterations' % niter
g.park_mode()
os.system('./ave_frames 10 \!center.fits')
nstars = find_boxes('center.fits')
#start turbina running
try:
current_star=open('current_object').read().strip()
except:
old_star = None
if (old_star is None) or (old_star != current_star):
#os.system('./run_turbina.py')
old_star = current_star
#display star and log information
os.system('cat center.fits | xpaset timDIMM fits')
os.system('./pygto900.py log >> gto900.log')
#measure star -- changed this d wn to 1000 from 10000
os.system("./measure_seeing 10000 `tail -1 gto900.log | cut -d ' ' -f 7` `cat exptime`")
# adjust the guiding
guide_gto900()
#update the documents
if os.path.isfile('seeing.out'):
t=datetime.datetime.now()
centroid_file='centroids_%s.dat' % t.strftime('%Y%m%d-%H%M%S')
shutil.move('centroids.dat', 'data/%s' % centroid_file)
os.chdir('data')
os.system('../dimm_stats.py %s' % centroid_file)
os.chdir('../')
os.system('echo "image;text 25 5 # text={Seeing = `cat seeing.out`}" | xpaset timDIMM regions')
os.system('echo "image;text 290 5 # text={R0 = `cat r0.out` cm}" | xpaset timDIMM regions')
#this is needed for the ELS viewer
os.system("date +'%Y-%m-%dT%H:%M:%S%z' >> seeing.out")
os.system("mv seeing.out seeing.txt")
#os.system("scp seeing.txt timdimm@timdimm:/Users/timdimm/Sites/")
pass
else:
print "FAIL!"
os.system('echo "image;text 125 5 # text={Unsuccessful Measurement}" | xpaset timDIMM regions')
if os.path.isfile('centroids.dat'): os.remove('centroids.dat')
if os.path.isfile('seeing.out'): os.remove('seeing.out')