• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pywt.idwt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_dwt_idwt_partial_complex

def test_dwt_idwt_partial_complex():
    x = np.asarray([3, 7, 1, 1, -2, 5, 4, 6])
    x = x + 0.5j*x

    cA, cD = pywt.dwt(x, 'haar')
    cA_rec_expect = np.array([5.0+2.5j, 5.0+2.5j, 1.0+0.5j, 1.0+0.5j,
                              1.5+0.75j, 1.5+0.75j, 5.0+2.5j, 5.0+2.5j])
    cA_rec = pywt.idwt(cA, None, 'haar')
    assert_allclose(cA_rec, cA_rec_expect)

    cD_rec_expect = np.array([-2.0-1.0j, 2.0+1.0j, 0.0+0.0j, 0.0+0.0j,
                              -3.5-1.75j, 3.5+1.75j, -1.0-0.5j, 1.0+0.5j])
    cD_rec = pywt.idwt(None, cD, 'haar')
    assert_allclose(cD_rec, cD_rec_expect)

    assert_allclose(cA_rec + cD_rec, x)
开发者ID:pombredanne,项目名称:pywt,代码行数:16,代码来源:test_dwt_idwt.py


示例17: waverec

def waverec(coeffs_list, wavelet, mode='sym'):
    a, ds = coeffs_list[0], coeffs_list[1:]

    for d in ds:
        a = pywt.idwt(a, d, wavelet, mode, 1)

    return a
开发者ID:candywow,项目名称:elevator_nurse,代码行数:7,代码来源:denoise.py


示例18: reconstructWPT

    def reconstructWPT(self,new_wp,wavelet,listleaves):
        """ Create a new wavelet packet tree by copying in the data for the leaves and then performing
        the idwt up the tree to the root.
        Assumes that listleaves is top-to-bottom, so just reverses it.
        """
        # Sort the list of leaves into order bottom-to-top, left-to-right
        working = listleaves.copy()
        working = working[-1::-1]

        level = int(np.floor(np.log2(working[0] + 1)))
        while level > 0:
            first = 2 ** level - 1
            while working[0] >= first:
                # Note that it assumes that the whole list is backwards
                parent = (working[0] - 1) // 2
                p = self.ConvertWaveletNodeName(parent)

                new_wp[p].data = pywt.idwt(new_wp[self.ConvertWaveletNodeName(working[1])].data,new_wp[self.ConvertWaveletNodeName(working[0])].data, wavelet)[:len(new_wp[p].data)]

                # Delete these two nodes from working
                working = np.delete(working, 1)
                working = np.delete(working, 0)
                # Insert parent into list of nodes at the next level
                ins = np.where(working > parent)
                if len(ins[0]) > 0:
                    ins = ins[0][-1] + 1
                else:
                    ins = 0
                working = np.insert(working, ins, parent)
            level = int(np.floor(np.log2(working[0] + 1)))
        return new_wp
开发者ID:smarsland,项目名称:birdscape,代码行数:31,代码来源:WaveletFunctions.py


示例19: test_dwt_idwt_allmodes

def test_dwt_idwt_allmodes():
    # Test that :func:`dwt` and :func:`idwt` can be performed using every mode
    x = [1, 2, 1, 5, -1, 8, 4, 6]
    dwt_result_modes = {
        'zero': ([-0.03467518, 1.73309178, 3.40612438, 6.32928585, 6.95094948],
                 [-0.12940952, -2.15599552, -5.95034847, -1.21545369,
                 -1.8625013]),
        'constant': ([1.28480404, 1.73309178, 3.40612438, 6.32928585,
                      7.51935555],
                     [-0.48296291, -2.15599552, -5.95034847, -1.21545369,
                      0.25881905]),
        'symmetric': ([1.76776695, 1.73309178, 3.40612438, 6.32928585,
                       7.77817459],
                      [-0.61237244, -2.15599552, -5.95034847, -1.21545369,
                       1.22474487]),
        'reflect': ([2.12132034, 1.73309178, 3.40612438, 6.32928585,
                     6.81224877],
                    [-0.70710678, -2.15599552, -5.95034847, -1.21545369,
                     -2.38013939]),
        'periodic': ([6.9162743, 1.73309178, 3.40612438, 6.32928585,
                      6.9162743],
                     [-1.99191082, -2.15599552, -5.95034847, -1.21545369,
                      -1.99191082]),
        'smooth': ([-0.51763809, 1.73309178, 3.40612438, 6.32928585,
                    7.45000519],
                   [0, -2.15599552, -5.95034847, -1.21545369, 0]),
        'periodization': ([4.053172, 3.05257099, 2.85381112, 8.42522221],
                          [0.18946869, 4.18258152, 4.33737503, 2.60428326])
    }

    for mode in pywt.Modes.modes:
        cA, cD = pywt.dwt(x, 'db2', mode)
        assert_allclose(cA, dwt_result_modes[mode][0], rtol=1e-7, atol=1e-8)
        assert_allclose(cD, dwt_result_modes[mode][1], rtol=1e-7, atol=1e-8)
        assert_allclose(pywt.idwt(cA, cD, 'db2', mode), x, rtol=1e-10)
开发者ID:HenryZhou1002,项目名称:pywt,代码行数:35,代码来源:test_modes.py


示例20: my_waverec

def my_waverec(data, wavelet, mode='sym', level=None):
    """
    Multilevel 1D Discrete Wavelet Transform of data.
    Returns coefficients list - [cAn, cDn, cDn-1, ..., cD2, cD1]

    data    - input data
    wavelet - wavelet to use (Wavelet object or name string)
    mode    - signal extension mode, see MODES
    level   - decomposition level. If level is None then it will be
              calculated using `dwt_max_level` function.
    """

    if not isinstance(wavelet, pywt.Wavelet):
        wavelet = pywt.Wavelet(wavelet)

    if level is None:
        level = pywt.dwt_max_level(len(data), wavelet.dec_len)
    elif level < 0:
        raise ValueError("Level value of %d is too low . Minimum level is 0." % level)

    a = data[0:2]
    d = data[2:4]
    for i in xrange(int(level)):
        offs = pow(2,i+2)
        a = pywt.idwt(a, d, wavelet, mode)
        d = data[offs:2*offs]

    return a
开发者ID:jpcoles,项目名称:jcode,代码行数:28,代码来源:wt.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pywt.idwt2函数代码示例发布时间:2022-05-26
下一篇:
Python pywt.dwtn函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap