带通滤波器ValueError:数字滤波器临界频率必须为0 < Wn&lt; 1

时间:2018-05-03 01:01:51

标签: python python-3.x signals bandpass-filter

我正在尝试对ecg信号使用带通滤波器, 这是代码:

const

每次尝试运行此功能时都会出现此错误:

public openWithInAppBrowser(url : string){
let theOptions = this.options;
 let target = "_blank";
 this.theInAppBrowser.create(url,target,theOptions);
}

任何人都可以帮助我。

2 个答案:

答案 0 :(得分:1)

可能是由于输入了参数fs。它必须大于2 * Wn中的任何一个。 如scipy / signal / filter_design.py源代码中所示:

if fs is not None:
    if analog:
        raise ValueError("fs cannot be specified for an analog filter")
    Wn = 2*Wn/fs

后来:

if not analog:
    if numpy.any(Wn <= 0) or numpy.any(Wn >= 1):
        raise ValueError("Digital filter critical frequencies must be 0 < Wn < 1")

答案 1 :(得分:0)

  

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

Wn:array_like

标量或长度为2的序列给出临界频率。对于巴特沃斯滤波器,这是增益下降到通带的1 / sqrt(2)的点(“-3 dB点”)。 对于数字滤波器,Wn从0归一化为1,其中1是奈奎斯特频率,pi弧度/样本。 (因此,Wn处于半周期/样本中。) 对于模拟滤波器,Wn是角频率(例如rad / s)。

你的例外是低位/高位不是[0,1]

<a href>Getting a head start in the health sector</a>
对于b, a = butter(filter_order, [low, high], btype='band', analog=False)

filter_type == 1除了nparray之外是浮动的。

https://github.com/scipy/scipy/blob/v0.19.1/scipy/signal/filter_design.py#L2226-L2297

Wn