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
c5913ca7
Commit
c5913ca7
authored
5 years ago
by
Jeremy M Fee
Browse files
Options
Downloads
Patches
Plain Diff
Update Algorithm and FilterAlgorithm can_produce_data to use utility methods
parent
62a163fd
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/algorithm/Algorithm.py
+8
-12
8 additions, 12 deletions
geomagio/algorithm/Algorithm.py
geomagio/algorithm/FilterAlgorithm.py
+25
-6
25 additions, 6 deletions
geomagio/algorithm/FilterAlgorithm.py
with
33 additions
and
18 deletions
geomagio/algorithm/Algorithm.py
+
8
−
12
View file @
c5913ca7
...
...
@@ -88,7 +88,9 @@ class Algorithm(object):
return
(
start
,
end
)
def
can_produce_data
(
self
,
starttime
,
endtime
,
stream
):
"""
Can Product data
"""
Can Produce data
By default require all channels to have data at the same time.
Parameters
----------
...
...
@@ -99,17 +101,11 @@ class Algorithm(object):
stream: obspy.core.Stream
The input stream we want to make certain has data for the algorithm
"""
input_gaps
=
TimeseriesUtility
.
get_merged_gaps
(
TimeseriesUtility
.
get_stream_gaps
(
stream
=
stream
,
channels
=
self
.
get_required_channels
()))
for
input_gap
in
input_gaps
:
# Check for gaps that include the entire range
if
(
starttime
>=
input_gap
[
0
]
and
starttime
<=
input_gap
[
1
]
and
endtime
<
input_gap
[
2
]):
return
False
return
True
return
TimeseriesUtility
.
has_all_channels
(
stream
,
self
.
get_required_channels
(),
starttime
,
endtime
)
def
get_next_starttime
(
self
):
"""
Check whether algorithm has a stateful start time.
...
...
This diff is collapsed.
Click to expand it.
geomagio/algorithm/FilterAlgorithm.py
+
25
−
6
View file @
c5913ca7
...
...
@@ -5,8 +5,7 @@ import scipy.signal as sps
from
numpy.lib
import
stride_tricks
as
npls
from
obspy.core
import
Stream
,
Stats
import
json
from
..TimeseriesUtility
import
get_delta_from_interval
from
..
import
TimeseriesUtility
STEPS
=
[
{
# 10 Hz to one second filter
...
...
@@ -101,6 +100,26 @@ class FilterAlgorithm(Algorithm):
steps
.
append
(
step
)
return
steps
def
can_produce_data
(
self
,
starttime
,
endtime
,
stream
):
"""
Can Produce data
The FilterAlgorithm can produce data for each channel independently.
Parameters
----------
starttime: UTCDateTime
start time of requested output
end : UTCDateTime
end time of requested output
stream: obspy.core.Stream
The input stream we want to make certain has data for the algorithm
"""
return
TimeseriesUtility
.
has_any_channels
(
stream
,
self
.
get_required_channels
(),
starttime
,
endtime
)
def
create_trace
(
self
,
channel
,
stats
,
data
):
"""
Utility to create a new trace object.
This may be necessary for more sophisticated metadata
...
...
@@ -282,8 +301,8 @@ class FilterAlgorithm(Algorithm):
Algorithm
.
configure
(
self
,
arguments
)
# intialize filter with command line arguments
self
.
coeff_filename
=
arguments
.
filter_coefficients
input_
interval
=
arguments
.
input
_interval
out
put_interval
=
arguments
.
output_
interval
self
.
in
put_sample_period
=
get_delta_from_interval
(
input_interval
)
self
.
output_sample_period
=
get_delta_from_interval
(
output_
interval
)
self
.
input_
sample_period
=
TimeseriesUtility
.
get_delta_from
_interval
(
arguments
.
in
put_interval
or
arguments
.
interval
)
self
.
out
put_sample_period
=
TimeseriesUtility
.
get_delta_from_interval
(
arguments
.
output_interval
or
arguments
.
interval
)
self
.
load_state
()
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