From 71b113da2658543e09ef7079624aec1e6fa85746 Mon Sep 17 00:00:00 2001
From: Jeremy Fee <jmfee@usgs.gov>
Date: Wed, 17 Jun 2020 19:42:37 -0600
Subject: [PATCH] Switch dbdt suffix from _DDT to _DT, round at 6 decimals

---
 geomagio/algorithm/DbDtAlgorithm.py       | 6 +++---
 geomagio/edge/MiniSeedFactory.py          | 4 ++--
 test/algorithm_test/DbDtAlgorithm_test.py | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/geomagio/algorithm/DbDtAlgorithm.py b/geomagio/algorithm/DbDtAlgorithm.py
index dd4caa06e..75a0cad39 100644
--- a/geomagio/algorithm/DbDtAlgorithm.py
+++ b/geomagio/algorithm/DbDtAlgorithm.py
@@ -34,11 +34,11 @@ class DbDtAlgorithm(Algorithm):
         """
         out = Stream()
         for trace in stream:
-            dbdt = np.diff(trace.data)
+            dbdt = np.around(np.diff(trace.data), decimals=6)
             stats = Stats(trace.stats)
-            stats.channel = "{}_DDT".format(stats.channel)
+            stats.channel = "{}_DT".format(stats.channel)
             trace_out = create_empty_trace(
-                starttime=stats.starttime + self.period,
+                starttime=stats.starttime + stats.delta,
                 endtime=stats.endtime,
                 observatory=stats.station,
                 type=stats.location,
diff --git a/geomagio/edge/MiniSeedFactory.py b/geomagio/edge/MiniSeedFactory.py
index 032351969..99c3b9eec 100644
--- a/geomagio/edge/MiniSeedFactory.py
+++ b/geomagio/edge/MiniSeedFactory.py
@@ -349,7 +349,7 @@ class MiniSeedFactory(TimeseriesFactory):
                 return channel
 
         if suffix is not None:
-            if suffix == "Dist" or suffix == "SQ" or suffix == "SV" or suffix == "DDT":
+            if suffix == "Dist" or suffix == "SQ" or suffix == "SV" or suffix == "DT":
                 # these suffixes modify location code, but use element channel
                 channel = element
             else:
@@ -421,7 +421,7 @@ class MiniSeedFactory(TimeseriesFactory):
                 location_suffix = "Q"
             elif suffix == "SV":
                 location_suffix = "V"
-            elif suffix == "DDT":
+            elif suffix == "DT":
                 location_suffix = "R"
             elif suffix not in ("Bin", "Volt"):
                 raise TimeseriesFactoryException(
diff --git a/test/algorithm_test/DbDtAlgorithm_test.py b/test/algorithm_test/DbDtAlgorithm_test.py
index 49c9ea509..df9fc08ef 100644
--- a/test/algorithm_test/DbDtAlgorithm_test.py
+++ b/test/algorithm_test/DbDtAlgorithm_test.py
@@ -10,7 +10,7 @@ def test_process():
     original script
     """
     # initialize DbDt object
-    dbdt = DbDtAlgorithm(inchannels=["H"], outchannels=["H_DDT"], period=60)
+    dbdt = DbDtAlgorithm(inchannels=["H"], outchannels=["H_DT"], period=60)
 
     # load boulder May 20 files from /etc/ directory
     hez_iaga2002_file = open("etc/dbdt/BOU202005vmin.min")
@@ -25,7 +25,7 @@ def test_process():
     result = dbdt.process(hez)
 
     # unpack channels from result
-    rh = result.select(channel="H_DDT")[0]
+    rh = result.select(channel="H_DT")[0]
     # unpack channels from BOU202005dbdt.min
     h = hez_dbdt.select(channel="H")[0]
 
-- 
GitLab