From 8b041d10d23a265a2e4aea4c634ca1b545ee0ba2 Mon Sep 17 00:00:00 2001
From: bgeels <bgeels@usgs.gov>
Date: Tue, 2 Apr 2024 07:21:54 -0600
Subject: [PATCH] Revert "Rename get_instrument function to be less confusing."

This reverts commit f10f33f3db85df6eb0f84e09ff0b5e4087cbaace.
---
 docs/elements.md                                   |  2 +-
 geomagio/edge/MiniSeedFactory.py                   |  4 ++--
 .../metadata/instrument/InstrumentCalibrations.py  |  2 +-
 test/Metadata_test.py                              | 14 ++++++--------
 test/edge_test/MiniSeedFactory_test.py             |  6 ++----
 5 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/docs/elements.md b/docs/elements.md
index ff68b4c9a..d4340c308 100644
--- a/docs/elements.md
+++ b/docs/elements.md
@@ -19,7 +19,7 @@ Elements generated by observatories running the Obsrio data acquisition system.
 
   - U, V, W
 
-    uses instrument metadata from `geomagio.metadata.instrument.InstrumentCalibrations.get_instrument_calibrations` to convert volt+bin to engineering units.
+    uses instrument metadata from `geomagio.Metadata.get_instrument` to convert volt+bin to engineering units.
 
     uses `geomagio.algorithm.FilterAlgorithm` to filter from 10Hz to 1Hz.
 
diff --git a/geomagio/edge/MiniSeedFactory.py b/geomagio/edge/MiniSeedFactory.py
index 63bbffe86..54885511b 100644
--- a/geomagio/edge/MiniSeedFactory.py
+++ b/geomagio/edge/MiniSeedFactory.py
@@ -20,7 +20,7 @@ from obspy.core import Stats, Stream, Trace, UTCDateTime
 
 from .. import ChannelConverter, TimeseriesUtility
 from ..geomag_types import DataInterval, DataType
-from ..metadata.instrument.InstrumentCalibrations import get_instrument_calibrations
+from ..metadata.instrument.InstrumentCalibrations import get_instrument
 from ..TimeseriesFactory import TimeseriesFactory
 from ..TimeseriesFactoryException import TimeseriesFactoryException
 from ..ObservatoryMetadata import ObservatoryMetadata
@@ -448,7 +448,7 @@ class MiniSeedFactory(TimeseriesFactory):
                   to contain just a single Trace.
         """
         out = Stream()
-        metadata = get_instrument_calibrations(observatory, starttime, endtime)
+        metadata = get_instrument(observatory, starttime, endtime)
         # loop in case request spans different configurations
         for entry in metadata:
             entry_endtime = entry["end_time"]
diff --git a/geomagio/metadata/instrument/InstrumentCalibrations.py b/geomagio/metadata/instrument/InstrumentCalibrations.py
index d3f52a9ad..a4ad6e640 100644
--- a/geomagio/metadata/instrument/InstrumentCalibrations.py
+++ b/geomagio/metadata/instrument/InstrumentCalibrations.py
@@ -296,7 +296,7 @@ class InstrumentCalibrations:
         return channels
 
 
-def get_instrument_calibrations(
+def get_instrument(
     observatory, start_time=None, end_time=None, calibrations=None, metadata_url=None
 ):
     """Get instrument metadata
diff --git a/test/Metadata_test.py b/test/Metadata_test.py
index 141a657c1..d56571ac9 100644
--- a/test/Metadata_test.py
+++ b/test/Metadata_test.py
@@ -1,7 +1,5 @@
 from obspy import UTCDateTime
-from geomagio.metadata.instrument.InstrumentCalibrations import (
-    get_instrument_calibrations,
-)
+from geomagio.metadata.instrument.InstrumentCalibrations import get_instrument
 from numpy.testing import assert_equal
 
 
@@ -28,7 +26,7 @@ TEST_METADATA = [METADATA1, METADATA2, METADATA3]
 
 def test_get_instrument_after():
     """Request an interval after the last entry, that has start_time None"""
-    matches = get_instrument_calibrations(
+    matches = get_instrument(
         "TST",
         UTCDateTime("2021-02-02T00:00:00Z"),
         UTCDateTime("2022-01-02T00:00:00Z"),
@@ -39,7 +37,7 @@ def test_get_instrument_after():
 
 def test_get_instrument_before():
     """Request an interval before the first entry, that has start_time None"""
-    matches = get_instrument_calibrations(
+    matches = get_instrument(
         "TST",
         UTCDateTime("2019-02-02T00:00:00Z"),
         UTCDateTime("2020-01-02T00:00:00Z"),
@@ -50,7 +48,7 @@ def test_get_instrument_before():
 
 def test_get_instrument_inside():
     """Request an interval that is wholly contained by one entry"""
-    matches = get_instrument_calibrations(
+    matches = get_instrument(
         "TST",
         UTCDateTime("2020-02-02T01:00:00Z"),
         UTCDateTime("2020-02-02T02:00:00Z"),
@@ -61,7 +59,7 @@ def test_get_instrument_inside():
 
 def test_get_instrument_span():
     """Request a time interval that spans multiple entries"""
-    matches = get_instrument_calibrations(
+    matches = get_instrument(
         "TST",
         UTCDateTime("2020-01-02T00:00:00Z"),
         UTCDateTime("2020-02-02T01:00:00Z"),
@@ -72,7 +70,7 @@ def test_get_instrument_span():
 
 def test_get_instrument_unknown():
     """Request an unknown observatory"""
-    matches = get_instrument_calibrations(
+    matches = get_instrument(
         "OTHER",
         UTCDateTime("2020-01-02T00:00:00Z"),
         UTCDateTime("2020-02-02T01:00:00Z"),
diff --git a/test/edge_test/MiniSeedFactory_test.py b/test/edge_test/MiniSeedFactory_test.py
index 75f895e5c..2e9d09526 100644
--- a/test/edge_test/MiniSeedFactory_test.py
+++ b/test/edge_test/MiniSeedFactory_test.py
@@ -10,9 +10,7 @@ import pytest
 
 from geomagio import TimeseriesUtility
 from geomagio.edge import MiniSeedFactory, MiniSeedInputClient
-from geomagio.metadata.instrument.InstrumentCalibrations import (
-    get_instrument_calibrations,
-)
+from geomagio.metadata.instrument.InstrumentCalibrations import get_instrument
 from .mseed_test_clients import MockMiniSeedClient, MisalignedMiniSeedClient
 
 
@@ -46,7 +44,7 @@ def misaligned_miniseed_factory() -> MiniSeedFactory:
 
 @pytest.fixture()
 def bou_u_metadata():
-    metadata = get_instrument_calibrations(observatory="BOU")
+    metadata = get_instrument(observatory="BOU")
     instrument = metadata[0]["instrument"]
     channels = instrument["channels"]
     yield channels["U"]
-- 
GitLab