Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
GW14 : dict
holds GW14 ratio values and times with corresponding positionlabel as key
GW23 : dict
holds GW23 ratio values and times with corresponding positionlabel as key
CCC : dict
holds CCC ratio values and times with corresponding positionlabel as key
"""
log = log_error_and_file.Log('PROCESS')
m = mnemonic_data
log.log('extract IMIR_HK_FW filterpositions')
FW = extract_data.extract_filterpos(mn.fw_nominals,
m['IMIR_HK_FW_POS_RATIO'], m['IMIR_HK_FW_CUR_POS'])
log.log('extract IMIR_HK_GW14 filterpositions')
GW14 = extract_data.extract_filterpos(mn.gw14_nominals,
m['IMIR_HK_GW14_POS_RATIO'], m['IMIR_HK_GW14_CUR_POS'])
log.log('extract IMIR_HK_GW23 filterpositions')
GW23 = extract_data.extract_filterpos(mn.gw23_nominals,
m['IMIR_HK_GW23_POS_RATIO'], m['IMIR_HK_GW23_CUR_POS'])
log.log('extract IMIR_HK_CCC filterpositions')
CCC = extract_data.extract_filterpos(mn.ccc_nominals,
m['IMIR_HK_CCC_POS_RATIO'], m['IMIR_HK_CCC_CUR_POS'])
return FW, GW14, GW23, CCC
GW23_volt : list
extracted data for IMIR_HK_GW23_POS_VOLT
CCC_volt : list
extracted data for IMIR_HK_CCC_POS_VOLT
"""
log = log_error_and_file.Log('Process')
m = mnemonic_data
returndata = dict()
# Define Condition Set 3
# add filtered engineering values of mnemonics given in list mnemonic_cond_3
con_set_3 = [
cond.greater(m['IMIR_HK_ICE_SEC_VOLT1'], 25.0)]
condition_3 = cond.condition(con_set_3)
for identifier in mn.mnemonic_cond_3:
data = extract_data.extract_data(condition_3, m[identifier])
if data is not None:
returndata.update({identifier: data})
log.log('Check condition 3 Succesful for ' + identifier)
else:
log.log('NO data in condition 3 for ' + identifier, 'Error')
del condition_3
# Define Condition Set FW
# add filtered engineering values of mnemonics given in list mnemonic_cond_FW
con_set_FW = [
cond.greater(m['IMIR_HK_FW_POS_VOLT'], 250.0)]
condition_FW = cond.condition(con_set_FW)
# SW was missing in the trainigs data so I could not use it for a condition.
# con_set_2 = [ \
# cond.greater(m['SE_ZIMIRFPEA'], 0.5), \
# cond.equal(m['IGDP_IT_MIR_IC_STATUS'], 'DETECTOR_READY'), \
# cond.equal(m['IGDP_IT_MIR_LW_STATUS'], 'DETECTOR_READY')]
con_set_2 = [ \
cond.equal(m['IGDP_IT_MIR_IC_STATUS'], 'DETECTOR_READY'), \
cond.equal(m['IGDP_IT_MIR_IC_STATUS'], 'DETECTOR_READY')]
# setup condition
condition_2 = cond.condition(con_set_2)
# add filtered engineering values of mnemonics given in list mnemonic_cond_2
# to dictitonary
for identifier in mn.mnemonic_cond_2:
data = extract_data.extract_data(condition_2, m[identifier])
if data != None:
returndata.update({identifier: data})
log.log('Check condition 2 Succesful for ' + identifier)
else:
log.log('NO data in condition 2 for ' + identifier, 'Error')
del condition_2
return returndata
toolbar_location="above", \
plot_width=1120, \
plot_height=500, \
y_range=[-2, 2], \
x_range=utils.time_delta(Time(end)), \
x_axis_type='datetime', \
x_axis_label='Date', y_axis_label='ratio (normalized)')
p.xaxis.formatter = copy.copy(utils.plot_x_axis_format)
p.grid.visible = True
p.title.text = "DGA-A Ratio"
p.title.align = "left"
pf.add_basic_layout(p)
pf.add_to_wplot(p, "SHORT", "IMIR_HK_GW14_POS_RATIO_SHORT", start, end, conn, mn.gw14_nominals['SHORT'],
color="green")
pf.add_to_wplot(p, "MEDIUM", "IMIR_HK_GW14_POS_RATIO_MEDIUM", start, end, conn, mn.gw14_nominals['MEDIUM'],
color="red")
pf.add_to_wplot(p, "LONG", "IMIR_HK_GW14_POS_RATIO_LONG", start, end, conn, mn.gw14_nominals['LONG'], color="blue")
p.legend.location = "bottom_right"
p.legend.click_policy = "hide"
return p
for mnemonic in m.mnemonic_set_database:
try:
c.execute('CREATE TABLE IF NOT EXISTS {} ( \
id INTEGER, \
start_time REAL, \
end_time REAL, \
data_points INTEGER, \
average REAL, \
deviation REAL, \
performed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\
PRIMARY KEY (id));'.format(mnemonic))
except Error as e:
print('e')
for mnemonic in m.mnemonic_wheelpositions:
try:
c.execute('CREATE TABLE IF NOT EXISTS {} ( \
id INTEGER, \
timestamp REAL, \
value REAL, \
performed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\
PRIMARY KEY (id));'.format(mnemonic))
except Error as e:
print('e')
#create anomaly
c.execute('CREATE TABLE IF NOT EXISTS miriAnomaly ( \
id INTEGER, \
start_time float, \
end_time float, \
plot char,\
toolbar_location="above", \
plot_width=1120, \
plot_height=500, \
y_range=[-2, 2], \
x_range=utils.time_delta(Time(end)), \
x_axis_type='datetime', \
x_axis_label='Date', y_axis_label='ratio (normalized)')
p.xaxis.formatter = copy.copy(utils.plot_x_axis_format)
p.grid.visible = True
p.title.text = "CCC Ratio"
pf.add_basic_layout(p)
# add_to_wplot(p, "LOCKED", "IMIR_HK_CCC_POS_RATIO_LOCKED", start, end, conn, mn.ccc_nominals['LOCKED'], color = "green")
pf.add_to_wplot(p, "OPEN", "IMIR_HK_CCC_POS_RATIO_OPEN", start, end, conn, mn.ccc_nominals['OPEN'], color="red")
pf.add_to_wplot(p, "CLOSED", "IMIR_HK_CCC_POS_RATIO_CLOSED", start, end, conn, mn.ccc_nominals['CLOSED'],
color="blue")
p.legend.location = "bottom_right"
p.legend.click_policy = "hide"
return p
Return
------
FW : dict
holds FW ratio values and times with corresponding positionlabel as key
GW14 : dict
holds GW14 ratio values and times with corresponding positionlabel as key
GW23 : dict
holds GW23 ratio values and times with corresponding positionlabel as key
CCC : dict
holds CCC ratio values and times with corresponding positionlabel as key
"""
log = log_error_and_file.Log('PROCESS')
m = mnemonic_data
log.log('extract IMIR_HK_FW filterpositions')
FW = extract_data.extract_filterpos(mn.fw_nominals,
m['IMIR_HK_FW_POS_RATIO'], m['IMIR_HK_FW_CUR_POS'])
log.log('extract IMIR_HK_GW14 filterpositions')
GW14 = extract_data.extract_filterpos(mn.gw14_nominals,
m['IMIR_HK_GW14_POS_RATIO'], m['IMIR_HK_GW14_CUR_POS'])
log.log('extract IMIR_HK_GW23 filterpositions')
GW23 = extract_data.extract_filterpos(mn.gw23_nominals,
m['IMIR_HK_GW23_POS_RATIO'], m['IMIR_HK_GW23_CUR_POS'])
log.log('extract IMIR_HK_CCC filterpositions')
CCC = extract_data.extract_filterpos(mn.ccc_nominals,
m['IMIR_HK_CCC_POS_RATIO'], m['IMIR_HK_CCC_CUR_POS'])
return FW, GW14, GW23, CCC
del condition_GW14
con_set_GW23 = [ \
cond.greater(m.mnemonic('IMIR_HK_GW23_POS_VOLT'),250.0)]
#setup condition
condition_GW23 = cond.condition(con_set_GW23)
GW23 = extract_filterpos(condition_GW23, mn.gw23_nominals, \
m.mnemonic('IMIR_HK_GW23_POS_RATIO'), m.mnemonic('IMIR_HK_GW23_CUR_POS'))
del condition_GW23
con_set_CCC = [ \
cond.greater(m.mnemonic('IMIR_HK_CCC_POS_VOLT'),250.0)]
#setup condition
condition_CCC = cond.condition(con_set_CCC)
CCC = extract_filterpos(condition_CCC, mn.ccc_nominals, \
m.mnemonic('IMIR_HK_CCC_POS_RATIO'), m.mnemonic('IMIR_HK_CCC_CUR_POS'))
del condition_CCC
return FW, GW14, GW23, CCC
start_time = Time(day + ' 12:00:00.000', format='iso')
end_time = Time(day + ' 12:15:00.000', format='iso')
# define time
start_time = Time(day + ' 00:00:00.001', format='iso')
end_time = Time(day + ' 23:59:59.000', format='iso')
# querry data 15 min STARTED
print("*************************************************************")
print("* querry data 15 min")
print("*************************************************************")
mnemonic_dict = {}
# go over all nmemonics
for mnemonic_name in mn.mnemonic_set_base:
try:
# set text and color
status = 'Succes'
color = '\033[0m' # color black (standard)
# get data
data, meta, info = edb.query_single_mnemonic(mnemonic_name, start_time, end_time, token=mast_token)
if data == None:
data = Table(names=('MJD', 'euvalue', 'sqldataType', 'theTime'), dtype=('f8', 'f8', 'U4', 'U21'))
status = 'Failure No data'
color = '\33[31m' # color red
# raise Exception('No data')
data['time_iso'] = Time(data['MJD'], format='mjd').iso
del data['theTime']