Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
toolbox
WindEnergyToolbox
Commits
b0ecd90d
Commit
b0ecd90d
authored
7 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
type in differentiation
parent
6d85bd66
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
wetb/signal/filters/_differentiation.py
+13
-3
13 additions, 3 deletions
wetb/signal/filters/_differentiation.py
wetb/signal/tests/test_differentiation.py
+2
-0
2 additions, 0 deletions
wetb/signal/tests/test_differentiation.py
with
15 additions
and
3 deletions
wetb/signal/filters/_differentiation.py
+
13
−
3
View file @
b0ecd90d
...
@@ -3,15 +3,19 @@ Created on 29. mar. 2017
...
@@ -3,15 +3,19 @@ Created on 29. mar. 2017
@author: mmpe
@author: mmpe
'''
'''
from
wetb.signal.filters.frq_filters
import
low_pass
import
numpy
as
np
import
numpy
as
np
def
differentiation
(
x
,
sample_frq
=
None
,
cutoff_frq
=
None
):
def
differentiation
(
x
,
type
=
'
center
'
,
sample_frq
=
None
,
cutoff_frq
=
None
):
"""
Differentiate the signal
"""
Differentiate the signal
Parameters
Parameters
----------
----------
x : array_like
x : array_like
The input signal
The input signal
type : {
'
right
'
,
'
center
'
,
'
left
'
}
right: change from current to next observation
\n
center: average change from previous to next observation
\n
left: change from previous to current observation
\n
sample_frq : int, float or None, optional
sample_frq : int, float or None, optional
sample frequency of signal (only required if low pass filer is applied)
sample frequency of signal (only required if low pass filer is applied)
cutoff_frq : int, float or None, optional
cutoff_frq : int, float or None, optional
...
@@ -30,8 +34,14 @@ def differentiation(x,sample_frq=None, cutoff_frq=None):
...
@@ -30,8 +34,14 @@ def differentiation(x,sample_frq=None, cutoff_frq=None):
if
cutoff_frq
is
not
None
:
if
cutoff_frq
is
not
None
:
assert
sample_frq
is
not
None
,
"
Argument sample_frq must be set to apply low pass filter
"
assert
sample_frq
is
not
None
,
"
Argument sample_frq must be set to apply low pass filter
"
from
wetb.signal.filters.frq_filters
import
low_pass
x
=
low_pass
(
x
,
sample_frq
,
cutoff_frq
)
x
=
low_pass
(
x
,
sample_frq
,
cutoff_frq
)
else
:
else
:
x
=
np
.
array
(
x
)
x
=
np
.
array
(
x
)
dy
=
np
.
r_
[
x
[
1
]
-
x
[
0
],
(
x
[
2
:]
-
x
[:
-
2
])
/
2
,
x
[
-
1
]
-
x
[
-
2
]]
if
type
==
"
left
"
:
dy
=
np
.
r_
[
np
.
nan
,
x
[
1
:]
-
x
[:
-
1
]]
if
type
==
"
center
"
:
dy
=
np
.
r_
[
x
[
1
]
-
x
[
0
],
(
x
[
2
:]
-
x
[:
-
2
])
/
2
,
x
[
-
1
]
-
x
[
-
2
]]
if
type
==
"
right
"
:
dy
=
np
.
r_
[
x
[
1
:]
-
x
[:
-
1
],
np
.
nan
]
return
dy
return
dy
\ No newline at end of file
This diff is collapsed.
Click to expand it.
wetb/signal/tests/test_differentiation.py
+
2
−
0
View file @
b0ecd90d
...
@@ -12,6 +12,8 @@ class Test(unittest.TestCase):
...
@@ -12,6 +12,8 @@ class Test(unittest.TestCase):
def
testDifferentiation
(
self
):
def
testDifferentiation
(
self
):
np
.
testing
.
assert_array_equal
(
differentiation
([
1
,
2
,
1
,
0
,
1
,
1
]),
[
1
,
0
,
-
1
,
0
,.
5
,
0
])
np
.
testing
.
assert_array_equal
(
differentiation
([
1
,
2
,
1
,
0
,
1
,
1
]),
[
1
,
0
,
-
1
,
0
,.
5
,
0
])
np
.
testing
.
assert_array_equal
(
differentiation
([
1
,
2
,
1
,
0
,
1
,
1
],
'
left
'
),
[
np
.
nan
,
1
,
-
1
,
-
1
,
1
,
0
])
np
.
testing
.
assert_array_equal
(
differentiation
([
1
,
2
,
1
,
0
,
1
,
1
],
'
right
'
),
[
1
,
-
1
,
-
1
,
1
,
0
,
np
.
nan
])
...
...
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