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
0f6debc2
Commit
0f6debc2
authored
4 years ago
by
Cain, Payton David
Browse files
Options
Downloads
Patches
Plain Diff
Remove blank lines, clean up matrix population from statefile
parent
b646420a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/algorithm/AdjustedAlgorithm.py
+5
-20
5 additions, 20 deletions
geomagio/algorithm/AdjustedAlgorithm.py
with
5 additions
and
20 deletions
geomagio/algorithm/AdjustedAlgorithm.py
+
5
−
20
View file @
0f6debc2
...
...
@@ -35,7 +35,7 @@ class AdjustedAlgorithm(Algorithm):
self
.
statefile
=
statefile
self
.
data_type
=
data_type
self
.
location
=
location
# load matrix with statefile
if
matrix
is
None
:
self
.
load_state
()
...
...
@@ -47,33 +47,21 @@ class AdjustedAlgorithm(Algorithm):
matrix_size
=
len
([
c
for
c
in
self
.
get_input_channels
()
if
c
!=
"
F
"
])
+
1
self
.
matrix
=
np
.
eye
(
matrix_size
)
self
.
pier_correction
=
0
if
self
.
statefile
is
None
:
return
data
=
None
try
:
with
open
(
self
.
statefile
,
"
r
"
)
as
f
:
data
=
f
.
read
()
data
=
json
.
loads
(
data
)
except
IOError
as
err
:
sys
.
stderr
.
write
(
"
I/O error {0}
"
.
format
(
err
))
if
data
is
None
or
data
==
""
:
return
PC
=
data
.
pop
(
"
PC
"
)
self
.
pier_correction
=
np
.
float64
(
PC
)
# excludes PC
keys
=
list
(
data
.
keys
())
# get maximum row/colum number
length
=
int
(
max
(
keys
)[
-
1
])
self
.
matrix
=
np
.
eye
(
length
)
for
i
in
range
(
length
):
for
j
in
range
(
length
):
key
=
"
M
"
+
str
(
i
+
1
)
+
str
(
j
+
1
)
self
.
matrix
[
i
,
j
]
=
np
.
float64
(
data
[
key
])
for
row
in
range
(
matrix_size
):
for
col
in
range
(
matrix_size
):
self
.
matrix
[
row
,
col
]
=
np
.
float64
(
data
[
f
"
M
{
row
+
1
}{
col
+
1
}
"
])
self
.
pier_correction
=
np
.
float64
(
data
[
"
PC
"
])
def
save_state
(
self
):
"""
Save algorithm state to a file.
...
...
@@ -82,14 +70,11 @@ class AdjustedAlgorithm(Algorithm):
if
self
.
statefile
is
None
:
return
data
=
{
"
PC
"
:
self
.
pier_correction
}
length
=
len
(
self
.
matrix
[
0
,
:])
for
i
in
range
(
0
,
length
):
for
j
in
range
(
0
,
length
):
key
=
"
M
"
+
str
(
i
+
1
)
+
str
(
j
+
1
)
data
[
key
]
=
self
.
matrix
[
i
,
j
]
with
open
(
self
.
statefile
,
"
w
"
)
as
f
:
f
.
write
(
json
.
dumps
(
data
))
...
...
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