[update] add channel naming for plots
This commit is contained in:
parent
9444405453
commit
d35c176aab
@ -4,6 +4,7 @@ networks: ["1Y", "HA"]
|
||||
stations: "*"
|
||||
locations: "*"
|
||||
channels: ["EX1", "EX2", "EX3", "VEI"] # Specify SOH channels, currently supported EX[1-3] and VEI
|
||||
channel_names: ["Temperature (°)", "Voltage (V)", "Voltage (V)", "Voltage (V)"] # names for plotting (optional)
|
||||
stations_blacklist: ["TEST", "EREA"]
|
||||
networks_blacklist: []
|
||||
interval: 60 # Perform checks every x seconds
|
||||
@ -16,12 +17,6 @@ dt_thresh: [300, 1800] # threshold (s) for timing delay colourisation (yello
|
||||
html_figures: True # Create html figure directory and links
|
||||
reread_parameters: True # reread parameters file (change parameters on runtime, not for itself/GUI refresh/datapath)
|
||||
|
||||
# add links to html table with specified key as column and value as relative link, interpretable string parameters:
|
||||
# nw (e.g. 1Y), st (e.g. GR01A), nwst_id (e.g. 1Y.GR01A)
|
||||
# can also be empty!
|
||||
add_links:
|
||||
slmon: {"URL": "{nw}_{st}.html", "text": "show"} # for example: slmon: {"URL": "{nw}_{st}.html", "text": "link"}
|
||||
|
||||
POWBOX:
|
||||
pb_ok: 1 # Voltage for PowBox OK
|
||||
pb_SOH2: # PowBox channel 2 voltage translations
|
||||
@ -49,13 +44,19 @@ THRESHOLDS:
|
||||
high_volt: 14.8 # max voltage for over voltage warning
|
||||
unclassified: 5 # min voltage samples not classified for warning
|
||||
|
||||
# E-mail notifications
|
||||
# add links to html table with specified key as column and value as relative link, interpretable string parameters:
|
||||
# nw (e.g. 1Y), st (e.g. GR01A), nwst_id (e.g. 1Y.GR01A)
|
||||
# optional!
|
||||
add_links:
|
||||
slmon: {"URL": "{nw}_{st}.html", "text": "show"} # for example: slmon: {"URL": "{nw}_{st}.html", "text": "link"}
|
||||
|
||||
# E-mail notifications (optional)
|
||||
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
|
||||
|
||||
# Factor for channel to SI-units (for plotting)
|
||||
# Factor for channel to SI-units (for plotting, optional)
|
||||
CHANNEL_UNITS:
|
||||
EX1: 1e-6
|
||||
EX2: 1e-6
|
||||
@ -63,6 +64,7 @@ CHANNEL_UNITS:
|
||||
VEI: 1e-3
|
||||
|
||||
# Transform channel for plotting, perform arithmetic operations in given order, e.g.: PBox EX1 V to deg C: 20 * x -20
|
||||
# optional!
|
||||
CHANNEL_TRANSFORM:
|
||||
EX1:
|
||||
- ["*", 20]
|
||||
|
21
survBot.py
21
survBot.py
@ -19,7 +19,7 @@ from obspy.clients.filesystem.sds import Client
|
||||
|
||||
from write_utils import write_html_text, write_html_row, write_html_footer, write_html_header, get_print_title_str, \
|
||||
init_html_table, finish_html_table
|
||||
from utils import get_bg_color, modify_stream_for_plot
|
||||
from utils import get_bg_color, modify_stream_for_plot, annotate_trace_axes
|
||||
|
||||
try:
|
||||
import smtplib
|
||||
@ -337,12 +337,19 @@ class SurveillanceBot(object):
|
||||
fnout = self.get_fig_path_abs(nwst_id)
|
||||
st = self.data.get(nwst_id)
|
||||
if st:
|
||||
st = modify_stream_for_plot(st, parameters=self.parameters)
|
||||
st.plot(fig=fig, show=False, draw=False, block=False, equal_scale=False, method='full')
|
||||
ax = fig.axes[0]
|
||||
ax.set_title(f'Plot refreshed at (UTC) {UTCDateTime.now().strftime("%Y-%m-%d %H:%M:%S")}. '
|
||||
f'Refreshed hourly or on FAIL status.')
|
||||
fig.savefig(fnout, dpi=150., bbox_inches='tight')
|
||||
# TODO: this section might fail, adding try-except block for analysis and to prevent program from crashing
|
||||
try:
|
||||
st = modify_stream_for_plot(st, parameters=self.parameters)
|
||||
st.plot(fig=fig, show=False, draw=False, block=False, equal_scale=False, method='full')
|
||||
annotate_trace_axes(fig, self.parameters, self.verbosity)
|
||||
except Exception as e:
|
||||
print(f'Could not generate plot for {nwst_id}:')
|
||||
print(traceback.format_exc())
|
||||
if len(fig.axes) > 0:
|
||||
ax = fig.axes[0]
|
||||
ax.set_title(f'Plot refreshed at (UTC) {UTCDateTime.now().strftime("%Y-%m-%d %H:%M:%S")}. '
|
||||
f'Refreshed hourly or on FAIL status.')
|
||||
fig.savefig(fnout, dpi=150., bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
def write_html_table(self, default_color='#e6e6e6'):
|
||||
|
@ -34,7 +34,7 @@ from obspy import UTCDateTime
|
||||
|
||||
from survBot import SurveillanceBot
|
||||
from write_utils import *
|
||||
from utils import get_bg_color, modify_stream_for_plot
|
||||
from utils import get_bg_color, modify_stream_for_plot, annotate_trace_axes
|
||||
|
||||
try:
|
||||
from rest_api.utils import get_station_iccid
|
||||
@ -316,6 +316,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.plot_widget.setWindowTitle(nwst_id)
|
||||
st = modify_stream_for_plot(st, parameters=self.parameters)
|
||||
st.plot(equal_scale=False, method='full', block=False, fig=self.plot_widget.canvas.fig)
|
||||
annotate_trace_axes(fig=self.plot_widget.canvas.fig, parameters=self.parameters)
|
||||
self.plot_widget.show()
|
||||
|
||||
def notification(self, text):
|
||||
|
20
utils.py
20
utils.py
@ -102,3 +102,23 @@ def transform_trace(data, transf):
|
||||
raise IOError(f'Unknown arithmethic operator string: {operator_str}')
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def annotate_trace_axes(fig, parameters, verbosity=0):
|
||||
"""
|
||||
Adds channel names to y-axis if defined in parameters.
|
||||
Can get mixed up if channel order in stream and channel names defined in parameters.yaml differ, but it is
|
||||
difficult to assess the correct order from Obspy plotting routing.
|
||||
"""
|
||||
names = parameters.get('channel_names')
|
||||
if not names: # or not len(st.traces):
|
||||
return
|
||||
if not len(names) == len(fig.axes):
|
||||
if verbosity:
|
||||
print('Mismatch in axis and label lengths. Not adding plot labels')
|
||||
return
|
||||
for channel_name, ax in zip(names, fig.axes):
|
||||
if channel_name:
|
||||
ax.set_ylabel(channel_name)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user