diff --git a/.gitignore b/.gitignore index 6d3feb6cc699a5af67da7cbd28e2fcf98554c058..5c2598f27ad1770a1ed8d9496ce0370c682371d5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.sel wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.dat wetb/prepost/tests/data/demo_dlc/remote* +/wetb/fatigue_tools/rainflowcounting/compile.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 74147a94fe67733d80d4035bbf6c5b4b15670bea..1e2bb25c45a3669bf572ccc112fe55d6f540cccf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,5 @@ test-3.4: image: mmpe/wetb script: #- python3 setup.py test - - pip3 install pytest-cov - python3 -m pytest --cov=wetb diff --git a/wetb/fatigue_tools/rainflowcounting/rainflowcount.py b/wetb/fatigue_tools/rainflowcounting/rainflowcount.py index 8d1bdd76e8bb550114bb552e5ae6985a8c9b427b..bac7c262bbe9582c28961aaabea600b9fd6d9d6b 100644 --- a/wetb/fatigue_tools/rainflowcounting/rainflowcount.py +++ b/wetb/fatigue_tools/rainflowcounting/rainflowcount.py @@ -6,7 +6,8 @@ from builtins import str from future import standard_library standard_library.install_aliases() import numpy as np - +from wetb.fatigue_tools.rainflowcounting import peak_trough +from wetb.fatigue_tools.rainflowcounting import pair_range def check_signal(signal): @@ -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 - 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 - sig_ext = peak_trough(signal, thresshold) + sig_ext = peak_trough.peak_trough(signal, thresshold) #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.round(ampl_mean / thresshold) * gain * thresshold diff --git a/wetb/fatigue_tools/tests/test_fatigue.py b/wetb/fatigue_tools/tests/test_fatigue.py index 904c8717db8caccc45055d66a3434e0ddb359a44..6e7c89f3219bf76ded45efa1fd1b5078dd1f3da5 100644 --- a/wetb/fatigue_tools/tests/test_fatigue.py +++ b/wetb/fatigue_tools/tests/test_fatigue.py @@ -8,6 +8,7 @@ from __future__ import unicode_literals from __future__ import print_function from __future__ import absolute_import from future import standard_library +import sys standard_library.install_aliases() import unittest @@ -57,6 +58,9 @@ class TestFatigueTools(unittest.TestCase): def test_windap3(self): data = Hawc2io.ReadHawc2(testfilepath + "test").ReadBinary([2]).flatten() + 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, %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.], [ 0., 1., 4., 0.], [ 0., 0., 0., 0.], diff --git a/wetb/prepost/GenerateDLCs.py b/wetb/prepost/GenerateDLCs.py index 3fe2133a542227862e9af3f35e82aa642ae33ca6..5cb2fe9bc7f2150ea524441566780234ce6aa75c 100644 --- a/wetb/prepost/GenerateDLCs.py +++ b/wetb/prepost/GenerateDLCs.py @@ -274,4 +274,5 @@ if __name__ == '__main__': dest='folder', help='Destination folder name') opt = parser.parse_args() DLB = GenerateDLCCases() - DLB.execute(filename=opt.filename, folder=opt.folder) \ No newline at end of file + DLB.execute(filename=opt.filename, folder=opt.folder) + diff --git a/wetb/prepost/Simulations.py b/wetb/prepost/Simulations.py index 585d5af901ebe7c5681d7531fdedbfbef759df42..90d800a30c255e20710a8f97d593740af6a00b7a 100755 --- a/wetb/prepost/Simulations.py +++ b/wetb/prepost/Simulations.py @@ -5121,38 +5121,6 @@ class Cases(object): return envelope - def int_envelope(ch1,ch2,Nx): - # Function to interpolate envelopes and output arrays of same length - - # Number of points is defined by Nx + 1, where the + 1 is needed to - # close the curve - - upper = [] - lower = [] - - indmax = np.argmax(ch1) - indmin = np.argmin(ch1) - if indmax > indmin: - lower = np.array([ch1[indmin:indmax+1],ch2[indmin:indmax+1]]).T - upper = np.concatenate((np.array([ch1[indmax:],ch2[indmax:]]).T,\ - np.array([ch1[:indmin+1],ch2[:indmin+1]]).T),axis=0) - else: - upper = np.array([ch1[indmax:indmin+1,:],ch2[indmax:indmin+1,:]]).T - lower = np.concatenate((np.array([ch1[indmin:],ch2[indmin:]]).T,\ - np.array([ch1[:indmax+1],ch2[:indmax+1]]).T),axis=0) - - - int_1 = np.linspace(min(min(upper[:,0]),min(lower[:,0])),\ - max(max(upper[:,0]),max(upper[:,0])),Nx/2+1) - upper = np.flipud(upper) - int_2_up = np.interp(int_1,np.array(upper[:,0]),np.array(upper[:,1])) - int_2_low = np.interp(int_1,np.array(lower[:,0]),np.array(lower[:,1])) - - int_env = np.concatenate((np.array([int_1[:-1],int_2_up[:-1]]).T,\ - np.array([int_1[::-1],int_2_low[::-1]]).T),axis=0) - - return int_env - def envelope(self, silent=False, ch_list=[], append=''): """ Calculate envelopes and save them in a table. diff --git a/wetb/prepost/dlcdefs.py b/wetb/prepost/dlcdefs.py index 278e9b571302ce84549c239ff51a31f96c7f1e20..664897c33aa92206756b6157758173b005bd80e4 100644 --- a/wetb/prepost/dlcdefs.py +++ b/wetb/prepost/dlcdefs.py @@ -422,14 +422,14 @@ class Tests(unittest.TestCase): """ def setUp(self): - self.fpath = 'data/DLCs' + self.fpath = os.path.join(os.path.dirname(__file__), 'data/DLCs') def test_read_tag_exchange_file(self): df_list = misc.read_excel_files(self.fpath, fext='xlsx', pignore=None, sheet=0, pinclude=None) - df = df_list[list(df_list.keys())[0]] +# df = df_list[list(df_list.keys())[0]] # df.fillna('', inplace=True) # df.replace(';', False, inplace=True) @@ -440,4 +440,3 @@ class Tests(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/wetb/utils/cluster_tools/pbswrap.py b/wetb/utils/cluster_tools/pbswrap.py index 0c98858c316da877c2c158fff5d8cd982da172d8..e4bff2dafb40e5836cb412283e234f1e8d884597 100644 --- a/wetb/utils/cluster_tools/pbswrap.py +++ b/wetb/utils/cluster_tools/pbswrap.py @@ -359,34 +359,6 @@ def create_input(walltime='00:59:59', queue='xpresq', pbs_in='pbs_in/', ppn=1, return pbs_in_file -def test(): - - # sample output - FILE = open('tests/sampleoutput_pbsnodes', 'rb') - output = FILE.readlines() - FILE.close() - pbsnodes, nodes = parse_pbsnode_lall(output) - - # sample output - FILE = open('tests/sampleoutput_qstat', 'rb') - output = FILE.readlines() - FILE.close() - users, host, nodesload = parse_qstat_n1(output) - - print_node_loading(users, host, nodes, nodesload) - print_dashboard(users, host, pbsnodes) - - if __name__ == '__main__': - #command = 'pbsnodes -l all' # | cut -c 22-35 - - output = os.popen('pbsnodes -l all').readlines() - pbsnodes, nodes = parse_pbsnode_lall(output) - - output = os.popen('qstat -n1').readlines() - users, host, nodesload = parse_qstat_n1(output) - - print_node_loading(users, host, nodes, nodesload) - print_dashboard(users, host, pbsnodes) - + pass