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

Python numpy.hanning函数代码示例

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

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



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

示例1: hanning_taper

 def hanning_taper(self, side='both', channels=None, offset=0):
     """Hanning taper
     
     Parameters
     ----------
     side : {'left', 'right', 'both'}
     channels : {None, int}
         The number of channels to taper. If None 5% of the total
         number of channels are tapered.
     offset : int
     
     Returns
     -------
     channels
     
     """
     if channels is None:
         channels = int(round(len(self()) * 0.02))
         if channels < 20:
             channels = 20
     dc = self.data
     if side == 'left' or side == 'both':
         dc[..., offset:channels+offset] *= (
             np.hanning(2*channels)[:channels])
         dc[...,:offset] *= 0. 
     if side== 'right' or side == 'both':
         if offset == 0:
             rl = None
         else:
             rl = -offset
         dc[..., -channels-offset:rl] *= (
             np.hanning(2*channels)[-channels:])
         if offset != 0:
             dc[..., -offset:] *= 0.
     return channels
开发者ID:AEljarrat,项目名称:hyperspy,代码行数:35,代码来源:spectrum.py


示例2: compute_window

def compute_window(x, crop1, crop2, MARGIN=0, Pow=1):
    #
    #    __margin__
    #   /          \
    #  c1          c2


    # 1D Function
    # -----------
    w = np.ones(x)
    c1 = crop1 + MARGIN
    c2 = crop2+MARGIN
    w[:c1] = np.hanning(2*c1)[:c1]**Pow
    w[-c2:] = np.hanning(2*c2)[-c2:]**Pow

    #~ import matplotlib.pyplot as plt
    #~ plt.figure()
    #~ plt.plot(w)
    #~ plt.plot(1-w)
    #~ plt.show()

    # Turn into 2D : distance to the center
    # -------------------------------------
    R, C = generate_coords((x, x))
    rmax = int(R.max()-0.5)
    M = np.int32(rmax-np.sqrt((R+0.5)**2+(C+0.5)**2));
    M[M<0] = 0
    return w[M]
开发者ID:pierrepaleo,项目名称:localtomo,代码行数:28,代码来源:utils.py


示例3: ripoc

def ripoc(f, g, M = 50, fitting_shape = (9, 9)):

    hy = numpy.hanning(f.shape[0])
    hx = numpy.hanning(f.shape[1])
    hw = hy.reshape(hy.shape[0], 1) * hx

    ff = f * hw
    gg = g * hw

    F = scipy.fftpack.fft2(ff)
    G = scipy.fftpack.fft2(gg)

    F = scipy.fftpack.fftshift(numpy.log(numpy.abs(F)))
    G = scipy.fftpack.fftshift(numpy.log(numpy.abs(G)))

    FLP = logpolar(F, (F.shape[0] / 2, F.shape[1] / 2), M)
    GLP = logpolar(G, (G.shape[0] / 2, G.shape[1] / 2), M)

    R = poc(FLP, GLP)

    angle = -R[1] / F.shape[0] * 360
    scale = 1.0 - R[2] / 100

    center = tuple(numpy.array(g.shape) / 2)
    rot = cv2.getRotationMatrix2D(center, -angle, 1.0 + (1.0 - scale))

    g_dash = cv2.warpAffine(g, rot, (g.shape[1], g.shape[0]), flags=cv2.INTER_LANCZOS4)

    t = poc(f, g_dash)

    return (t[1], t[2], angle, scale)
开发者ID:daisukekobayashi,项目名称:phase-only-correlation,代码行数:31,代码来源:poc.py


示例4: gen_spec

    def gen_spec(self,x,m):
        itsreal = np.isreal(x[0])

        lx = x.size
        nt = (lx +m -1) // m
        xb = np.append(x,np.zeros(-lx+nt*m))
        xc = np.append(np.roll(x,int(m/2)),np.zeros(nt*m - lx))


        xr = np.reshape(xb, (m,nt), order='F') * np.outer(np.hanning(m),np.ones(nt))
        xs = np.reshape(xc, (m,nt), order='F') * np.outer(np.hanning(m),np.ones(nt))

        xm = np.zeros((m,2*nt),dtype='complex')
        xm[:,::2] = xr
        xm[:,1::2] = xs
        #xm=xr

        if itsreal:
            spec = np.fft.fft(xm,m,axis=0)[int(m/2):]
        else:
            spec = np.fft.fftshift(np.fft.fft(xm,m,axis=0))
        mx = np.max(spec)

        pwr = 64*(20* np.log(np.abs(spec)/mx + 1e-6)  + 60 )/60

        return np.real(pwr)
开发者ID:peragwin,项目名称:fmradio-qt,代码行数:26,代码来源:rtanimexample.py


示例5: hanningWindow

def hanningWindow(nx, ny, nPixX, nPixY):
	"""
	Return a Hanning window in 2D
	
	Args:
	    nx (TYPE): number of pixels in x-direction of mask
	    ny (TYPE): number of pixels in y-direction of mask
	    nPixX (TYPE): number of pixels in x-direction of the transition
	    nPixY (TYPE): number of pixels in y-direction of the transition
	
	Returns:
		 real: 2D apodization mask
		
	"""					
	winX = np.hanning(nPixX)
	winY = np.hanning(nPixY)

	winOutX = np.ones(nx)
	winOutX[0:nPixX/2] = winX[0:nPixX/2]
	winOutX[-nPixX/2:] = winX[-nPixX/2:]

	winOutY = np.ones(ny)
	winOutY[0:nPixY/2] = winY[0:nPixY/2]
	winOutY[-nPixY/2:] = winY[-nPixY/2:]		

	return np.outer(winOutX, winOutY)
开发者ID:postfix,项目名称:pcaDeconvolution,代码行数:26,代码来源:lowRank.py


示例6: test_calculate_lanczos_kernel

    def test_calculate_lanczos_kernel(self):
        """
        Tests the kernels implemented in C against their numpy counterpart.
        """
        x = np.linspace(-5, 5, 11)

        values = calculate_lanczos_kernel(x, 5, "hanning")
        np.testing.assert_allclose(
            values["only_sinc"], np.sinc(x), atol=1E-9)
        np.testing.assert_allclose(
            values["only_taper"], np.hanning(len(x)), atol=1E-9)
        np.testing.assert_allclose(
            values["full_kernel"], np.sinc(x) * np.hanning(len(x)),
            atol=1E-9)

        values = calculate_lanczos_kernel(x, 5, "blackman")
        np.testing.assert_allclose(
            values["only_sinc"], np.sinc(x), atol=1E-9)
        np.testing.assert_allclose(
            values["only_taper"], np.blackman(len(x)), atol=1E-9)
        np.testing.assert_allclose(
            values["full_kernel"], np.sinc(x) * np.blackman(len(x)),
            atol=1E-9)

        values = calculate_lanczos_kernel(x, 5, "lanczos")
        np.testing.assert_allclose(
            values["only_sinc"], np.sinc(x), atol=1E-9)
        np.testing.assert_allclose(
            values["only_taper"], np.sinc(x / 5.0), atol=1E-9)
        np.testing.assert_allclose(
            values["full_kernel"], np.sinc(x) * np.sinc(x / 5.0),
            atol=1E-9)
开发者ID:rpratt20,项目名称:obspy,代码行数:32,代码来源:test_interpolation.py


示例7: bell

def bell(size, ratio):
  n = size / ratio
  first_half = numpy.hanning(n * 2)[:n] * 65535
  r = size - n
  second_half = numpy.hanning(r * 2)[r:] * 65535
  bell = list(first_half) + list(second_half) + [0]
  return bell
开发者ID:Buerk,项目名称:axoloti,代码行数:7,代码来源:lookup_tables.py


示例8: applyWindow

 def applyWindow(self, window="hanning", ww=0, cf=0):
     '''
     Apply window function to frequency domain data
     cf: the frequency the window is centered over [Hz]
     ww: the window width [Hz], if ww equals 0 the window covers the full range
     '''
     self.info("Applying %s window ..." % window)
     if window == "hanning":
         if ww == 0:
             w = np.hanning(self.numfreq)
         else:
             pos = int((cf - self.lowF) / self.deltaF)
             halfwidth = int(ww / (2.0 * self.deltaF))
             w = np.zeros(self.numfreq)
             w[pos - halfwidth:pos + halfwidth] = np.hanning(2 * halfwidth)
     elif window == "hamming":
         if ww == 0:
             w = np.hamming(self.numfreq)
         else:
             pos = int((cf - self.lowF) / self.deltaF)
             halfwidth = int(ww / (2.0 * self.deltaF))
             w = np.zeros(self.numfreq)
             w[pos - halfwidth:pos + halfwidth] = np.hamming(2 * halfwidth)
     elif window == "blackman":
         if ww == 0:
             w = np.blackman(self.numfreq)
         else:
             pos = int((cf - self.lowF) / self.deltaF)
             halfwidth = int(ww / (2.0 * self.deltaF))
             w = np.zeros(self.numfreq)
             w[pos - halfwidth:pos + halfwidth] = np.blackman(2 * halfwidth)
     self.data = self.data * w
     self.done()
开发者ID:kmunve,项目名称:processgpr,代码行数:33,代码来源:gpr.py


示例9: lcn_octaves

def lcn_octaves(X, kernel):
    """Apply octave-varying contrast normalization to an input with a given
    kernel.

    Notes:
    * This is the variant introduced in the LVCE Section of Chapter 5.
    * This approach is painfully heuristic, and tuned for the dimensions used
        in this work (36 bpo, 7 octaves).

    Parameters
    ----------
    X : np.ndarray, ndim=2, shape[1]==252.
        CQT representation, with 36 bins per octave and 252 filters.
    kernel : np.ndarray
        Convolution kernel (should be roughly low-pass).

    Returns
    -------
    Z : np.ndarray
        The processed output.
    """
    if X.shape[-1] != 252:
        raise ValueError(
            "Apologies, but this method is currently designed for input "
            "representations with a last dimension of 252.")
    x_hp = highpass(X, kernel)
    x_73 = local_l2norm(x_hp, np.hanning(73).reshape(1, -1))
    x_37 = local_l2norm(x_hp, np.hanning(37).reshape(1, -1))
    x_19 = local_l2norm(x_hp, np.hanning(19).reshape(1, -1))
    x_multi = np.array([x_73, x_37, x_19]).transpose(1, 2, 0)
    w = _create_triband_mask()**2.0
    return (x_multi * w).sum(axis=-1)
开发者ID:agangzz,项目名称:dl4mir,代码行数:32,代码来源:lcn.py


示例10: load_signature

def load_signature(guids,sample_rate,nbits):

    amp,ampS, t= .49,.49,.05                   #Variable handels for Bits
    tBit = np.arange(0,t*sample_rate+1)/float(sample_rate)  #time Vector for Bits
    F0,F1,Fsync = 19600, 19300, 19900                       #Bits Carrier Frequency


    y0=amp*np.cos(2*np.pi*F0*tBit)                          #Bit0
    winB=np.hanning(len(y0))                                #Applying Windows
    y0=y0*winB

    y1=amp*np.cos(2*np.pi*F1*tBit)                          #Bit1
    y1=y1*winB                                              #Applying Windows

    ysync=ampS*np.cos(2*np.pi*Fsync*tBit)                   #Bit for Synchronization
    winS=np.hanning(len(ysync))                             #Applying Windows
    ysync=ysync*winS

    ySilence=amp*np.sin(2*np.pi*0*tBit)                     #Adding Silence in between all bits



    y0=np.concatenate([ySilence,y0,ySilence,ysync])         #Bit0 coupled with silence and Sync
    y1=np.concatenate([ySilence,y1,ySilence,ysync])         #Bit1 coupled with silence and Sync


    guids1=guids[0]                                         #First available guid
    signature=ysync                                         #Declare and place Sync
    for g in guids1:                                        #Complete Concatenated Signature
        if g=='0':                                          # concatenate Bit0
            signature=np.concatenate([signature,y0])
        else:                                               # concatenate Bit1
            signature=np.concatenate([signature,y1])

    return signature
开发者ID:mmaazkamal,项目名称:Backend,代码行数:35,代码来源:AcousticGuids.py


示例11: fft_data

def fft_data(arr, ft='lag'):
    """
    Returns the windowed fft of a time/freq array along the time axis, freq axis, or both.
    
    Parameters
    ==========
    arr: complex array
         (nfreq x ntimes) array of complex visibilities
    ft: str
         transform to return, either lag, m, or mlag

    Returns
    =======
    Returns the fft array that was asked for in ft argument.
    """
    freq_window = np.hanning(arr.shape[0])[:, np.newaxis] 
    time_window = np.hanning(arr.shape[-1])[np.newaxis, :]

    if ft=='lag':
        return np.fft.fftshift(np.fft.fft(freq_window * arr, axis=0), axes=0)
    elif ft=='m':
        return np.fft.fftshift(np.fft.fft(time_window * arr, axis=-1), axes=-1)
    elif ft=='mlag':
        return np.fft.fftshift(np.fft.fft2(freq_window * time_window * arr))
    else:
        raise Exception('only lag, m, or mlag allowed')
开发者ID:fandinomat,项目名称:ch_misc_routines,代码行数:26,代码来源:misc_data_io.py


示例12: de_disperse

def de_disperse(Data, DM, del_t):
        """ De-disperses pulsar data. First fourier transforms data along time axis then get 
        the fourier frequencies with length "ntimes". The FT is then multiplied by the delay 
        phase factor, correcting for dispersion, and data is transformed back.
        
        Parameters
        ----------
        Data : float or array of floats
                Pulsar data array. Assumes (freq, corr_prod, time)
        DM :
                Pulsar dispersion measure in pc/cm**3 
        del_t: 
                Total observation time in seconds 
        Returns
        -------
        De-dispersed data

        """
        n_times = Data.shape[-1]
        FT_Data = np.fft.fft(np.hanning(n_times)[np.newaxis, :] * Data, axis=-1)
        ft_freq = np.fft.fftfreq(n_times)
        delay_nu = time_delay(DM, Data.shape[0])[0]
        FT_Data = FT_Data * np.exp(2j * np.pi * ft_freq[np.newaxis, :] * delay_nu[:, np.newaxis] * n_times / del_t)

        return np.fft.fft(np.hanning(n_times)[np.newaxis, :] * FT_Data, axis=-1)
开发者ID:fandinomat,项目名称:ch_misc_routines,代码行数:25,代码来源:psr_dedisperse.py


示例13: spec_est2

def spec_est2(A,d1,d2,win=True):

    """    computes 2D spectral estimate of A
           obs: the returned array is fftshifted
           and consistent with the f1,f2 arrays
           d1,d2 are the sampling rates in rows,columns   """
    
    import numpy as np

    l1,l2,l3 = A.shape
    df1 = 1./(l1*d1)
    df2 = 1./(l2*d2)
    f1Ny = 1./(2*d1)
    f2Ny = 1./(2*d2)

    f1 = np.arange(-f1Ny,f1Ny,df1)
    f2 = np.arange(-f2Ny,f2Ny,df2)
    
    if win == True:
        wx = np.matrix(np.hanning(l1))
        wy =  np.matrix(np.hanning(l2))
        window_s = np.repeat(np.array(wx.T*wy),l3).reshape(l1,l2,l3)
    else:
        window_s = np.ones((l1,l2,l3))

    an = np.fft.fft2(A*window_s,axes=(0,1))
    E = (an*an.conjugate()) / (df1*df2) / ((l1*l2)**2)
    E = np.fft.fftshift(E)
    E = E.mean(axis=2)

    return np.real(E),f1,f2,df1,df2,f1Ny,f2Ny
开发者ID:crocha700,项目名称:MITgcm_llc_4320,代码行数:31,代码来源:2d_spec_estimate_uv_nondiv.py


示例14: new_resize_data_fft

def new_resize_data_fft(data,factor=3,window=14):
    xwidth, ywidth = data.shape
    max_size = max(data.shape)

    print window
    #create hanning window and apply
    #hx = kaiser(xwidth,window)
    #hy = kaiser(ywidth,window)
    hx = hanning(xwidth)
    hy = hanning(ywidth)
    ham2d = sqrt(outer(hx,hy))

    if window is not None:
        data = data*ham2d

    #just create an array odd number as big
    #to avoid overuns etc - It needs to be padded anyhow
    max_size = max_size*factor

    if not max_size % 2:
        print "Not correct"
        return -1
        
    new_array = zeros([max_size, max_size], dtype="complex")
    x_start = (max_size - 1)/2 - (xwidth-1)/2
    x_end = x_start + xwidth
    y_start = (max_size - 1)/2 - (xwidth-1)/2
    y_end = y_start + ywidth

    print x_start,x_end,y_start,y_end

    new_array[x_start:x_end,y_start:y_end] = data
        
    return new_array,ham2d
开发者ID:CCATObservatory,项目名称:ccat-wfs-software,代码行数:34,代码来源:ffttools.py


示例15: __init__

    def __init__(self):
        """ """
#         self.in_filename = 'WURB-1_20160612T230008+0200_N57.6629E12.6390_FS-384_Enil_UTAN_KON_TESTFIL-INDATA-FDX.wav'
        self.in_filename = 'TEST_FS384.wav'
        self.out_filename = 'TEST_FDX.wav'
        self.sample_rate_in = 384000
        self.sample_rate_out = 38400 ###### 44100
        self.channels = 1
        self.sample_width = 2 # 16 bits.
#         self.buffer_size_in = 1024 * 16
        self.buffer_size_in = 1024 * 4
#         self.buffer_size_in = 1024 * 2
#         self.buffer_size_out = 1878
#         self.buffer_size_out = 648
#         self.buffer_size_out = 204
        self.buffer_size_out = 408
#        self.buffer_size_out = 202
        self.divide_factor = 10
        self.overlap_in = self.buffer_size_in / 2
        self.overlap_out = self.buffer_size_out / 2
        # Create Hann window
#         self.window_in=0.5-np.cos(np.arange(self.buffer_size_in,dtype='float')*2.0*np.pi/(self.buffer_size_in-1))*0.5
#         self.window_out=0.5-np.cos(np.arange(self.buffer_size_out,dtype='float')*2.0*np.pi/(self.buffer_size_out-1))*0.5
        self.window_in=np.hanning(self.buffer_size_in)
        self.window_out=np.hanning(self.buffer_size_out)
        #
        self.extra_freq_bins = None
        # Perform translation.
        self.from_fs384_to_fdx()       
开发者ID:arnoldandreasson,项目名称:cloudedbats,代码行数:29,代码来源:sound_processing.py


示例16: window_func_2d

def window_func_2d(height, width):
    win_col = np.hanning(width)
    win_row = np.hanning(height)
    mask_col, mask_row = np.meshgrid(win_col, win_row)

    win = mask_col * mask_row

    return win
开发者ID:TianhongDai,项目名称:mosse-object-tracking,代码行数:8,代码来源:utils.py


示例17: comp_sig_repr

 def comp_sig_repr(self):
     """Computes the signal representation, stft
     """
     if not hasattr(self.audioObject, '_data'):
         self.audioObject._read()
     
     if self.verbose:
         print ("Computing the chosen signal representation:")
     
     nc = self.audioObject.channels
     if nc != 2:
         raise ValueError("This implementation only deals "+
                          "with stereo audio!")
     
     self.sig_repr = {}
     
     # if more than 1min of signal, take 1 min in the middle
     # better way : sample data so as to take randomly in the signal
     lengthData = self.audioObject.data.shape[0]
     startData = 0
     endData = lengthData
     oneMinLenData = 60*self.audioObject.samplerate
     oneMinLenData *= 2 # or more than 1min?
     
     if lengthData>oneMinLenData:
         startData = (lengthData - oneMinLenData)/2
         endData = startData + oneMinLenData
         
     if self.sig_repr_params['tfrepresentation'] == 'stftold':
         self.sig_repr[0], freqs, times = ao.stft(
             self.audioObject.data[startData:endData,0],
             window=np.hanning(self.sig_repr_params['wlen']),
             hopsize=self.sig_repr_params['hopsize'],
             nfft=self.sig_repr_params['fsize'],
             fs=self.audioObject.samplerate
             )
         
         self.sig_repr[1], freqs, times = ao.stft(
             self.audioObject.data[startData:endData,1],
             window=np.hanning(self.sig_repr_params['wlen']),
             hopsize=self.sig_repr_params['hopsize'],
             nfft=self.sig_repr_params['fsize'],
             fs=self.audioObject.samplerate
             )
     else:
         self.tft.computeTransform(
             self.audioObject.data[startData:endData,0],)
         self.sig_repr[0] = self.tft.transfo
         self.tft.computeTransform(
             self.audioObject.data[startData:endData,1],)
         self.sig_repr[1] = self.tft.transfo
         freqs = self.tft.freq_stamps
             
     # keeping the frequencies, not computing them each time
     self.freqs = freqs
     
     del self.audioObject.data
开发者ID:ParisiLabs,项目名称:pyfasst,代码行数:57,代码来源:demixTF.py


示例18: initialize

    def initialize(self, frame, target_centre, target_shape, context=2,
                   features=no_op, learn_filter=learn_mosse,
                   increment_filter=increment_mosse, response_cov=3,
                   n_perturbations=10, noise_std=0.04, l=0.01,
                   normalize=normalizenorm_vec, mask=True,
                   boundary='constant'):

        self.target_shape = target_shape
        self.learn_filter = learn_filter
        self.increment_filter = increment_filter
        self.features = features
        self.l = l
        self.normalize = normalize
        self.boundary = boundary

        # compute context shape
        self.context_shape = np.round(context * np.asarray(target_shape))
        self.context_shape[0] += (0 if np.remainder(self.context_shape[0], 2)
                                  else 1)
        self.context_shape[1] += (0 if np.remainder(self.context_shape[1], 2)
                                  else 1)

        # compute subframe size
        self.subframe_shape = self.context_shape + 8
        # compute target centre coordinates in subframe
        self.subframe_target_centre = PointCloud((
            self.subframe_shape // 2)[None])

        # extract subframe
        subframe = frame.extract_patches(target_centre,
                                         patch_size=self.subframe_shape)[0]

        # compute features
        subframe = self.features(subframe)

        # obtain targets
        targets = extract_targets(subframe, self.subframe_target_centre,
                                  self.context_shape, n_perturbations,
                                  noise_std)

        # generate gaussian response
        self.response = generate_gaussian_response(self.target_shape[-2:],
                                                   response_cov)

        if mask:
            cy = np.hanning(self.context_shape[0])
            cx = np.hanning(self.context_shape[1])
            self.cosine_mask = cy[..., None].dot(cx[None, ...])

        targets_pp = []
        for j, t in enumerate(targets):
            targets_pp.append(self._preprocess_vec(t))
        targets_pp = np.asarray(targets_pp)

        self.filter, self.num, self.den = self.learn_filter(
            targets_pp, self.response, l=self.l, boundary=self.boundary)
开发者ID:duxiaofei283,项目名称:templatetracker,代码行数:56,代码来源:base.py


示例19: get_wins

def get_wins(correlation):
    
    # Initialize array for windows
    win_signl = np.zeros(len(correlation.data))
    win_noise = np.zeros(len(correlation.data))
    success = False
    
    # Determine window bounds for signal window
    s_0 = int((len(correlation.data)-1)/2)
    t_lo = int((correlation.stats.sac['dist']/minp.g_speed-minp.hw)*\
    correlation.stats.sampling_rate)
    t_hi = int((correlation.stats.sac['dist']/minp.g_speed+minp.hw)*\
    correlation.stats.sampling_rate)
    w_ind = (s_0-t_hi+1, s_0-t_lo+1, s_0+t_lo, s_0+t_hi)

    if w_ind[2] < w_ind[1] and minp.win_overlap == False:
        if minp.verbose == True:
            print 'No windows found. (Windows overlap) '
        return win_signl, win_noise, success
        
    
    # Construct signal window
    if minp.window == 'boxcar':
         win_signl[w_ind[0]:w_ind[1]] += 1.
         win_signl[w_ind[2]:w_ind[3]] += 1.
    elif minp.window == 'hann':
         win_signl[w_ind[0]:w_ind[1]] += np.hanning(w_ind[1]-w_ind[0])
         win_signl[w_ind[2]:w_ind[3]] += np.hanning(w_ind[3]-w_ind[2])
   
    
    # Determine window bounds for noise window
    noisewinshift = minp.sepsignoise*minp.hw
    t_lo = t_hi + int(noisewinshift*correlation.stats.sampling_rate)
    t_hi = t_lo + int(2*minp.hw*correlation.stats.sampling_rate)
    w_ind = (s_0-t_hi+1, s_0-t_lo+1, s_0+t_lo, s_0+t_hi)
    
    # Out of bounds?
    if w_ind[0] < 0 or w_ind[3] > len(correlation.data):
        if minp.verbose == True:
            print 'No windows found. (Noise window not covered by data)'
        # return two zero arrays - no measurement possible
        return win_noise, win_noise, success

    # Construct noise window
    if minp.window == 'boxcar':
         win_noise[w_ind[0]:w_ind[1]] += 1.
         win_noise[w_ind[2]:w_ind[3]] += 1.
    elif minp.window == 'hann':
         win_noise[w_ind[0]:w_ind[1]] += np.hanning(w_ind[1]-w_ind[0])
         win_noise[w_ind[2]:w_ind[3]] += np.hanning(w_ind[3]-w_ind[2])
    success = True
    
    return win_signl, win_noise, success

    
    
开发者ID:echolite,项目名称:ANTS,代码行数:53,代码来源:measr_asym.py


示例20: hanning2D

def hanning2D(M, N):
    """
    A 2D hanning window, as per IDL's hanning function.  See numpy.hanning for the 1D description
    """
    if N <= 1:
        return np.hanning(M)
    elif M <= 1:
        return np.hanning(N) # scalar unity; don't window if dims are too small
    else:
        return np.outer(np.hanning(M),np.hanning(N))
开发者ID:acostaj,项目名称:devel,代码行数:10,代码来源:bdm_array.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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