From bfbfa91579313acabd509bd3d7f5f63c1519995d Mon Sep 17 00:00:00 2001 From: "E. Joshua Rigler" <erigler@usgs.gov> Date: Fri, 5 Jan 2024 21:02:25 -0700 Subject: [PATCH] Instantiate EdgeFactory with a snclMapper Allow EdgeFactory to change which mappings will be used from common channels (i.e., X, Y, Z, etc), to SEED SNCLs (station, network, channel, location) codes. For now we default to "legacy", for backward compatibility, but we can specify snclMapper="geomag" to use the modern SNCLs used by the USGS Geomagnetism Program. --- geomagio/edge/EdgeFactory.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/geomagio/edge/EdgeFactory.py b/geomagio/edge/EdgeFactory.py index 87e254c2..c85aba4a 100644 --- a/geomagio/edge/EdgeFactory.py +++ b/geomagio/edge/EdgeFactory.py @@ -24,6 +24,7 @@ from ..TimeseriesFactory import TimeseriesFactory from ..TimeseriesFactoryException import TimeseriesFactoryException from ..ObservatoryMetadata import ObservatoryMetadata from .RawInputClient import RawInputClient +from .SNCL import SNCL from .LegacySNCL import LegacySNCL @@ -64,6 +65,9 @@ class EdgeFactory(TimeseriesFactory): all data written to edge (via raw input client) will be scaled by this integer prior to write; all data read from edge will be will be divided by this integer after read; default = 1000 + snclMapper: {'default','legacy','iris'} + a mapper of common channel names to SEED SNCL codes (that is, + station, network, channel, location codes); default = legacy See Also -------- @@ -91,6 +95,7 @@ class EdgeFactory(TimeseriesFactory): observatoryMetadata: Optional[ObservatoryMetadata] = None, locationCode: Optional[str] = None, scaleFactor: int = 1000, + snclMapper: str = "legacy", ): TimeseriesFactory.__init__(self, observatory, channels, type, interval) if port == 2060: @@ -108,6 +113,12 @@ class EdgeFactory(TimeseriesFactory): self.observatoryMetadata = observatoryMetadata or ObservatoryMetadata() self.locationCode = locationCode self.scaleFactor = scaleFactor + if snclMapper == "legacy": + self.get_sncl = LegacySNCL.get_sncl + elif snclMapper == "geomag": + self.get_sncl = SNCL.get_sncl + else: + raise TimeseriesFactoryException("Unrecognized SNCL mapper") def get_timeseries( self, @@ -329,7 +340,7 @@ class EdgeFactory(TimeseriesFactory): data: Trace timeseries trace of the requested channel data """ - sncl = LegacySNCL.get_sncl( + sncl = self.get_sncl( station=observatory, data_type=type, interval=interval, @@ -440,7 +451,7 @@ class EdgeFactory(TimeseriesFactory): ----- RawInputClient seems to only work when sockets are """ - sncl = LegacySNCL.get_sncl( + sncl = self.get_sncl( station=observatory, data_type=type, interval=interval, -- GitLab