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
a9d3ea16
Commit
a9d3ea16
authored
2 years ago
by
Jeremy M Fee
Browse files
Options
Downloads
Patches
Plain Diff
Clean up copy_absolutes
parent
d5a81c41
No related branches found
No related tags found
1 merge request
!189
Add absolutes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/processing/copy_absolutes.py
+9
-15
9 additions, 15 deletions
geomagio/processing/copy_absolutes.py
with
9 additions
and
15 deletions
geomagio/processing/copy_absolutes.py
+
9
−
15
View file @
a9d3ea16
...
@@ -4,16 +4,15 @@ Created on Thu Jul 7 11:05:19 2022
...
@@ -4,16 +4,15 @@ Created on Thu Jul 7 11:05:19 2022
@author: awernle
@author: awernle
"""
"""
import
os
import
json
import
json
import
os
from
datetime
import
date
,
datetime
,
time
,
timedelta
from
datetime
import
date
,
datetime
,
time
,
timedelta
from
typing
import
List
from
typing
import
List
import
typer
import
typer
from
obspy
import
UTCDateTime
from
obspy
import
UTCDateTime
from
..metadata
import
Metadata
,
Metadata
Fact
ory
,
Metadata
Categ
ory
from
..metadata
import
Metadata
,
Metadata
Categ
ory
,
Metadata
Fact
ory
from
..residual
import
Reading
,
WebAbsolutesFactory
from
..residual
import
Reading
,
WebAbsolutesFactory
TODAY
=
datetime
.
combine
(
date
.
today
(),
time
(
0
,
0
,
0
))
TODAY
=
datetime
.
combine
(
date
.
today
(),
time
(
0
,
0
,
0
))
...
@@ -51,7 +50,7 @@ def copy_absolutes(
...
@@ -51,7 +50,7 @@ def copy_absolutes(
starttime
=
UTCDateTime
(
starttime
),
starttime
=
UTCDateTime
(
starttime
),
endtime
=
UTCDateTime
(
endtime
),
endtime
=
UTCDateTime
(
endtime
),
)
)
typer
.
echo
(
f
"
Found
{
len
(
readings
)
}
absolutes
"
)
print
(
f
"
Found
{
len
(
readings
)
}
absolutes
"
)
# write readings to metadata service
# write readings to metadata service
metadata_factory
=
MetadataFactory
(
token
=
metadata_token
,
url
=
metadata_url
)
metadata_factory
=
MetadataFactory
(
token
=
metadata_token
,
url
=
metadata_url
)
with
typer
.
progressbar
(
with
typer
.
progressbar
(
...
@@ -73,25 +72,20 @@ def create_reading_metadata(reading: Reading) -> Metadata:
...
@@ -73,25 +72,20 @@ def create_reading_metadata(reading: Reading) -> Metadata:
-------
-------
metadata object for reading
metadata object for reading
"""
"""
json_string
=
reading
.
json
()
measurement_times
=
[
m
.
time
for
m
in
reading
.
measurements
if
m
.
time
]
reading_dict
=
json
.
loads
(
json_string
)
reviewer
=
reading
.
metadata
.
get
[
"
reviewer
"
]
metadata
=
Metadata
(
metadata
=
Metadata
(
category
=
MetadataCategory
.
READING
,
category
=
MetadataCategory
.
READING
,
created_by
=
reading
.
metadata
.
get
(
"
observer
"
,
"
copy_absolutes
"
),
created_by
=
reading
.
metadata
.
get
(
"
observer
"
,
"
copy_absolutes
"
),
endtime
=
max
(
measurement_times
),
metadata
=
json
.
loads
(
reading
.
json
()),
network
=
"
NT
"
,
network
=
"
NT
"
,
updated_by
=
reviewer
,
starttime
=
min
(
measurement_times
),
status
=
"
reviewed
"
if
reading
.
metadata
.
get
(
"
reviewed
"
)
else
"
new
"
,
starttime
=
min
([
m
.
time
for
m
in
reading
.
measurements
if
m
.
time
]),
endtime
=
max
([
m
.
time
for
m
in
reading
.
measurements
if
m
.
time
]),
station
=
reading
.
metadata
[
"
station
"
],
station
=
reading
.
metadata
[
"
station
"
],
metadata
=
reading_dict
,
status
=
"
reviewed
"
if
reading
.
metadata
.
get
(
"
reviewed
"
)
else
"
new
"
,
updated_by
=
reading
.
metadata
.
get
(
"
reviewer
"
),
)
)
return
metadata
return
metadata
pass
def
get_readings
(
def
get_readings
(
factory
:
WebAbsolutesFactory
,
factory
:
WebAbsolutesFactory
,
...
...
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