当前位置: 首页>>代码示例>>Python>>正文


Python pywt.idwt函数代码示例

本文整理汇总了Python中pywt.idwt函数的典型用法代码示例。如果您正苦于以下问题:Python idwt函数的具体用法?Python idwt怎么用?Python idwt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了idwt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: func_2

def func_2():
    Fs = 5000
    T = 1 / Fs
    N = 2000

    t = np.linspace(0, N * T, N)
    y = np.sin(2 * np.pi * 10 * t)# + 0.1 * np.sin(2 * np.pi * 300 * t)
    y[500:1000] += 0.1 * np.sin(2 * np.pi * 500 * t[500:1000])

    [cA3, cD3, cD2, cD1] = pywt.wavedec(y, wavelet='db1', level=3)
    A3 = pywt.idwt(cA=cA3, cD=None, wavelet='db1')
    D3 = pywt.idwt(cA=None, cD=cD3, wavelet='db1')
    D2 = pywt.idwt(cA=None, cD=cD2, wavelet='db1')
    D1 = pywt.idwt(cA=None, cD=cD1, wavelet='db1')

    plt.subplot(511)
    plt.plot(y)
    plt.subplot(512)
    plt.plot(A3)
    plt.subplot(513)
    plt.plot(D1)
    plt.subplot(514)
    plt.plot(D2)
    plt.subplot(515)
    plt.plot(D3)

    plt.show()
开发者ID:BossKwei,项目名称:temp,代码行数:27,代码来源:dwt_1.py

示例2: iswt

def iswt(coefficients, wavelet):
    """
     Input parameters:
       coefficients
         approx and detail coefficients, arranged in level value
         exactly as output from swt:
         e.g. [(cA1, cD1), (cA2, cD2), ..., (cAn, cDn)]
       wavelet
         Either the name of a wavelet or a Wavelet object
   """
    output = coefficients[0][0].copy() # Avoid modification of input data
    #num_levels, equivalent to the decomposition level, n
    num_levels = len(coefficients)
    for j in range(num_levels,0,-1):
        step_size = int(math.pow(2, j-1))
        last_index = step_size
        _, cD = coefficients[num_levels - j]
        for first in range(last_index): # 0 to last_index - 1
            # Getting the indices that we will transform
            indices = arange(first, len(cD), step_size)
            # select the even indices
            even_indices = indices[0::2]
            # select the odd indices
            odd_indices = indices[1::2]
            # perform the inverse dwt on the selected indices,
            # making sure to use periodic boundary conditions
            x1 = pywt.idwt(output[even_indices], cD[even_indices],wavelet, 'per')
            x2 = pywt.idwt(output[odd_indices], cD[odd_indices],wavelet, 'per')
            # perform a circular shift right
            x2 = roll(x2, 1)
            # average and insert into the correct indices
            output[indices] = (x1 + x2)/2.
    return output
开发者ID:c-fos,项目名称:fEPSP_analyser_2,代码行数:33,代码来源:externalFunctions_lib.py

示例3: test_idwt_axis_arg

def test_idwt_axis_arg():
    x = [[3, 7, 1, 1], [-2, 5, 4, 6]]

    cA, cD = pywt.dwt(x, "db2", axis=1)

    x_ = pywt.idwt(cA, cD, "db2", axis=-1)
    x = pywt.idwt(cA, cD, "db2", axis=1)

    assert_allclose(x_, x)
开发者ID:rgommers,项目名称:pywt,代码行数:9,代码来源:test_dwt_idwt.py

示例4: test_idwt_single_axis

def test_idwt_single_axis():
    x = [[3, 7, 1, 1], [-2, 5, 4, 6]]

    cA, cD = pywt.dwt(x, "db2", axis=-1)

    x0 = pywt.idwt(cA[0], cD[0], "db2", axis=-1)
    x1 = pywt.idwt(cA[1], cD[1], "db2", axis=-1)

    assert_allclose(x[0], x0)
    assert_allclose(x[1], x1)
开发者ID:rgommers,项目名称:pywt,代码行数:10,代码来源:test_dwt_idwt.py

示例5: test_idwt_none_input

def test_idwt_none_input():
    # None input equals arrays of zeros of the right length
    res1 = pywt.idwt([1, 2, 0, 1], None, 'db2', 'symmetric')
    res2 = pywt.idwt([1, 2, 0, 1], [0, 0, 0, 0], 'db2', 'symmetric')
    assert_allclose(res1, res2, rtol=1e-15, atol=1e-15)

    res1 = pywt.idwt(None, [1, 2, 0, 1], 'db2', 'symmetric')
    res2 = pywt.idwt([0, 0, 0, 0], [1, 2, 0, 1], 'db2', 'symmetric')
    assert_allclose(res1, res2, rtol=1e-15, atol=1e-15)

    # Only one argument at a time can be None
    assert_raises(ValueError, pywt.idwt, None, None, 'db2', 'symmetric')
开发者ID:pombredanne,项目名称:pywt,代码行数:12,代码来源:test_dwt_idwt.py

示例6: test_idwt_single_axis

def test_idwt_single_axis():
    x = [[3, 7, 1, 1],
         [-2, 5, 4, 6]]

    x = np.asarray(x)
    x = x + 1j*x   # test with complex data
    cA, cD = pywt.dwt(x, 'db2', axis=-1)

    x0 = pywt.idwt(cA[0], cD[0], 'db2', axis=-1)
    x1 = pywt.idwt(cA[1], cD[1], 'db2', axis=-1)

    assert_allclose(x[0], x0)
    assert_allclose(x[1], x1)
开发者ID:holgern,项目名称:pywt,代码行数:13,代码来源:test_dwt_idwt.py

示例7: yidwtfun

def yidwtfun(L, H, wname):
    # Ls = np.shape(L)
    # Hs = np.shape(H)
    matSize = np.shape(L)
    testData = pywt.idwt(L[0, :, 0], H[0, :, 0], wname)
    data = np.zeros((matSize[0], testData.shape[0], matSize[2]), dtype='float64')
    for i in range(0, matSize[0]):
        for j in range(0, matSize[2]):
            L1 = L[i, :, j]
            H1 = H[i, :, j]
            line = pywt.idwt(L1, H1, wname)
            data[i, :, j] = line;
    return data
开发者ID:dragonabyss,项目名称:2016project,代码行数:13,代码来源:main.py

示例8: zidwtfun

def zidwtfun(L, H, wname):
    # Ls = np.shape(L)
    # Hs = np.shape(H)
    matSize = np.shape(L)
    testData = pywt.idwt(L[0, 0, :], H[0, 0, :], wname)
    data = np.zeros((matSize[0], matSize[1], testData.shape[0]), dtype="float64")
    for i in range(0, matSize[0]):
        for j in range(0, matSize[1]):
            L1 = L[i, j, :]
            H1 = H[i, j, :]
            line = pywt.idwt(L1, H1, wname)
            data[i, j, :] = line;
    return data
开发者ID:dragonabyss,项目名称:2016project,代码行数:13,代码来源:main.py

示例9: test_idwt_mixed_complex_dtype

def test_idwt_mixed_complex_dtype():
    x = np.arange(8).astype(float)
    x = x + 1j*x[::-1]
    cA, cD = pywt.dwt(x, 'db2')

    x_roundtrip = pywt.idwt(cA, cD, 'db2')
    assert_allclose(x_roundtrip, x, rtol=1e-10)

    # mismatched dtypes OK
    x_roundtrip2 = pywt.idwt(cA.astype(np.complex128), cD.astype(np.complex64),
                             'db2')
    assert_allclose(x_roundtrip2, x, rtol=1e-7, atol=1e-7)
    assert_(x_roundtrip2.dtype == np.complex128)
开发者ID:PyWavelets,项目名称:pywt,代码行数:13,代码来源:test_dwt_idwt.py

示例10: test_dwt_idwt_basic

def test_dwt_idwt_basic():
    x = [3, 7, 1, 1, -2, 5, 4, 6]
    cA, cD = pywt.dwt(x, "db2")
    cA_expect = [5.65685425, 7.39923721, 0.22414387, 3.33677403, 7.77817459]
    cD_expect = [-2.44948974, -1.60368225, -4.44140056, -0.41361256, 1.22474487]
    assert_allclose(cA, cA_expect)
    assert_allclose(cD, cD_expect)

    x_roundtrip = pywt.idwt(cA, cD, "db2")
    assert_allclose(x_roundtrip, x, rtol=1e-10)

    # mismatched dtypes OK
    x_roundtrip2 = pywt.idwt(cA.astype(np.float64), cD.astype(np.float32), "db2")
    assert_allclose(x_roundtrip2, x, rtol=1e-7, atol=1e-7)
    assert_(x_roundtrip.dtype == np.float64)
开发者ID:rgommers,项目名称:pywt,代码行数:15,代码来源:test_dwt_idwt.py

示例11: collapse

def collapse(triangle,trind,wavelet):
    low=get_band(triangle,trind,trind.shape[0]-1)
    for band in range(1,trind.shape[0]):
        high=get_band(triangle,trind,trind.shape[0]-band-1)
        low=low[:high.shape[0]]
        low=pywt.idwt(low,high,wavelet)
    return low
开发者ID:solomongarber,项目名称:MarkovLowPass,代码行数:7,代码来源:wPyr.py

示例12: check_reconstruction

def check_reconstruction(pmode, mmode, wavelet, dtype):
    data_size = list(range(2, 40)) + [100, 200, 500, 1000, 2000, 10000,
                                50000, 100000]
    np.random.seed(12345)
    #TODO: smoke testing - more failures for different seeds

    if dtype == np.float32:
        epsilon = 3e-7
    else:
        #FIXME: limit was 5e-11, but gave failures.  Investigate
        epsilon = 1e-8

    for N in data_size:
        data = np.asarray(np.random.random(N), dtype)

        # compute dwt coefficients
        pa, pd = pywt.dwt(data, wavelet, pmode)

        # compute reconstruction
        rec = pywt.idwt(pa, pd, wavelet, pmode)

        if len(data) % 2:
            rec = rec[:len(data)]

        rms_rec = np.sqrt(np.mean((data-rec)**2))
        msg = ('[RMS_REC > EPSILON] for Mode: %s, Wavelet: %s, '
               'Length: %d, rms=%.3g' % (pmode, wavelet, len(data), rms_rec))
        assert_(rms_rec < epsilon, msg=msg)
开发者ID:Dapid,项目名称:pywt,代码行数:28,代码来源:test_perfect_reconstruction.py

示例13: func_dwt

def func_dwt(Fs, T, N):
    t = np.linspace(0, N * T, N)
    y = np.sin(2 * np.pi * 10 * t) + 0.1 * np.sin(2 * np.pi * 300 * t)

    (cA, cD) = pywt.dwt(y, 'db1')
    yy = pywt.idwt(cA, cD, 'db1')
    print(np.sum(np.abs(yy - y)) / N)
开发者ID:BossKwei,项目名称:temp,代码行数:7,代码来源:fft_3.py

示例14: update_dwt

def update_dwt(coeffs, wavelet, mode='sym'):
    new_coeffs = [0] * len(coeffs)
    resized_coeffs = []

    # parse coeffs into approximation and details
    a, ds = coeffs[0], coeffs[1:]

    for d in ds:
        if isinstance(d, collections.Iterable):
            for index in range(0, len(d)):
                try:
                    d[index] = float(d[index])
                except Exception:
                    d[index] = float(d[index].split('e')[0])
                    
            d_copy = copy([float(e) for e in d if e != ''])
#            d_copy = copy([float(e) for e in d])
            if len(a) != len(d):
                d_copy.resize(len(a), refcheck = False)

            a = pywt.idwt(a, d_copy, wavelet, mode, 1)
            resized_coeffs.append(d_copy)

    new_coeffs[0] = coeffs[0]
    new_coeffs[1:] = resized_coeffs

    return new_coeffs
开发者ID:Xifax,项目名称:muscale,代码行数:27,代码来源:wavelets.py

示例15: test_perfect_reconstruction

def test_perfect_reconstruction(families, wavelets, modes, epsilon, dtype):
    for wavelet in wavelets:
        for pmode, mmode in modes:
            print "Wavelet: %-8s Mode: %s" % (wavelet, pmode),

            data_size = range(2, 40) + [100, 200, 500, 1000, 2000, 10000, 50000, 100000]

            ok, over = 0, 0
            for N in data_size:
                data = numpy.asarray(numpy.random.random(N), dtype)

                # compute dwt coefficients
                pa, pd = pywt.dwt(data, wavelet, pmode)

                # compute reconstruction
                rec = pywt.idwt(pa, pd, wavelet, pmode)

                if len(data) % 2:
                    rec = rec[: len(data)]

                rms_rec = rms(data, rec)
                if rms_rec > epsilon:
                    if not over:
                        print
                    print "[RMS_REC > EPSILON] for Mode: %s, Wavelet: %s, " "Length: %d, rms=%.3g" % (
                        pmode,
                        wavelet,
                        len(data),
                        rms_rec,
                    )
                    over += 1
                else:
                    ok += 1
            if not over:
                print "- RMSE for all %d cases was under %s" % (len(data_size), epsilon)
开发者ID:Joehere,项目名称:pywt,代码行数:35,代码来源:test_perfect_reconstruction.py


注:本文中的pywt.idwt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。