當前位置: 首頁>>代碼示例>>Python>>正文


Python signal.sosfilt方法代碼示例

本文整理匯總了Python中scipy.signal.sosfilt方法的典型用法代碼示例。如果您正苦於以下問題:Python signal.sosfilt方法的具體用法?Python signal.sosfilt怎麽用?Python signal.sosfilt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.signal的用法示例。


在下文中一共展示了signal.sosfilt方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: bandpass_filter

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def bandpass_filter(signal_in,f_band_nom): 


	'''	Filter N channels with fir filter of order 101

	Keyword arguments:
	signal_in -- numpy array of size [NO_channels, NO_samples]
	f_band_nom -- normalized frequency band [freq_start, freq_end]

	Return:	filtered signal 
	'''
	order = 4
	sos = butter(order, f_band_nom, analog=False, btype='band', output='sos')
	sig_filt = sosfilt(sos, signal_in)

	return sig_filt 
開發者ID:MultiScale-BCI,項目名稱:IV-2a,代碼行數:18,代碼來源:filters.py

示例2: __butter_bandstop_filter

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def __butter_bandstop_filter(self, data, lowcut, highcut, fs, order=5):
        sos = self.__butter_bandstop(lowcut, highcut, fs, order=order)
        y = sosfilt(sos, data).astype(np.float32)
        return y 
開發者ID:iver56,項目名稱:audiomentations,代碼行數:6,代碼來源:transforms.py

示例3: test_iir_filter

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def test_iir_filter(filtername):
    sos = FILTERS[filtername]
    assert len(sos.shape) == 2
    assert sos.shape[1] == 6, sos.shape

    t, noise = noisy_chirp(fs=FS, seconds=1.0)

    ref = signal.sosfilt(sos, noise)
    out = eml_signal.iirfilter(sos, noise)
    rel_err = numpy.abs((out-ref)/ref)

    assert ref.shape == out.shape, out.shape
    numpy.testing.assert_allclose(ref, out, atol=1e-4)
    assert numpy.median(rel_err) < 1e-4 
開發者ID:emlearn,項目名稱:emlearn,代碼行數:16,代碼來源:test_filters.py

示例4: filter

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def filter(self,x):
        """
        Filter the signal using second-order sections
        """
        y = signal.sosfilt(self.sos,x)
        return y 
開發者ID:mwickert,項目名稱:scikit-dsp-comm,代碼行數:8,代碼來源:multirate_helper.py

示例5: up

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def up(self,x,L_change = 12):
        """
        Upsample and filter the signal
        """
        y = L_change*ssd.upsample(x,L_change)
        y = signal.sosfilt(self.sos,y)
        return y 
開發者ID:mwickert,項目名稱:scikit-dsp-comm,代碼行數:9,代碼來源:multirate_helper.py

示例6: dn

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def dn(self,x,M_change = 12):
        """
        Downsample and filter the signal
        """
        y = signal.sosfilt(self.sos,x)
        y = ssd.downsample(y,M_change)
        return y 
開發者ID:mwickert,項目名稱:scikit-dsp-comm,代碼行數:9,代碼來源:multirate_helper.py

示例7: driving_signals_25d

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def driving_signals_25d(delay, weight, sos, phaseshift, signal):
    """Get 2.5-dimensional NFC-HOA driving signals.

    Parameters
    ----------
    delay : float
        Overall delay in seconds.
    weight : float
        Overall weight.
    sos : list of array_like
        Second-order section filters :func:`scipy.signal.sosfilt`.
    phaseshift : (N,) array_like
        Phase shift in radians.
    signal : (L,) array_like + float
        Excitation signal consisting of (mono) audio data and a sampling
        rate (in Hertz).  A `DelayedSignal` object can also be used.

    Returns
    -------
    `DelayedSignal`
        A tuple containing the delayed signals (in a `numpy.ndarray`
        with shape ``(L, N)``), followed by the sampling rate (in Hertz)
        and a (possibly negative) time offset (in seconds).

    """
    data, fs, t_offset = _util.as_delayed_signal(signal)
    N = len(phaseshift)
    out = _np.tile(_np.expand_dims(_sig.sosfilt(sos[0], data), 1), (1, N))
    for m in range(1, len(sos)):
        modal_response = _sig.sosfilt(sos[m], data)[:, _np.newaxis]
        out += modal_response * _np.cos(m * phaseshift)
    return _util.DelayedSignal(2 * weight * out, fs, t_offset + delay) 
開發者ID:sfstoolbox,項目名稱:sfs-python,代碼行數:34,代碼來源:nfchoa.py

示例8: driving_signals_3d

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def driving_signals_3d(delay, weight, sos, phaseshift, signal):
    """Get 3-dimensional NFC-HOA driving signals.

    Parameters
    ----------
    delay : float
        Overall delay in seconds.
    weight : float
        Overall weight.
    sos : list of array_like
        Second-order section filters :func:`scipy.signal.sosfilt`.
    phaseshift : (N,) array_like
        Phase shift in radians.
    signal : (L,) array_like + float
        Excitation signal consisting of (mono) audio data and a sampling
        rate (in Hertz).  A `DelayedSignal` object can also be used.

    Returns
    -------
    `DelayedSignal`
        A tuple containing the delayed signals (in a `numpy.ndarray`
        with shape ``(L, N)``), followed by the sampling rate (in Hertz)
        and a (possibly negative) time offset (in seconds).

    """
    data, fs, t_offset = _util.as_delayed_signal(signal)
    N = len(phaseshift)
    out = _np.tile(_np.expand_dims(_sig.sosfilt(sos[0], data), 1), (1, N))
    for m in range(1, len(sos)):
        modal_response = _sig.sosfilt(sos[m], data)[:, _np.newaxis]
        out += (2 * m + 1) * modal_response * _legendre(m, _np.cos(phaseshift))
    return _util.DelayedSignal(weight / 4 / _np.pi * out, fs, t_offset + delay) 
開發者ID:sfstoolbox,項目名稱:sfs-python,代碼行數:34,代碼來源:nfchoa.py

示例9: butter_fir_filter

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def butter_fir_filter(signal_in,filter_coeff):

	if filter_coeff.ndim == 2: # butter worth 
		return sosfilt(filter_coeff, signal_in)
	elif filter_coeff.ndim ==1: # fir filter 
		
		NO_channels ,NO_samples = signal_in.shape 
		sig_filt = np.zeros((NO_channels ,NO_samples))

		for channel in range(0,NO_channels):
			sig_filt[channel] = signal.convolve(signal_in[channel,:],filter_coeff,mode='same') # signal has same size as signal_in (centered)
		
		return sig_filt 
開發者ID:MultiScale-BCI,項目名稱:IV-2a,代碼行數:15,代碼來源:filters.py

示例10: butter_bandpass_filter

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import sosfilt [as 別名]
def butter_bandpass_filter(data, lowcut, highcut, fs, order=5):
        sos = butter_bandpass(lowcut, highcut, fs, order=order)
        y = sosfilt(sos, data)
        return y 
開發者ID:MultiScale-BCI,項目名稱:IV-2a,代碼行數:6,代碼來源:filters.py


注:本文中的scipy.signal.sosfilt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。