示例#1
0
def test_findrfc():
    t = 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]
    for method in ['clib', 2, 1, 0]:
        ind1 = findrfc(tp, 0.3, method=method)
        if method in [1, 0]:
            ind1 = ind1[:-1]
        assert_allclose(ind1, [0, 9, 32, 53, 74, 95, 116, 137])
        # print(tp[ind1].tolist())
        truth =  [-0.007433524853697526, 1.0875397175924215, -1.0720654490829054,
                1.0955083650755328, -1.0794045843842426, 1.0784939627613357,
                -1.0995005995649583, 1.0809445217915996]
        assert_allclose(tp[ind1], truth)
示例#2
0
def test_findrfc():
    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]
    ind1 = findrfc(tp, 0.3)
    assert_array_almost_equal(ind1, np.array([0, 9, 32, 53, 74, 95, 116, 137]))
    assert_array_almost_equal(
        tp[ind1],
        np.array([
            -0.00743352, 1.08753972, -1.07206545, 1.09550837, -1.07940458,
            1.07849396, -1.0995006, 1.08094452
        ]))
示例#3
0
def test_findrfc():
    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]
    for method in ['clib', 2, 1, 0]:
        ind1 = findrfc(tp, 0.3, method=method)
        if method in [1, 0]:
            ind1 = ind1[:-1]
        assert_array_almost_equal(
            ind1,
            np.array([0, 9, 32, 53, 74, 95, 116, 137]))
        assert_array_almost_equal(
            tp[ind1],
            np.array(
                [-0.00743352, 1.08753972, -1.07206545, 1.09550837, -1.07940458,
                 1.07849396, -1.0995006, 1.08094452]))