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
0927b8b9
Commit
0927b8b9
authored
6 years ago
by
Jeremy M Fee
Browse files
Options
Downloads
Patches
Plain Diff
Add channels parameter to TimeseriesUtility.get_stream_gaps
parent
bf15c8ff
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/TimeseriesUtility.py
+4
-1
4 additions, 1 deletion
geomagio/TimeseriesUtility.py
test/TimeseriesUtility_test.py
+19
-0
19 additions, 0 deletions
test/TimeseriesUtility_test.py
with
23 additions
and
1 deletion
geomagio/TimeseriesUtility.py
+
4
−
1
View file @
0927b8b9
...
@@ -4,7 +4,7 @@ import numpy
...
@@ -4,7 +4,7 @@ import numpy
import
obspy.core
import
obspy.core
def
get_stream_gaps
(
stream
):
def
get_stream_gaps
(
stream
,
channels
=
None
):
"""
Get gaps in a given stream
"""
Get gaps in a given stream
Parameters
Parameters
----------
----------
...
@@ -12,6 +12,7 @@ def get_stream_gaps(stream):
...
@@ -12,6 +12,7 @@ def get_stream_gaps(stream):
the stream to check for gaps
the stream to check for gaps
channels: array_like
channels: array_like
list of channels to check for gaps
list of channels to check for gaps
Default is None (check all channels).
Returns
Returns
-------
-------
...
@@ -25,6 +26,8 @@ def get_stream_gaps(stream):
...
@@ -25,6 +26,8 @@ def get_stream_gaps(stream):
gaps
=
{}
gaps
=
{}
for
trace
in
stream
:
for
trace
in
stream
:
channel
=
trace
.
stats
.
channel
channel
=
trace
.
stats
.
channel
if
channels
is
not
None
and
channel
not
in
channels
:
continue
gaps
[
channel
]
=
get_trace_gaps
(
trace
)
gaps
[
channel
]
=
get_trace_gaps
(
trace
)
return
gaps
return
gaps
...
...
This diff is collapsed.
Click to expand it.
test/TimeseriesUtility_test.py
+
19
−
0
View file @
0927b8b9
...
@@ -36,6 +36,25 @@ def test_get_stream_gaps():
...
@@ -36,6 +36,25 @@ def test_get_stream_gaps():
# no gaps in Z channel
# no gaps in Z channel
assert_equals
(
len
(
gaps
[
'
Z
'
]),
0
)
assert_equals
(
len
(
gaps
[
'
Z
'
]),
0
)
def
test_get_stream_gaps_channels
():
"""
TimeseriesUtility_test.test_get_stream_gaps_channels()
test that gaps are only checked in specified channels.
"""
stream
=
Stream
stream
=
Stream
([
__create_trace
(
'
H
'
,
[
numpy
.
nan
,
1
,
1
,
numpy
.
nan
,
numpy
.
nan
]),
__create_trace
(
'
Z
'
,
[
0
,
0
,
0
,
1
,
1
,
1
])
])
for
trace
in
stream
:
# set time of first sample
trace
.
stats
.
starttime
=
UTCDateTime
(
'
2015-01-01T00:00:00Z
'
)
# set sample rate to 1 second
trace
.
stats
.
delta
=
1
# find gaps
gaps
=
TimeseriesUtility
.
get_stream_gaps
(
stream
,
[
'
Z
'
])
assert_equals
(
'
H
'
in
gaps
,
False
)
assert_equals
(
len
(
gaps
[
'
Z
'
]),
0
)
def
test_get_trace_gaps
():
def
test_get_trace_gaps
():
"""
TimeseriesUtility_test.test_get_trace_gaps()
"""
TimeseriesUtility_test.test_get_trace_gaps()
...
...
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