diff --git a/geomagio/api/ws/DataApiQuery.py b/geomagio/api/ws/DataApiQuery.py index 8202c6b6e5b0b7ada151adb91602aacfb62e57c1..af1c3f73ff3fc880cc75df45cad2bc20240225f8 100644 --- a/geomagio/api/ws/DataApiQuery.py +++ b/geomagio/api/ws/DataApiQuery.py @@ -39,13 +39,6 @@ class SamplingPeriod(float, enum.Enum): HOUR = 3600.0 DAY = 86400.0 - @property - def input_factory(self): - if self in [SamplingPeriod.TEN_HERTZ, SamplingPeriod.HOUR, SamplingPeriod.DAY]: - return "miniseed" - else: - return "edge" - class DataApiQuery(BaseModel): id: str diff --git a/geomagio/api/ws/data.py b/geomagio/api/ws/data.py index 797e382cd4d75c26d3ce3763659a25c3adbd7eaa..2592daa49d12181c95555f1ae42ffc682a99b172 100644 --- a/geomagio/api/ws/data.py +++ b/geomagio/api/ws/data.py @@ -29,11 +29,15 @@ def get_data_factory( Edge or miniseed factory object """ host = os.getenv("DATA_HOST", "cwbpub.cr.usgs.gov") - factory = query.sampling_period.input_factory - if factory == "edge": - return EdgeFactory(host=host, port=os.getenv("DATA_EARTHWORM_PORT", "2060")) - elif factory == "miniseed": + sampling_period = query.sampling_period + if sampling_period in [ + SamplingPeriod.TEN_HERTZ, + SamplingPeriod.HOUR, + SamplingPeriod.DAY, + ]: return MiniSeedFactory(host=host, port=os.getenv("DATA_MINISEED_PORT", "2061")) + elif sampling_period in [SamplingPeriod.SECOND, SamplingPeriod.MINUTE]: + return EdgeFactory(host=host, port=os.getenv("DATA_EARTHWORM_PORT", "2060")) else: return None