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
93337fd7
Commit
93337fd7
authored
4 years ago
by
Cain, Payton David
Browse files
Options
Downloads
Patches
Plain Diff
Edit test for readability
parent
cb4476bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/algorithm_test/AdjustedAlgorithm_test.py
+50
-56
50 additions, 56 deletions
test/algorithm_test/AdjustedAlgorithm_test.py
with
50 additions
and
56 deletions
test/algorithm_test/AdjustedAlgorithm_test.py
+
50
−
56
View file @
93337fd7
...
...
@@ -6,14 +6,12 @@ from numpy.testing import assert_almost_equal, assert_equal
def
test_construct
():
"""
algorithm_test.AdjustedAlgorithm_test.test_construct()
"""
matrix
=
None
pier_correction
=
None
# load adjusted data transform matrix and pier correction
a
=
adj
(
matrix
,
pier_correction
,
"
etc/adjusted/adjbou_state_.json
"
)
a
=
adj
(
statefile
=
"
etc/adjusted/adjbou_state_.json
"
)
assert_almost_equal
(
a
.
matrix
[
0
,
0
],
9.83427577e-01
,
6
)
assert_almost_equal
(
actual
=
a
.
matrix
[
0
,
0
],
desired
=
9.83427577e-01
,
decimal
=
6
)
assert_equal
(
a
.
pier_correction
,
-
22
)
assert_equal
(
actual
=
a
.
pier_correction
,
desired
=
-
22
)
def
test_process_XYZF
():
...
...
@@ -22,38 +20,39 @@ def test_process_XYZF():
Check adjusted data processing versus files generated from
original script
"""
matrix
=
None
pier_correction
=
None
# load adjusted data transform matrix and pier correction
a
=
adj
(
matrix
,
pier_correction
,
"
etc/adjusted/adjbou_state_.json
"
,
)
a
=
adj
(
statefile
=
"
etc/adjusted/adjbou_state_.json
"
)
# load boulder Jan 16 files from /etc/ directory
hezf_iaga2002_file
=
open
(
"
etc/adjusted/BOU201601vmin.min
"
)
hezf_iaga2002_string
=
hezf_iaga2002_file
.
read
()
xyzf_iaga2002_file
=
open
(
"
etc/adjusted/BOU201601adj.min
"
)
xyzf_iaga2002_string
=
xyzf_iaga2002_file
.
read
()
factory
=
i2
.
IAGA2002Factory
()
hezf
=
factory
.
parse_string
(
hezf_iaga2002_string
)
xyzf
=
factory
.
parse_string
(
xyzf_iaga2002_string
)
with
open
(
"
etc/adjusted/BOU201601vmin.min
"
)
as
f
:
raw
=
i2
.
IAGA2002Factory
().
parse_string
(
f
.
read
())
with
open
(
"
etc/adjusted/BOU201601adj.min
"
)
as
f
:
expected
=
i2
.
IAGA2002Factory
().
parse_string
(
f
.
read
())
# process hezf (raw) channels with loaded transform
adj
_bou
=
a
.
process
(
hezf
)
adj
usted
=
a
.
process
(
raw
)
# unpack channels from loaded adjusted data file
x
=
xyzf
.
select
(
channel
=
"
X
"
)[
0
]
y
=
xyzf
.
select
(
channel
=
"
Y
"
)[
0
]
z
=
xyzf
.
select
(
channel
=
"
Z
"
)[
0
]
f
=
xyzf
.
select
(
channel
=
"
F
"
)[
0
]
# unpack channels from adjusted processing of raw data
x_adj
=
adj_bou
.
select
(
channel
=
"
X
"
)[
0
]
y_adj
=
adj_bou
.
select
(
channel
=
"
Y
"
)[
0
]
z_adj
=
adj_bou
.
select
(
channel
=
"
Z
"
)[
0
]
f_adj
=
adj_bou
.
select
(
channel
=
"
F
"
)[
0
]
assert_almost_equal
(
x
.
data
,
x_adj
.
data
,
2
)
assert_almost_equal
(
y
.
data
,
y_adj
.
data
,
2
)
assert_almost_equal
(
z
.
data
,
z_adj
.
data
,
2
)
assert_almost_equal
(
f
.
data
,
f_adj
.
data
,
2
)
# compare channels from adjusted and expected streams
assert_almost_equal
(
actual
=
adjusted
.
select
(
channel
=
"
X
"
)[
0
].
data
,
desired
=
expected
.
select
(
channel
=
"
X
"
)[
0
].
data
,
decimal
=
2
,
)
assert_almost_equal
(
actual
=
adjusted
.
select
(
channel
=
"
Y
"
)[
0
].
data
,
desired
=
expected
.
select
(
channel
=
"
Y
"
)[
0
].
data
,
decimal
=
2
,
)
assert_almost_equal
(
actual
=
adjusted
.
select
(
channel
=
"
Z
"
)[
0
].
data
,
desired
=
expected
.
select
(
channel
=
"
Z
"
)[
0
].
data
,
decimal
=
2
,
)
assert_almost_equal
(
actual
=
adjusted
.
select
(
channel
=
"
F
"
)[
0
].
data
,
desired
=
expected
.
select
(
channel
=
"
F
"
)[
0
].
data
,
decimal
=
2
,
)
def
test_process_reverse_polarity
():
...
...
@@ -62,35 +61,30 @@ def test_process_reverse_polarity():
Check adjusted data processing versus files generated from
original script. Tests reverse polarity martix.
"""
matrix
=
None
pier_correction
=
None
# load adjusted data transform matrix and pier correction
a
=
adj
(
matrix
,
pier_correction
,
"
etc/adjusted/adjbou_state_HE_.json
"
,
statefile
=
"
etc/adjusted/adjbou_state_HE_.json
"
,
inchannels
=
[
"
H
"
,
"
E
"
],
outchannels
=
[
"
H
"
,
"
E
"
],
)
# load boulder May 20 files from /etc/ directory
he_iaga2002_file
=
open
(
"
etc/adjusted/BOU202005vmin.min
"
)
he_iaga2002_string
=
he_iaga2002_file
.
read
()
he_inv_iaga2002_file
=
open
(
"
etc/adjusted/BOU202005adj.min
"
)
he_inv_iaga2002_string
=
he_inv_iaga2002_file
.
read
()
factory
=
i2
.
IAGA2002Factory
()
he
=
factory
.
parse_string
(
he_iaga2002_string
)
he_inv
=
factory
.
parse_string
(
he_inv_iaga2002_string
)
# process hezf (raw) channels with loaded transform
adj_bou
=
a
.
process
(
he
)
# unpack channels from loaded adjusted data file
h
=
he_inv
.
select
(
channel
=
"
H
"
)[
0
]
e
=
he_inv
.
select
(
channel
=
"
E
"
)[
0
]
# unpack channels from adjusted processing of raw data
h_adj
=
adj_bou
.
select
(
channel
=
"
H
"
)[
0
]
e_adj
=
adj_bou
.
select
(
channel
=
"
E
"
)[
0
]
assert_almost_equal
(
h
.
data
,
h_adj
.
data
,
2
)
assert_almost_equal
(
e
.
data
,
e_adj
.
data
,
2
)
with
open
(
"
etc/adjusted/BOU202005vmin.min
"
)
as
f
:
raw
=
i2
.
IAGA2002Factory
().
parse_string
(
f
.
read
())
with
open
(
"
etc/adjusted/BOU202005adj.min
"
)
as
f
:
expected
=
i2
.
IAGA2002Factory
().
parse_string
(
f
.
read
())
# process he(raw) channels with loaded transform
adjusted
=
a
.
process
(
raw
)
# compare channels from adjusted and expected streams
assert_almost_equal
(
actual
=
adjusted
.
select
(
channel
=
"
H
"
)[
0
].
data
,
desired
=
expected
.
select
(
channel
=
"
H
"
)[
0
].
data
,
decimal
=
2
,
)
assert_almost_equal
(
actual
=
adjusted
.
select
(
channel
=
"
E
"
)[
0
].
data
,
desired
=
expected
.
select
(
channel
=
"
E
"
)[
0
].
data
,
decimal
=
2
,
)
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