From c57763c016bbf07eab9e3c43680b332f1e1a6624 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 13 Aug 2024 13:38:50 +0200 Subject: [PATCH] [update] added coloring for temperature warning and a critical temperature level, improved tooltip message --- parameters.yaml | 7 ++++--- survBot.py | 19 ++++++++++++++----- utils.py | 20 +++++++++++++------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/parameters.yaml b/parameters.yaml index 83aeea4..519fbaa 100644 --- a/parameters.yaml +++ b/parameters.yaml @@ -3,11 +3,11 @@ datapath: "/data/SDS/" # SC3 Datapath networks: ["1Y", "HA", "MK"] # select networks, list or str stations: "*" # select stations, list or str locations: "*" # select locations, list or str -stations_blacklist: ["TEST", "EREA", "DOMV"] # exclude these stations +stations_blacklist: ["TEST", "EREA", "DOMV", "LFKM", "GR19", "LAKA"] # exclude these stations networks_blacklist: [] # exclude these networks interval: 60 # Perform checks every x seconds n_track: 360 # wait n_track * intervals before performing an action (i.e. send mail/end highlight status) -timespan: 3 # Check data of the recent x days +timespan: 7 # Check data of the recent x days verbosity: 0 # verbosity flag for program console output (not logging) logging_level: WARN # set logging level (info, warning, debug) track_changes: True # tracks all changes since GUI startup by text highlighting (GUI only) @@ -40,6 +40,7 @@ POWBOX: THRESHOLDS: pb_thresh: 0.2 # Threshold for PowBox Voltage check +/- (V) max_temp: 50 # max temperature for temperature warning + critical_temp: 65 # max temperature for critical warning (fail) low_volt: 12 # min voltage for low voltage warning high_volt: 14.8 # max voltage for over voltage warning unclassified: 5 # min voltage samples not classified for warning @@ -139,7 +140,7 @@ EMAIL: mailserver: "localhost" addresses: ["marcel.paffrath@rub.de", "kasper.fischer@rub.de"] # list of mail addresses for info mails sender: "webmaster@geophysik.ruhr-uni-bochum.de" # mail sender - stations_blacklist: ['GR33'] # do not send emails for specific stations + stations_blacklist: [] # do not send emails for specific stations networks_blacklist: [] # do not send emails for specific network # specify recipients for single stations in a yaml: key = email-address, val = station list (e.g. [1Y.GR01, 1Y.GR02]) external_mail_list: "mailing_list.yaml" diff --git a/survBot.py b/survBot.py index b6e306e..174bfe7 100755 --- a/survBot.py +++ b/survBot.py @@ -1024,7 +1024,7 @@ class StationQC(object): self.warn(key, detailed_message=detailed_message, count=n_undervolt, last_occurrence=self.get_last_occurrence(trace, undervolt)) - def pb_temp_analysis(self, channel='EX1'): + def pb_temp_analysis(self, channel='EX1', t_max_default=50, t_crit_default=70): """ Analyse PowBox temperature output. """ key = 'temp' st = self.stream.select(channel=channel) @@ -1047,12 +1047,21 @@ class StationQC(object): logging.info(f'Average temperature at {np.nanmean(temp)}\N{DEGREE SIGN}') logging.info(f'Peak temperature at {max(temp)}\N{DEGREE SIGN}') logging.info(f'Min temperature at {min(temp)}\N{DEGREE SIGN}') - max_temp = thresholds.get('max_temp') + max_temp = thresholds.get('max_temp', t_max_default) + max_temp_crit = thresholds.get('critical_temp', t_crit_default) t_check = np.where(temp > max_temp)[0] - if len(t_check) > 0: + t_check_crit = np.where(temp > max_temp_crit)[0] + tcheck_message_template = ('Trace {id}: Temperature over {tmax}' + f'\N{DEGREE SIGN}' + + '! Current temperature: {temp}' + f'\N{DEGREE SIGN}') + if len(t_check_crit) > 0: + self.error(key=key, + detailed_message=tcheck_message_template.format(id=trace.get_id(), tmax=max_temp, temp=cur_temp) + + self.get_last_occurrence_timestring(trace, t_check_crit), + last_occurrence=self.get_last_occurrence(trace, t_check_crit)) + elif len(t_check) > 0: self.warn(key=key, - detailed_message=f'Trace {trace.get_id()}: ' - f'Temperature over {max_temp}\N{DEGREE SIGN} at {trace.get_id()}!' + detailed_message=tcheck_message_template.format(id=trace.get_id(), tmax=max_temp_crit, + temp=cur_temp) + self.get_last_occurrence_timestring(trace, t_check), last_occurrence=self.get_last_occurrence(trace, t_check)) else: diff --git a/utils.py b/utils.py index f05dcbf..2723635 100644 --- a/utils.py +++ b/utils.py @@ -9,6 +9,14 @@ import numpy as np from obspy import Stream +COLORS_DICT = {'FAIL': (195, 29, 14, 255), + 'NO DATA': (255, 255, 125, 255), + 'WARN': (250, 192, 63, 255), + 'OK': (185, 245, 145, 255), + 'undefined': (240, 240, 240, 255), + 'disc': (126, 127, 131, 255), } + + def get_bg_color(check_key, status, dt_thresh=None, hex=False): message = status.message if check_key == 'last active': @@ -43,13 +51,9 @@ def get_color(key): # 'OK': (173, 255, 133, 255), # 'undefined': (230, 230, 230, 255), # 'disc': (255, 160, 40, 255),} - colors_dict = {'FAIL': (195, 29, 14, 255), - 'NO DATA': (255, 255, 125, 255), - 'WARN': (250, 192, 63, 255), - 'OK': (185, 245, 145, 255), - 'undefined': (240, 240, 240, 255), - 'disc': (126, 127, 131, 255), } - return colors_dict.get(key) + if not key in COLORS_DICT.keys(): + key = 'undefined' + return COLORS_DICT.get(key) def get_color_mpl(key): @@ -84,6 +88,8 @@ def get_mass_color(message): def get_temp_color(temp, vmin=-10, vmax=60, cmap='coolwarm'): """ Get an rgba temperature value back from specified cmap, linearly interpolated between vmin and vmax. """ if type(temp) in [str]: + if temp in COLORS_DICT.keys(): + return get_color(temp) return get_color('undefined') cmap = matplotlib.cm.get_cmap(cmap) val = (temp - vmin) / (vmax - vmin)