-
Notifications
You must be signed in to change notification settings - Fork 0
/
reprocess.py
executable file
·109 lines (93 loc) · 3.56 KB
/
reprocess.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
#!/usr/bin/env python
# #!/usr/bin/env python #-m pdb
# import signal
# signal.signal(signal.SIGINT, signal.SIG_DFL)
import E200
import mytools as mt
import numpy as np
import analyze_matlab as analyze_matlab
from save_analysis import save_analysis
sets = [
['20140625', '13438'],
['20140625', '13449'],
['20140625', '13450'],
['20140629', '13537']
]
# sets = [['20140625', '13438'],
sets = [['20140629', '13537']]
# sets = [['20140625', '13450']]
logger = mt.mylogger(filename='reprocess')
logger.setLevel(51)
logger.debug('Beginning reprocessing...')
for pair in sets:
setdate = pair[0]
setnumber = pair[1]
loadfile = 'nas/nas-li20-pm00/E200/2014/{}/E200_{}'.format(setdate, setnumber)
data = E200.E200_load_data(loadfile, local=True)
wf = data.write_file
data_wf = wf['data']
processed_wf = data_wf['processed']
arrays_wf = processed_wf['arrays']
vectors_wf = processed_wf['vectors']
rf = data.read_file
data_rf = rf['data']
camname_list = E200.E200_api_getdat(arrays_wf['ss_camname'])
camname_list_UID = np.array([camname_list.UID]).flatten()
for i, uid in enumerate(camname_list_UID):
camname = camname_list.dat[i]
head_str = 'ss_{}_'.format(camname)
logger.debug('Loaded camname: {camname}, UID: {uid}'.format(camname=camname, uid=uid))
oimg = E200.E200_api_getdat(arrays_wf['{}image'.format(head_str)], uid)
oimg = oimg.dat[0]
rect_vec_str = E200.E200_api_getdat(vectors_wf['{}rect'.format(head_str)], uid)
rect_vec = rect_vec_str.dat[0]
rect = mt.qt.Rectangle(*rect_vec)
try:
logger.debug('Re-analyzing...')
out = analyze_matlab(
data = data_rf ,
camname = camname ,
oimg = oimg ,
rect = rect ,
uid = uid
)
logger.debug('Re-saving...')
print(i)
print(uid)
print(out.scanfit.fitresults.emitn)
save_analysis(
dataset = data ,
analyze_out = out ,
rect_arr = rect_vec ,
camname = camname ,
oimg = oimg ,
uid = uid ,
valid = True
)
except:
save_analysis(
dataset = data ,
analyze_out = out ,
rect_arr = rect_vec ,
camname = camname ,
oimg = oimg ,
uid = uid ,
valid = False
)
logger.log(level=51, msg='Error analyzing')
# if __name__ == '__main__':
# parser=argparse.ArgumentParser(description='Loads and runs a gui to analyze saved spectrometer data.')
# parser.add_argument('-v', '--verbose', action='store_true',
# help='enable verbose mode')
# parser.add_argument('-l', '--log', default='info', choices=['debug', 'info', 'warning', 'error', 'critical'],
# help='increase logging level')
# parser.add_argument('-f', '--file',
# help='file to process')
# parser.add_argument('-c', '--camera',
# help='camera name')
# parser.add_argument('-i', '--imgnum', type=int,
# help='image number')
#
# arg=parser.parse_args()
#
# runGUI(arg.file, arg.camera, arg.imgnum, verbose=arg.verbose, loglevel=arg.log)