Skip to content
Snippets Groups Projects
Commit 017cf128 authored by Claycomb, Abram Earl's avatar Claycomb, Abram Earl
Browse files

fixes test errors

parent 6857aefc
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,7 @@ class FilterAlgorithm(Algorithm):
trace_channels = []
for trace in stream:
trace_channels += trace.stats.channel
trace_channels += [trace.stats.channel]
trace_chan_dict = dict(zip(trace_channels, self.outchannels))
......@@ -92,9 +92,10 @@ class FilterAlgorithm(Algorithm):
filtered = self.firfilter(data, self.window, step)
stats=Stats(trace.stats)
stats.channel = trace_chan_dict[trace.stats.channels]
stats.delta = trace.delta*step
stats.pop('processing')
stats.channel = trace_chan_dict[stats.channel]
stats.delta = stats.delta*step
if 'processing' in stats:
stats.pop('processing')
stats.npts = filtered.shape[0]
trace_out = self.create_trace(
stats.channel, stats, filtered)
......@@ -140,7 +141,7 @@ class FilterAlgorithm(Algorithm):
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
as_invalid_masked = np.ma.masked_greater(as_weight_sums, allowed_bad)
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
# seems to be a move toward np.matmul and/or @ operator as opposed to
......
......@@ -13,8 +13,10 @@ def test_process():
# load boulder Jan 16 files from /etc/ directory
min_iaga2002_file = open('etc/filter/BOU20180901vmin.min')
min_iaga2002_string = min_iaga2002_file.read()
min_iaga2002_file.close()
sec_iaga2002_file = open('etc/filter/BOU20180901vsec.sec')
sec_iaga2002_string = sec_iaga2002_file.read()
sec_iaga2002_file.close()
factory = i2.IAGA2002Factory()
min = factory.parse_string(min_iaga2002_string)
sec = factory.parse_string(sec_iaga2002_string)
......@@ -25,19 +27,19 @@ def test_process():
filt_bou = a.process(sec)
# unpack channels from loaded adjusted data file
# 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]
# unpack channels from adjusted processing of raw data
# 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):
assert_almost_equals(u.data[r], u_filt.data[r], 2)
assert_almost_equals(v.data[r], v_filt.data[r], 2)
assert_almost_equals(w.data[r], w_filt.data[r], 2)
assert_almost_equals(f.data[r], f_filt.data[r], 2)
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)
assert_almost_equals(f.data[r], f_filt.data[r], 1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment