diff --git a/geomagio/edge/EdgeFactory.py b/geomagio/edge/EdgeFactory.py index a4294c79b553aa34c677afb6e48192efcb0a146e..af226a63a2cd07747d1825d11d805965657b12b2 100644 --- a/geomagio/edge/EdgeFactory.py +++ b/geomagio/edge/EdgeFactory.py @@ -22,7 +22,7 @@ from ..TimeseriesFactory import TimeseriesFactory from ..TimeseriesFactoryException import TimeseriesFactoryException from ..ObservatoryMetadata import ObservatoryMetadata from .RawInputClient import RawInputClient -from .SNCLFactory import SNCLFactory +from .LegacySNCL import LegacySNCL class EdgeFactory(TimeseriesFactory): @@ -301,8 +301,11 @@ class EdgeFactory(TimeseriesFactory): obspy.core.trace timeseries trace of the requested channel data """ - sncl = SNCLFactory(data_format="legacy").get_sncl( - station=observatory, data_type=type, element=channel, interval=interval + sncl = LegacySNCL().get_sncl( + station=observatory, + data_type=type, + interval=interval, + element=channel, ) try: data = self.client.get_waveforms( @@ -399,8 +402,8 @@ class EdgeFactory(TimeseriesFactory): ----- RawInputClient seems to only work when sockets are """ - sncl = SNCLFactory(data_format="legacy").get_sncl( - station=observatory, data_type=type, element=channel, interval=interval + sncl = LegacySNCL().get_sncl( + station=observatory, data_type=type, interval=interval, element=channel ) now = obspy.core.UTCDateTime(datetime.utcnow()) diff --git a/geomagio/edge/LegacySNCL.py b/geomagio/edge/LegacySNCL.py new file mode 100644 index 0000000000000000000000000000000000000000..be1c3300d5ce001b0e5c9f2ce75fbe0da421dcb6 --- /dev/null +++ b/geomagio/edge/LegacySNCL.py @@ -0,0 +1,81 @@ +from __future__ import annotations +from typing import Optional + +from .SNCL import SNCL + +ELEMENT_CONVERSIONS = { + # e-field + "E-E": "QE", + "E-N": "QN", + # derived indicies + "SQ": "SQ", + "SV": "SV", + "DIST": "DT", + "DST": "GD", +} +CHANNEL_CONVERSIONS = { + ELEMENT_CONVERSIONS[key]: key for key in ELEMENT_CONVERSIONS.keys() +} + + +class LegacySNCL(SNCL): + def get_sncl( + self, + station: str, + data_type: str, + interval: str, + element: str, + ) -> LegacySNCL: + from .SNCLFactory import SNCLFactory + + factory = SNCLFactory(data_format="legacy") + return LegacySNCL( + station=station, + network=self.network, + channel=factory.get_channel(element=element, interval=interval), + location=factory.get_location(element=element, data_type=data_type), + ) + + @property + def element(self) -> str: + predefined_element = self.__check_predefined_element() + element = self.__get_element() + return predefined_element or element + + @property + def interval(self) -> str: + channel_start = self.channel[0] + if channel_start == "S": + return "second" + elif channel_start == "M": + return "minute" + elif channel_start == "H": + return "hour" + elif channel_start == "D": + return "day" + raise ValueError(f"Unexcepted interval code: {channel_start}") + + def __get_element(self): + """Translates channel/location to element""" + element_start = self.channel[2] + channel = self.channel + channel_middle = channel[1] + location_end = self.location[1] + if channel_middle in ["Q", "E"]: + element_end = "_Volt" + elif channel_middle == "Y": + element_end = "_Bin" + elif channel_middle == "K": + element_end = "_Temp" + elif location_end == "1": + element_end = "_Sat" + else: + element_end = "" + return element_start + element_end + + def __check_predefined_element(self) -> Optional[str]: + channel = self.channel + channel_end = channel[1:] + if channel_end in CHANNEL_CONVERSIONS: + return CHANNEL_CONVERSIONS[channel_end] + return None diff --git a/geomagio/edge/MiniSeedFactory.py b/geomagio/edge/MiniSeedFactory.py index 133edeeaeca8237add1547613c660ba4325058b0..f3530cdd6bd2b7f653d2530b8713a85baede0cb6 100644 --- a/geomagio/edge/MiniSeedFactory.py +++ b/geomagio/edge/MiniSeedFactory.py @@ -23,7 +23,7 @@ from ..TimeseriesFactory import TimeseriesFactory from ..TimeseriesFactoryException import TimeseriesFactoryException from ..ObservatoryMetadata import ObservatoryMetadata from .MiniSeedInputClient import MiniSeedInputClient -from .SNCLFactory import SNCLFactory +from .SNCL import SNCL class MiniSeedFactory(TimeseriesFactory): @@ -319,8 +319,8 @@ class MiniSeedFactory(TimeseriesFactory): obspy.core.trace timeseries trace of the requested channel data """ - sncl = SNCLFactory().get_sncl( - station=observatory, data_type=type, element=channel, interval=interval + sncl = SNCL().get_sncl( + station=observatory, data_type=type, interval=interval, element=channel ) data = self.client.get_waveforms( sncl.network, sncl.station, sncl.location, sncl.channel, starttime, endtime @@ -460,8 +460,11 @@ class MiniSeedFactory(TimeseriesFactory): to_write = to_write.split() to_write = TimeseriesUtility.unmask_stream(to_write) # relabel channels from internal to edge conventions - sncl = SNCLFactory().get_sncl( - station=observatory, data_type=type, element=channel, interval=interval + sncl = SNCL().get_sncl( + station=observatory, + data_type=type, + interval=interval, + element=channel, ) for trace in to_write: trace.stats.station = sncl.station diff --git a/geomagio/edge/SNCL.py b/geomagio/edge/SNCL.py index df75fa3a45f35abc8f4f433b2142d8e23e86fb59..395bfefe53f0b40d95a95c2aabf2c40b719f567a 100644 --- a/geomagio/edge/SNCL.py +++ b/geomagio/edge/SNCL.py @@ -1,22 +1,8 @@ -from typing import Dict, Optional, Set +from __future__ import annotations +from typing import Dict, Optional from pydantic import BaseModel -INTERVAL_CONVERSIONS = { - "legacy": { - "second": "S", - "minute": "M", - "hour": "H", - "day": "D", - }, - "miniseed": { - "tenhertz": "B", - "second": "L", - "minute": "U", - "hour": "R", - "day": "P", - }, -} ELEMENT_CONVERSIONS = { # e-field "E-E": "QE", @@ -24,10 +10,6 @@ ELEMENT_CONVERSIONS = { # derived indicies "Dst3": "X3", "Dst4": "X4", - "SQ": "SQ", - "SV": "SV", - "DIST": "DT", - "DST": "GD", } CHANNEL_CONVERSIONS = { @@ -36,11 +18,27 @@ CHANNEL_CONVERSIONS = { class SNCL(BaseModel): - station: str + station: str = None network: str = "NT" - channel: str - location: str - data_format: str = "miniseed" + channel: str = None + location: str = None + + def get_sncl( + self, + station: str, + data_type: str, + interval: str, + element: str, + ) -> SNCL: + from .SNCLFactory import SNCLFactory + + factory = SNCLFactory(data_format="miniseed") + return SNCL( + station=station, + network=self.network, + channel=factory.get_channel(element=element, interval=interval), + location=factory.get_location(element=element, data_type=data_type), + ) def parse_sncl(self) -> Dict: return { @@ -51,16 +49,6 @@ class SNCL(BaseModel): "interval": self.interval, } - def dict(self, exclude: Set = {"data_format"}) -> dict: - return super().dict( - exclude=exclude, - ) - - def json(self, exclude: Set = {"data_format"}) -> str: - return super().json( - exclude=exclude, - ) - @property def data_type(self) -> str: """Translates beginning of location code to data type""" @@ -84,15 +72,18 @@ class SNCL(BaseModel): @property def interval(self) -> str: """Translates beginning of channel to interval""" - interval_conversions = INTERVAL_CONVERSIONS[self.data_format] - interval_code_conversions = { - interval_conversions[key]: key for key in interval_conversions.keys() - } channel_start = self.channel[0] - try: - return interval_code_conversions[channel_start] - except: - raise ValueError(f"Unexcepted interval code: {channel_start}") + if channel_start == "B": + return "tenhertz" + elif channel_start == "L": + return "second" + elif channel_start == "U": + return "minute" + elif channel_start == "R": + return "hour" + elif channel_start == "P": + return "day" + raise ValueError(f"Unexcepted interval code: {channel_start}") def __get_element(self): """Translates channel/location to element""" @@ -100,7 +91,7 @@ class SNCL(BaseModel): channel = self.channel channel_middle = channel[1] location_end = self.location[1] - if channel_middle in ["Q", "E"]: + if channel_middle == "E": element_end = "_Volt" elif channel_middle == "Y": element_end = "_Bin" diff --git a/geomagio/edge/SNCLFactory.py b/geomagio/edge/SNCLFactory.py index 4b76fa1572207084cdeecf105b7a52b7efb5777a..c4be5e89970797ebde38fe86d73e0feeb2826bc7 100644 --- a/geomagio/edge/SNCLFactory.py +++ b/geomagio/edge/SNCLFactory.py @@ -1,25 +1,46 @@ -from typing import Optional +from typing import Literal, Optional, Union -from .SNCL import SNCL, INTERVAL_CONVERSIONS, ELEMENT_CONVERSIONS +from .SNCL import SNCL, ELEMENT_CONVERSIONS as MINISEED_CONVERSIONS +from .LegacySNCL import LegacySNCL, ELEMENT_CONVERSIONS as LEGACY_CONVERSIONS + +INTERVAL_CONVERSIONS = { + "miniseed": { + "tenhertz": "B", + "second": "L", + "minute": "U", + "hour": "R", + "day": "P", + }, + "legacy": { + "second": "S", + "minute": "M", + "hour": "H", + "day": "D", + }, +} class SNCLFactory(object): - def __init__(self, data_format: str = "miniseed"): + def __init__(self, data_format: Literal["miniseed", "legacy"] = "miniseed"): self.data_format = data_format def get_sncl( self, station: str, - data_type: str, - element: str, - interval: str, - network: str = "NT", - ) -> SNCL: - return SNCL( - station=station, - network=network, - channel=self.get_channel(element=element, interval=interval), - location=self.get_location(element=element, data_type=data_type), + network: str, + channel: str, + location: str, + ) -> Union[SNCL, LegacySNCL]: + sncl_params = { + "station": station, + "network": network, + "channel": channel, + "location": location, + } + return ( + SNCL(**sncl_params) + if self.data_format == "miniseed" + else LegacySNCL(**sncl_params) ) def get_channel(self, element: str, interval: str) -> str: @@ -36,16 +57,23 @@ class SNCLFactory(object): return location_start + location_end def __get_channel_start(self, interval: str) -> str: + interval_conversions = INTERVAL_CONVERSIONS[self.data_format] try: - return INTERVAL_CONVERSIONS[self.data_format][interval] + return interval_conversions[interval] except: raise ValueError(f"Unexpected interval: {interval}") def __check_predefined_channel(self, element: str, interval: str) -> Optional[str]: - if element in ELEMENT_CONVERSIONS: + channel_conversions = ( + MINISEED_CONVERSIONS + if self.data_format == "miniseed" + else LEGACY_CONVERSIONS + ) + + if element in channel_conversions: return ( self.__get_channel_start(interval=interval) - + ELEMENT_CONVERSIONS[element] + + channel_conversions[element] ) elif len(element) == 3: return element @@ -85,10 +113,11 @@ class SNCLFactory(object): """Translates element suffix to end of location code""" if "_Sat" in element: return "1" - if "_Dist" in element: - return "D" - if "_SQ" in element: - return "Q" - if "_SV" in element: - return "V" + if self.data_format == "miniseed": + if "_Dist" in element: + return "D" + if "_SQ" in element: + return "Q" + if "_SV" in element: + return "V" return "0" diff --git a/geomagio/edge/__init__.py b/geomagio/edge/__init__.py index bf808a25a139d19e517045c80229950d7a8c34e1..77d5fee305c3d5cb1e53b544934ae5f9294d3b7f 100644 --- a/geomagio/edge/__init__.py +++ b/geomagio/edge/__init__.py @@ -9,6 +9,7 @@ from .MiniSeedInputClient import MiniSeedInputClient from .RawInputClient import RawInputClient from .SNCL import SNCL from .SNCLFactory import SNCLFactory +from .LegacySNCL import LegacySNCL __all__ = [ "EdgeFactory", @@ -20,4 +21,5 @@ __all__ = [ "LegacySNIDE", "SNCL", "SNCLFactory", + "LegacySNCL", ] diff --git a/test/edge_test/LegacySNCL_test.py b/test/edge_test/LegacySNCL_test.py new file mode 100644 index 0000000000000000000000000000000000000000..8d7233ffc39af802ea5a20486ba857778d0a0b9c --- /dev/null +++ b/test/edge_test/LegacySNCL_test.py @@ -0,0 +1,169 @@ +from geomagio.edge import LegacySNCL + + +def test_data_type(): + """edge_test.LegacySNCL_test.test_data_type()""" + assert ( + LegacySNCL(station="BOU", channel="LFU", location="R0").data_type == "variation" + ) + assert ( + LegacySNCL(station="BOU", channel="LFU", location="A0").data_type == "adjusted" + ) + assert ( + LegacySNCL(station="BOU", channel="LFU", location="Q0").data_type + == "quasi-definitive" + ) + assert ( + LegacySNCL(station="BOU", channel="LFU", location="D0").data_type + == "definitive" + ) + + +def test_element(): + """edge_test.LegacySNCL_test.test_element()""" + assert ( + LegacySNCL( + station="BOU", + channel="MVD", + location="R0", + ).element + == "D" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MVU", + location="R0", + ).element + == "U" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MSF", + location="R0", + ).element + == "F" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MVH", + location="R0", + ).element + == "H" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MQE", + location="R0", + ).element + == "E-E" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MQN", + location="R0", + ).element + == "E-N" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MEH", + location="R0", + ).element + == "H_Volt" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MYH", + location="R0", + ).element + == "H_Bin" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MVH", + location="R1", + ).element + == "H_Sat" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MDT", + location="R0", + ).element + == "DIST" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MGD", + location="R0", + ).element + == "DST" + ) + + +def test_get_sncl(): + """edge_test.LegacySNCL_test.test_get_sncl()""" + assert LegacySNCL().get_sncl( + station="BOU", data_type="variation", interval="second", element="H" + ) == LegacySNCL(station="BOU", network="NT", channel="SVH", location="R0") + + +def test_interval(): + """edge_test.LegacySNCL_test.test_interval()""" + assert ( + LegacySNCL( + station="BOU", + channel="SVH", + location="R0", + data_format="legacy", + ).interval + == "second" + ) + assert ( + LegacySNCL( + station="BOU", + channel="MVH", + location="R0", + data_format="legacy", + ).interval + == "minute" + ) + assert ( + LegacySNCL( + station="BOU", + channel="HVH", + location="R0", + data_format="legacy", + ).interval + == "hour" + ) + assert ( + LegacySNCL( + station="BOU", + channel="DVH", + location="R0", + data_format="legacy", + ).interval + == "day" + ) + + +def test_parse_sncl(): + """edge_test.LegacySNCL_test.test_parse_sncl()""" + assert LegacySNCL(station="BOU", channel="MVH", location="R0").parse_sncl() == { + "station": "BOU", + "network": "NT", + "data_type": "variation", + "element": "H", + "interval": "minute", + } diff --git a/test/edge_test/SNCLFactory_test.py b/test/edge_test/SNCLFactory_test.py index 44f2d0de01856690aafcd9a496b8f9ce3edf4c57..0920c804cb55648f675ca1083f64a38499966af1 100644 --- a/test/edge_test/SNCLFactory_test.py +++ b/test/edge_test/SNCLFactory_test.py @@ -1,70 +1,41 @@ -from geomagio.edge import SNCL, SNCLFactory - - -def test_get_sncl(): - assert ( - SNCLFactory(data_format="miniseed").get_sncl( - station="BOU", - data_type="variation", - element="UFU", - interval="minute", - ) - == SNCL(station="BOU", network="NT", channel="UFU", location="R0") - ) - assert ( - SNCLFactory(data_format="legacy").get_sncl( - station="BOU", - data_type="variation", - element="MVH", - interval="minute", - ) - == SNCL(station="BOU", network="NT", channel="MVH", location="R0") - ) +from geomagio.edge import SNCL, SNCLFactory, LegacySNCL def test_get_channel(): - # test miniseed format + """edge_test.SNCLFactory_test.test_get_channel()""" factory = SNCLFactory(data_format="miniseed") - assert factory.get_channel(element="D", interval="minute") == "UFD" + assert factory.get_channel(element="U_Volt", interval="tenhertz") == "BEU" + assert factory.get_channel(element="U_Bin", interval="tenhertz") == "BYU" + assert factory.get_channel(element="D", interval="second") == "LFD" assert factory.get_channel(element="F", interval="minute") == "UFF" - assert factory.get_channel(element="H", interval="minute") == "UFH" - assert factory.get_channel(element="Dst4", interval="minute") == "UX4" + assert factory.get_channel(element="H", interval="hour") == "RFH" + assert factory.get_channel(element="Dst4", interval="day") == "PX4" assert factory.get_channel(element="Dst3", interval="minute") == "UX3" assert factory.get_channel(element="E-E", interval="minute") == "UQE" assert factory.get_channel(element="E-N", interval="minute") == "UQN" - assert factory.get_channel(element="SQ", interval="minute") == "USQ" - assert factory.get_channel(element="SV", interval="minute") == "USV" assert factory.get_channel(element="UK1", interval="minute") == "UK1" - assert factory.get_channel(element="UK2", interval="minute") == "UK2" - assert factory.get_channel(element="UK3", interval="minute") == "UK3" - assert factory.get_channel(element="UK4", interval="minute") == "UK4" - assert factory.get_channel(element="DIST", interval="minute") == "UDT" - assert factory.get_channel(element="DST", interval="minute") == "UGD" assert factory.get_channel(element="U_Dist", interval="minute") == "UFU" + assert factory.get_channel(element="U_SQ", interval="minute") == "UFU" + assert factory.get_channel(element="U_SV", interval="minute") == "UFU" assert factory.get_channel(element="UK1.R0", interval="minute") == "UK1" # test legacy format factory = SNCLFactory(data_format="legacy") - assert factory.get_channel(element="D", interval="minute") == "MVD" + assert factory.get_channel(element="D", interval="second") == "SVD" assert factory.get_channel(element="F", interval="minute") == "MSF" - assert factory.get_channel(element="H", interval="minute") == "MVH" - assert factory.get_channel(element="Dst4", interval="minute") == "MX4" - assert factory.get_channel(element="Dst3", interval="minute") == "MX3" - assert factory.get_channel(element="E-E", interval="minute") == "MQE" + assert factory.get_channel(element="H", interval="hour") == "HVH" + assert factory.get_channel(element="E-E", interval="day") == "DQE" assert factory.get_channel(element="E-N", interval="minute") == "MQN" assert factory.get_channel(element="SQ", interval="minute") == "MSQ" assert factory.get_channel(element="SV", interval="minute") == "MSV" assert factory.get_channel(element="UK1", interval="minute") == "UK1" - assert factory.get_channel(element="UK2", interval="minute") == "UK2" - assert factory.get_channel(element="UK3", interval="minute") == "UK3" - assert factory.get_channel(element="UK4", interval="minute") == "UK4" assert factory.get_channel(element="DIST", interval="minute") == "MDT" assert factory.get_channel(element="DST", interval="minute") == "MGD" - assert factory.get_channel(element="H_Dist", interval="minute") == "MVH" assert factory.get_channel(element="UK1.R0", interval="minute") == "UK1" def test_get_location(): + """edge_test.SNCLFactory_test.test_get_location()""" factory = SNCLFactory(data_format="miniseed") assert factory.get_location(element="D", data_type="variation") == "R0" assert factory.get_location(element="D", data_type="adjusted") == "A0" @@ -74,3 +45,20 @@ def test_get_location(): assert factory.get_location(element="D_Dist", data_type="variation") == "RD" assert factory.get_location(element="D_SQ", data_type="variation") == "RQ" assert factory.get_location(element="D_SV", data_type="variation") == "RV" + + factory = SNCLFactory(data_format="legacy") + assert factory.get_location(element="D", data_type="variation") == "R0" + assert factory.get_location(element="D", data_type="adjusted") == "A0" + assert factory.get_location(element="D", data_type="quasi-definitive") == "Q0" + assert factory.get_location(element="D", data_type="definitive") == "D0" + assert factory.get_location(element="D_Sat", data_type="variation") == "R1" + + +def test_get_sncl(): + """edge_test.SNCLFactory_test.test_get_sncl()""" + assert SNCLFactory(data_format="miniseed").get_sncl( + station="BOU", network="NT", channel="UFU", location="R0" + ) == SNCL(station="BOU", network="NT", channel="UFU", location="R0") + assert SNCLFactory(data_format="legacy").get_sncl( + station="BOU", network="NT", channel="MVH", location="R0" + ) == LegacySNCL(station="BOU", network="NT", channel="MVH", location="R0") diff --git a/test/edge_test/SNCL_test.py b/test/edge_test/SNCL_test.py index 7f59107d9b9d49a2d096c583a8e28ef4c39496bb..b2ca4a1bed472b9ec1a28c56fb17db3e7457ac0d 100644 --- a/test/edge_test/SNCL_test.py +++ b/test/edge_test/SNCL_test.py @@ -2,6 +2,7 @@ from geomagio.edge import SNCL def test_data_type(): + """edge_test.SNCL_test.test_data_type()""" assert SNCL(station="BOU", channel="LFU", location="R0").data_type == "variation" assert SNCL(station="BOU", channel="LFU", location="A0").data_type == "adjusted" assert ( @@ -11,88 +12,8 @@ def test_data_type(): assert SNCL(station="BOU", channel="LFU", location="D0").data_type == "definitive" -def test_interval(): - # miniseed format - assert ( - SNCL( - station="BOU", - channel="BEU", - location="R0", - ).interval - == "tenhertz" - ) - assert ( - SNCL( - station="BOU", - channel="LEU", - location="R0", - ).interval - == "second" - ) - assert ( - SNCL( - station="BOU", - channel="UEU", - location="R0", - ).interval - == "minute" - ) - assert ( - SNCL( - station="BOU", - channel="REU", - location="R0", - ).interval - == "hour" - ) - assert ( - SNCL( - station="BOU", - channel="PEU", - location="R0", - ).interval - == "day" - ) - # legacy format - assert ( - SNCL( - station="BOU", - channel="SVH", - location="R0", - data_format="legacy", - ).interval - == "second" - ) - assert ( - SNCL( - station="BOU", - channel="MVH", - location="R0", - data_format="legacy", - ).interval - == "minute" - ) - assert ( - SNCL( - station="BOU", - channel="HVH", - location="R0", - data_format="legacy", - ).interval - == "hour" - ) - assert ( - SNCL( - station="BOU", - channel="DVH", - location="R0", - data_format="legacy", - ).interval - == "day" - ) - - def test_element(): + """edge_test.SNCL_test.test_element()""" assert ( SNCL( station="BOU", @@ -182,147 +103,64 @@ def test_element(): == "U_Sat" ) + +def test_get_sncl(): + """edge_test.SNCL_test.test_get_sncl()""" + assert SNCL().get_sncl( + station="BOU", data_type="variation", interval="second", element="U" + ) == SNCL(station="BOU", network="NT", channel="LFU", location="R0") + + +def test_interval(): + """edge_test.SNCL_test.test_interval()""" assert ( SNCL( station="BOU", - channel="MVD", - location="R0", - data_format="legacy", - ).element - == "D" - ) - assert ( - SNCL( - station="BOU", - channel="MVU", - location="R0", - data_format="legacy", - ).element - == "U" - ) - assert ( - SNCL( - station="BOU", - channel="MSF", - location="R0", - data_format="legacy", - ).element - == "F" - ) - assert ( - SNCL( - station="BOU", - channel="MVH", - location="R0", - data_format="legacy", - ).element - == "H" - ) - assert ( - SNCL( - station="BOU", - channel="MX4", - location="R0", - data_format="legacy", - ).element - == "Dst4" - ) - assert ( - SNCL( - station="BOU", - channel="MX3", + channel="BEU", location="R0", - data_format="legacy", - ).element - == "Dst3" + ).interval + == "tenhertz" ) assert ( SNCL( station="BOU", - channel="MQE", + channel="LEU", location="R0", - data_format="legacy", - ).element - == "E-E" + ).interval + == "second" ) assert ( SNCL( station="BOU", - channel="MQN", + channel="UEU", location="R0", - data_format="legacy", - ).element - == "E-N" + ).interval + == "minute" ) assert ( SNCL( station="BOU", - channel="MEH", + channel="REU", location="R0", - data_format="legacy", - ).element - == "H_Volt" + ).interval + == "hour" ) assert ( SNCL( station="BOU", - channel="MYH", + channel="PEU", location="R0", - data_format="legacy", - ).element - == "H_Bin" - ) - assert ( - SNCL( - station="BOU", - channel="MVH", - location="R1", - data_format="legacy", - ).element - == "H_Sat" - ) - assert ( - SNCL( - station="BOU", - channel="MVH", - location="RD", - data_format="legacy", - ).element - == "H_Dist" - ) - assert ( - SNCL( - station="BOU", - channel="MVH", - location="RQ", - data_format="legacy", - ).element - == "H_SQ" - ) - assert ( - SNCL( - station="BOU", - channel="MVH", - location="RV", - data_format="legacy", - ).element - == "H_SV" - ) - assert ( - SNCL( - station="BOU", - channel="MDT", - location="RV", - data_format="legacy", - ).element - == "DIST" - ) - assert ( - SNCL( - station="BOU", - channel="MGD", - location="RV", - data_format="legacy", - ).element - == "DST" + ).interval + == "day" ) + + +def test_parse_sncl(): + """edge_test.SNCL_test.test_parse_sncl()""" + assert SNCL(station="BOU", channel="UFU", location="R0").parse_sncl() == { + "station": "BOU", + "network": "NT", + "data_type": "variation", + "element": "U", + "interval": "minute", + }