-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathps_stats.py
More file actions
31 lines (27 loc) · 1.04 KB
/
ps_stats.py
File metadata and controls
31 lines (27 loc) · 1.04 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
# script to scan through all point source scans and create a target list.
import katfile
import katarchive
#locate the files
#myfiles = katarchive.get_katfiles(interactive = False,description = 'point source scan')
myfiles = katarchive.list_katfiles(start='30/7/2011',end='1/8/2011',description='point source scan')
list_len = len(myfiles)
log_file = open('point_source_scan_log_test.txt','w')
for i,file in enumerate(myfiles):
percent = int(float(i)/list_len * 100.0)
if percent % 10 == 0:
print "Percent = " + str(percent)
h5 = katfile.open(file)
try:
for scan_index, compscan_index, state, target in h5.scans():
if state != 'scan':
continue
timestamps = h5.timestamps()
time = timestamps[len(timestamps) // 2]
log_file.write("%s, %s, %f\n" % (h5.version,target.description,time))
except KeyError as error:
print 'Failed to read scans from File: ',file,' with Key Error:',error
except ValueError as error:
print 'Failed to read scans from File: ',file,' with Value Error:',error
except:
print 'Some other error'
pass