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

Python pywt.dwt函数代码示例

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

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



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

示例1: collect

def collect(S, wavelet, mode, level):
    '''
    Returns the full binary tree of wavelet packets.
    @param S:         Input signal.
                      Both single and double precision floating-point data types are supported
                      and the output type depends on the input type. If the input data is not
                      in one of these types it will be converted to the default double precision
                      data format before performing computations.
    @param wavelet:   Wavelet to use in the transform. 
                      This must be a name of the wavelet from the wavelist() list.
    @param mode:      Signal extension mode to deal with the border distortion problem.
    @param level:     Number of decomposition steps to perform. If the level is None, then the
                      full decomposition up to the level computed with dwt_max_level() function for
                      the given data and wavelet lengths is performed.
    @return:          The full binary tree of wavelet packets.
    '''
    Nodes = [[] for i in range(level)]
    (Cl, Cr) = pywt.dwt(S, wavelet=wavelet, mode=mode)
    Nodes[0] = [node.Node(Cl, 0, 0), node.Node(Cr, 0, 1)]
    for l in range(0, level-1):
        Parents = Nodes[l]
        Childs = []
        for p in range(len(Parents)):
            (Cl, Cr) = pywt.dwt(Parents[p].C, wavelet=wavelet, mode=mode)
            Childs.append(node.Node(Cl, l+1, 2*p))
            Childs.append(node.Node(Cr, l+1, 2*p+1))
        Nodes[l+1] = Childs 
    return Nodes
开发者ID:matt77hias,项目名称:FingerprintCompression,代码行数:28,代码来源:binarytree.py


示例2: ecg_plot

def ecg_plot(data, ax1,signum):
	x, y = [], []
	print("Tworze wykres numer %d" % signum)
	#for row in arr[2:]:
	#	x.append(row[0])
	#	y.append(row[signum])
	x, y =[], []
	for index, cell in enumerate(data[signum-1]):
		x.append(index)
		y.append(float(cell)/mV)
		
	global X
	global Y
	X.append(x)
	Y.append(y)
	if(signum==1):
		find_QRS(y)
	ax1.plot(X[signum-1],Y[signum-1])
	fftax = np.fft.fft(y)/ylen
	fftax = fftax[0:int(ylen/2)]

	(wtaxA, wtaxD) = pywt.dwt((y),'db1') ##wt approximation + detail coefficients cokolwiek to znaczy
	if(WT_times > 1):
		for i in range(WT_times-1):
			(wtaxA,wtaxD) = pywt.dwt((wtaxA),'db1')

	global FFTaxes
	global WTaxesA
	global WTaxesD
	FFTaxes[signum-1] = fftax
	WTaxesA[signum-1] = wtaxA
	WTaxesD[signum-1] = wtaxD
开发者ID:Raynoox,项目名称:iwm,代码行数:32,代码来源:reader.py


示例3: test_dwt_axis_arg

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

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

    assert_allclose(cA_, cA)
    assert_allclose(cD_, cD)
开发者ID:rgommers,项目名称:pywt,代码行数:8,代码来源:test_dwt_idwt.py


示例4: test_default_mode

def test_default_mode():
    # The default mode should be 'symmetric'
    x = [1, 2, 1, 5, -1, 8, 4, 6]
    cA, cD = pywt.dwt(x, 'db2')
    cA2, cD2 = pywt.dwt(x, 'db2', mode='symmetric')
    assert_allclose(cA, cA2)
    assert_allclose(cD, cD2)
    assert_allclose(pywt.idwt(cA, cD, 'db2'), x)
开发者ID:HenryZhou1002,项目名称:pywt,代码行数:8,代码来源:test_modes.py


示例5: extractFeatureFromWave

def extractFeatureFromWave(wave):
    cA, cD = pywt.dwt(wave, 'dmey')
    counter = 1
    while counter <= 4:
        print cA.shape
        cA, cD = pywt.dwt(cA, 'dmey')
        counter = counter + 1
    return cA, cD
开发者ID:LoftyRock,项目名称:ReduceFA_2015,代码行数:8,代码来源:dmey_converter.py


示例6: bpm_detector

def bpm_detector(data,fs):
    cA = []
    cD = []
    correl = []
    cD_sum = []
    levels = 4
    max_decimation = 2**(levels-1);
    min_ndx = 60./ 220 * (fs/max_decimation)
    max_ndx = 60./ 40 * (fs/max_decimation)

    for loop in range(0,levels):
        cD = []
        # 1) DWT
        if loop == 0:
            [cA,cD] = pywt.dwt(data,'db4');
            cD_minlen = len(cD)/max_decimation+1;
            cD_sum = numpy.zeros(cD_minlen);
        else:
            [cA,cD] = pywt.dwt(cA,'db4');
        # 2) Filter
        cD = signal.lfilter([0.01],[1 -0.99],cD);

        # 4) Subtractargs.filename out the mean.

        # 5) Decimate for reconstruction later.
        cD = abs(cD[::(2**(levels-loop-1))]);
        cD = cD - numpy.mean(cD);
        # 6) Recombine the signal before ACF
        #    essentially, each level I concatenate
        #    the detail coefs (i.e. the HPF values)
        #    to the beginning of the array
        cD_sum = cD[0:cD_minlen] + cD_sum;

    if [b for b in cA if b != 0.0] == []:
        return no_audio_data()
    # adding in the approximate data as well...
    cA = signal.lfilter([0.01],[1 -0.99],cA);
    cA = abs(cA);
    cA = cA - numpy.mean(cA);
    cD_sum = cA[0:cD_minlen] + cD_sum;

    # ACF
    correl = numpy.correlate(cD_sum,cD_sum,'full')

    midpoint = len(correl) / 2
    correl_midpoint_tmp = correl[midpoint:]
    peak_ndx = peak_detect(correl_midpoint_tmp[min_ndx:max_ndx]);
    if len(peak_ndx) > 1:
        return no_audio_data()

    peak_ndx_adjusted = peak_ndx[0]+min_ndx;
    bpm = 60./ peak_ndx_adjusted * (fs/max_decimation)
    global bpm_list
    bpm_list.append(bpm.item(0))
    #print bpm
    return bpm,correl
开发者ID:CMPUT414,项目名称:DancingQueen,代码行数:56,代码来源:BPMDetector.py


示例7: swt

def swt(data, wavelet, level=None):
    """
    Stationary Wavelet Transform

    This version is 2 orders of magnitude faster than the one in pywt
    even though it uses pywt for all the calculations.
    
      Input parameters: 

        data
          One-dimensional data to transform
        wavelet
          Either the name of a wavelet or a Wavelet object
        level
          Number of levels

    """
    if level is None:
        level = pywt.swt_max_level(len(data))
    num_levels = level
    idata = data.copy()
    res = []
    for j in range(1,num_levels+1): 
        step_size = int(math.pow(2, j-1))
        last_index = step_size
        # allocate
        cA = np.empty_like(data)
        cD = np.empty_like(data)
        for first in xrange(last_index): # 0 to last_index - 1
            # Getting the indices that we will transform 
            indices = np.arange(first, len(cD), step_size)

            # select the even indices
            even_indices = indices[0::2] 
            # select the odd indices
            odd_indices = indices[1::2] 
            
            # get the even
            (cA1,cD1) = pywt.dwt(idata[indices], wavelet, 'per')
            cA[even_indices] = cA1
            cD[even_indices] = cD1

            # then the odd
            (cA1,cD1) = pywt.dwt(np.roll(idata[indices],-1), wavelet, 'per')
            cA[odd_indices] = cA1
            cD[odd_indices] = cD1

        # set the data for the next loop
        idata = cA

        # prepend the result
        res.insert(0,(cA,cD))

    return res
开发者ID:Shotgunosine,项目名称:ptsa,代码行数:54,代码来源:wavelet.py


示例8: zdwtfun

def zdwtfun(data, wname):
    matSize = np.shape(data)
    testL, testH = pywt.dwt(data[0, 0, :], wname)
    L = np.zeros((matSize[0], matSize[1], testL.shape[0]), dtype='float64')
    H = np.zeros((matSize[0], matSize[1], testH.shape[0]), dtype='float64')
    for i in range(0, matSize[0]):
        for j in range(0, matSize[1]):
            line = np.float64(data[i, j, :])
            cL, cH = pywt.dwt(line, wname)
            L[i, j, :] = cL
            H[i, j, :] = cH
    return L, H
开发者ID:dragonabyss,项目名称:2016project,代码行数:12,代码来源:main.py


示例9: makeWT

def makeWT(y,times): ## robi pare razy WT na approx.
	(wtaxA, wtaxD) = pywt.dwt((y),'db1')
	if(times > 1):
		for i in range(times-1):
			(wtaxA,wtaxD) = pywt.dwt((wtaxA),'db1')
	ymin = min(wtaxD)
	for index,x in enumerate(wtaxD):
		wtaxD[index-1]=wtaxD[index-1]-ymin
	ymin = min(wtaxA)
	for index,x in enumerate(wtaxA):
		wtaxA[index-1]=wtaxA[index-1] - ymin
	
	return wtaxA,wtaxD
开发者ID:likeMyCode,项目名称:ECGDiagnose,代码行数:13,代码来源:preprocessing.py


示例10: test_mode_equivalence

def test_mode_equivalence():
    old_new = [('zpd', 'zero'),
               ('cpd', 'constant'),
               ('sym', 'symmetric'),
               ('ppd', 'periodic'),
               ('sp1', 'smooth'),
               ('per', 'periodization')]
    x = np.arange(8.)
    with warnings.catch_warnings():
        warnings.simplefilter('ignore', DeprecationWarning)
        for old, new in old_new:
            assert_array_equal(pywt.dwt(x, 'db2', mode=old),
                               pywt.dwt(x, 'db2', mode=new))
开发者ID:HenryZhou1002,项目名称:pywt,代码行数:13,代码来源:test_deprecations.py


示例11: test_dwt_single_axis

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

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

    cA0, cD0 = pywt.dwt(x[0], "db2")
    cA1, cD1 = pywt.dwt(x[1], "db2")

    assert_allclose(cA[0], cA0)
    assert_allclose(cA[1], cA1)

    assert_allclose(cD[0], cD0)
    assert_allclose(cD[1], cD1)
开发者ID:rgommers,项目名称:pywt,代码行数:13,代码来源:test_dwt_idwt.py


示例12: coiflets_wavelets_transf

def coiflets_wavelets_transf(X, parameter1=1):
    parameter1 = parameter1 if parameter1 in range(1, 6) else 1
    funct = 'coif'+str(parameter1)
    funct = funct if funct in pywt.wavelist('coif') else 'coif1'
    Xt = np.array([np.concatenate(pywt.dwt(X[:, i], funct))
                   for i in range(X.shape[1])])
    return Xt
开发者ID:tgquintela,项目名称:TimeSeriesTools,代码行数:7,代码来源:feature_representation.py


示例13: symlets_wavelets_transf

def symlets_wavelets_transf(X, parameter1=2):
    parameter1 = parameter1 if parameter1 in range(2, 21) else 2
    funct = 'sym'+str(parameter1)
    funct = funct if funct in pywt.wavelist('sym') else 'sym2'
    Xt = np.array([np.concatenate(pywt.dwt(X[:, i], funct))
                  for i in range(X.shape[1])])
    return Xt
开发者ID:tgquintela,项目名称:TimeSeriesTools,代码行数:7,代码来源:feature_representation.py


示例14: daubechies_wavelet_transf

def daubechies_wavelet_transf(X, parameter1=1):
    parameter1 = parameter1 if parameter1 in range(1, 21) else 1
    funct = 'db'+str(parameter1)
    funct = funct if funct in pywt.wavelist('db') else 'db1'
    Xt = np.array([np.concatenate(pywt.dwt(X[:, i], funct))
                   for i in range(X.shape[1])])
    return Xt
开发者ID:tgquintela,项目名称:TimeSeriesTools,代码行数:7,代码来源:feature_representation.py


示例15: wavelet

    def wavelet(self, column, name):
        sample_size = self.sample_size
        sc = self.sc
        link = self.file
        length = self.file_size

        tab = []
        for i in range(0, length):
            tab.append(length - i)

        def get_key(iterator, size):
            key = int(iterator/size)
            iterator += 1
            return key

        rdd = sc\
            .textFile(link)\
            .filter(lambda line: name not in line)\
            .map(lambda line: (get_key(tab.pop(), sample_size), re.split(r';', line)[column]))\
            .groupByKey().mapValues(list)\
            .map(lambda line: (line[0], pywt.dwt(line[1], 'db1')[1]))

        def get_previous_line(line):
            iterator = line[0]
            if iterator == 0:
                prev = rdd.filter(lambda my_line: my_line[0] == iterator).collect()[0][1]
            else:
                prev = rdd.filter(lambda my_line: my_line[0] == iterator - 1).collect()[0][1]
            d = distance.euclidean(line[1], prev)
            return d

        return rdd\
            .map(lambda line: get_previous_line(line))\
            .collect()
开发者ID:EnzoTheBrown,项目名称:PySpark_intership,代码行数:34,代码来源:Wavelet.py


示例16: 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


示例17: task_1

def task_1():
    dwt_haar_4 = find_dwt_matrix(4, 'haar')
    dwt_haar_8 = find_dwt_matrix(8, 'haar')
    x = np.array([1.0, 2.0, 3.0, 2.0, 1.0, 3.0, 3.0, 3.0])
    x_dwt = np.dot(dwt_haar_8, x)

    print()
    print("DWT Matrix of size 4:")
    print(dwt_haar_4)

    print()
    print("DWT Matrix of size 8:")
    print(dwt_haar_8)

    print()
    print("x:")
    print(x)

    print()
    print("DWT of x with matrix:")
    print(x_dwt)

    print()
    print("DWT of x with pywt:")
    print(pywt.dwt(x, 'haar', mode='ppd'))
开发者ID:Gachapen,项目名称:imt4202-image-processing,代码行数:25,代码来源:code.py


示例18: 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


示例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: wavelet_trasnform

def wavelet_trasnform(sig):
    mode = pywt.Modes.smooth
    w = 'coif3'
    w = pywt.Wavelet(w)
    
#    hasil=[]
#    for n in range(data.shape[0]):
        #dd = data[n,1:24]
    ca = []
    cd = []
    for i in range(5):
            (a, d) = pywt.dwt(sig, w, mode)
            ca.append(a)
            cd.append(d)
    rec_a = []
    rec_d = []
    for i, coeff in enumerate(ca):
        coeff_list = [coeff, None] + [None] * i
        rec_a.append(pywt.waverec(coeff_list, w))
    for i, coeff in enumerate(cd):
        coeff_list = [None, coeff] + [None] * i
        rec_d.append(pywt.waverec(coeff_list, w))
#    hasil.append(rec_a[0])
        
    return rec_a[0];
开发者ID:tjipenk,项目名称:py_proj,代码行数:25,代码来源:wavelet_denoise.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pywt.dwt2函数代码示例发布时间:2022-05-26
下一篇:
Python tests.client_for函数代码示例发布时间: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