### scipy.signal.ellip 椭圆滤波器

scipy.signal.ellip(N, rp, rs, Wn, btype='low',analog=False, output='ba', fs=None)[source]

Elliptic (Cauer) digital and analog filterdesign.

Design an Nth-order digital or analog ellipticfilter and return the filter coefficients.

Parameters:

N ：int

Rp：float

The maximum ripple allowed below unity gain inthe passband. Specified in decibels, as a positive number. 通带中单位增益以下允许的最大值

Rs：float

The minimum attenuation required in the stopband. Specified in decibels, as a positive number. 阻带内所需的最小衰减

Wn：array_like

A scalar or length-2 sequence giving thecritical frequencies. For elliptic filters, this is the point in the transitionband at which the gain first drops below -rp.

For digital filters, Wn are in the same unitsas fs. By default, fs is 2 half-cycles/sample, so these are normalized from 0to 1, where 1 is the Nyquist frequency. (Wn is thus in half-cycles / sample.)

For analog filters, Wn is an angular frequency(e.g., rad/s).

Btype：{‘lowpass’,‘highpass’, ‘bandpass’, ‘bandstop’}, optional

The type of filter. Default is ‘lowpass’.

Analog：bool,optional

When True, return an analog filter, otherwise adigital filter is returned.

Output：{‘ba’,‘zpk’, ‘sos’}, optional

Type of output: numerator/denominator (‘ba’),pole-zero (‘zpk’), or second-order sections (‘sos’). Default is ‘ba’ forbackwards compatibility, but ‘sos’ should be used for general-purposefiltering.

Fs：float,optional

The sampling frequency of the digital system.

Returns:

b, andarray, ndarray

Numerator (b) and denominator (a)polynomials of the IIR filter. Only returned if output='ba'.

IIR滤波器的分子（B）和分母（a）多项式

z, p, kndarray,ndarray, float

Zeros, poles, and system gain of the IIRfilter transfer function. Only returned if output='zpk'.

IIR滤波器传递函数的零点、极点和系统增益。

sosndarray

Second-order sections representation ofthe IIR filter. Only returned if output='sos'.

IIR滤波器的二阶部分表示。

### scipy.signal.filtfilt滤波函数

b: 滤波器的分子系数向量

a: 滤波器的分母系数向量

x: 要过滤的数据数组。（array型）

axis: 指定要过滤的数据数组x的轴

irlen：当method为“gust”时，irlen指定滤波器的脉冲响应的长度。如果irlen是None，则脉冲响应的任何部分都被忽略。对于长信号，指定irlen可以显著改善滤波器的性能。（int型或None）

y:滤波后的数据数组

### scipy.signal.butter 巴特沃斯滤波器

scipy.signal.butter(N, Wn, btype='low', analog=False, output='ba')

N:滤波器的阶数

Wn：归一化截止频率。计算公式Wn=2*截止频率/采样频率。（注意：根据采样定理，采样频率要大于两倍的信号本身最大的频率，才能还原信号。截止频率一定小于信号本身最大的频率，所以Wn一定在0和1之间）。当构造带通滤波器或者带阻滤波器时，Wn为长度为2的列表。

btype : 滤波器类型{‘lowpass’,‘highpass’, ‘bandpass’, ‘bandstop’},

output : 输出类型{‘ba’,‘zpk’, ‘sos’},

b，a: IIR滤波器的分子（b）和分母（a）多项式系数向量。output='ba'

z,p,k: IIR滤波器传递函数的零点、极点和系统增益.output= 'zpk'

sos: IIR滤波器的二阶截面表示。output='sos'

(1).高通滤波

# 这里假设采样频率为1000hz,信号本身最大的频率为500hz，要滤除10hz以下频率成分，即截至频率为10hz，则wn=2*10/1000=0.02

# from scipy import signal

# b, a = signal.butter(8, 0.02, 'highpass')

# filtedData = signal.filtfilt(b, a, data)#data为要过滤的信号

(2).低通滤波

# 这里假设采样频率为1000hz,信号本身最大的频率为500hz，要滤除10hz以上频率成分，即截至频率为10hz，则wn=2*10/1000=0.02

# from scipy import signal

# b, a = signal.butter(8, 0.02, 'lowpass')

# filtedData = signal.filtfilt(b, a, data) #data为要过滤的信号

(3).带通滤波

# 这里假设采样频率为1000hz,信号本身最大的频率为500hz，要滤除10hz以下和400hz以上频率成分，即截至频率为10hz和400hz,则wn1=2*10/1000=0.02,wn2=2*400/1000=0.8。Wn=[0.02,0.8]

# from scipy import signal

# b, a = signal.butter(8, [0.02,0.8], 'bandpass')

# filtedData = signal.filtfilt(b, a, data) #data为要过滤的信号