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
8ecd0806
Commit
8ecd0806
authored
4 years ago
by
Cain, Payton David
Browse files
Options
Downloads
Patches
Plain Diff
Changes test precision, remove rounding
parent
e5f2ebdd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
geomagio/residual/Calculation.py
+7
-15
7 additions, 15 deletions
geomagio/residual/Calculation.py
test/residual_test/residual_test.py
+3
-3
3 additions, 3 deletions
test/residual_test/residual_test.py
with
10 additions
and
18 deletions
geomagio/residual/Calculation.py
+
7
−
15
View file @
8ecd0806
...
...
@@ -29,9 +29,7 @@ def calculate(reading: Reading, adjust_reference: bool = True) -> Reading:
NOTE: rest of reading object is shallow copy.
"""
# reference measurement, used to adjust absolutes
reference
=
None
if
adjust_reference
==
True
:
reference
=
reading
[
mt
.
WEST_DOWN
][
0
]
reference
=
reading
[
mt
.
WEST_DOWN
][
0
]
# calculate inclination
inclination
,
f
,
mean
=
calculate_I
(
hemisphere
=
reading
.
hemisphere
,
measurements
=
reading
.
measurements
...
...
@@ -41,15 +39,14 @@ def calculate(reading: Reading, adjust_reference: bool = True) -> Reading:
absoluteH
,
absoluteZ
=
calculate_HZ_absolutes
(
corrected_f
=
corrected_f
,
inclination
=
inclination
,
reference
=
adjust_reference
and
reference
or
None
,
mean
=
mean
,
reference
=
reference
,
)
absoluteD
=
calculate_D_absolute
(
azimuth
=
reading
.
azimuth
,
h_baseline
=
absoluteH
.
baseline
,
measurements
=
reading
.
measurements
,
reference
=
reference
,
mean
=
mean
,
reference
=
adjust_reference
and
reference
or
mean
,
)
# calculate scale
if
reading
[
mt
.
NORTH_DOWN_SCALE
]:
...
...
@@ -75,7 +72,6 @@ def calculate_D_absolute(
azimuth
:
float
,
h_baseline
:
float
,
reference
:
Measurement
,
mean
:
Measurement
,
)
->
Absolute
:
"""
Calculate D absolute.
...
...
@@ -115,19 +111,15 @@ def calculate_D_absolute(
for
m
in
declination_measurements
]
)
shift
=
0.0
if
azimuth
>
180
:
azimuth
-=
180
shift
=
-
180
else
:
shift
=
0.0
# add subtract average mark angle from average meridian angle and add
# azimuth to get the declination baseline
d_b
=
(
meridian
-
average_mark
)
+
azimuth
# calculate absolute
if
reference
:
d_abs
=
d_b
+
np
.
degrees
(
np
.
arctan
(
reference
.
e
/
(
reference
.
h
+
h_baseline
)))
else
:
d_abs
=
d_b
+
np
.
degrees
(
np
.
arctan
(
mean
.
e
/
(
mean
.
h
+
h_baseline
)))
d_abs
=
d_b
+
np
.
degrees
(
np
.
arctan
(
reference
.
e
/
(
reference
.
h
+
h_baseline
)))
return
Absolute
(
element
=
"
D
"
,
absolute
=
d_abs
,
baseline
=
d_b
,
shift
=
shift
)
...
...
@@ -155,8 +147,8 @@ def calculate_HZ_absolutes(
inclination_radians
=
np
.
radians
(
inclination
)
h_abs
=
corrected_f
*
np
.
cos
(
inclination_radians
)
z_abs
=
corrected_f
*
np
.
sin
(
inclination_radians
)
h_b
=
round
(
np
.
sqrt
(
h_abs
**
2
-
mean
.
e
**
2
)
-
mean
.
h
,
1
)
z_b
=
round
(
z_abs
-
mean
.
z
,
1
)
h_b
=
np
.
sqrt
(
h_abs
**
2
-
mean
.
e
**
2
)
-
mean
.
h
z_b
=
z_abs
-
mean
.
z
# adjust absolutes to reference measurement
if
reference
:
h_abs
=
np
.
sqrt
((
h_b
+
reference
.
h
)
**
2
+
(
reference
.
e
)
**
2
)
...
...
This diff is collapsed.
Click to expand it.
test/residual_test/residual_test.py
+
3
−
3
View file @
8ecd0806
...
...
@@ -13,19 +13,19 @@ def assert_readings_equal(expected: Reading, actual: Reading):
assert_almost_equal
(
[
expected_absolutes
[
"
H
"
].
absolute
,
expected_absolutes
[
"
H
"
].
baseline
],
[
actual_absolutes
[
"
H
"
].
absolute
,
actual_absolutes
[
"
H
"
].
baseline
],
decimal
=
4
,
decimal
=
1
,
verbose
=
True
,
)
assert_almost_equal
(
[
expected_absolutes
[
"
D
"
].
absolute
,
expected_absolutes
[
"
D
"
].
baseline
],
[
actual_absolutes
[
"
D
"
].
absolute
,
actual_absolutes
[
"
D
"
].
baseline
],
decimal
=
3
,
decimal
=
1
,
verbose
=
True
,
)
assert_almost_equal
(
[
expected_absolutes
[
"
Z
"
].
absolute
,
expected_absolutes
[
"
Z
"
].
baseline
],
[
actual_absolutes
[
"
Z
"
].
absolute
,
actual_absolutes
[
"
Z
"
].
baseline
],
decimal
=
4
,
decimal
=
1
,
verbose
=
True
,
)
assert_almost_equal
(
...
...
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