Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
017cf128
Commit
017cf128
authored
6 years ago
by
Claycomb, Abram Earl
Browse files
Options
Downloads
Patches
Plain Diff
fixes test errors
parent
6857aefc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
geomagio/algorithm/FilterAlgorithm.py
+6
-5
6 additions, 5 deletions
geomagio/algorithm/FilterAlgorithm.py
test/algorithm_test/FilterAlgorithm_test.py
+8
-6
8 additions, 6 deletions
test/algorithm_test/FilterAlgorithm_test.py
with
14 additions
and
11 deletions
geomagio/algorithm/FilterAlgorithm.py
+
6
−
5
View file @
017cf128
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
test/algorithm_test/FilterAlgorithm_test.py
+
8
−
6
View file @
017cf128
...
...
@@ -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
adjus
te
d
data file
# unpack channels from loaded
minu
te
s
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment