-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshot_db_ops.py
More file actions
181 lines (135 loc) · 5.35 KB
/
shot_db_ops.py
File metadata and controls
181 lines (135 loc) · 5.35 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import shot_params as sp
from numpy import nan,isnan
def sanity_check(shot):
#for key in shot_params.shot_params.keys():
# shot_db_ops.sanity_check(key)
params = sp.shot_params[shot]
if (params['current'] != 0 and
(isnan(params['field_delay']) or isnan(params['t_field']))):
print "Warning on shot " + str(shot) + ": Current specified but time value(s) are nans."
if (params['current'] == 0 and
(not(isnan(params['field_delay'])) or not(isnan(params['t_field'])))):
print "Warning on shot " + str(shot) + ": No current, but field timing values are given."
if (params['current'] != 0 and
(params['field_delay'] + params['t_field']) !=
(params['shot_length'] - 5)):
print "Suspicious shot and field timing on shot " + str(shot)
if params['udv_delay'] >= params['shot_length']:
print "Suspicious UDV delay on shot " + str(shot)
if (len(params['channels']) != len(params['alphas']) or
len(params['channels']) != len(params['betas']) or
len(params['channels']) != len(params['offsets']) or
len(params['channels']) != len(params['ports'])):
print "Length mismatch between UDV probe parameter arrays"
if (not(is_ekman(shot)) and not(is_split(shot)) and
not(is_solid_body(shot)) and not(is_mri_z(shot)) and
not(is_mri_mango(shot)) and not(is_mri(shot)) and
not(is_mri_new(shot))):
print "Suspicious component speeds in shot " + str(shot)
if shot != params['shot_num']:
print "Index number and shot_num mismatch in shot " + str(shot)
def is_set_trouble_flag(shot):
if sp.shot_params[shot].__contains__('trouble_flag'):
print '\033[91m'+"Warning: trouble_flag set on shot "+str(shot)+'\033[0m'
return True
return False
def is_solid_body(shot):
IC = sp.shot_params[shot]['ICspeed']
IR = sp.shot_params[shot]['IRspeed']
OR = sp.shot_params[shot]['ORspeed']
OC = sp.shot_params[shot]['OCspeed']
if IC == IR and IC == OR and IC == OC:
return True
return False
def is_split(shot):
IC = sp.shot_params[shot]['ICspeed']
IR = sp.shot_params[shot]['IRspeed']
OR = sp.shot_params[shot]['ORspeed']
OC = sp.shot_params[shot]['OCspeed']
if IC == IR and OC == OR and IC != OC:
return True
return False
def is_split_unstable(shot):
IC = sp.shot_params[shot]['ICspeed']
IR = sp.shot_params[shot]['IRspeed']
OR = sp.shot_params[shot]['ORspeed']
OC = sp.shot_params[shot]['OCspeed']
if IC == IR and OR == 0 and OC == 0 and IC != 0:
return True
return False
def is_split_cyclonic(shot):
IC = sp.shot_params[shot]['ICspeed']
IR = sp.shot_params[shot]['IRspeed']
OR = sp.shot_params[shot]['ORspeed']
OC = sp.shot_params[shot]['OCspeed']
if OC == OR and IR == 0 and IC == 0 and OC != 0:
return True
return False
def is_ekman(shot):
IC = sp.shot_params[shot]['ICspeed']
IR = sp.shot_params[shot]['IRspeed']
OR = sp.shot_params[shot]['ORspeed']
OC = sp.shot_params[shot]['OCspeed']
if IC != 0 and IC != IR and IR == OR and IR == OC:
return True
return False
def is_mri_z(shot):
IC = sp.shot_params[shot]['ICspeed']
IR = sp.shot_params[shot]['IRspeed']
OR = sp.shot_params[shot]['ORspeed']
OC = sp.shot_params[shot]['OCspeed']
if(IR == 0 or OR == 0 or OC == 0):
return False
IRrat = float(IC)/float(IR)
ORrat = float(IC)/float(OR)
OCrat = float(IC)/float(OC)
in_range = lambda x, y: abs(1.0 - x/y) < 0.01
if (OC != 0 and OR != 0 and IR != 0 and in_range(IRrat, 1.818) and
in_range(ORrat, 7.547) and in_range(OCrat, 7.547)):
return True
return False
def is_mri_new(shot):
IC = sp.shot_params[shot]['ICspeed']
IR = sp.shot_params[shot]['IRspeed']
OR = sp.shot_params[shot]['ORspeed']
OC = sp.shot_params[shot]['OCspeed']
if(IR == 0 or OR == 0 or OC == 0):
return False
IRrat = float(IC)/float(IR)
ORrat = float(IC)/float(OR)
OCrat = float(IC)/float(OC)
in_range = lambda x, y: abs(1.0 - x/y) < 0.01
if (OC != 0 and OR != 0 and IR != 0 and in_range(IRrat, 2.0) and
in_range(ORrat, 6.061) and in_range(OCrat, 7.547)):
return True
return False
def is_mri(shot):
IC = sp.shot_params[shot]['ICspeed']
IR = sp.shot_params[shot]['IRspeed']
OR = sp.shot_params[shot]['ORspeed']
OC = sp.shot_params[shot]['OCspeed']
if(IR == 0 or OR == 0 or OC == 0):
return False
IRrat = float(IC)/float(IR)
ORrat = float(IC)/float(OR)
OCrat = float(IC)/float(OC)
in_range = lambda x, y: abs(1.0 - x/y) < 0.01
if (OC != 0 and OR != 0 and IR != 0 and in_range(IRrat, 2.740) and
in_range(ORrat, 10.0) and in_range(OCrat, 7.547)):
return True
return False
def is_mri_mango(shot):
IC = sp.shot_params[shot]['ICspeed']
IR = sp.shot_params[shot]['IRspeed']
OR = sp.shot_params[shot]['ORspeed']
OC = sp.shot_params[shot]['OCspeed']
if(IR == 0 or OR == 0 or OC == 0):
return False
IRrat = float(IC)/float(IR)
ORrat = float(IC)/float(OR)
OCrat = float(IC)/float(OC)
in_range = lambda x, y: abs(1.0 - x/y) < 0.01
if (OC != 0 and OR != 0 and IR != 0 and in_range(IRrat, 1.481) and
in_range(ORrat, 7.547) and in_range(OCrat, 7.547)):
return True
return False