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
ffed3674
Commit
ffed3674
authored
4 years ago
by
Cain, Payton David
Committed by
Jeremy M Fee
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add controller arguments, change interval to period, and reformat interval method
parent
5aa97805
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
geomagio/algorithm/DbDtAlgorithm.py
+25
-8
25 additions, 8 deletions
geomagio/algorithm/DbDtAlgorithm.py
geomagio/algorithm/DbDtAlgoritm.py
+0
-64
0 additions, 64 deletions
geomagio/algorithm/DbDtAlgoritm.py
with
25 additions
and
72 deletions
geomagio/algorithm/DbDtAlgorithm.py
+
25
−
8
View file @
ffed3674
from
.Algorithm
import
Algorithm
from
..TimeseriesUtility
import
create_empty_trace
,
get_interval_from_delta
from
..TimeseriesUtility
import
(
create_empty_trace
,
get_interval_from_delta
,
get_delta_from_interval
,
)
import
numpy
as
np
from
obspy.core
import
Stream
,
Stats
class
DbDtAlgorithm
(
Algorithm
):
def
__init__
(
self
,
inchannels
=
None
,
outchannels
=
None
,
interval
=
None
):
def
__init__
(
self
,
inchannels
=
None
,
outchannels
=
None
,
period
=
None
):
"""
Derivative algorithm that takes derivative of timeseries using second order central differences(numpy.gradient)
"""
Algorithm
.
__init__
(
self
,
inchannels
=
None
,
outchannels
=
None
)
self
.
inchannels
=
inchannels
self
.
outchannels
=
outchannels
self
.
interval
=
interval
self
.
period
=
period
def
process
(
self
,
stream
):
"""
...
...
@@ -32,9 +36,9 @@ class DbDtAlgorithm(Algorithm):
for
trace
in
stream
:
dbdt
=
np
.
diff
(
trace
.
data
)
stats
=
Stats
(
trace
.
stats
)
stats
.
channel
=
"
{}_
_
DDT
"
.
format
(
stats
.
channel
)
stats
.
channel
=
"
{}_DDT
"
.
format
(
stats
.
channel
)
trace_out
=
create_empty_trace
(
starttime
=
stats
.
starttime
+
self
.
interval
,
starttime
=
stats
.
starttime
+
self
.
period
,
endtime
=
stats
.
endtime
,
observatory
=
stats
.
station
,
type
=
stats
.
location
,
...
...
@@ -48,17 +52,30 @@ class DbDtAlgorithm(Algorithm):
out
+=
trace_out
return
out
def
get_interval
(
self
,
start
):
def
get_
input_
interval
(
self
,
start
,
end
,
observatory
=
None
,
channels
=
None
):
"""
Adjust time interval for input data.
Parameters
----------
start : obspy.core.UTCDatetime
input starttime
end : obspy.core.UTCDatetime
input endtime
Returns
-------
start : obspy.core.UTCDatetime
output starttime
end : obspy.core.UTCDatetime
output endtime
"""
start
-=
self
.
interval
return
start
start
-=
self
.
period
return
(
start
,
end
)
def
configure
(
self
,
arguments
):
"""
Configure algorithm using comand line arguments.
Parameters
----------
arguments: Namespace
parsed command line arguments
"""
self
.
period
=
get_delta_from_interval
(
arguments
.
interval
)
This diff is collapsed.
Click to expand it.
geomagio/algorithm/DbDtAlgoritm.py
deleted
100644 → 0
+
0
−
64
View file @
5aa97805
from
.Algorithm
import
Algorithm
from
..TimeseriesUtility
import
create_empty_trace
,
get_interval_from_delta
import
numpy
as
np
from
obspy.core
import
Stream
,
Stats
class
DbDtAlgorithm
(
Algorithm
):
def
__init__
(
self
,
inchannels
=
None
,
outchannels
=
None
,
interval
=
None
):
"""
Derivative algorithm that takes derivative of timeseries using second order central differences(numpy.gradient)
"""
Algorithm
.
__init__
(
self
,
inchannels
=
None
,
outchannels
=
None
)
self
.
inchannels
=
inchannels
self
.
outchannels
=
outchannels
self
.
interval
=
interval
def
process
(
self
,
stream
):
"""
Run algorithm for a stream.
Processes all traces in the stream.
Parameters
----------
stream : obspy.core.Stream
stream of data to process
Returns
-------
out : obspy.core.Stream
stream containing 1 trace per original trace.
"""
out
=
Stream
()
for
trace
in
stream
:
dbdt
=
np
.
diff
(
trace
.
data
)
stats
=
Stats
(
trace
.
stats
)
stats
.
channel
=
"
{}__DDT
"
.
format
(
stats
.
channel
)
trace_out
=
create_empty_trace
(
starttime
=
stats
.
starttime
,
endtime
=
stats
.
endtime
,
observatory
=
stats
.
station
,
type
=
stats
.
location
,
interval
=
get_interval_from_delta
(
stats
.
delta
),
channel
=
stats
.
channel
,
network
=
stats
.
network
,
station
=
stats
.
station
,
location
=
stats
.
location
,
)
trace_out
.
data
=
dbdt
out
+=
trace_out
return
out
def
get_interval
(
self
,
end
):
"""
Adjust time interval for input data.
Parameters
----------
end : obspy.core.UTCDatetime
input endtime
Returns
-------
end : obspy.core.UTCDatetime
output endtime
"""
end
+=
self
.
interval
return
end
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