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


Python signal.cheby1函数代码示例

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


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

示例1: _design

    def _design(self):
        if not self.ripple and 'ripple' in self.filter_parameters:
            self.ripple = self.filter_parameters['ripple']
        elif not self.ripple and 'ripple' not in self.filter_parameters:
            raise ValueError("Needs a ripple value.")

        if self.already_normalized_Wn:
            self.Z, self.P, self.K = signal.cheby1(self.N, self.ripple, self.Wn,
                                                   self.filter_kind, analog=False,
                                                   output='zpk')
        else:
            self.Z, self.P, self.K = signal.cheby1(self.N, self.ripple, self.normalize_Wn(),
                                                   self.filter_kind, analog=False,
                                                   output='zpk')
开发者ID:Python-Devs-Brasil,项目名称:pyfilter,代码行数:14,代码来源:digital.py

示例2: decimate

def decimate(x, q, n=None, ftype='iir', axis=-1, zero_phase=False):
    """
    Downsample the signal by using a filter.

    By default, an order 8 Chebyshev type I filter is used.  A 30 point FIR
    filter with hamming window is used if `ftype` is 'fir'.

    Parameters
    ----------
    x : ndarray
        The signal to be downsampled, as an N-dimensional array.
    q : int
        The downsampling factor.
    n : int, optional
        The order of the filter (1 less than the length for 'fir').
    ftype : str {'iir', 'fir'}, optional
        The type of the lowpass filter.
    axis : int, optional
        The axis along which to decimate.
    zero_phase : bool
        Prevent phase shift by filtering with ``filtfilt`` instead of ``lfilter``.
    Returns
    -------
    y : ndarray
        The down-sampled signal.

    See also
    --------
    resample

    Notes
    -----
    The ``zero_phase`` keyword was added in 0.17.0.
    The possibility to use instances of ``lti`` as ``ftype`` was added in 0.17.0.

    """

    if not isinstance(q, int):
        raise TypeError("q must be an integer")

    if ftype == 'fir':
        if n is None:
            n = 30
        system = lti(firwin(n + 1, 1. / q, window='hamming'), 1.)

    elif ftype == 'iir':
        if n is None:
            n = 8
        system = lti(*cheby1(n, 0.05, 0.8 / q))
    else:
        system = ftype

    if zero_phase:
        y = filtfilt(system.num, system.den, x, axis=axis)
    else:
        y = lfilter(system.num, system.den, x, axis=axis)

    sl = [slice(None)] * y.ndim
    sl[axis] = slice(None, None, q)
    return y[sl]
开发者ID:felipebetancur,项目名称:python-acoustics,代码行数:60,代码来源:signal.py

示例3: decimate_coeffs

def decimate_coeffs(q, n=None, ftype='iir'):

    if type(q) != type(1):
        raise Error, "q should be an integer"

    if n is None:
        if ftype == 'fir':
            n = 30
        else:
            n = 8
            
    if ftype == 'fir':
        coeffs = GlobalVars.decimate_fir_coeffs
        if (n, 1./q) not in coeffs:
            coeffs[n,1./q] = signal.firwin(n+1, 1./q, window='hamming')
        
        b = coeffs[n,1./q]
        return b, [1.], n 

    else:
        coeffs = GlobalVars.decimate_iir_coeffs
        if (n,0.05,0.8/q) not in coeffs:
            coeffs[n,0.05,0.8/q] = signal.cheby1(n, 0.05, 0.8/q)
           
        b, a = coeffs[n,0.05,0.8/q]
        return b, a, n
开发者ID:kshramt,项目名称:pyrocko,代码行数:26,代码来源:util.py

示例4: data_hpass

    def data_hpass(self, x, Wp, srate):
        ''' High-pass filter '''
        Wp = float(Wp*2/srate)
        Ws = Wp*float(self.lineEdit_19.text())
        Rp = float(self.lineEdit_17.text())
        Rs = float(self.lineEdit_18.text())

        tempstring = self.lineEdit_16.text()
        if tempstring == 'auto':
            if self.comboBox_2.currentIndex() == 0:
                (norder, Wn) = buttord(Wp, Ws, Rp, Rs)
            elif self.comboBox_2.currentIndex() == 1:
                (norder, Wn) = ellipord(Wp, Ws, Rp, Rs)
            else:
                (norder, Wn) = cheb1ord(Wp, Ws, Rp, Rs)
        else:
            norder = float(tempstring)
            Wn = Wp

        if self.comboBox_2.currentIndex() == 0:
            (b, a)  =  butter(norder, Wn, btype = 'high')
        elif self.comboBox_2.currentIndex() == 1:
            (b, a)  =  ellip(norder, Rp, Rs, Wn)
        else:
            (b, a)  =  cheby1(norder, Rp, Wn)


        y  =  filtfilt(b, a, x)

        return(y)
开发者ID:Bruyant,项目名称:Linx,代码行数:30,代码来源:Linx.py

示例5: bandpass

 def bandpass(x, y):
     cutoff1 = int(x)
     cutoff2 = int(y)
     fs = 48000
     Wn = [cutoff1/(fs/2), cutoff2/(fs/2)]
     b, a = signal.cheby1(1, 1, Wn, 'bandpass', analog=False)
     return b, a
开发者ID:SoCdesign,项目名称:webserver,代码行数:7,代码来源:test.py

示例6: test_decimate

def test_decimate():
    from numpy import arange,sin
    from scipy.signal import decimate, resample, cheby1, lfilter, filtfilt
    t = arange(0,30)
    q = 2
    n = 8
    print(t)
    print(decimate(t,2))
    print(resample(t, len(t)/2))
    t2 = sin(t)
    print(t2)
    print(len(t2))
    d2 = decimate(t2,2, ftype='fir')
    print(d2)
    print(len(d2))
    b, a = cheby1(n, 0.05, 0.8 / q)
    print(b,a)
    y = filtfilt(b, a, t2)
    print(y)
    sl = [slice(None)] * y.ndim

    sl[-1] = slice(None, None, -q)
    print(sl)
    print(y[sl])
    print(t2[sl])
    #r2 = resample(t2, len(t2)/2)
    #print(r2)
    #print(len(r2))
    assert(False)
开发者ID:mattare2,项目名称:python-acoustic-similarity,代码行数:29,代码来源:test_helper.py

示例7: HPmin

 def HPmin(self, fil_dict):
     self._get_params(fil_dict)
     self.N, self.F_PBC = cheb1ord(self.F_PB,self.F_SB, self.A_PB,self.A_SB,
                                                       analog=self.analog)
     if not self._test_N():
         return -1
     self._save(fil_dict, sig.cheby1(self.N, self.A_PB, self.F_PBC,
                     btype='highpass', analog=self.analog, output=self.FRMT))
开发者ID:chipmuenk,项目名称:pyFDA,代码行数:8,代码来源:cheby1.py

示例8: BSmin

 def BSmin(self, fil_dict):
     self._get_params(fil_dict)
     self.N, self.F_PBC = cheb1ord([self.F_PB, self.F_PB2],
         [self.F_SB, self.F_SB2], self.A_PB,self.A_SB, analog = self.analog)
     if not self._test_N():
         return -1
     self._save(fil_dict, sig.cheby1(self.N, self.A_PB, self.F_PBC,
                     btype='bandstop', analog=self.analog, output=self.FRMT))
开发者ID:chipmuenk,项目名称:pyFDA,代码行数:8,代码来源:cheby1.py

示例9: cheby_filter

def cheby_filter(frames):
    b, a = signal.cheby1(order, rp, Wn, 'bandpass', analog=False)
    print "Filtering..."
    frames = signal.filtfilt(b, a, frames, axis=0)
    #for i in range(frames.shape[-1]):
    #    frames[:, i] = signal.filtfilt(b, a, frames[:, i])
    print "Done!"
    return frames
开发者ID:fbolanos,项目名称:ImagingAnalysis,代码行数:8,代码来源:old_filter.py

示例10: __init__

 def __init__(self, threshold_freq, order=2, design='cheby1'):
     """
     :param threshold_freq: Threshold frequency to filter out, as a fraction of sampling freq.  E.g. 0.1
     """
     self.b, self.a = \
         butter(N=order, Wn=threshold_freq, btype='low') if design == 'butter' else \
         cheby1(N=order, rp=0.1, Wn=threshold_freq, btype='low') if design == 'cheby1' else \
         bad_value(design)
     self.filter_state = lfilter_zi(b=self.b, a=self.a)
开发者ID:petered,项目名称:pdnn-test,代码行数:9,代码来源:pid_encoder_decoder.py

示例11: decimate

def decimate(x, q, n=None, ftype='iir', axis=-1):
    """Downsample the signal x by an integer factor q, using an order n filter

    By default, an order 8 Chebyshev type I filter is used or a 30 point FIR 
    filter with hamming window if ftype is 'fir'.

    (port to python of the GNU Octave function decimate.)

    Inputs:
        x -- the signal to be downsampled (N-dimensional array)
        q -- the downsampling factor
        n -- order of the filter (1 less than the length of the filter for a
             'fir' filter)
        ftype -- type of the filter; can be 'iir' or 'fir'
        axis -- the axis along which the filter should be applied

    Outputs:
        y -- the downsampled signal

    """

    if type(q) != type(1):
        raise TypeError("q should be an integer")

    if n is None:
        if ftype == 'fir':
            n = 30
        else:
            n = 8
    if ftype == 'fir':
        # PBS - This method must be verified
        b = firwin(n+1, 1./q, window='hamming')
        y = lfilter(b, 1., x, axis=axis)
    else:
        (b, a) = cheby1(n, 0.05, 0.8/q)

        # reshape the data to 2D with time on the 2nd dimension
        origshape = x.shape
        y = reshape_to_2d(x,axis)

        # loop over final dimension
        for i in range(y.shape[0]):
            y[i] = filtfilt(b,a,y[i])
        #y = filtfilt2(b,a,y)

        # reshape the data back
        y = reshape_from_2d(y,axis,origshape)

        # This needs to be filtfilt eventually
        #y = lfilter(b, a, x, axis=axis)

    return y.swapaxes(0,axis)[::q].swapaxes(0,axis)
开发者ID:ctw,项目名称:ptsa_new,代码行数:52,代码来源:filt.py

示例12: cheby1_lowpass_filter

def cheby1_lowpass_filter(_data, _frequency_cutoff, _carrier_frequency, order):
    """

    :param _data: The data to be lowpassed
    :param _frequency_cutoff: The frequency cutoff for the filter
    :param _carrier_frequency: The carrier frequency for the filter
    :param order: The order of the filter
    :return: The output of the lowpass filter (entire window)
    """
    nyq = 0.5 * _carrier_frequency
    low = _frequency_cutoff / nyq
    b, a = signal.cheby1(order, 5, low, 'low', analog=False, output='ba')
    return signal.lfilter(b, a, _data)
开发者ID:kevroy314,项目名称:AccTCP,代码行数:13,代码来源:Filters.py

示例13: decimate

def decimate(x, q, n=None, ftype='iir', axis=-1):
    """
    Downsample the signal by using a filter.

    By default, an order 8 Chebyshev type I filter is used. A 30 point FIR
    filter with hamming window is used if `ftype` is 'fir'.

    Parameters
    ----------
    x : ndarray
    The signal to be downsampled, as an N-dimensional array.
    q : int
    The downsampling factor.
    n : int, optional
    The order of the filter (1 less than the length for 'fir').
    ftype : str {'iir', 'fir'}, optional
    The type of the lowpass filter.
    axis : int, optional
    The axis along which to decimate.

    Returns
    -------
    y : ndarray
    The down-sampled signal.

    See also
    --------
    resample

    """

    if not isinstance(q, int):
        raise TypeError("q must be an integer")

    if n is None:
        if ftype == 'fir':
            n = 30
        else:
            n = 8

    if ftype == 'fir':
        b = signal.firwin(n + 1, 1. / q, window='hamming')
        a = 1.
    else:
        b, a = signal.cheby1(n, 0.05, 0.8 / q)

    y = signal.lfilter(b, a, x, axis=axis)

    sl = [slice(None)] * y.ndim
    sl[axis] = slice(None, None, q)
    return y[sl]
开发者ID:mcoughlin,项目名称:gwpy,代码行数:51,代码来源:series.py

示例14: __init__

 def __init__(self,M_change = 12,fcutoff=0.9,N_filt_order=8,ftype='butter'):
     """
     Object constructor method
     """
     self.M = M_change # Rate change factor M or L
     self.fc = fcutoff*.5 # must be fs/(2*M), but scale by fcutoff
     self.N_forder = N_filt_order
     if ftype.lower() == 'butter':
         self.b, self.a = signal.butter(self.N_forder,2/self.M*self.fc)
     elif ftype.lower() == 'cheby1':
         # Set the ripple to 0.05 dB
         self.b, self.a = signal.cheby1(self.N_forder,0.05,2/self.M*self.fc)
     else:
         print('ftype must be "butter" or "cheby1"')
开发者ID:akatumba,项目名称:scikit-dsp-comm,代码行数:14,代码来源:multirate_helper.py

示例15: blackbox

def blackbox(x, samplerate, axis=0):
    """Some unknown (except that it's LTI) digital system.

    Parameters
    ----------
    x : array_like
        Input signal.
    samplerate : float
        Sampling rate in Hertz.
    axis : int, optional
        The axis of the input data array along which to apply the
        system.  By default, this is the first axis.

    Returns
    -------
    numpy.ndarray
        The output signal.

    """
    # You are not supposed to look!
    b, a = signal.cheby1(8, 0.1, 3400 * 2 / samplerate)
    x = signal.lfilter(b, a, x, axis)
    b, a = signal.cheby1(4, 0.1, 300 * 2 / samplerate, 'high')
    return signal.lfilter(b, a, x, axis)
开发者ID:spatialaudio,项目名称:selected-topics-in-audio-signal-processing-exercises,代码行数:24,代码来源:tools.py


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