[minor] soft-coded unit factor for channel analysis

This commit is contained in:
Marcel Paffrath 2022-12-22 15:56:32 +01:00
parent 03616a2b7b
commit bc70dc0816

View File

@ -721,6 +721,15 @@ class StationQC(object):
def return_analysis(self): def return_analysis(self):
return self.status_dict return self.status_dict
def get_unit_factor(self, channel):
""" Get channel multiplier for unit from parameters. If none is specified return 1 """
channel_params = self.parameters.get('CHANNELS').get(channel)
if channel_params:
multiplier = channel_params.get('unit')
if multiplier:
return float(multiplier)
return 1
def get_last_occurrence_timestring(self, trace, indices): def get_last_occurrence_timestring(self, trace, indices):
""" returns a nicely formatted string of the timedelta since program starttime and occurrence and abs time""" """ returns a nicely formatted string of the timedelta since program starttime and occurrence and abs time"""
last_occur = self.get_last_occurrence(trace, indices) last_occur = self.get_last_occurrence(trace, indices)
@ -765,7 +774,7 @@ class StationQC(object):
+ self.get_last_occurrence_timestring(trace, clockQuality_warn) + self.get_last_occurrence_timestring(trace, clockQuality_warn)
self.status_ok(key, detailed_message=detailed_message) self.status_ok(key, detailed_message=detailed_message)
# set WARN status for sever warnings in the past # set WARN status for severe warnings in the past
if len(clockQuality_fail) > 0: if len(clockQuality_fail) > 0:
# try calculate number of fail peaks from gaps between indices # try calculate number of fail peaks from gaps between indices
n_qc_fail = self.calc_occurrences(clockQuality_fail) n_qc_fail = self.calc_occurrences(clockQuality_fail)
@ -785,7 +794,7 @@ class StationQC(object):
trace = self.get_trace(st, key) trace = self.get_trace(st, key)
if not trace: if not trace:
return return
voltage = trace.data * 1e-3 voltage = trace.data * self.get_unit_factor(channel)
low_volt = self.parameters.get('THRESHOLDS').get('low_volt') low_volt = self.parameters.get('THRESHOLDS').get('low_volt')
high_volt = self.parameters.get('THRESHOLDS').get('high_volt') high_volt = self.parameters.get('THRESHOLDS').get('high_volt')
@ -824,7 +833,7 @@ class StationQC(object):
trace = self.get_trace(st, key) trace = self.get_trace(st, key)
if not trace: if not trace:
return return
voltage = trace.data * 1e-6 voltage = trace.data * self.get_unit_factor(channel)
thresholds = self.parameters.get('THRESHOLDS') thresholds = self.parameters.get('THRESHOLDS')
temp = 20. * voltage - 20 temp = 20. * voltage - 20
# average temp # average temp
@ -870,7 +879,7 @@ class StationQC(object):
# correct for channel unit # correct for channel unit
for trace in st: for trace in st:
trace.data = trace.data * 1e-6 # TODO: Here and elsewhere: hardcoded, change this? trace.data = trace.data * self.get_unit_factor(trace.stats.channel)
# calculate average of absolute maximum of mass offset of last n_samp_mean # calculate average of absolute maximum of mass offset of last n_samp_mean
last_values = np.array([trace.data[-n_samp_mean:] for trace in st]) last_values = np.array([trace.data[-n_samp_mean:] for trace in st])
@ -908,7 +917,7 @@ class StationQC(object):
if not trace: if not trace:
return return
voltage = trace.data * 1e-6 voltage = trace.data * self.get_unit_factor(channel)
if self.verbosity > 1: if self.verbosity > 1:
self.print(40 * '-') self.print(40 * '-')
self.print('Performing PowBox 12V/230V check (EX2)', flush=False) self.print('Performing PowBox 12V/230V check (EX2)', flush=False)
@ -931,7 +940,7 @@ class StationQC(object):
if not trace: if not trace:
return return
voltage = trace.data * 1e-6 voltage = trace.data * self.get_unit_factor(channel)
if self.verbosity > 1: if self.verbosity > 1:
self.print(40 * '-') self.print(40 * '-')
self.print('Performing PowBox Router/Charger check (EX3)', flush=False) self.print('Performing PowBox Router/Charger check (EX3)', flush=False)