Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wela
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Swain Lab
wela
Commits
513526ae
Commit
513526ae
authored
11 months ago
by
Peter Swain
Browse files
Options
Downloads
Patches
Plain Diff
feature: added Arin's butterfilter
parent
6f84a19a
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
butterfilter.py
+28
-0
28 additions, 0 deletions
butterfilter.py
with
28 additions
and
0 deletions
butterfilter.py
0 → 100644
+
28
−
0
View file @
513526ae
import
numpy
as
np
from
scipy
import
signal
def
butterfilter
(
timeseries
,
params
=
None
):
"""
Apply Butterworth filter to time series arranged in rows.
"""
# second-order-sections output
# by default, using a digital filter
if
params
is
None
:
params
=
{
"
order
"
:
2
,
"
critical_freqs
"
:
(
1
/
350
),
"
filter_type
"
:
"
highpass
"
,
"
sampling_freq
"
:
1
/
3
,
}
sos
=
signal
.
butter
(
N
=
params
[
"
order
"
],
Wn
=
params
[
"
critical_freqs
"
],
btype
=
params
[
"
filter_type
"
],
fs
=
params
[
"
sampling_freq
"
],
output
=
"
sos
"
,
)
# subtract time series by mean
timeseries_norm
=
timeseries
-
np
.
nanmean
(
timeseries
,
axis
=
1
).
reshape
(
timeseries
.
shape
[
0
],
1
)
filtered_timeseries
=
signal
.
sosfiltfilt
(
sos
,
timeseries_norm
,
axis
=
1
)
return
filtered_timeseries
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