From addb7aba7079eb99f0e5dd72cf9098bf8d68d65e Mon Sep 17 00:00:00 2001
From: Abram Claycomb <aclaycomb@usgs.gov>
Date: Wed, 7 Nov 2018 09:29:24 -0700
Subject: [PATCH] fixed test error, change invalid criteria to sum of weights

---
 geomagio/algorithm/FilterAlgorithm.py       | 10 ++++------
 test/algorithm_test/FilterAlgorithm_test.py |  1 +
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/geomagio/algorithm/FilterAlgorithm.py b/geomagio/algorithm/FilterAlgorithm.py
index d32b73288..552f7be58 100644
--- a/geomagio/algorithm/FilterAlgorithm.py
+++ b/geomagio/algorithm/FilterAlgorithm.py
@@ -138,14 +138,12 @@ class FilterAlgorithm(Algorithm):
         # sums of the total 'weights' of the filter corresponding to 
         # valid samples
         as_weight_sums =  np.dot(window, (~as_masked.mask).T)
-        # sums of total number of invalid entries for each appplication
+        # sums of total number of invalid entries for each application
         # of the filter
         as_invalid_sums = np.sum(as_masked.mask)
         # mark the output locations as 'bad' that don't have the minimum
         # number of samples
-        as_invalid_masked = np.ma.masked_greater(as_invalid_sums, 
-                                                 np.floor(
-                                                    allowed_bad*numtaps))
+        as_invalid_masked = np.ma.masked_greater(as_weight_sums, allowed_bad)
 
         # apply filter, using masked version of dot (in 3.5 and above, there
         # seems to be a move toward np.matmul and/or @ operator as opposed to
@@ -185,8 +183,8 @@ class FilterAlgorithm(Algorithm):
         """
 
         half = self.numtaps//2
-        start = start - half*self.interval
-        end = end + half*self.interval
+        start = start - half*self.sample_period
+        end = end + half*self.sample_period
 
         return (start, end)
 
diff --git a/test/algorithm_test/FilterAlgorithm_test.py b/test/algorithm_test/FilterAlgorithm_test.py
index 98b39f14e..4b06d8d33 100644
--- a/test/algorithm_test/FilterAlgorithm_test.py
+++ b/test/algorithm_test/FilterAlgorithm_test.py
@@ -18,6 +18,7 @@ def test_process():
     factory = i2.IAGA2002Factory()
     min = factory.parse_string(min_iaga2002_string)
     sec = factory.parse_string(sec_iaga2002_string)
+    a = filt()
 
     # process hezf (raw) channels with loaded transform
     filt_bou = a.process(sec, inchannels=('SVH','SVE','SVZ','SSF'), 
-- 
GitLab