Skip to content
Snippets Groups Projects
Commit 023a61bf authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

add debug stuff to test_windap3

parent 525941a4
No related branches found
No related tags found
No related merge requests found
...@@ -19,3 +19,4 @@ wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.sel ...@@ -19,3 +19,4 @@ wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.sel
wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.dat wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.dat
wetb/prepost/tests/data/demo_dlc/remote* wetb/prepost/tests/data/demo_dlc/remote*
/wetb/fatigue_tools/rainflowcounting/compile.py
...@@ -6,7 +6,8 @@ from builtins import str ...@@ -6,7 +6,8 @@ from builtins import str
from future import standard_library from future import standard_library
standard_library.install_aliases() standard_library.install_aliases()
import numpy as np import numpy as np
from wetb.fatigue_tools.rainflowcounting import peak_trough
from wetb.fatigue_tools.rainflowcounting import pair_range
def check_signal(signal): def check_signal(signal):
...@@ -73,16 +74,14 @@ def rainflow_windap(signal, levels=255., thresshold=(255 / 50)): ...@@ -73,16 +74,14 @@ def rainflow_windap(signal, levels=255., thresshold=(255 / 50)):
# If possible the module is compiled using cython otherwise the python implementation is used # If possible the module is compiled using cython otherwise the python implementation is used
from wetb.fatigue_tools.rainflowcounting.peak_trough import peak_trough
from wetb.fatigue_tools.rainflowcounting.pair_range import pair_range_amplitude_mean
#Convert to list of local minima/maxima where difference > thresshold #Convert to list of local minima/maxima where difference > thresshold
sig_ext = peak_trough(signal, thresshold) sig_ext = peak_trough.peak_trough(signal, thresshold)
#rainflow count #rainflow count
ampl_mean = pair_range_amplitude_mean(sig_ext) ampl_mean = pair_range.pair_range_amplitude_mean(sig_ext)
ampl_mean = np.array(ampl_mean) ampl_mean = np.array(ampl_mean)
ampl_mean = np.round(ampl_mean / thresshold) * gain * thresshold ampl_mean = np.round(ampl_mean / thresshold) * gain * thresshold
......
...@@ -59,7 +59,8 @@ class TestFatigueTools(unittest.TestCase): ...@@ -59,7 +59,8 @@ class TestFatigueTools(unittest.TestCase):
def test_windap3(self): def test_windap3(self):
data = Hawc2io.ReadHawc2(testfilepath + "test").ReadBinary([2]).flatten() data = Hawc2io.ReadHawc2(testfilepath + "test").ReadBinary([2]).flatten()
from wetb.fatigue_tools.rainflowcounting import peak_trough from wetb.fatigue_tools.rainflowcounting import peak_trough
self.assertTrue(peak_trough.__file__.lower()[-4:] == ".pyd" or peak_trough.__file__.lower()[-3:] == ".so", "not compiled, %s"%sys.executable) self.assertTrue(peak_trough.__file__.lower()[-4:] == ".pyd" or peak_trough.__file__.lower()[-3:] == ".so",
"not compiled, %s, %s\n%s"%(sys.executable, peak_trough.__file__, os.listdir(os.path.dirname(peak_trough.__file__))))
np.testing.assert_array_equal(cycle_matrix(data, 4, 4, rainflow_func=rainflow_windap)[0], np.array([[ 14., 65., 39., 24.], np.testing.assert_array_equal(cycle_matrix(data, 4, 4, rainflow_func=rainflow_windap)[0], np.array([[ 14., 65., 39., 24.],
[ 0., 1., 4., 0.], [ 0., 1., 4., 0.],
[ 0., 0., 0., 0.], [ 0., 0., 0., 0.],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment