Skip to content

Commit e70d811

Browse files
committed
Started shot_db_ops with routines to sanity check the shot database
1 parent 4adb055 commit e70d811

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

shot_db_ops.py

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import shot_params as sp
2+
from numpy import nan,isnan
3+
4+
def sanity_check(shot):
5+
#for key in shot_params.shot_params.keys():
6+
# shot_db_ops.sanity_check(key)
7+
8+
params = sp.shot_params[shot]
9+
10+
if (params['current'] != 0 and
11+
(isnan(params['field_delay']) or isnan(params['t_field']))):
12+
print "Warning on shot " + str(shot) + ": Current specified but time value(s) are nans."
13+
14+
if (params['current'] == 0 and
15+
(not(isnan(params['field_delay'])) or not(isnan(params['t_field'])))):
16+
print "Warning on shot " + str(shot) + ": No current, but field timing values are given."
17+
18+
if (params['current'] != 0 and
19+
(params['field_delay'] + params['t_field']) !=
20+
(params['shot_length'] - 5)):
21+
print "Suspicious shot and field timing on shot " + str(shot)
22+
23+
if params['udv_delay'] >= params['shot_length']:
24+
print "Suspicious UDV delay on shot " + str(shot)
25+
26+
if (len(params['channels']) != len(params['alphas']) or
27+
len(params['channels']) != len(params['betas']) or
28+
len(params['channels']) != len(params['offsets']) or
29+
len(params['channels']) != len(params['ports'])):
30+
print "Length mismatch between UDV probe parameter arrays"
31+
32+
if (not(is_ekman(shot)) and not(is_split(shot)) and
33+
not(is_solid_body(shot)) and not(is_mri_z(shot)) and
34+
not(is_mri_mango(shot)) and not(is_mri(shot)) and
35+
not(is_mri_new(shot))):
36+
print "Suspicious component speeds in shot " + str(shot)
37+
38+
if shot != params['shot_num']:
39+
print "Index number and shot_num mismatch in shot " + str(shot)
40+
41+
42+
43+
def is_set_trouble_flag(shot):
44+
if sp.shot_params[shot].__contains__('trouble_flag'):
45+
print '\033[91m'+"Warning: trouble_flag set on shot "+str(shot)+'\033[0m'
46+
return True
47+
return False
48+
49+
50+
def is_solid_body(shot):
51+
IC = sp.shot_params[shot]['ICspeed']
52+
IR = sp.shot_params[shot]['IRspeed']
53+
OR = sp.shot_params[shot]['ORspeed']
54+
OC = sp.shot_params[shot]['OCspeed']
55+
if IC == IR and IC == OR and IC == OC:
56+
return True
57+
return False
58+
59+
60+
def is_split(shot):
61+
IC = sp.shot_params[shot]['ICspeed']
62+
IR = sp.shot_params[shot]['IRspeed']
63+
OR = sp.shot_params[shot]['ORspeed']
64+
OC = sp.shot_params[shot]['OCspeed']
65+
if IC == IR and OC == OR and IC != OC:
66+
return True
67+
return False
68+
69+
70+
def is_split_unstable(shot):
71+
IC = sp.shot_params[shot]['ICspeed']
72+
IR = sp.shot_params[shot]['IRspeed']
73+
OR = sp.shot_params[shot]['ORspeed']
74+
OC = sp.shot_params[shot]['OCspeed']
75+
if IC == IR and OR == 0 and OC == 0 and IC != 0:
76+
return True
77+
return False
78+
79+
80+
def is_ekman(shot):
81+
IC = sp.shot_params[shot]['ICspeed']
82+
IR = sp.shot_params[shot]['IRspeed']
83+
OR = sp.shot_params[shot]['ORspeed']
84+
OC = sp.shot_params[shot]['OCspeed']
85+
if IC != 0 and IC != IR and IR == OR and IR == OC:
86+
return True
87+
return False
88+
89+
90+
def is_mri_z(shot):
91+
IC = sp.shot_params[shot]['ICspeed']
92+
IR = sp.shot_params[shot]['IRspeed']
93+
OR = sp.shot_params[shot]['ORspeed']
94+
OC = sp.shot_params[shot]['OCspeed']
95+
96+
IRrat = float(IC)/float(IR)
97+
ORrat = float(IC)/float(OR)
98+
OCrat = float(IC)/float(OC)
99+
100+
in_range = lambda x, y: abs(1.0 - x/y) < 0.01
101+
102+
if (OC != 0 and OR != 0 and IR != 0 and in_range(IRrat, 1.818) and
103+
in_range(ORrat, 7.547) and in_range(OCrat, 7.547)):
104+
return True
105+
return False
106+
107+
108+
def is_mri_new(shot):
109+
IC = sp.shot_params[shot]['ICspeed']
110+
IR = sp.shot_params[shot]['IRspeed']
111+
OR = sp.shot_params[shot]['ORspeed']
112+
OC = sp.shot_params[shot]['OCspeed']
113+
114+
IRrat = float(IC)/float(IR)
115+
ORrat = float(IC)/float(OR)
116+
OCrat = float(IC)/float(OC)
117+
118+
in_range = lambda x, y: abs(1.0 - x/y) < 0.01
119+
120+
if (OC != 0 and OR != 0 and IR != 0 and in_range(IRrat, 2.0) and
121+
in_range(ORrat, 6.061) and in_range(OCrat, 7.547)):
122+
return True
123+
return False
124+
125+
126+
127+
128+
def is_mri_mango(shot):
129+
IC = sp.shot_params[shot]['ICspeed']
130+
IR = sp.shot_params[shot]['IRspeed']
131+
OR = sp.shot_params[shot]['ORspeed']
132+
OC = sp.shot_params[shot]['OCspeed']
133+
134+
IRrat = float(IC)/float(IR)
135+
ORrat = float(IC)/float(OR)
136+
OCrat = float(IC)/float(OC)
137+
138+
in_range = lambda x, y: abs(1.0 - x/y) < 0.01
139+
140+
if (OC != 0 and OR != 0 and IR != 0 and in_range(IRrat, 1.481) and
141+
in_range(ORrat, 7.547) and in_range(OCrat, 7.547)):
142+
return True
143+
return False

0 commit comments

Comments
 (0)