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
94ebbcb3
Commit
94ebbcb3
authored
4 years ago
by
Cain, Payton David
Browse files
Options
Downloads
Patches
Plain Diff
Implement updating for legacy data
parent
f35496be
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!146
Release CMO metadata to production
,
!52
Update legacy
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/processing/update_legacy.py
+74
-0
74 additions, 0 deletions
geomagio/processing/update_legacy.py
with
74 additions
and
0 deletions
geomagio/processing/update_legacy.py
0 → 100644
+
74
−
0
View file @
94ebbcb3
import
os
from
..
import
Controller
from
..edge
import
EdgeFactory
from
..algorithm
import
FilterAlgorithm
from
..TimeseriesUtility
import
(
get_delta_from_interval
,
get_previous_interval
,
get_merged_gaps
,
get_stream_gaps
,
)
from
datetime
import
datetime
from
obspy.core
import
UTCDateTime
import
typer
def
main
():
typer
.
run
(
update_legacy
)
def
update_legacy
(
observatory
:
str
,
interval
:
str
,
input_channels
:
list
,
output_channels
:
list
=
None
,
realtime_interval
:
int
=
86400
,
edge_host
:
str
=
os
.
getenv
(
"
EDGE_HOST
"
,
"
cwbpub.cr.usgs.gov
"
),
edge_port
:
int
=
os
.
getenv
(
"
EDGE_PORT
"
,
2061
),
):
current_time
=
datetime
.
utcnow
()
current_time_string
=
current_time
.
strftime
(
"
%Y-%m-%d
"
)
endtime
=
UTCDateTime
(
current_time_string
)
-
1
starttime
=
endtime
-
realtime_interval
timeseries_factory
=
EdgeFactory
(
host
=
edge_host
,
port
=
edge_port
,
interval
=
interval
)
output_timeseries
=
timeseries_factory
.
get_timeseries
(
observatory
=
observatory
,
starttime
=
starttime
,
endtime
=
endtime
,
channels
=
channels
,
type
=
"
variation
"
,
)
output_gaps
=
get_merged_gaps
(
get_stream_gaps
(
output_timeseries
))
if
len
(
output_gaps
)
==
0
:
return
input_interval
=
get_previous_interval
(
interval
)
input_delta
=
get_delta_from_interval
(
input_interval
)
output_delta
=
get_delta_from_interval
(
interval
)
controller
=
Controller
(
algorithm
=
FilterAlgorithm
(
input_sample_period
=
input_delta
,
output_sample_period
=
output_delta
),
inputFactory
=
EdgeFactory
(
host
=
edge_host
,
port
=
edge_port
,
interval
=
input_interval
),
outputFactory
=
timeseries_factory
,
)
for
output_gap
in
output_gaps
:
controller
.
run
(
observatory
=
(
observatory
,),
starttime
=
output_gap
[
0
],
endtime
=
output_gap
[
1
],
input_channels
=
input_channels
,
output_channels
=
output_channels
,
)
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