diff --git a/geomagio/edge/LegacySNCL.py b/geomagio/edge/LegacySNCL.py index 0f4479546a18d5a18947185b99052bb98d9777f3..1099bfd43292463f5913b7e457a4b1e3eabb4899 100644 --- a/geomagio/edge/LegacySNCL.py +++ b/geomagio/edge/LegacySNCL.py @@ -146,17 +146,17 @@ def _get_channel_end(element: str, data_type: str) -> str: channel_middle = "K" elif element in ["F", "G"]: channel_middle = "S" - channel_end = element.split("_")[0] + channel_end = element.split("_") if data_type == "variation" or data_type[0] == "R": - # this may not actually be necessary since UVW were - # never used as legacy channels; it is included here - # solely for consistency with SNCL.py, but should be safe - if channel_end == "U": - channel_end = "H" - elif channel_end == "V": - channel_end = "Y" - elif channel_end == "W": - channel_end = "Z" + if len(channel_end) == 1: + channel_end = channel_end[0] + if channel_end == "U": + channel_end = "H" + elif channel_end == "V": + channel_end = "E" + elif channel_end == "W": + channel_end = "Z" + channel_end = channel_end[0][0] # 2nd [0] ensures a single character return channel_middle + channel_end diff --git a/geomagio/edge/SNCL.py b/geomagio/edge/SNCL.py index 421190d86340ad78b2d79b5169feb6eea2f4ae89..6975ef7f2bb4138fed7498ff0a8a7333a10dc0dd 100644 --- a/geomagio/edge/SNCL.py +++ b/geomagio/edge/SNCL.py @@ -177,14 +177,17 @@ def _get_channel_end(element: str, data_type: str) -> str: channel_middle = "Y" elif "_Temp" in element: channel_middle = "K" - channel_end = element.split("_")[0] + channel_end = element.split("_") if data_type == "variation" or data_type[0] == "R": - if channel_end == "H": - channel_end = "U" - elif channel_end == "E": - channel_end = "V" - elif channel_end == "Z": - channel_end = "W" + if len(channel_end) == 1: + channel_end = channel_end[0] + if channel_end == "H": + channel_end = "U" + elif channel_end == "E": + channel_end = "V" + elif channel_end == "Z": + channel_end = "W" + channel_end = channel_end[0][0] # 2nd [0] ensures a single character return channel_middle + channel_end diff --git a/test/edge_test/LegacySNCL_test.py b/test/edge_test/LegacySNCL_test.py index f5b8e517b84c43b4ebb1362eb9b2e4305d646d7a..bc67a0636b2d95719e53ce46ce4c272e3251e240 100644 --- a/test/edge_test/LegacySNCL_test.py +++ b/test/edge_test/LegacySNCL_test.py @@ -116,6 +116,7 @@ def test_get_channel(): assert get_channel(element="D", interval="second", data_type="variation") == "SVD" assert get_channel(element="F", interval="minute", data_type="variation") == "MSF" assert get_channel(element="H", interval="hour", data_type="variation") == "HVH" + assert get_channel(element="U", interval="hour", data_type="variation") == "HVH" assert get_channel(element="E-E", interval="day", data_type="variation") == "DQE" assert get_channel(element="E-N", interval="minute", data_type="variation") == "MQN" assert get_channel(element="SQ", interval="minute", data_type="variation") == "MSQ" diff --git a/test/edge_test/SNCL_test.py b/test/edge_test/SNCL_test.py index 33da2b192a3d3d51d751aea774ef2077ddda5c39..c1dde9838fd1bf947b13fe8db1a344fd87782455 100644 --- a/test/edge_test/SNCL_test.py +++ b/test/edge_test/SNCL_test.py @@ -173,6 +173,9 @@ def test_get_channel(): assert ( get_channel(element="U_Dist", interval="minute", data_type="variation") == "UFU" ) + assert ( + get_channel(element="H_Dist", interval="minute", data_type="variation") == "UFH" + ) assert get_channel(element="U", interval="minute", data_type="RD") == "UFU" assert ( get_channel(element="U_SQ", interval="minute", data_type="variation") == "UFU"