diff --git a/sohstationviewer/controller/util.py b/sohstationviewer/controller/util.py index b68469620155ed640ebedbde79f23d227bdcfe06..a46f6d39124d23f07fc885d24fae77dd7c4e04be 100644 --- a/sohstationviewer/controller/util.py +++ b/sohstationviewer/controller/util.py @@ -349,7 +349,7 @@ def check_chan(chan_id: str, req_soh_chans: List[str], req_wf_chans: List[str], """ if chan_id.startswith('VM'): if (not include_mp123zne and - chan_id[-1] in ['1', '2', '3', 'Z', 'N', 'E']): + chan_id[-1] in ['1', '2', '3', 'Z', 'N', 'E', 'A', 'B', 'C']): return False if (not include_mp456uvw and chan_id[-1] in ['4', '5', '6', 'U', 'V', 'W']): diff --git a/sohstationviewer/view/help_view.py b/sohstationviewer/view/help_view.py index a2c63c1d4f15d85620714e4987ddb266dfceefe0..d90adb3f5f637533bdd6553cd258ef4c64ffbf4e 100644 --- a/sohstationviewer/view/help_view.py +++ b/sohstationviewer/view/help_view.py @@ -71,8 +71,8 @@ class HelpBrowser(QtWidgets.QWidget): screen size. """ - SCREEN_SIZE_SCALAR_X = 0.50 - SCREEN_SIZE_SCALAR_Y = 0.50 + SCREEN_SIZE_SCALAR_X = 0.75 + SCREEN_SIZE_SCALAR_Y = 0.75 TREE_VIEW_SCALAR = 0.25 def __init__( diff --git a/sohstationviewer/view/ui/main_ui.py b/sohstationviewer/view/ui/main_ui.py index bf796eae77be982c8bf8213c6befabc042384ad7..1784637c5551f0f7331414e591d1c7abd1143e9f 100755 --- a/sohstationviewer/view/ui/main_ui.py +++ b/sohstationviewer/view/ui/main_ui.py @@ -375,7 +375,7 @@ class UIMainWindow(object): left_widget = QWidget(self.central_widget) h_layout.addWidget(left_widget) - left_widget.setFixedWidth(240) + left_widget.setFixedWidth(255) # left_widget.setMinimumHeight(650) left_layout = QVBoxLayout() left_layout.setContentsMargins(0, 0, 0, 0) @@ -526,9 +526,10 @@ class UIMainWindow(object): mass_pos_layout = QHBoxLayout() left_layout.addLayout(mass_pos_layout) - mass_pos_layout.addWidget(QLabel('Mass Pos ')) + mass_pos_layout.addWidget(QLabel('MassPos ')) self.mass_pos_123zne_check_box = QCheckBox( - '123/ZNE', self.central_widget) + '123/ZNE/ABC', self.central_widget) + self.mass_pos_123zne_check_box.setMinimumWidth(120) mass_pos_layout.addWidget(self.mass_pos_123zne_check_box) self.mass_pos_456uvw_check_box = QCheckBox( '456/UVW', self.central_widget) diff --git a/sohstationviewer/view/util/functions.py b/sohstationviewer/view/util/functions.py index 3eae9a6e5fe8222e223c247b09a1999efbbd4270..4e56d329a7792e5389a3d4af0712f0d0d83879eb 100644 --- a/sohstationviewer/view/util/functions.py +++ b/sohstationviewer/view/util/functions.py @@ -223,9 +223,54 @@ def check_masspos(mp_data: Dict[str, Dict], req_mp = [] if include_mp123: - req_mp += ['1', '2', '3'] + """ + If the MassPos 123/ZNE/ABC checkbox is checked, the included_mp list + will be compared against 3 predefined lists: 123, ZNE, ABC. + If any channel in included_mp matches a channel from one of these + lists, the entire list (123, ZNE, or ABC) will be used for checking + missing channels. + If no channel in included_mp matches any of the channels from these + lists, only the 123 list will be included in the warning message + regarding missing channels. + """ + req_mp123 = [] # represent 123/zne/abc + mp123 = ['1', '2', '3'] + mpzne = ['Z', 'N', 'E'] + mpabc = ['A', 'B', 'C'] + if any(chan in mp123 for chan in included_mp): + req_mp123 += mp123 + if any(chan in mpzne for chan in included_mp): + req_mp123 += mpzne + if any(chan in mpabc for chan in included_mp): + req_mp123 += mpabc + + if req_mp123 == []: + # if none of 123/zne/abc, just report 123 + req_mp123 += mp123 + req_mp += req_mp123 + if include_mp456: - req_mp += ['4', '5', '6'] + """ + If the MassPos 456/UVW checkbox is checked, the included_mp list + will be compared against 2 predefined lists: 456, UVW. + If any channel in included_mp matches a channel from one of these + lists, the entire list (123, ZNE, or ABC) will be used for checking + missing channels. + If no channel in included_mp matches any of the channels from these + lists, only the 456 list will be included in the warning message + regarding missing channels. + """ + req_mp456 = [] # represent 456/uvw + mp456 = ['4', '5', '6'] + mpuvw = ['U', 'V', 'W'] + if any(chan in mp456 for chan in included_mp): + req_mp456 += mp456 + if any(chan in mpuvw for chan in included_mp): + req_mp456 += mpuvw + if req_mp456 == []: + # if none of 456/uvw, just report 456 + req_mp456 += mp456 + req_mp += req_mp456 not_included_mp = [mp for mp in req_mp if mp not in included_mp] diff --git a/tests/view/util/test_functions.py b/tests/view/util/test_functions.py index 1e2855cdbc4b26bf8b284d17789066772cc7d619..12e6b95c331c0e2a08e3ec19f060cfb1cad6200c 100644 --- a/tests/view/util/test_functions.py +++ b/tests/view/util/test_functions.py @@ -383,38 +383,96 @@ class TestCheckChanWildcardsFormat(BaseTestCase): class TestCheckMassPos(BaseTestCase): @classmethod def setUpClass(cls) -> None: - cls.mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1}, - 'MP3': {'chan_id': 'MP3', 'samplerate': 1}, - 'MP4': {'chan_id': 'MP4', 'samplerate': 1}} cls.sel_key = '1378' - def test_include_mp123(self): - with self.assertRaises(Exception) as context: - check_masspos(self.mp_data, self.sel_key, - include_mp123=True, include_mp456=False) - self.assertEqual( - str(context.exception), - f"Data set {self.sel_key} doesn't include mass position 2") + def test_include_mp123_not_include_mp456(self): + with self.subTest("Consist of MP1,MP3"): + mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1}, + 'MP3': {'chan_id': 'MP3', 'samplerate': 1}, + 'MP4': {'chan_id': 'MP4', 'samplerate': 1}} + with self.assertRaises(Exception) as context: + check_masspos(mp_data, self.sel_key, + include_mp123=True, include_mp456=False) + self.assertEqual( + str(context.exception), + f"Data set {self.sel_key} doesn't include mass position 2") + with self.subTest("Consist of MP1,MP3,MPE"): + mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1}, + 'MP3': {'chan_id': 'MP3', 'samplerate': 1}, + 'MPE': {'chan_id': 'MPE', 'samplerate': 1}, + 'MP4': {'chan_id': 'MP4', 'samplerate': 1}} + with self.assertRaises(Exception) as context: + check_masspos(mp_data, self.sel_key, + include_mp123=True, include_mp456=False) + self.assertEqual( + str(context.exception), + f"Data set {self.sel_key} doesn't include mass position " + f"2,Z,N") + with self.subTest("Consist of MPB"): + mp_data = {'MPB': {'chan_id': 'MPB', 'samplerate': 1}, + 'MP4': {'chan_id': 'MP4', 'samplerate': 1}} + with self.assertRaises(Exception) as context: + check_masspos(mp_data, self.sel_key, + include_mp123=True, include_mp456=False) + self.assertEqual( + str(context.exception), + f"Data set {self.sel_key} doesn't include mass position " + f"A,C") + with self.subTest("No MP 123/ZNE/ABC"): + mp_data = {'MP4': {'chan_id': 'MP4', 'samplerate': 1}} + with self.assertRaises(Exception) as context: + check_masspos(mp_data, self.sel_key, + include_mp123=True, include_mp456=False) + self.assertEqual( + str(context.exception), + f"Data set {self.sel_key} doesn't include mass position " + f"1,2,3") - def test_include_mp456(self): - with self.assertRaises(Exception) as context: - check_masspos(self.mp_data, self.sel_key, - include_mp123=False, include_mp456=True) - self.assertEqual( - str(context.exception), - f"Data set {self.sel_key} doesn't include mass position 5,6") + def test_include_mp456_not_include456(self): + with self.subTest("Consist of MP4"): + mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1}, + 'MP4': {'chan_id': 'MP4', 'samplerate': 1}} + with self.assertRaises(Exception) as context: + check_masspos(mp_data, self.sel_key, + include_mp123=False, include_mp456=True) + self.assertEqual( + str(context.exception), + f"Data set {self.sel_key} doesn't include mass position 5,6") + with self.subTest("Consist of MPW"): + mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1}, + 'MPW': {'chan_id': 'MPW', 'samplerate': 1}} + with self.assertRaises(Exception) as context: + check_masspos(mp_data, self.sel_key, + include_mp123=False, include_mp456=True) + self.assertEqual( + str(context.exception), + f"Data set {self.sel_key} doesn't include mass position U,V") + with self.subTest("No MP 456/UVW"): + mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1}} + with self.assertRaises(Exception) as context: + check_masspos(mp_data, self.sel_key, + include_mp123=False, include_mp456=True) + self.assertEqual( + str(context.exception), + f"Data set {self.sel_key} doesn't include mass position " + f"4,5,6") def test_include_mp123456(self): + mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1}, + 'MP3': {'chan_id': 'MP3', 'samplerate': 1}, + 'MP4': {'chan_id': 'MP4', 'samplerate': 1}} with self.assertRaises(Exception) as context: - check_masspos(self.mp_data, self.sel_key, + check_masspos(mp_data, self.sel_key, include_mp123=True, include_mp456=True) self.assertEqual( str(context.exception), f"Data set {self.sel_key} doesn't include mass position 2,5,6") def test_not_include_mp(self): + mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1}, + 'MP4': {'chan_id': 'MP4', 'samplerate': 1}} try: - check_masspos(self.mp_data, self.sel_key, + check_masspos(mp_data, self.sel_key, include_mp123=False, include_mp456=False) except Exception: self.fail("check_masspos() raise Exception unexpectedly")