def test_rfcfilter(): # 1. Filtered signal y is the turning points of x. x = sea() y = rfcfilter(x[:, 1], h=0.0, method=1) assert_array_almost_equal( y[0:5], np.array([-1.2004945, 0.83950546, -0.09049454, -0.02049454, -0.09049454])) # 2. This removes all rainflow cycles with range less than 0.5. y1 = rfcfilter(x[:, 1], h=0.5, method=0) assert_array_almost_equal( y1[0:5], np.array([-1.2004945, 0.83950546, -0.43049454, 0.34950546, -0.51049454])) # return t = linspace(0, 7 * pi, 250) x = sin(t) + 0.1 * sin(50 * t) ind = findextrema(x) assert_array_almost_equal( ind, np.array( [1, 3, 4, 6, 7, 9, 11, 13, 14, 16, 18, 19, 21, 23, 25, 26, 28, 29, 31, 33, 35, 36, 38, 39, 41, 43, 45, 46, 48, 50, 51, 53, 55, 56, 58, 60, 61, 63, 65, 67, 68, 70, 71, 73, 75, 77, 78, 80, 81, 83, 85, 87, 88, 90, 92, 93, 95, 97, 99, 100, 102, 103, 105, 107, 109, 110, 112, 113, 115, 117, 119, 120, 122, 124, 125, 127, 129, 131, 132, 134, 135, 137, 139, 141, 142, 144, 145, 147, 149, 151, 152, 154, 156, 157, 159, 161, 162, 164, 166, 167, 169, 171, 173, 174, 176, 177, 179, 181, 183, 184, 186, 187, 189, 191, 193, 194, 196, 198, 199, 201, 203, 205, 206, 208, 209, 211, 213, 215, 216, 218, 219, 221, 223, 225, 226, 228, 230, 231, 233, 235, 237, 238, 240, 241, 243, 245, 247, 248])) _ti, tp = t[ind], x[ind] tp03 = rfcfilter(tp, 0.3) assert_array_almost_equal( tp03, np.array( [-0.00743352, 1.08753972, -1.07206545, 1.09550837, -1.07940458, 1.07849396, -1.0995006, 1.08094452, 0.11983423])) tp3 = findrfc_astm(tp) assert_array_almost_equal((77, 3), tp3.shape) # print(tp3[-5:]) assert_array_almost_equal(tp3[-5:], [[0.01552179, 0.42313414, 1.], [1.09750448, -0.00199612, 0.5], [1.09022256, -0.00927804, 0.5], [0.48055514, 0.60038938, 0.5], [0.03200274, 0.15183698, 0.5]]) assert_array_almost_equal(tp3[:5], [[0.03578165, 0.28906389, 1.], [0.03602834, 0.56726584, 1.], [0.03816623, 0.76461446, 1.], [0.0638364, 0.92381302, 1.], [0.07759006, 0.99628738, 1.]])
def test_rfcfilter(sea1): # 1. Filtered signal y is the turning points of x. x = sea1 y = rfcfilter(x[:, 1], h=0.0, method=1) assert_allclose( y[0:5], [-1.2004945, 0.83950546, -0.09049454, -0.02049454, -0.09049454]) # 2. This removes all rainflow cycles with range less than 0.5. y1 = rfcfilter(x[:, 1], h=0.5, method=0) assert_allclose( y1[0:5], [-1.2004945, 0.83950546, -0.43049454, 0.34950546, -0.51049454]) # return t = np.linspace(0, 7 * pi, 250) x = sin(t) + 0.1 * sin(50 * t) ind = findextrema(x) assert_allclose(ind, [ 1, 3, 4, 6, 7, 9, 11, 13, 14, 16, 18, 19, 21, 23, 25, 26, 28, 29, 31, 33, 35, 36, 38, 39, 41, 43, 45, 46, 48, 50, 51, 53, 55, 56, 58, 60, 61, 63, 65, 67, 68, 70, 71, 73, 75, 77, 78, 80, 81, 83, 85, 87, 88, 90, 92, 93, 95, 97, 99, 100, 102, 103, 105, 107, 109, 110, 112, 113, 115, 117, 119, 120, 122, 124, 125, 127, 129, 131, 132, 134, 135, 137, 139, 141, 142, 144, 145, 147, 149, 151, 152, 154, 156, 157, 159, 161, 162, 164, 166, 167, 169, 171, 173, 174, 176, 177, 179, 181, 183, 184, 186, 187, 189, 191, 193, 194, 196, 198, 199, 201, 203, 205, 206, 208, 209, 211, 213, 215, 216, 218, 219, 221, 223, 225, 226, 228, 230, 231, 233, 235, 237, 238, 240, 241, 243, 245, 247, 248 ]) _ti, tp = t[ind], x[ind] tp03 = rfcfilter(tp, 0.3) # print(tp03.tolist()) truth = [ -0.007433524853697526, 1.0875397175924215, -1.0720654490829054, 1.0955083650755328, -1.0794045843842426, 1.0784939627613357, -1.0995005995649583, 1.0809445217915996, 0.11983423290349654 ] assert_allclose(tp03, truth) tp3 = findrfc_astm(tp) assert_allclose((77, 3), tp3.shape) # print(tp3[-5:].tolist()) assert_allclose(tp3[-5:], [[0.01552179103405038, 0.4231341427960734, 1.0], [1.0975044823202456, -0.001996117244712714, 0.5], [1.090222560678279, -0.00927803888667933, 0.5], [0.48055514444405156, 0.600389377347548, 0.5], [0.032002742614076624, 0.15183697551757316, 0.5]]) # print(tp3[:5].tolist()) assert_allclose(tp3[:5], [[0.035781645324019146, 0.28906389183961456, 1.0], [0.03602834384593512, 0.5672658361052029, 1.0], [0.038166226239640555, 0.7646144604852383, 1.0], [0.06383640016547976, 0.9238130173264235, 1.0], [0.07759005562881188, 0.9962873791766909, 1.0]])
def test_rfcfilter(): # 1. Filtered signal y is the turning points of x. x = sea() y = rfcfilter(x[:, 1], h=0.0, method=1) assert_array_almost_equal( y[0:5], np.array( [-1.2004945, 0.83950546, -0.09049454, -0.02049454, -0.09049454])) # 2. This removes all rainflow cycles with range less than 0.5. y1 = rfcfilter(x[:, 1], h=0.5, method=0) assert_array_almost_equal( y1[0:5], np.array( [-1.2004945, 0.83950546, -0.43049454, 0.34950546, -0.51049454])) # return t = linspace(0, 7 * pi, 250) x = sin(t) + 0.1 * sin(50 * t) ind = findextrema(x) assert_array_almost_equal( ind, np.array([ 1, 3, 4, 6, 7, 9, 11, 13, 14, 16, 18, 19, 21, 23, 25, 26, 28, 29, 31, 33, 35, 36, 38, 39, 41, 43, 45, 46, 48, 50, 51, 53, 55, 56, 58, 60, 61, 63, 65, 67, 68, 70, 71, 73, 75, 77, 78, 80, 81, 83, 85, 87, 88, 90, 92, 93, 95, 97, 99, 100, 102, 103, 105, 107, 109, 110, 112, 113, 115, 117, 119, 120, 122, 124, 125, 127, 129, 131, 132, 134, 135, 137, 139, 141, 142, 144, 145, 147, 149, 151, 152, 154, 156, 157, 159, 161, 162, 164, 166, 167, 169, 171, 173, 174, 176, 177, 179, 181, 183, 184, 186, 187, 189, 191, 193, 194, 196, 198, 199, 201, 203, 205, 206, 208, 209, 211, 213, 215, 216, 218, 219, 221, 223, 225, 226, 228, 230, 231, 233, 235, 237, 238, 240, 241, 243, 245, 247, 248 ])) _ti, tp = t[ind], x[ind] tp03 = rfcfilter(tp, 0.3) assert_array_almost_equal( tp03, np.array([ -0.00743352, 1.08753972, -1.07206545, 1.09550837, -1.07940458, 1.07849396, -1.0995006, 1.08094452, 0.11983423 ])) tp3 = findrfc_astm(tp) assert_array_almost_equal((77, 3), tp3.shape) # print(tp3[-5:]) assert_array_almost_equal( tp3[-5:], [[0.01552179, 0.42313414, 1.], [1.09750448, -0.00199612, 0.5], [1.09022256, -0.00927804, 0.5], [0.48055514, 0.60038938, 0.5], [0.03200274, 0.15183698, 0.5]]) assert_array_almost_equal( tp3[:5], [[0.03578165, 0.28906389, 1.], [0.03602834, 0.56726584, 1.], [0.03816623, 0.76461446, 1.], [0.0638364, 0.92381302, 1.], [0.07759006, 0.99628738, 1.]])
def test_rfcfilter(): # 1. Filtered signal y is the turning points of x. x = sea() y = rfcfilter(x[:, 1], h=0, method=1) assert_array_almost_equal( y[0:5], np.array( [-1.2004945, 0.83950546, -0.09049454, -0.02049454, -0.09049454])) # 2. This removes all rainflow cycles with range less than 0.5. y1 = rfcfilter(x[:, 1], h=0.5) assert_array_almost_equal( y1[0:5], np.array( [-1.2004945, 0.83950546, -0.43049454, 0.34950546, -0.51049454])) t = linspace(0, 7 * pi, 250) x = sin(t) + 0.1 * sin(50 * t) ind = findextrema(x) assert_array_almost_equal( ind, np.array([ 1, 3, 4, 6, 7, 9, 11, 13, 14, 16, 18, 19, 21, 23, 25, 26, 28, 29, 31, 33, 35, 36, 38, 39, 41, 43, 45, 46, 48, 50, 51, 53, 55, 56, 58, 60, 61, 63, 65, 67, 68, 70, 71, 73, 75, 77, 78, 80, 81, 83, 85, 87, 88, 90, 92, 93, 95, 97, 99, 100, 102, 103, 105, 107, 109, 110, 112, 113, 115, 117, 119, 120, 122, 124, 125, 127, 129, 131, 132, 134, 135, 137, 139, 141, 142, 144, 145, 147, 149, 151, 152, 154, 156, 157, 159, 161, 162, 164, 166, 167, 169, 171, 173, 174, 176, 177, 179, 181, 183, 184, 186, 187, 189, 191, 193, 194, 196, 198, 199, 201, 203, 205, 206, 208, 209, 211, 213, 215, 216, 218, 219, 221, 223, 225, 226, 228, 230, 231, 233, 235, 237, 238, 240, 241, 243, 245, 247, 248 ])) _ti, tp = t[ind], x[ind] tp03 = rfcfilter(tp, 0.3) assert_array_almost_equal( tp03, np.array([ -0.00743352, 1.08753972, -1.07206545, 1.09550837, -1.07940458, 1.07849396, -1.0995006, 1.08094452, 0.11983423 ]))
def test_rfcfilter(): # 1. Filtered signal y is the turning points of x. x = sea() y = rfcfilter(x[:, 1], h=0, method=1) assert_array_almost_equal( y[0:5], np.array([-1.2004945, 0.83950546, -0.09049454, -0.02049454, -0.09049454])) # 2. This removes all rainflow cycles with range less than 0.5. y1 = rfcfilter(x[:, 1], h=0.5) assert_array_almost_equal( y1[0:5], np.array([-1.2004945, 0.83950546, -0.43049454, 0.34950546, -0.51049454])) t = linspace(0, 7 * pi, 250) x = sin(t) + 0.1 * sin(50 * t) ind = findextrema(x) assert_array_almost_equal( ind, np.array( [1, 3, 4, 6, 7, 9, 11, 13, 14, 16, 18, 19, 21, 23, 25, 26, 28, 29, 31, 33, 35, 36, 38, 39, 41, 43, 45, 46, 48, 50, 51, 53, 55, 56, 58, 60, 61, 63, 65, 67, 68, 70, 71, 73, 75, 77, 78, 80, 81, 83, 85, 87, 88, 90, 92, 93, 95, 97, 99, 100, 102, 103, 105, 107, 109, 110, 112, 113, 115, 117, 119, 120, 122, 124, 125, 127, 129, 131, 132, 134, 135, 137, 139, 141, 142, 144, 145, 147, 149, 151, 152, 154, 156, 157, 159, 161, 162, 164, 166, 167, 169, 171, 173, 174, 176, 177, 179, 181, 183, 184, 186, 187, 189, 191, 193, 194, 196, 198, 199, 201, 203, 205, 206, 208, 209, 211, 213, 215, 216, 218, 219, 221, 223, 225, 226, 228, 230, 231, 233, 235, 237, 238, 240, 241, 243, 245, 247, 248])) _ti, tp = t[ind], x[ind] tp03 = rfcfilter(tp, 0.3) assert_array_almost_equal( tp03, np.array( [-0.00743352, 1.08753972, -1.07206545, 1.09550837, -1.07940458, 1.07849396, -1.0995006, 1.08094452, 0.11983423]))