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
6632e8f3
Commit
6632e8f3
authored
4 years ago
by
Cain, Payton David
Committed by
Jeremy M Fee
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Merge pcdcp methods, simplify time calculations
parent
eaadad80
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/pcdcp/__init__.py
+1
-2
1 addition, 2 deletions
geomagio/pcdcp/__init__.py
geomagio/processing/magproc.py
+65
-64
65 additions, 64 deletions
geomagio/processing/magproc.py
with
66 additions
and
66 deletions
geomagio/pcdcp/__init__.py
+
1
−
2
View file @
6632e8f3
...
@@ -2,8 +2,7 @@
...
@@ -2,8 +2,7 @@
"""
"""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
.PCDCPFactory
import
PCDCPFactory
from
.PCDCPFactory
import
PCDCPFactory
,
PCDCP_FILE_PATTERN
from
.PCDCPFactory
import
PCDCP_FILE_PATTERN
from
.StreamPCDCPFactory
import
StreamPCDCPFactory
from
.StreamPCDCPFactory
import
StreamPCDCPFactory
from
.PCDCPParser
import
PCDCPParser
from
.PCDCPParser
import
PCDCPParser
from
.PCDCPWriter
import
PCDCPWriter
from
.PCDCPWriter
import
PCDCPWriter
...
...
This diff is collapsed.
Click to expand it.
geomagio/processing/magproc.py
+
65
−
64
View file @
6632e8f3
...
@@ -4,15 +4,16 @@ import sys
...
@@ -4,15 +4,16 @@ import sys
from
datetime
import
datetime
from
datetime
import
datetime
from
dateutil.relativedelta
import
relativedelta
from
dateutil.relativedelta
import
relativedelta
from
obspy.core
import
UTCDateTime
from
obspy.core
import
UTCDateTime
,
Stream
import
typer
import
typer
from
..algorithm.FilterAlgorithm
import
FilterAlgorithm
from
..edge.EdgeFactory
import
EdgeFactory
from
..edge.EdgeFactory
import
EdgeFactory
from
..pcdcp
import
PCDCPFactory
,
PCDCP_FILE_PATTERN
from
..pcdcp
import
PCDCPFactory
,
PCDCP_FILE_PATTERN
from
..residual
import
WebAbsolutesFactory
,
CalFileFactory
from
..residual
import
WebAbsolutesFactory
,
CalFileFactory
CAL_FILENAME_FORMAT
=
"
{OBSERVATORY}/{OBSERVATORY}{YEAR}PCD.cal
"
CAL_FILENAME_FORMAT
=
"
{OBSERVATORY}/{OBSERVATORY}{YEAR}PCD.cal
"
MIN_TEMPLATE
=
"
file://c:/USGSDCP/
%(OBS)s/
"
+
PCDCP_FILE_PATTERN
MIN_TEMPLATE
=
"
%(OBS)s/
"
+
PCDCP_FILE_PATTERN
RAW_TEMPLATE
=
"
%(OBS)s/
"
+
PCDCP_FILE_PATTERN
RAW_TEMPLATE
=
"
%(OBS)s/
"
+
PCDCP_FILE_PATTERN
...
@@ -21,14 +22,47 @@ def main():
...
@@ -21,14 +22,47 @@ def main():
def
prepfiles
(
observatory
:
str
,
year
:
int
,
month
:
int
):
def
prepfiles
(
observatory
:
str
,
year
:
int
,
month
:
int
):
start
time
=
datetime
(
year
,
month
,
1
)
month_
start
=
datetime
(
year
,
month
,
1
)
endtime
=
start
time
+
relativedelta
(
months
=
+
1
)
month_end
=
month_
start
+
relativedelta
(
months
=
1
)
write_cal_file
(
starttime
,
endtime
,
observatory
)
write_cal_file
(
starttime
=
UTCDateTime
(
month_start
-
relativedelta
(
months
=
1
)),
endtime
=
UTCDateTime
(
month_end
+
relativedelta
(
months
=
1
)),
observatory
=
observatory
,
)
timeseries_min
,
timeseries_sec
=
gather_data
(
starttime
=
UTCDateTime
(
month_start
),
endtime
=
UTCDateTime
(
month_end
),
observatory
=
observatory
,
)
write_pcdcp_file
(
starttime
=
UTCDateTime
(
month_start
),
endtime
=
UTCDateTime
(
month_end
),
timeseries
=
timeseries_sec
,
observatory
=
observatory
,
interval
=
"
second
"
,
base_directory
=
"
file://c:/RAW/
"
,
template
=
RAW_TEMPLATE
,
)
write_pcdcp_file
(
starttime
=
UTCDateTime
(
month_start
),
endtime
=
UTCDateTime
(
month_end
),
timeseries
=
timeseries_min
,
observatory
=
observatory
,
interval
=
"
minute
"
,
base_directory
=
"
file://c:/USGSDCP/
"
,
template
=
MIN_TEMPLATE
,
)
def
write_cal_file
(
def
write_cal_file
(
starttime
,
endtime
,
observatory
,
base_directory
=
"
file://c:/Calibrat/
"
starttime
:
UTCDateTime
,
endtime
:
UTCDateTime
,
observatory
:
str
,
base_directory
:
str
=
"
file://c:/Calibrat/
"
,
):
):
filename
=
CAL_FILENAME_FORMAT
.
format
(
OBSERVATORY
=
observatory
,
YEAR
=
starttime
.
year
)
filename
=
CAL_FILENAME_FORMAT
.
format
(
OBSERVATORY
=
observatory
,
YEAR
=
starttime
.
year
)
starttime
=
starttime
+
relativedelta
(
months
=-
1
)
starttime
=
starttime
+
relativedelta
(
months
=-
1
)
...
@@ -48,74 +82,41 @@ def write_cal_file(
...
@@ -48,74 +82,41 @@ def write_cal_file(
CalFileFactory
().
write_file
(
path
=
base_directory
+
filename
,
readings
=
readings
)
CalFileFactory
().
write_file
(
path
=
base_directory
+
filename
,
readings
=
readings
)
def
write_raw_file
(
starttime
,
endtime
,
observatory
,
base_directory
=
"
file://c:/RAW/
"
):
def
gather_data
(
starttime
:
UTCDateTime
,
endtime
:
UTCDateTime
,
observatory
:
str
):
starttime
=
UTCDateTime
(
f
=
FilterAlgorithm
(
input_sample_period
=
1.0
,
output_sample_period
=
60.0
)
year
=
starttime
.
year
,
month
=
starttime
.
month
,
day
=
starttime
.
day
f_starttime
,
f_endtime
=
f
.
get_input_interval
(
starttime
,
endtime
)
)
e
=
EdgeFactory
()
endtime
=
UTCDateTime
(
year
=
endtime
.
year
,
month
=
endtime
.
month
,
day
=
endtime
.
day
)
timeseries_sec
=
e
.
get_timeseries
(
starttime
=
f_starttime
,
channels
=
[
"
H
"
,
"
E
"
,
"
Z
"
,
"
F
"
]
endtime
=
f_endtime
,
edge_factory
=
EdgeFactory
()
raw_timeseries
=
edge_factory
.
get_timeseries
(
observatory
=
observatory
,
starttime
=
starttime
,
endtime
=
endtime
,
channels
=
channels
,
interval
=
"
second
"
,
type
=
"
variation
"
,
)
raw_factory
=
PCDCPFactory
(
observatory
=
observatory
,
observatory
=
observatory
,
channels
=
channels
,
channels
=
[
"
H
"
,
"
E
"
,
"
Z
"
,
"
F
"
]
,
type
=
"
variation
"
,
type
=
"
variation
"
,
interval
=
"
second
"
,
interval
=
"
second
"
,
urlInterval
=
86400
,
urlTemplate
=
base_directory
+
f
"
{
RAW_TEMPLATE
}
"
,
)
)
return
(
raw_factory
.
put_timeseries
(
f
.
process
(
timeseries_sec
),
timeseries
=
raw_timeseries
,
timeseries_sec
.
trim
(
starttime
=
starttime
,
endtime
=
endtime
),
starttime
=
starttime
,
endtime
=
endtime
,
interval
=
"
second
"
,
type
=
"
variation
"
,
channels
=
channels
,
)
)
def
write_min_file
(
starttime
,
endtime
,
observatory
,
base_directory
=
"
file://c:/MIN/
"
):
def
write_pcdcp_file
(
starttime
=
UTCDateTime
(
starttime
:
UTCDateTime
,
year
=
starttime
.
year
,
month
=
starttime
.
month
,
day
=
starttime
.
day
endtime
:
UTCDateTime
,
)
timeseries
:
Stream
,
endtime
=
UTCDateTime
(
year
=
endtime
.
year
,
month
=
endtime
.
month
,
day
=
endtime
.
day
)
observatory
:
str
,
interval
:
str
,
channels
=
[
"
H
"
,
"
E
"
,
"
Z
"
,
"
F
"
]
base_directory
:
str
,
template
:
str
=
PCDCP_FILE_PATTERN
,
min_timeseries
=
EdgeFactory
().
get_timeseries
(
):
observatory
=
observatory
,
raw_factory
=
PCDCPFactory
(
starttime
=
starttime
,
urlInterval
=
86400
,
urlTemplate
=
base_directory
+
f
"
{
template
}
"
,
endtime
=
endtime
,
channels
=
channels
,
interval
=
"
minute
"
,
type
=
"
variation
"
,
)
min_factory
=
PCDCPFactory
(
observatory
=
observatory
,
channels
=
channels
,
type
=
"
variation
"
,
interval
=
"
minute
"
,
urlInterval
=
86400
,
urlTemplate
=
base_directory
+
f
"
{
MIN_TEMPLATE
}
"
,
)
)
min
_factory
.
put_timeseries
(
raw
_factory
.
put_timeseries
(
timeseries
=
min_
timeseries
,
timeseries
=
timeseries
,
starttime
=
starttime
,
starttime
=
starttime
,
endtime
=
endtime
,
endtime
=
endtime
,
interval
=
"
m
in
u
te
"
,
interval
=
inte
rval
,
type
=
"
variation
"
,
type
=
"
variation
"
,
channels
=
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