Skip to content
Snippets Groups Projects
Commit c7b66da9 authored by Lan Dam's avatar Lan Dam
Browse files

combine get_wf_plot_info() into get_chan_plot_info

parent a41506c6
No related branches found
No related tags found
1 merge request!131combine get wf plot info to get chan plot info
...@@ -5,7 +5,7 @@ from sohstationviewer.database.process_db import execute_db_dict, execute_db ...@@ -5,7 +5,7 @@ from sohstationviewer.database.process_db import execute_db_dict, execute_db
from sohstationviewer.conf.dbSettings import dbConf from sohstationviewer.conf.dbSettings import dbConf
def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str, def get_chan_plot_info(org_chan_id: str, data_type: str,
color_mode: ColorMode = 'B') -> Dict: color_mode: ColorMode = 'B') -> Dict:
""" """
Given chanID read from raw data file and detected dataType Given chanID read from raw data file and detected dataType
...@@ -24,10 +24,10 @@ def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str, ...@@ -24,10 +24,10 @@ def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str,
chan = 'VM?' chan = 'VM?'
if org_chan_id.startswith('MassPos'): if org_chan_id.startswith('MassPos'):
chan = 'MassPos?' chan = 'MassPos?'
if org_chan_id.startswith('DS'):
chan = 'SEISMIC'
if org_chan_id.startswith('Event DS'): if org_chan_id.startswith('Event DS'):
chan = 'Event DS?' chan = 'Event DS?'
if org_chan_id.startswith('DS'):
chan = 'DS?'
if org_chan_id.startswith('Disk Usage'): if org_chan_id.startswith('Disk Usage'):
chan = 'Disk Usage?' chan = 'Disk Usage?'
if dbConf['seisRE'].match(chan): if dbConf['seisRE'].match(chan):
...@@ -46,17 +46,13 @@ def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str, ...@@ -46,17 +46,13 @@ def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str,
sql = (f"{o_sql} WHERE channel='{chan}' and C.param=P.param" sql = (f"{o_sql} WHERE channel='{chan}' and C.param=P.param"
f" and dataType='{data_type}'") f" and dataType='{data_type}'")
chan_db_info = execute_db_dict(sql) chan_db_info = execute_db_dict(sql)
seismic_label = None
if len(chan_db_info) == 0: if len(chan_db_info) == 0:
chan_db_info = execute_db_dict( chan_db_info = execute_db_dict(
f"{o_sql} WHERE channel='DEFAULT' and C.param=P.param") f"{o_sql} WHERE channel='DEFAULT' and C.param=P.param")
else: else:
if chan_db_info[0]['channel'] == 'SEISMIC': if chan_db_info[0]['channel'] == 'SEISMIC':
try: seismic_label = get_seismic_chan_label(org_chan_id)
chan_db_info[0]['label'] = dbConf['seisLabel'][org_chan_id[-1]]
except KeyError:
chan_db_info[0]['label'] = str(chan_info['samplerate'])
chan_db_info[0]['channel'] = org_chan_id chan_db_info[0]['channel'] = org_chan_id
chan_db_info[0]['label'] = ( chan_db_info[0]['label'] = (
...@@ -68,6 +64,8 @@ def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str, ...@@ -68,6 +64,8 @@ def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str,
else chan_db_info[0]['fixPoint']) else chan_db_info[0]['fixPoint'])
if chan_db_info[0]['label'].strip() == '': if chan_db_info[0]['label'].strip() == '':
chan_db_info[0]['label'] = chan_db_info[0]['channel'] chan_db_info[0]['label'] = chan_db_info[0]['channel']
elif seismic_label is not None:
chan_db_info[0]['label'] = seismic_label
else: else:
chan_db_info[0]['label'] = '-'.join([chan_db_info[0]['channel'], chan_db_info[0]['label'] = '-'.join([chan_db_info[0]['channel'],
chan_db_info[0]['label']]) chan_db_info[0]['label']])
...@@ -76,30 +74,13 @@ def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str, ...@@ -76,30 +74,13 @@ def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str,
return chan_db_info[0] return chan_db_info[0]
def get_wf_plot_info(org_chan_id: str, *args, **kwargs) -> Dict: def get_seismic_chan_label(chan_id):
""" """
:param org_chan_id: channel name read from data source Get label for chan_id in which data stream can use chan_id for label while
:param chan_info: to be compliant with get_chan_plot_info() other seismic need to add coordinate to chan_id for label
:param data_type: to be compliant with get_chan_plot_info() :param chan_id: name of channel
:param color_mode: to be compliant with get_chan_plot_info() :return label: label to put in front of the plot of the channel
:return info of channel read from DB which is used for plotting
""" """
# Waveform plot's color is fixed to NULL in the database, so we do not need
# to get the valueColors columns from the database.
chan_info = execute_db_dict(
"SELECT param, plotType, height "
"FROM Parameters WHERE param='Seismic data'")
# The plotting API still requires that the key 'valueColors' is mapped to
# something, so we are setting it to None.
chan_info[0]['valueColors'] = None
chan_info[0]['label'] = get_chan_label(org_chan_id)
chan_info[0]['unit'] = ''
chan_info[0]['channel'] = 'SEISMIC'
chan_info[0]['convertFactor'] = 1
return chan_info[0]
def get_chan_label(chan_id):
if chan_id.startswith("DS"): if chan_id.startswith("DS"):
label = chan_id label = chan_id
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment