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
af2548e9
Commit
af2548e9
authored
7 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
bug fix in bin_fit + import optimization
parent
b0ecd90d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
wetb/signal/filters/_despike.py
+3
-2
3 additions, 2 deletions
wetb/signal/filters/_despike.py
wetb/signal/filters/first_order.py
+4
-1
4 additions, 1 deletion
wetb/signal/filters/first_order.py
wetb/signal/fit/_bin_fit.py
+4
-3
4 additions, 3 deletions
wetb/signal/fit/_bin_fit.py
with
11 additions
and
6 deletions
wetb/signal/filters/_despike.py
+
3
−
2
View file @
af2548e9
...
...
@@ -4,7 +4,7 @@ Created on 13/07/2016
@author: MMPE
'''
import
numpy
as
np
from
wetb.signal.filters
import
replacer
,
frq_filters
from
wetb.signal.filters
import
replacer
replace_by_nan
=
replacer
.
replace_by_nan
...
...
@@ -62,7 +62,8 @@ def despike(data, spike_length, spike_finder=univeral_thresshold_finder, spike_r
if
plt
:
plt
.
plot
(
data
,
label
=
'
Input
'
)
data
=
np
.
array
(
data
).
copy
()
lp_data
=
low_pass
(
data
,
spike_length
,
1
)
from
wetb.signal.filters
import
frq_filters
lp_data
=
frq_filters
.
low_pass
(
data
,
spike_length
,
1
)
hp_data
=
data
-
lp_data
hp_data
=
frq_filters
.
high_pass
(
data
,
spike_length
*
4
,
1
,
order
=
2
)
#spike_length, sample_frq/2, 1, order=1)
...
...
This diff is collapsed.
Click to expand it.
wetb/signal/filters/first_order.py
+
4
−
1
View file @
af2548e9
...
...
@@ -4,13 +4,16 @@ Created on 10/01/2015
@author: mmpe
'''
import
numpy
as
np
from
wetb.signal.filters
import
cy_filters
def
low_pass
(
input
,
delta_t
,
tau
,
method
=
1
):
from
wetb.signal.filters
import
cy_filters
if
isinstance
(
tau
,
(
int
,
float
)):
return
cy_filters
.
cy_low_pass_filter
(
input
.
astype
(
np
.
float64
),
delta_t
,
tau
)
else
:
return
cy_filters
.
cy_dynamic_low_pass_filter
(
input
.
astype
(
np
.
float64
),
delta_t
,
tau
,
method
)
def
high_pass
(
input
,
delta_t
,
tau
):
from
wetb.signal.filters
import
cy_filters
return
cy_filters
.
cy_high_pass_filter
(
input
.
astype
(
np
.
float64
),
delta_t
,
tau
)
This diff is collapsed.
Click to expand it.
wetb/signal/fit/_bin_fit.py
+
4
−
3
View file @
af2548e9
...
...
@@ -77,7 +77,7 @@ def bin_fit(x,y, bins=10, kind='linear', bin_func=np.nanmean, bin_min_count=3, l
lower
,
upper
=
lower_upper
#Add value to min(x)
if
bin_x_fit
[
0
]
>
np
.
nanmin
(
x
):
if
bin_x_fit
[
0
]
>
np
.
nanmin
(
x
)
or
np
.
isnan
(
bin_y_fit
[
0
])
:
if
lower
==
'
extrapolate
'
:
bin_y_fit
=
np
.
r_
[
bin_y_fit
[
0
]
-
(
bin_x_fit
[
0
]
-
np
.
nanmin
(
x
))
*
(
bin_y_fit
[
1
]
-
bin_y_fit
[
0
])
/
(
bin_x_fit
[
1
]
-
bin_x_fit
[
0
]),
bin_y_fit
]
...
...
@@ -91,7 +91,7 @@ def bin_fit(x,y, bins=10, kind='linear', bin_func=np.nanmean, bin_min_count=3, l
raise
NotImplementedError
(
"
Argument for handling lower observations, %s, not implemented
"
%
lower
)
#add value to max(x)
if
bin_x_fit
[
-
1
]
<
np
.
nanmax
(
x
):
if
bin_x_fit
[
-
1
]
<
np
.
nanmax
(
x
)
or
np
.
isnan
(
bin_y_fit
[
-
1
])
:
if
upper
==
'
extrapolate
'
:
bin_y_fit
=
np
.
r_
[
bin_y_fit
,
bin_y_fit
[
-
1
]
+
(
np
.
nanmax
(
x
)
-
bin_x_fit
[
-
1
])
*
(
bin_y_fit
[
-
1
]
-
bin_y_fit
[
-
2
])
/
(
bin_x_fit
[
-
1
]
-
bin_x_fit
[
-
2
])
]
bin_x_fit
=
np
.
r_
[
bin_x_fit
,
np
.
nanmax
(
x
)]
...
...
@@ -194,6 +194,7 @@ def _interpolate_fit(bin_x_fit, bin_y_fit, kind='linear'):
x
=
x
[:].
copy
().
astype
(
np
.
float
)
x
[
x
<
bin_x_fit
[
0
]]
=
np
.
nan
x
[
x
>
bin_x_fit
[
-
1
]]
=
np
.
nan
return
interp1d
(
bin_x_fit
,
bin_y_fit
,
kind
)(
x
[:])
m
=
~
(
np
.
isnan
(
bin_x_fit
)
|
np
.
isnan
(
bin_y_fit
))
return
interp1d
(
bin_x_fit
[
m
],
bin_y_fit
[
m
],
kind
)(
x
[:])
return
fit
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