use function calc_occurences

This commit is contained in:
Kasper D. Fischer 2022-12-06 15:51:24 +01:00
parent 541815d81f
commit 735abac249

View File

@ -735,13 +735,10 @@ class StationQC(object):
self.status_ok(key, detailed_message=f'ClockQuality={(clockQuality[-1])}') self.status_ok(key, detailed_message=f'ClockQuality={(clockQuality[-1])}')
return return
n_qc_warn = 0
n_qc_fail = 0
warn_message = f'Trace {trace.get_id()}:' warn_message = f'Trace {trace.get_id()}:'
if len(clockQuality_warn) > 0: if len(clockQuality_warn) > 0:
# try calculate number of warn peaks from gaps between indices # try calculate number of warn peaks from gaps between indices
n_qc_warn = len(np.where(np.diff(clockQuality_warn) > 1)[0]) + 1 n_qc_warn = self.calc_occurrences(clockQuality_warn)
detailed_message = warn_message + f' {n_qc_warn}x Qlock Quality less then {clockQuality_warn_level}' \ detailed_message = warn_message + f' {n_qc_warn}x Qlock Quality less then {clockQuality_warn_level}' \
+ self.get_last_occurrence_timestring(trace, clockQuality_warn) + self.get_last_occurrence_timestring(trace, clockQuality_warn)
self.warn(key, detailed_message=detailed_message, count=n_qc_warn, self.warn(key, detailed_message=detailed_message, count=n_qc_warn,
@ -749,7 +746,7 @@ class StationQC(object):
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 = len(np.where(np.diff(clockQuality_fail) > 1)[0]) + 1 n_qc_fail = self.calc_occurrences(clockQuality_fail)
detailed_message = warn_message + f' {n_qc_fail}x Qlock Quality less then {clockQuality_fail_level}V ' \ detailed_message = warn_message + f' {n_qc_fail}x Qlock Quality less then {clockQuality_fail_level}V ' \
+ self.get_last_occurrence_timestring(trace, clockQuality_fail) + self.get_last_occurrence_timestring(trace, clockQuality_fail)
self.error(key, detailed_message=detailed_message, count=n_qc_fail, self.error(key, detailed_message=detailed_message, count=n_qc_fail,