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
eee72814
Commit
eee72814
authored
8 years ago
by
Jeremy M Fee
Browse files
Options
Downloads
Patches
Plain Diff
Update imfv283 factories to use generic _get_timeseries method
parent
a8ea5893
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/imfv283/IMFV283Factory.py
+14
-27
14 additions, 27 deletions
geomagio/imfv283/IMFV283Factory.py
geomagio/imfv283/StreamIMFV283Factory.py
+2
-4
2 additions, 4 deletions
geomagio/imfv283/StreamIMFV283Factory.py
with
16 additions
and
31 deletions
geomagio/imfv283/IMFV283Factory.py
+
14
−
27
View file @
eee72814
"""
Factory that loads IAGA2002 Files.
"""
"""
Factory that loads IAGA2002 Files.
"""
import
obspy.core
import
numpy
import
numpy
from
..
import
ChannelConverter
from
..
import
ChannelConverter
from
..TimeseriesFactory
import
TimeseriesFactory
from
..TimeseriesFactory
import
TimeseriesFactory
from
..Util
import
read_url
from
IMFV283Parser
import
IMFV283Parser
from
IMFV283Parser
import
IMFV283Parser
from
..ObservatoryMetadata
import
ObservatoryMetadata
from
..ObservatoryMetadata
import
ObservatoryMetadata
...
@@ -23,10 +21,8 @@ class IMFV283Factory(TimeseriesFactory):
...
@@ -23,10 +21,8 @@ class IMFV283Factory(TimeseriesFactory):
url/file reading.
url/file reading.
"""
"""
def
__init__
(
self
,
urlTemplate
,
observatory
=
None
,
channels
=
None
,
type
=
None
,
def
__init__
(
self
,
observatoryMetadata
=
None
,
**
kwargs
):
interval
=
None
,
observatoryMetadata
=
None
):
TimeseriesFactory
.
__init__
(
self
,
**
kwargs
)
TimeseriesFactory
.
__init__
(
self
,
observatory
,
channels
,
type
,
interval
,
urlTemplate
)
self
.
observatoryMetadata
=
observatoryMetadata
or
ObservatoryMetadata
()
self
.
observatoryMetadata
=
observatoryMetadata
or
ObservatoryMetadata
()
def
get_timeseries
(
self
,
starttime
,
endtime
,
observatory
=
None
,
def
get_timeseries
(
self
,
starttime
,
endtime
,
observatory
=
None
,
...
@@ -57,24 +53,21 @@ class IMFV283Factory(TimeseriesFactory):
...
@@ -57,24 +53,21 @@ class IMFV283Factory(TimeseriesFactory):
if invalid values are requested, or errors occur while
if invalid values are requested, or errors occur while
retrieving timeseries.
retrieving timeseries.
"""
"""
timeseries
=
self
.
_get_timeseries
(
starttime
=
starttime
,
endtime
=
endtime
,
observatory
=
observatory
,
channels
=
channels
,
type
=
type
,
interval
=
interval
)
observatory
=
observatory
or
self
.
observatory
observatory
=
observatory
or
self
.
observatory
channels
=
channels
or
self
.
channels
type
=
type
or
self
.
type
interval
=
interval
or
self
.
interval
timeseries
=
obspy
.
core
.
Stream
()
url_id
=
self
.
_get_url
(
observatory
,
obspy
.
core
.
UTCDateTime
(),
type
,
interval
)
imfV283File
=
read_url
(
url_id
)
timeseries
+=
self
.
parse_string
(
imfV283File
)
# merge channel traces for multiple days
timeseries
.
merge
()
# trim to requested start/end time
timeseries
.
trim
(
starttime
,
endtime
)
self
.
_post_process
(
timeseries
)
if
observatory
is
not
None
:
if
observatory
is
not
None
:
timeseries
=
timeseries
.
select
(
station
=
observatory
)
timeseries
=
timeseries
.
select
(
station
=
observatory
)
return
timeseries
.
select
(
station
=
observatory
)
for
trace
in
timeseries
:
stats
=
trace
.
stats
self
.
observatoryMetadata
.
set_metadata
(
stats
,
stats
.
station
,
stats
.
channel
,
'
variation
'
,
'
minute
'
)
return
timeseries
def
parse_string
(
self
,
imfV283String
):
def
parse_string
(
self
,
imfV283String
):
"""
Parse the contents of a string in the format of an IMFV283 file.
"""
Parse the contents of a string in the format of an IMFV283 file.
...
@@ -104,9 +97,3 @@ class IMFV283Factory(TimeseriesFactory):
...
@@ -104,9 +97,3 @@ class IMFV283Factory(TimeseriesFactory):
trace
.
data
=
ChannelConverter
.
get_radians_from_minutes
(
trace
.
data
=
ChannelConverter
.
get_radians_from_minutes
(
trace
.
data
)
trace
.
data
)
return
stream
return
stream
def
_post_process
(
self
,
timeseries
):
for
trace
in
timeseries
:
stats
=
trace
.
stats
self
.
observatoryMetadata
.
set_metadata
(
stats
,
stats
.
station
,
stats
.
channel
,
'
variation
'
,
'
minute
'
)
This diff is collapsed.
Click to expand it.
geomagio/imfv283/StreamIMFV283Factory.py
+
2
−
4
View file @
eee72814
...
@@ -17,10 +17,8 @@ class StreamIMFV283Factory(IMFV283Factory):
...
@@ -17,10 +17,8 @@ class StreamIMFV283Factory(IMFV283Factory):
IMFV283Factory
IMFV283Factory
Timeseriesfactory
Timeseriesfactory
"""
"""
def
__init__
(
self
,
stream
,
observatory
=
None
,
channels
=
None
,
def
__init__
(
self
,
stream
,
**
kwargs
):
type
=
None
,
interval
=
None
):
IMFV283Factory
.
__init__
(
self
,
**
kwargs
)
IMFV283Factory
.
__init__
(
self
,
None
,
observatory
,
channels
,
type
,
interval
)
self
.
_stream
=
stream
self
.
_stream
=
stream
def
get_timeseries
(
self
,
starttime
,
endtime
,
observatory
=
None
,
def
get_timeseries
(
self
,
starttime
,
endtime
,
observatory
=
None
,
...
...
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