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


Python pywt.dwt函数代码示例

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


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


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