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
2e9dbf42
Commit
2e9dbf42
authored
5 years ago
by
Cain, Payton David
Browse files
Options
Downloads
Patches
Plain Diff
Input and output intervals set by get_delta_from_interval method
parent
8aefe105
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/algorithm/FilterAlgorithm.py
+9
-23
9 additions, 23 deletions
geomagio/algorithm/FilterAlgorithm.py
with
9 additions
and
23 deletions
geomagio/algorithm/FilterAlgorithm.py
+
9
−
23
View file @
2e9dbf42
...
...
@@ -5,6 +5,7 @@ from numpy.lib import stride_tricks as npls
import
scipy.signal
as
sps
from
obspy.core
import
Stream
,
Stats
import
json
from
..
import
TimeseriesUtility
as
tu
class
FilterAlgorithm
(
Algorithm
):
...
...
@@ -31,8 +32,6 @@ class FilterAlgorithm(Algorithm):
# Initialize filter to execute filtering step with custom coefficients
if
self
.
filtertype
==
'
custom
'
:
self
.
load_state
()
self
.
decimation
=
int
(
self
.
output_sample_period
/
self
.
input_sample_period
)
self
.
numtaps
=
len
(
self
.
window
)
# initialize filter to execute cascading filtering steps
else
:
...
...
@@ -125,7 +124,7 @@ class FilterAlgorithm(Algorithm):
if
self
.
filtertype
==
'
custom
'
:
for
trace
in
stream
:
data
=
trace
.
data
step
=
self
.
decimation
step
=
int
(
output_sample_period
/
input_sample_period
)
filtered
=
self
.
firfilter
(
data
,
self
.
window
,
step
)
stats
=
Stats
(
trace
.
stats
)
stats
.
starttime
=
trace
.
stats
.
starttime
+
\
...
...
@@ -141,7 +140,7 @@ class FilterAlgorithm(Algorithm):
# set stop index to where the sampling period in steparr
# equals the desired output sample period
stop_idx
=
np
.
argwhere
(
self
.
steparr
==
self
.
output_sample_period
)[
0
][
0
]
stop_idx
=
np
.
argwhere
(
self
.
steparr
==
output_sample_period
)[
0
][
0
]
for
trace
in
stream
:
# reinitialize input sample period
input_sample_period
=
self
.
input_sample_period
...
...
@@ -311,7 +310,8 @@ class FilterAlgorithm(Algorithm):
parser: ArgumentParser
command line argument parser
"""
# input and output time intervals are managed by Controller
# input and output time intervals are managed
# by Controller and TimeriesUtility
parser
.
add_argument
(
'
--filter-type
'
,
help
=
'
Specify default filters or custom filter
'
,
...
...
@@ -342,21 +342,7 @@ class FilterAlgorithm(Algorithm):
self
.
volt_conv
=
arguments
.
volt_conversion
self
.
bin_conv
=
arguments
.
bin_conversion
self
.
coeff_filename
=
arguments
.
filter_coefficients
if
arguments
.
input_interval
in
[
'
tenhertz
'
]:
self
.
input_sample_period
=
0.1
elif
arguments
.
input_interval
in
[
'
second
'
]:
self
.
input_sample_period
=
1.0
elif
arguments
.
input_interval
in
[
'
minute
'
]:
self
.
input_sample_period
=
60.0
elif
arguments
.
input_interval
in
[
'
hour
'
,
'
hourly
'
]:
self
.
input_sample_period
=
3600.0
if
arguments
.
output_interval
in
[
'
tenhertz
'
]:
self
.
output_sample_period
=
0.1
elif
arguments
.
output_interval
in
[
'
second
'
]:
self
.
output_sample_period
=
1.0
elif
arguments
.
output_interval
in
[
'
minute
'
]:
self
.
output_sample_period
=
60.0
elif
arguments
.
output_interval
in
[
'
hour
'
,
'
hourly
'
]:
self
.
output_sample_period
=
3600.0
input_interval
=
arguments
.
input_interval
output_interval
=
arguments
.
output_interval
self
.
input_sample_period
=
tu
.
get_delta_from_interval
(
input_interval
)
self
.
output_sample_period
=
tu
.
get_delta_from_interval
(
output_interval
)
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