Compare commits
No commits in common. "a89ea1b06d58e647a7f03fe3e3d5ed3fd36712bd" and "03616a2b7b64c94a8c1303de177b7f7d7dfdfb4d" have entirely different histories.
a89ea1b06d
...
03616a2b7b
47
survBot.py
47
survBot.py
@ -469,14 +469,12 @@ class SurveillanceBot(object):
|
||||
|
||||
|
||||
class StationQC(object):
|
||||
def __init__(self, parent, stream, nsl, parameters, keys, starttime, verbosity, print_func, status_track=None):
|
||||
def __init__(self, parent, stream, nsl, parameters, keys, starttime, verbosity, print_func, status_track={}):
|
||||
"""
|
||||
Station Quality Check class.
|
||||
:param nsl: dictionary containing network, station and location (key: str)
|
||||
:param parameters: parameters dictionary from parameters.yaml file
|
||||
"""
|
||||
if status_track is None:
|
||||
status_track = {}
|
||||
self.parent = parent
|
||||
self.stream = stream
|
||||
self.nsl = nsl
|
||||
@ -723,15 +721,6 @@ class StationQC(object):
|
||||
def return_analysis(self):
|
||||
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):
|
||||
""" returns a nicely formatted string of the timedelta since program starttime and occurrence and abs time"""
|
||||
last_occur = self.get_last_occurrence(trace, indices)
|
||||
@ -750,44 +739,44 @@ class StationQC(object):
|
||||
trace = self.get_trace(st, key)
|
||||
if not trace:
|
||||
return
|
||||
clock_quality = trace.data
|
||||
clock_quality_warn_level = self.parameters.get('THRESHOLDS').get('clockquality_warn')
|
||||
clock_quality_fail_level = self.parameters.get('THRESHOLDS').get('clockquality_fail')
|
||||
clockQuality = trace.data
|
||||
clockQuality_warn_level = self.parameters.get('THRESHOLDS').get('clockquality_warn')
|
||||
clockQuality_fail_level = self.parameters.get('THRESHOLDS').get('clockquality_fail')
|
||||
|
||||
if self.verbosity > 1:
|
||||
self.print(40 * '-')
|
||||
self.print('Performing Clock Quality check', flush=False)
|
||||
|
||||
clockQuality_warn = np.where(clock_quality < clock_quality_warn_level)[0]
|
||||
clockQuality_fail = np.where(clock_quality < clock_quality_fail_level)[0]
|
||||
clockQuality_warn = np.where(clockQuality < clockQuality_warn_level)[0]
|
||||
clockQuality_fail = np.where(clockQuality < clockQuality_fail_level)[0]
|
||||
|
||||
if len(clockQuality_warn) == 0 and len(clockQuality_fail) == 0:
|
||||
self.status_ok(key, detailed_message=f'ClockQuality={(clock_quality[-1])}')
|
||||
self.status_ok(key, detailed_message=f'ClockQuality={(clockQuality[-1])}')
|
||||
return
|
||||
|
||||
last_val_average = np.nanmean(clock_quality[-n_sample_average:])
|
||||
last_val_average = np.nanmean(clockQuality[-n_sample_average:])
|
||||
|
||||
# keep OK status if there are only minor warnings (lower warn level)
|
||||
warn_message = f'Trace {trace.get_id()}:'
|
||||
if len(clockQuality_warn) > 0:
|
||||
# try calculate number of warn peaks from gaps between indices
|
||||
n_qc_warn = self.calc_occurrences(clockQuality_warn)
|
||||
detailed_message = warn_message + f' {n_qc_warn}x Clock quality less then {clock_quality_warn_level}%' \
|
||||
detailed_message = warn_message + f' {n_qc_warn}x Clock quality less then {clockQuality_warn_level}%' \
|
||||
+ self.get_last_occurrence_timestring(trace, clockQuality_warn)
|
||||
self.status_ok(key, detailed_message=detailed_message)
|
||||
|
||||
# set WARN status for severe warnings in the past
|
||||
# set WARN status for sever warnings in the past
|
||||
if len(clockQuality_fail) > 0:
|
||||
# try calculate number of fail peaks from gaps between indices
|
||||
n_qc_fail = self.calc_occurrences(clockQuality_fail)
|
||||
detailed_message = warn_message + f' {n_qc_fail}x Clock quality less then {clock_quality_fail_level}%' \
|
||||
detailed_message = warn_message + f' {n_qc_fail}x Clock quality less then {clockQuality_fail_level}%' \
|
||||
+ self.get_last_occurrence_timestring(trace, clockQuality_fail)
|
||||
self.warn(key, detailed_message=detailed_message, count=n_qc_fail,
|
||||
last_occurrence=self.get_last_occurrence(trace, clockQuality_fail))
|
||||
|
||||
# set FAIL state if last value is less than fail level
|
||||
if last_val_average < clock_quality_fail_level:
|
||||
self.error(key, detailed_message=f'ClockQuality={(clock_quality[-1])}')
|
||||
if last_val_average < clockQuality_fail_level:
|
||||
self.error(key, detailed_message=f'ClockQuality={(clockQuality[-1])}')
|
||||
|
||||
def voltage_analysis(self, channel='VEI'):
|
||||
""" Analyse voltage channel for over/undervoltage """
|
||||
@ -796,7 +785,7 @@ class StationQC(object):
|
||||
trace = self.get_trace(st, key)
|
||||
if not trace:
|
||||
return
|
||||
voltage = trace.data * self.get_unit_factor(channel)
|
||||
voltage = trace.data * 1e-3
|
||||
low_volt = self.parameters.get('THRESHOLDS').get('low_volt')
|
||||
high_volt = self.parameters.get('THRESHOLDS').get('high_volt')
|
||||
|
||||
@ -835,7 +824,7 @@ class StationQC(object):
|
||||
trace = self.get_trace(st, key)
|
||||
if not trace:
|
||||
return
|
||||
voltage = trace.data * self.get_unit_factor(channel)
|
||||
voltage = trace.data * 1e-6
|
||||
thresholds = self.parameters.get('THRESHOLDS')
|
||||
temp = 20. * voltage - 20
|
||||
# average temp
|
||||
@ -881,7 +870,7 @@ class StationQC(object):
|
||||
|
||||
# correct for channel unit
|
||||
for trace in st:
|
||||
trace.data = trace.data * self.get_unit_factor(trace.stats.channel)
|
||||
trace.data = trace.data * 1e-6 # TODO: Here and elsewhere: hardcoded, change this?
|
||||
|
||||
# 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])
|
||||
@ -919,7 +908,7 @@ class StationQC(object):
|
||||
if not trace:
|
||||
return
|
||||
|
||||
voltage = trace.data * self.get_unit_factor(channel)
|
||||
voltage = trace.data * 1e-6
|
||||
if self.verbosity > 1:
|
||||
self.print(40 * '-')
|
||||
self.print('Performing PowBox 12V/230V check (EX2)', flush=False)
|
||||
@ -942,7 +931,7 @@ class StationQC(object):
|
||||
if not trace:
|
||||
return
|
||||
|
||||
voltage = trace.data * self.get_unit_factor(channel)
|
||||
voltage = trace.data * 1e-6
|
||||
if self.verbosity > 1:
|
||||
self.print(40 * '-')
|
||||
self.print('Performing PowBox Router/Charger check (EX3)', flush=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user