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
07bfe69d
Commit
07bfe69d
authored
3 years ago
by
Cain, Payton David
Committed by
Wilbur, Spencer Franklin
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
add IRISFactory
parent
3f088cdd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!252
Latest Pcain-Iris-Factory Merge Attemp
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/edge/IRISFactory.py
+154
-0
154 additions, 0 deletions
geomagio/edge/IRISFactory.py
with
154 additions
and
0 deletions
geomagio/edge/IRISFactory.py
0 → 100644
+
154
−
0
View file @
07bfe69d
from
typing
import
List
,
Optional
from
obspy
import
Trace
,
UTCDateTime
from
obspy.clients.iris.client
import
Client
from
..geomag_types
import
DataInterval
,
DataType
from
..ObservatoryMetadata
import
ObservatoryMetadata
from
..
import
TimeseriesUtility
from
.IRISSNCL
import
IRISSNCL
from
.MiniSeedFactory
import
MiniSeedFactory
class
IRISFactory
(
MiniSeedFactory
):
"""
MiniSeedFactory for IRIS related data.
Parameters
----------
base_url: str
iris web service url
host: str
a string representing the IP number of the host to connect to
write_port: int
the port number the miniseed client writes data
network: str
data network
observatory: str
observatory id
channels: array
list of channels
type: {
"
adjusted
"
,
"
definitive
"
,
"
quasi-definitive
"
,
"
variation
"
}
data type
interval: {
"
tenhertz
"
,
"
second
"
,
"
minute
"
,
"
hour
"
,
"
day
"
}
data interval
observatoryMetadata: ObservatoryMetadata
observatory metadata to replace the default ObservatoryMetadata
locationCode: str
the location code for the given edge server
convert_channels: array
list of channels to convert from volt/bin to nT
See Also
--------
MiniSeedFactory
Notes
-----
This factory is designed to receive data from IRIS and write to edge.
convert_channels should only be used with tenhertz NT data (U, V, W).
Non-NT data conversions are automatically handled by the IRIS web service.
"""
def
__init__
(
self
,
base_url
:
str
=
"
http://service.iris.edu/irisws
"
,
host
:
str
=
"
cwbpub.cr.usgs.gov
"
,
write_port
:
int
=
7974
,
network
:
str
=
"
NT
"
,
observatory
:
Optional
[
str
]
=
None
,
channels
:
Optional
[
List
[
str
]]
=
None
,
type
:
Optional
[
DataType
]
=
None
,
interval
:
Optional
[
DataInterval
]
=
None
,
observatoryMetadata
:
Optional
[
ObservatoryMetadata
]
=
None
,
locationCode
:
Optional
[
str
]
=
None
,
convert_channels
:
Optional
[
List
[
str
]]
=
None
,
):
super
().
__init__
(
host
=
host
,
write_port
=
write_port
,
observatory
=
observatory
,
channels
=
channels
,
type
=
type
,
interval
=
interval
,
observatoryMetadata
=
observatoryMetadata
or
ObservatoryMetadata
(),
locationCode
=
locationCode
,
convert_channels
=
convert_channels
,
)
self
.
base_url
=
base_url
self
.
network
=
network
self
.
client
=
Client
(
base_url
=
base_url
)
def
_get_timeseries
(
self
,
starttime
:
UTCDateTime
,
endtime
:
UTCDateTime
,
observatory
:
str
,
channel
:
str
,
type
:
DataType
,
interval
:
DataInterval
,
add_empty_channels
:
bool
=
True
,
)
->
Trace
:
"""
get timeseries data for a single channel
Parameters
----------
starttime: UTCDateTime
the starttime of requested data
endtime: UTCDateTime
the endtime of requested data
observatory: str
observatory id
channel: str
channel name
type: {
"
adjusted
"
,
"
definitive
"
,
"
quasi-definitive
"
,
"
variation
"
}
data type
interval: {
"
tenhertz
"
,
"
second
"
,
"
minute
"
,
"
hour
"
,
"
day
"
}
data interval
add_empty_channels: bool
if True, returns channels without data as empty traces
Returns
-------
data: Trace
timeseries trace of the requested channel data
"""
sncl
=
IRISSNCL
.
get_sncl
(
data_type
=
type
,
element
=
channel
,
interval
=
interval
,
station
=
observatory
,
network
=
self
.
network
,
location
=
self
.
locationCode
,
)
filter
=
[
"
correct
"
]
if
sncl
.
channel
[
1
]
in
[
"
E
"
,
"
Y
"
]:
filter
=
[]
data
=
self
.
client
.
timeseries
(
network
=
sncl
.
network
,
station
=
sncl
.
station
,
location
=
sncl
.
location
,
channel
=
sncl
.
channel
,
starttime
=
starttime
,
endtime
=
endtime
,
filter
=
filter
,
)
data
.
merge
()
if
data
.
count
()
==
0
and
add_empty_channels
:
data
+=
self
.
_get_empty_trace
(
starttime
=
starttime
,
endtime
=
endtime
,
observatory
=
observatory
,
channel
=
channel
,
data_type
=
type
,
interval
=
interval
,
network
=
sncl
.
network
,
location
=
sncl
.
location
,
)
if
data
.
count
()
!=
0
:
TimeseriesUtility
.
pad_and_trim_trace
(
trace
=
data
[
0
],
starttime
=
starttime
,
endtime
=
endtime
)
self
.
_set_metadata
(
data
,
observatory
,
channel
,
type
,
interval
)
return
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