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
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
wtlib
WindEnergyToolbox
Commits
8c00274a
Commit
8c00274a
authored
8 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
Changed amplitude bins to range 0-max(ampl[weights>0]) in fatigue-cycle_matrix to avoid empty bins
parent
c7ed24c1
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/fatigue_tools/fatigue.py
+5
-12
5 additions, 12 deletions
wetb/fatigue_tools/fatigue.py
wetb/fatigue_tools/tests/test_fatigue.py
+7
-0
7 additions, 0 deletions
wetb/fatigue_tools/tests/test_fatigue.py
with
12 additions
and
12 deletions
wetb/fatigue_tools/fatigue.py
+
5
−
12
View file @
8c00274a
...
...
@@ -116,8 +116,8 @@ def cycle_matrix(signals, ampl_bins=10, mean_bins=10, rainflow_func=rainflow_win
Parameters
----------
Signals : array-like or list of tuples
if array-like, the raw signal
if list of tuples, list of (weight, signal), e.g. [(0.1,sig1), (0.8,sig2), (.1,sig3)]
-
if array-like, the raw signal
\n
-
if list of tuples, list of (weight, signal), e.g. [(0.1,sig1), (0.8,sig2), (.1,sig3)]
\n
ampl_bins : int or array-like, optional
if int, Number of amplitude value bins (default is 10)
if array-like, the bin edges for amplitude
...
...
@@ -149,19 +149,12 @@ def cycle_matrix(signals, ampl_bins=10, mean_bins=10, rainflow_func=rainflow_win
"""
if
isinstance
(
signals
[
0
],
tuple
):
ampls
=
np
.
empty
((
0
,),
dtype
=
np
.
float64
)
means
=
np
.
empty
((
0
,),
dtype
=
np
.
float64
)
weights
=
np
.
empty
((
0
,),
dtype
=
np
.
float64
)
for
w
,
signal
in
signals
:
a
,
m
=
rainflow_func
(
signal
[:])
ampls
=
np
.
r_
[
ampls
,
a
]
means
=
np
.
r_
[
means
,
m
]
weights
=
np
.
r_
[
weights
,
(
np
.
zeros_like
(
a
)
+
w
)]
weights
,
ampls
,
means
=
np
.
array
([(
np
.
zeros_like
(
ampl
)
+
weight
,
ampl
,
mean
)
for
weight
,
signal
in
signals
for
ampl
,
mean
in
rainflow_func
(
signal
[:]).
T
],
dtype
=
np
.
float64
).
T
else
:
ampls
,
means
=
rainflow_func
(
signals
[:])
weights
=
np
.
ones_like
(
ampls
)
if
isinstance
(
ampl_bins
,
int
):
ampl_bins
=
np
.
linspace
(
0
,
1
,
num
=
ampl_bins
+
1
)
*
ampls
.
max
()
ampl_bins
=
np
.
linspace
(
0
,
1
,
num
=
ampl_bins
+
1
)
*
ampls
[
weights
>
0
]
.
max
()
cycles
,
ampl_edges
,
mean_edges
=
np
.
histogram2d
(
ampls
,
means
,
[
ampl_bins
,
mean_bins
],
weights
=
weights
)
ampl_bin_sum
=
np
.
histogram2d
(
ampls
,
means
,
[
ampl_bins
,
mean_bins
],
weights
=
weights
*
ampls
)[
0
]
...
...
@@ -169,7 +162,7 @@ def cycle_matrix(signals, ampl_bins=10, mean_bins=10, rainflow_func=rainflow_win
mask
=
(
cycles
>
0
)
ampl_bin_mean
[
mask
]
=
ampl_bin_sum
[
mask
]
/
cycles
[
mask
]
mean_bin_sum
=
np
.
histogram2d
(
ampls
,
means
,
[
ampl_bins
,
mean_bins
],
weights
=
weights
*
means
)[
0
]
mean_bin_mean
=
np
.
zeros_like
(
cycles
)
mean_bin_mean
=
np
.
zeros_like
(
cycles
)
+
np
.
nan
mean_bin_mean
[
cycles
>
0
]
=
mean_bin_sum
[
cycles
>
0
]
/
cycles
[
cycles
>
0
]
cycles
=
cycles
/
2
# to get full cycles
return
cycles
,
ampl_bin_mean
,
ampl_edges
,
mean_bin_mean
,
mean_edges
...
...
This diff is collapsed.
Click to expand it.
wetb/fatigue_tools/tests/test_fatigue.py
+
7
−
0
View file @
8c00274a
...
...
@@ -73,6 +73,13 @@ class TestFatigueTools(unittest.TestCase):
[
0.
,
1.
,
4.
,
0.
],
[
0.
,
0.
,
0.
,
0.
],
[
0.
,
1.
,
2.
,
0.
]])
/
2
,
0.001
)
def
test_astm_weighted
(
self
):
data
=
Hawc2io
.
ReadHawc2
(
testfilepath
+
"
test
"
).
ReadBinary
([
2
]).
flatten
()
np
.
testing
.
assert_allclose
(
cycle_matrix
([(
1
,
data
),(
1
,
data
)],
4
,
4
,
rainflow_func
=
rainflow_astm
)[
0
],
np
.
array
([[
24.
,
83.
,
53.
,
26.
],
[
0.
,
1.
,
4.
,
0.
],
[
0.
,
0.
,
0.
,
0.
],
[
0.
,
1.
,
2.
,
0.
]])
,
0.001
)
if
__name__
==
"
__main__
"
:
#import sys;sys.argv = ['', 'Test.testName']
...
...
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