diff --git a/sohstationviewer/database/backup.db b/sohstationviewer/database/backup.db index 84c93c54148da8209629d211eb90c79d6bdb0f27..fb6b3af8e31e10dc4165d61ed2bc0e27077e6565 100755 Binary files a/sohstationviewer/database/backup.db and b/sohstationviewer/database/backup.db differ diff --git a/sohstationviewer/database/extract_data.py b/sohstationviewer/database/extract_data.py index 3cc98c88bc7d4a55dd3ea2a58356c86d68f58d4e..1937cb6e683d8ab09e352097172b0f953fc61e31 100755 --- a/sohstationviewer/database/extract_data.py +++ b/sohstationviewer/database/extract_data.py @@ -23,7 +23,8 @@ def get_chan_plot_info(org_chan_id: str, data_type: str, + Key 'label' keeps label to be displayed in the plotting """ chan = org_chan_id - chan = convert_actual_channel_to_db_channel_w_question_mark(chan) + chan = convert_actual_channel_to_db_channel_w_question_mark(chan, + data_type) if len(org_chan_id) == 3 and org_chan_id.startswith('DS'): chan = 'SEISMIC' @@ -88,7 +89,8 @@ def get_convert_factor(chan_id: str, data_type: str) -> float: :param data_type: type of data in data set :return: converting factor """ - chan_id = convert_actual_channel_to_db_channel_w_question_mark(chan_id) + chan_id = convert_actual_channel_to_db_channel_w_question_mark(chan_id, + data_type) sql = f"SELECT convertFactor FROM Channels WHERE channel='{chan_id}' " \ f"AND dataType='{data_type}'" ret = execute_db(sql) @@ -98,12 +100,15 @@ def get_convert_factor(chan_id: str, data_type: str) -> float: return None -def convert_actual_channel_to_db_channel_w_question_mark(chan_id: str) -> str: +def convert_actual_channel_to_db_channel_w_question_mark( + chan_id: str, data_type: str) -> str: """ The digit in channel end with a digit is represented with the question mark '?' in DB. This function change the real channel name to DB channel name with '?'. :param chan_id: real channel name + :param data_type: the data type of the channel, used for handling masspos + data of Q330 data :return chan_id: channel name with '?' at the end if available """ sql = "SELECT * FROM Channels WHERE channel like '%?'" @@ -113,6 +118,13 @@ def convert_actual_channel_to_db_channel_w_question_mark(chan_id: str) -> str: if chan_id[-1].isdigit(): # to prevent the case prefix similar to prefix of channel w/o ? chan_id = chan_id[:-1] + '?' + # Mass-position channels for Q330 data can sometimes end with a letter. + elif data_type == 'Q330': + mass_pos_letter_suffixes = ['Z', 'N', 'E', 'U', 'V', 'W'] + if (chan_id.startswith('VM') and + chan_id[-1] in mass_pos_letter_suffixes): + chan_id = 'VM?' + return chan_id diff --git a/sohstationviewer/database/soh.db b/sohstationviewer/database/soh.db index 84c93c54148da8209629d211eb90c79d6bdb0f27..fb6b3af8e31e10dc4165d61ed2bc0e27077e6565 100755 Binary files a/sohstationviewer/database/soh.db and b/sohstationviewer/database/soh.db differ diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_helper.py b/sohstationviewer/view/plotting/plotting_widget/plotting_helper.py index c04d880e91c490864f3595f73448538f33000834..f6310b48b0ae3c4aeb88f9d20ab677d702ed54d2 100644 --- a/sohstationviewer/view/plotting/plotting_widget/plotting_helper.py +++ b/sohstationviewer/view/plotting/plotting_widget/plotting_helper.py @@ -12,7 +12,7 @@ from sohstationviewer.database.extract_data import get_convert_factor mass_pos_volt_ranges = {"regular": [0.5, 2.0, 4.0, 7.0], "trillium": [0.5, 1.8, 2.4, 3.5]} mass_pos_color_pallets = {"B": ["C", "G", "Y", "R", "M"], - "W": ["B", "B", "B", "B", "B"]} + "W": ["C", "G", "Y", "R", "M"]} def get_masspos_value_colors( diff --git a/tests/database/test_extract_data.py b/tests/database/test_extract_data.py index 3a480f8f4dc731f9167c4da67237fbcd13905aa0..17664da7562d69966d700bbd8f2ef1a099e3edd6 100644 --- a/tests/database/test_extract_data.py +++ b/tests/database/test_extract_data.py @@ -241,13 +241,22 @@ class TestGetColorRanges(BaseTestCase): class TestConvertActualChannelToDBChannelWQuestionMark(BaseTestCase): def test_question_channel(self): - ret = convert_actual_channel_to_db_channel_w_question_mark('VM1') + ret = convert_actual_channel_to_db_channel_w_question_mark('VM1', '') self.assertEqual(ret, 'VM?') def test_non_question_channel(self): - ret = convert_actual_channel_to_db_channel_w_question_mark('VCO') + ret = convert_actual_channel_to_db_channel_w_question_mark('VCO', '') self.assertEqual(ret, 'VCO') + def test_q330_letter_masspos_channel(self): + for suffix in ['Z', 'N', 'E', 'U', 'V', 'W']: + channel = 'VM' + suffix + with self.subTest(f'Test {channel}'): + ret = convert_actual_channel_to_db_channel_w_question_mark( + channel, 'Q330' + ) + self.assertEqual(ret, 'VM?') + class TestGetConvertFactor(BaseTestCase): def test_question_channel(self): diff --git a/tests/view/plotting/plotting_widget/test_plotting_helper.py b/tests/view/plotting/plotting_widget/test_plotting_helper.py index 3e6bbfc7041ce6952aaa2fb099d26841207ecf13..762016eb87988fbdecfc382e5e8e02e6343a2ddc 100644 --- a/tests/view/plotting/plotting_widget/test_plotting_helper.py +++ b/tests/view/plotting/plotting_widget/test_plotting_helper.py @@ -23,9 +23,9 @@ class TestGetMassposValue(BaseTestCase): """ expected_input_output_pairs = { ('regular', 'B'): '0.5:C|2.0:G|4.0:Y|7.0:R|7.0:+M', - ('regular', 'W'): '0.5:B|2.0:B|4.0:B|7.0:B|7.0:+B', + ('regular', 'W'): '0.5:C|2.0:G|4.0:Y|7.0:R|7.0:+M', ('trillium', 'B'): '0.5:C|1.8:G|2.4:Y|3.5:R|3.5:+M', - ('trillium', 'W'): '0.5:B|1.8:B|2.4:B|3.5:B|3.5:+B', + ('trillium', 'W'): '0.5:C|1.8:G|2.4:Y|3.5:R|3.5:+M', } test_names = ( 'test_regular_B', @@ -52,11 +52,11 @@ class TestGetMassposValue(BaseTestCase): ('regular', 'B'): [(0.5, 'C'), (2.0, 'G'), (4.0, 'Y'), (7.0, 'R'), (7.0, 'M')], ('regular', 'W'): - [(0.5, 'B'), (2.0, 'B'), (4.0, 'B'), (7.0, 'B'), (7.0, 'B')], + [(0.5, 'C'), (2.0, 'G'), (4.0, 'Y'), (7.0, 'R'), (7.0, 'M')], ('trillium', 'B'): [(0.5, 'C'), (1.8, 'G'), (2.4, 'Y'), (3.5, 'R'), (3.5, 'M')], ('trillium', 'W'): - [(0.5, 'B'), (1.8, 'B'), (2.4, 'B'), (3.5, 'B'), (3.5, 'B')], + [(0.5, 'C'), (1.8, 'G'), (2.4, 'Y'), (3.5, 'R'), (3.5, 'M')], } test_names = ( 'test_regular_B',