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


Python fftpack.hilbert函数代码示例

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


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

示例1: test_random_odd

 def test_random_odd(self):
     for n in [33,65,55]:
         f = random((n,))
         af = sum(f,axis=0)/n
         f = f-af
         assert_almost_equal(sum(f,axis=0),0.0)
         assert_array_almost_equal(ihilbert(hilbert(f)),f)
         assert_array_almost_equal(hilbert(ihilbert(f)),f)
开发者ID:BranYang,项目名称:scipy,代码行数:8,代码来源:test_pseudo_diffs.py

示例2: test_definition

 def test_definition(self):
     for n in [16,17,64,127]:
         x = arange(n)*2*pi/n
         y = hilbert(sin(x))
         y1 = direct_hilbert(sin(x))
         assert_array_almost_equal(y,y1)
         assert_array_almost_equal(hilbert(sin(2*x)),
                                   direct_hilbert(sin(2*x)))
开发者ID:BranYang,项目名称:scipy,代码行数:8,代码来源:test_pseudo_diffs.py

示例3: envelope

    def envelope(self):
        '''
        Computes the envelope of the trace. 
        '''
        from scipy.fftpack import hilbert

        self.values = 20 * np.log10(np.abs(hilbert(self.values)))
开发者ID:kmunve,项目名称:processgpr,代码行数:7,代码来源:trace.py

示例4: analytic_signal

def analytic_signal(x):
    """ A short-cut assuming that the incoming signal is reasonable
    e.g. fairly pure sinusoid.
    So far this has no strategy to minimize fourier transform time.
    """ 
    x = x - np.mean(x)
    return(x+1j*hilbert(x))
开发者ID:bdb112,项目名称:pyfusion,代码行数:7,代码来源:restore_sin.py

示例5: bench_random

 def bench_random(self):
     print()
     print(' Hilbert transform of periodic functions')
     print('=========================================')
     print(' size  | optimized |    naive')
     print('-----------------------------------------')
     for size,repeat in [(100,1500),(1000,300),
                         (256,1500),
                         (512,1000),
                         (1024,500),
                         (2048,200),
                         (2048*2,100),
                         (2048*4,50),
                         ]:
         print('%6s' % size, end=' ')
         sys.stdout.flush()
         x = arange(size)*2*pi/size
         if size < 2000:
             f = sin(x)*cos(4*x)+exp(sin(3*x))
         else:
             f = sin(x)*cos(4*x)
         assert_array_almost_equal(hilbert(f),direct_hilbert(f))
         print('| %9.2f' % measure('hilbert(f)',repeat), end=' ')
         sys.stdout.flush()
         print('| %9.2f' % measure('direct_hilbert(f)',repeat), end=' ')
         sys.stdout.flush()
         print(' (secs for %s calls)' % (repeat))
开发者ID:ChadFulton,项目名称:scipy,代码行数:27,代码来源:bench_pseudo_diffs.py

示例6: get_iprobe

    def get_iprobe(self, leakage=None, t_comp=None):
        """ main purpose is to subtract leakage currents
        Will use the full data, as the t_range is meant to be plasma interval
        returns a copy of the measured courremt, overwritten with the
        corrected iprobe
        """
        # obtain leakage estimate
        if t_comp is None:
            t_comp = self.t_comp
        FFT_size = nice_FFT_size(len(self.imeasfull.timebase), -1)
        self.iprobefull = self.imeasfull.copy()
        self.sweepQ = []  # will keep these for synchronous sampling
        input_leakage = leakage
        for (c, chan) in enumerate(self.imeasfull.channels):
            if self.select is not None and c not in self.select:
                continue
            leakage = input_leakage
            cname = chan.config_name
            sweepV = self.vcorrfull.signal[self.vlookup[self.vassoc[c]]][0:FFT_size]
            sweepQ = hilbert(sweepV)
            self.sweepQ.append(sweepQ)  # save for synchronising segments (it is smoothed)

            # these attempts to make it accept a single channel are only partial
            imeas = self.imeasfull.signal[c] # len(self.imeasfull.channels) >1 else self.imeasfull.signal
            tb = self.imeasfull.timebase

            w_comp = np.where((tb>=t_comp[0]) & (tb<=t_comp[1]))[0]
            if len(w_comp) < 2000:

                raise ValueError('Not enough points {wc} t_comp - try {tt}'
                    .format(tt=np.round([tb[0], tb[0] + t_comp[1]-t_comp[0]],3),
                            wc=len(w_comp)))
            ns = len(w_comp)
            wind = np.blackman(ns)
            offset = np.mean(wind * imeas[w_comp])/np.mean(wind)
            sweepVFT = np.fft.fft(AC(sweepV[w_comp]) * wind)
            imeasFT = np.fft.fft(AC(imeas[w_comp]) * wind)
            ipk = np.argmax(np.abs(sweepVFT)[0:ns//2])  # avoid the upper one
            comp = imeasFT[ipk]/sweepVFT[ipk]

            #print('leakage compensation factor = {r:.2e} + j{i:.2e}'
            #      .format(r=np.real(comp), i=np.imag(comp)))
            print('{u}sing computed leakage comp factor = {m:.2e} e^{p:.2f}j'
                  .format(u = ["Not u", "U"][leakage is None],
                          m=np.abs(comp), p=np.angle(comp)))
            if leakage is None:
                leakage = [np.real(comp), np.imag(comp)]

            # find the common length - assuming they start at the same time????
            comlen = min(len(self.imeasfull.timebase),len(self.vmeasfull.timebase),len(sweepQ))
            # put signals back into rdata (original was copied by reduce_time)
            # overwrite - is this OK?
            self.iprobefull.signal[c] = self.iprobefull.signal[c]*0.  # clear it
            # sweepV has a DC component! beware
            self.iprobefull.signal[c][0:comlen] = self.imeasfull.signal[c][0:comlen]-offset \
                                        - sweepV[0:comlen] * leakage[0] - sweepQ[0:comlen] * leakage[1]
            # remove DC cpt (including that from the compensation sweepV)
            offset = np.mean(wind * self.iprobefull.signal[c][w_comp])/np.mean(wind)
            self.iprobefull.signal[c][0:comlen] -= offset
开发者ID:bdb112,项目名称:pyfusion,代码行数:59,代码来源:process_swept_Langmuir.py

示例7: test_tilbert_relation

 def test_tilbert_relation(self):
     for n in [16,17,64,127]:
         x = arange(n)*2*pi/n
         f = sin(x)+cos(2*x)*sin(x)
         y = hilbert(f)
         y1 = direct_hilbert(f)
         assert_array_almost_equal(y,y1)
         y2 = tilbert(f,h=10)
         assert_array_almost_equal(y,y2)
开发者ID:BranYang,项目名称:scipy,代码行数:9,代码来源:test_pseudo_diffs.py

示例8: frequency_estimate_ml

def frequency_estimate_ml(x):
    x_ = scifft.hilbert(x)
    x_ = noiseWhite(x_)
    datalen = len(x_)

    for i in range(0, datalen):
        x_[i] = np.math.log(abs(x_[i]))/(i+1)
    averge_ = np.average(x_)
    result_ = abs(averge_)
    return result_
开发者ID:AirSmithX,项目名称:Digital_Signal_Process,代码行数:10,代码来源:mathtools.py

示例9: test_random_even

 def test_random_even(self):
     for n in [32,64,56]:
         f = random((n,))
         af = sum(f,axis=0)/n
         f = f-af
         # zeroing Nyquist mode:
         f = diff(diff(f,1),-1)
         assert_almost_equal(sum(f,axis=0),0.0)
         assert_array_almost_equal(direct_hilbert(direct_ihilbert(f)),f)
         assert_array_almost_equal(hilbert(ihilbert(f)),f)
开发者ID:BranYang,项目名称:scipy,代码行数:10,代码来源:test_pseudo_diffs.py

示例10: envelope

    def envelope(self):
        '''
        NEEDS TESTING
        
        Computes the envelope of the traces using the Hilbert transform. 
        '''
        from scipy.fftpack import hilbert

        self.info('Applying Hilbert transform ...')
        for trace in range(self.traces):
            self.data[:, trace] = np.abs(hilbert(self.data[:, trace]))
        self.done()
开发者ID:kmunve,项目名称:processgpr,代码行数:12,代码来源:gpr.py

示例11: compressed_sensing_1VD

def compressed_sensing_1VD( fid, mask, num_iter=500, factor=0.95, tol = 0.01, maxPeaks=2 ):
    
    sss = numpy.zeros( len(fid))
    sss0 = numpy.zeros( len(fid))
    
    final_iter_value  = 0
    final_tol_value   = 0
    final_numpeaks_value = 0

    fid1 = fid.copy()
    tol_diff = (numpy.sqrt(((abs(fid1)).sum())/32.))
    
    k=0
    kkk = []
    rrr = fftpack.fft(fid1)
    rss0 = []
    rss0.append(abs(rrr).sum())
    
    tol0 = abs(rrr).sum()
    tol_diff = ( tol0 - abs(rrr).sum() )*100.0 / tol0
    while (tol_diff < tol) and (k < num_iter) and numPeaks( sss ) <maxPeaks:
        
        sss0 = 1.0*sss
        
        rrr = fftpack.fft(fid1)
        m1 = max(rrr.real)
        
        sss_max_old = sss.max()
               
        for i,r in enumerate(rrr):
            if r.real > m1* factor:
                sss[i] = sss[i]+rrr[i].real
                rrr[i] = complex(m1*factor)
        sss_max = sss.max()
        
        rrr_iii = fftpack.hilbert( rrr.real )
        
        rrr = rrr.real + 1j * rrr_iii
        
        fid1 = fftpack.ifft(rrr)
        
        fid1 *= mask
        tol_diff = ( tol0 - abs(rrr).sum() )*100.0 / tol0
        k +=1

    final_iter_value = k
    final_numpeaks_value = numPeaks(sss)
    final_tol_value = tol_diff
    
    return( sss0, [final_iter_value, final_numpeaks_value, final_tol_value ] )
开发者ID:EricHughesABC,项目名称:strayfieldimaging,代码行数:50,代码来源:ist.py

示例12: reconstruct

 def reconstruct(self, paData):
     if paData.ndim == 2:
         (nSamples, nSteps) = paData.shape
         paData = np.reshape(paData, (nSamples, nSteps, 1))
     (nSamples, nSteps, zSteps) = paData.shape
     reImg1 = np.copy(super().reconstruct(paData))
     # take 90-degree phase shift
     import scipy.fftpack as spfp
     for z in range(zSteps):
         for n in range(nSteps):
             paData[:, n, z] = spfp.hilbert(paData[:, n, z])
     reImg2 = np.copy(super().reconstruct(paData))
     self.reImg = np.sqrt(reImg1 ** 2 + reImg2 ** 2)
     return self.reImg
开发者ID:lirenzhucn,项目名称:PACT_code_v2,代码行数:14,代码来源:ring_pact_reconstruction.py

示例13: analytic_phase

def analytic_phase(x, t=None, subint=None):
    """ gets the phase from an amazing variety of signals
    http://en.wikipedia.org/wiki/Analytic_signal
    subinterval idea is not debugged and is probably unnecessary
    may shorten data?
    """
    from scipy.fftpack import hilbert
    from pyfusion.utils import fix2pi_skips
    from numpy import zeros, arctan2
    # this subinterval idea does not seem necessary and is not debugged
    if subint != None:
        subint=powerof2(subint)
        nsubints = int(len(x)/subint)
        phs = zeros([nsubints, subint])
        for i in range(nsubints):
            xsub = x[i*subint:(i+1)*subint]
            phs[i,:] = arctan2(xsub, hilbert(xsub))
        phi = phs.flatten()
    else:
        y=hilbert(x)  # use hilbert twice just to remove DC (lazy)
        phi = arctan2(y, hilbert(y))

    return(fix2pi_skips(phi, sign='+'))
开发者ID:shaunhaskey,项目名称:python-h1,代码行数:23,代码来源:signal_processing.py

示例14: envelope

def envelope(data):
    """
    Envelope of a function.

    Computes the envelope of the given function. The envelope is determined by
    adding the squared amplitudes of the function and it's Hilbert-Transform
    and then taking the square-root. (See [Kanasewich1981]_)
    The envelope at the start/end should not be taken too seriously.

    :param data: Data to make envelope of, type numpy.ndarray.
    :return: Envelope of input data.
    """
    hilb = hilbert(data)
    data = (data ** 2 + hilb ** 2) ** 0.5
    return data
开发者ID:kaeufl,项目名称:obspy,代码行数:15,代码来源:filter.py

示例15: Kosambi_Hilbert_phase

def Kosambi_Hilbert_phase(X, sampling_rate, passband=None, index=0, moving_window=False):

	y = Kosambi_Hilbert_torsion(X, sampling_rate, passband=passband, index=index, moving_window=moving_window)
	Hy = hilbert(y)

	radius = np.sqrt(y**2+Hy**2)
	phase = np.arctan2(y, Hy)
	phi_u = unmod(phase)

	if phi_u[-1]-phi_u[0] < 0.:	# if phase shrinks, reverse it.
		phase = -phase

	phase = np.mod(phase, pi2)

	return phase, radius
开发者ID:jusjusjus,项目名称:KHT_PRL2016,代码行数:15,代码来源:kht.py


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