diff --git a/sohstationviewer/database/extract_data.py b/sohstationviewer/database/extract_data.py index c6cf6581b84373601f8515046c48be5098b86e67..dcb518d2ab21b8353fab8c1a9274c38d955e9d3d 100755 --- a/sohstationviewer/database/extract_data.py +++ b/sohstationviewer/database/extract_data.py @@ -5,7 +5,7 @@ from sohstationviewer.database.process_db import execute_db_dict, execute_db 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: """ 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, chan = 'VM?' if org_chan_id.startswith('MassPos'): chan = 'MassPos?' + if org_chan_id.startswith('DS'): + chan = 'SEISMIC' if org_chan_id.startswith('Event DS'): chan = 'Event DS?' - if org_chan_id.startswith('DS'): - chan = 'DS?' if org_chan_id.startswith('Disk Usage'): chan = 'Disk Usage?' if dbConf['seisRE'].match(chan): @@ -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" f" and dataType='{data_type}'") chan_db_info = execute_db_dict(sql) - + seismic_label = None if len(chan_db_info) == 0: chan_db_info = execute_db_dict( f"{o_sql} WHERE channel='DEFAULT' and C.param=P.param") else: if chan_db_info[0]['channel'] == 'SEISMIC': - try: - chan_db_info[0]['label'] = dbConf['seisLabel'][org_chan_id[-1]] - except KeyError: - chan_db_info[0]['label'] = str(chan_info['samplerate']) - + seismic_label = get_seismic_chan_label(org_chan_id) chan_db_info[0]['channel'] = org_chan_id chan_db_info[0]['label'] = ( @@ -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']) if chan_db_info[0]['label'].strip() == '': chan_db_info[0]['label'] = chan_db_info[0]['channel'] + elif seismic_label is not None: + chan_db_info[0]['label'] = seismic_label else: chan_db_info[0]['label'] = '-'.join([chan_db_info[0]['channel'], chan_db_info[0]['label']]) @@ -76,30 +74,13 @@ def get_chan_plot_info(org_chan_id: str, chan_info: Dict, data_type: str, 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 - :param chan_info: to be compliant with get_chan_plot_info() - :param data_type: to be compliant with get_chan_plot_info() - :param color_mode: to be compliant with get_chan_plot_info() - :return info of channel read from DB which is used for plotting + Get label for chan_id in which data stream can use chan_id for label while + other seismic need to add coordinate to chan_id for label + :param chan_id: name of channel + :return label: label to put in front of the plot of the channel """ - # 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"): label = chan_id else: