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
86ed9e47
Commit
86ed9e47
authored
5 years ago
by
Cain, Payton David
Browse files
Options
Downloads
Patches
Plain Diff
Move arrays holding measurement types to top of module
parent
97b18fa3
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
geomagio/residual/Calculation.py
+15
-11
15 additions, 11 deletions
geomagio/residual/Calculation.py
with
15 additions
and
11 deletions
geomagio/residual/Calculation.py
+
15
−
11
View file @
86ed9e47
...
@@ -6,6 +6,18 @@ from .MeasurementType import MeasurementType as mt
...
@@ -6,6 +6,18 @@ from .MeasurementType import MeasurementType as mt
from
pydantic
import
BaseModel
from
pydantic
import
BaseModel
# specify mark measurement types
MARK_TYPES
=
[
mt
.
FIRST_MARK_DOWN
,
mt
.
FIRST_MARK_UP
,
mt
.
SECOND_MARK_DOWN
,
mt
.
SECOND_MARK_UP
,
]
# define measurement types used to calculate inclination
INCLINATION_TYPES
=
[
mt
.
NORTH_DOWN
,
mt
.
NORTH_UP
,
mt
.
SOUTH_DOWN
,
mt
.
SOUTH_UP
]
class
Calculate
(
BaseModel
):
class
Calculate
(
BaseModel
):
"""
"""
Class object for performing calculations.
Class object for performing calculations.
...
@@ -40,11 +52,9 @@ def calculate(reading):
...
@@ -40,11 +52,9 @@ def calculate(reading):
ordinate_index
=
reading
.
ordinate_index
()
ordinate_index
=
reading
.
ordinate_index
()
measurements
=
reading
.
measurements
measurements
=
reading
.
measurements
measurement_index
=
reading
.
measurement_index
()
measurement_index
=
reading
.
measurement_index
()
# define measurement types used to calculate inclination
inclination_types
=
[
mt
.
NORTH_DOWN
,
mt
.
NORTH_UP
,
mt
.
SOUTH_DOWN
,
mt
.
SOUTH_UP
]
# get ordinate values across h, e, z, and f for inclination measurement types
# get ordinate values across h, e, z, and f for inclination measurement types
inclination_ordinates
=
[
inclination_ordinates
=
[
o
for
o
in
ordinates
if
o
.
measurement_type
in
inclination_types
o
for
o
in
ordinates
if
o
.
measurement_type
in
INCLINATION_TYPES
]
]
# get average ordinate values across h, e, z, and f
# get average ordinate values across h, e, z, and f
mean
=
average_ordinate
(
inclination_ordinates
,
None
)
mean
=
average_ordinate
(
inclination_ordinates
,
None
)
...
@@ -157,20 +167,14 @@ def calculate_D(ordinates_index, measurements, measurements_index, azimuth, h_b)
...
@@ -157,20 +167,14 @@ def calculate_D(ordinates_index, measurements, measurements_index, azimuth, h_b)
ordinates, measurements, measurement_index(dictionary), azimuth and H baseline
ordinates, measurements, measurement_index(dictionary), azimuth and H baseline
Returns absolute and baseline for declination.
Returns absolute and baseline for declination.
"""
"""
# specify mark measurement types
mark_types
=
[
mt
.
FIRST_MARK_DOWN
,
mt
.
FIRST_MARK_UP
,
mt
.
SECOND_MARK_DOWN
,
mt
.
SECOND_MARK_UP
,
]
# average mark angles
# average mark angles
# note that angles are being converted to geon
# note that angles are being converted to geon
average_mark
=
np
.
average
(
average_mark
=
np
.
average
(
[
[
convert_to_geon
(
m
.
angle
)
convert_to_geon
(
m
.
angle
)
for
m
in
measurements
for
m
in
measurements
if
m
.
measurement_type
in
mark_types
if
m
.
measurement_type
in
MARK_TYPES
]
]
)
)
# add 100 if mark up is greater than mark down
# add 100 if mark up is greater than mark down
...
...
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