diff --git a/geomagio/algorithm/FilterAlgorithm.py b/geomagio/algorithm/FilterAlgorithm.py index 66920c8cc8b9bb4716c5faf851a61bcdd31e2e9c..5a7b4e02caa9fef6324f28e06646fd7be0025197 100644 --- a/geomagio/algorithm/FilterAlgorithm.py +++ b/geomagio/algorithm/FilterAlgorithm.py @@ -83,7 +83,10 @@ class FilterAlgorithm(Algorithm): for trace in stream: trace_channels += [trace.stats.channel] - trace_chan_dict = dict(zip(trace_channels, self.outchannels)) + trace_chan_dict1 = dict(zip(self.inchannels, trace_channels)) + print(trace_chan_dict1) + trace_chan_dict2 = dict(zip(trace_channels, self.outchannels)) + print(trace_chan_dict2) for trace in stream: data = trace.data @@ -92,7 +95,7 @@ class FilterAlgorithm(Algorithm): filtered = self.firfilter(data, self.window, step) stats=Stats(trace.stats) - stats.channel = trace_chan_dict[stats.channel] + stats.channel = trace_chan_dict2[stats.channel] stats.delta = stats.delta*step if 'processing' in stats: stats.pop('processing') @@ -140,7 +143,7 @@ class FilterAlgorithm(Algorithm): # valid samples as_weight_sums = np.dot(window, (~as_masked.mask).T) # mark the output locations as 'bad' that have missing input weights - # that sum to greater than + # that sum to greater than the allowed_bad threshhold as_invalid_masked = np.ma.masked_less(as_weight_sums, 1 - allowed_bad) # apply filter, using masked version of dot (in 3.5 and above, there diff --git a/test/algorithm_test/FilterAlgorithm_test.py b/test/algorithm_test/FilterAlgorithm_test.py index c5d8412ef7af76361b925ae5a7cb7c3ae4086b93..b7b50e380c1be0936c0a1956f4d028a3f93d45be 100644 --- a/test/algorithm_test/FilterAlgorithm_test.py +++ b/test/algorithm_test/FilterAlgorithm_test.py @@ -1,6 +1,5 @@ from geomagio.algorithm import FilterAlgorithm as filt import geomagio.iaga2002 as i2 -from nose.tools import assert_equals from nose.tools import assert_almost_equals def test_process(): @@ -18,7 +17,7 @@ def test_process(): sec_iaga2002_string = sec_iaga2002_file.read() sec_iaga2002_file.close() factory = i2.IAGA2002Factory() - min = factory.parse_string(min_iaga2002_string) + mint = factory.parse_string(min_iaga2002_string) sec = factory.parse_string(sec_iaga2002_string) # process hezf (raw) channels with loaded transform @@ -28,17 +27,17 @@ def test_process(): filt_bou = a.process(sec) # unpack channels from loaded minutes data file - u = min.select(channel='MVH')[0] - v = min.select(channel='MVE')[0] - w = min.select(channel='MVZ')[0] - f = min.select(channel='MSF')[0] + u = mint.select(channel='MVH')[0] + v = mint.select(channel='MVE')[0] + w = mint.select(channel='MVZ')[0] + f = mint.select(channel='MSF')[0] # unpack channels from filtered data u_filt = filt_bou.select(channel='MVH')[0] v_filt = filt_bou.select(channel='MVE')[0] w_filt = filt_bou.select(channel='MVZ')[0] f_filt = filt_bou.select(channel='MSF')[0] - for r in range(min[0].data.size): + for r in range(mint[0].data.size): assert_almost_equals(u.data[r], u_filt.data[r], 1) assert_almost_equals(v.data[r], v_filt.data[r], 1) assert_almost_equals(w.data[r], w_filt.data[r], 1)