Python scipy.signal.remez高通滤波器设计产生奇怪的传递函数 [英] Python scipy.signal.remez high pass filter design yields strange transfer function

查看:1898
本文介绍了Python scipy.signal.remez高通滤波器设计产生奇怪的传递函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用python的scipy.signal.remez函数设计equiripple高通滤波器。然而,由此产生的传递函数看起来很奇怪,在通带内峰值达到15dB,阻带衰减只有6dB。相应的低通设计看起来不错(〜0.1分贝的通带波纹和40分贝的阻带衰减):

 #!/ usr / bin / env python 
# - * - coding:iso-8859-15 - * -
#remez(equiripple)过滤器设计的最小工作示例:__future__ import bb,print_function
导入numpy为np
导入scipy.signal为sig
导入matplotlib.pyplot为plt
F_PB = 0.1#通带转角频率
F_SB = 0.15#转角频带的频率
W_PB = 1#通带的权重因子
W_SB = 1#阻带权重因子
L = 40#滤波器顺序
#b = sig.remez (L,[0,F_PB,F_SB,0.5],[1,0],[W_PB,W_SB],Hz = 1)#低通
b = sig.remez 0.5],[0,1],[W_PB,W_SB],Hz = 1)#高通
#计算H(w),w = 0 ... pi,1024点。将b转换为标准化的频率F = 0 ... 0.5:
F = w /(2 * np)
[w,H] = sig.freqz(b,worN = 1024) .pi)
plt.figure(1)
plt.plot(F,20 * np.log10(abs(H)))
plt.title(r'Magnitude transfer function in dB ')
plt.show()

有谁可以向我解释发生了什么事? / p>

干杯,基督徒 对于高通滤波器, a href =http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.remez.html =nofollow noreferrer> remez 参数 type ='bandpass',使用奇数的水龙头。在偶数的情况下, remez 创建一个II型滤波器,其奈奎斯特频率为零。该算法很难创建一个具有这种约束的高通滤波器。



下面是当 L = 41 $ b


$ b

OR 使用偶数的水龙头, type ='hilbert' 。下面显示了用 L = 40 type ='hilbert'获得的结果:





但是,请注意,FIR滤波器在这种情况下是IV型 - 滤波器系数具有奇对称性。

I'm trying to design equiripple high-pass filters using python's scipy.signal.remez function. However, the resulting transfer functions look very strange to me with ~ 15 db peaking in the pass band and only 6 dB stop band attenuation. The corresponding low-pass design looks ok (~ 0.1 dB pass band ripple and 40 dB stop band attenuation):

#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# Minimum working example for remez (equiripple) filter designs:
from __future__ import division, print_function
import numpy as np
import scipy.signal as sig
import matplotlib.pyplot as plt
F_PB = 0.1  # corner frequency of pass band
F_SB = 0.15 # corner frequency of stop band
W_PB = 1    # weight factor for pass band 
W_SB = 1    # weight factor for stop band
L = 40 # filter order
#b = sig.remez(L, [0, F_PB, F_SB, 0.5], [1, 0], [W_PB, W_SB], Hz = 1) # low pass
b = sig.remez(L, [0, F_PB, F_SB, 0.5], [0, 1], [W_PB, W_SB], Hz = 1) # high pass
# Calculate H(w), w = 0 ... pi, 1024 Pts.
[w, H] = sig.freqz(b, worN = 1024)
# Translate w to normalized frequencies F = 0 ... 0.5:                   
F = w / (2 * np.pi)   
plt.figure(1)
plt.plot(F, 20 * np.log10(abs(H)))
plt.title(r'Magnitude transfer function in dB')
plt.show()

Can anybody explain to me what's going on?

Cheers, Christian

解决方案

For a highpass filter with the default remez argument type='bandpass', use an odd number of taps. With an even number of taps, remez creates a Type II filter, which has a zero at the Nyquist frequency. The algorithm has a hard time creating a highpass filter with such a constraint.

Here's a plot of the gain when L = 41:

OR use an even number of taps, and type='hilbert'. The following shows the result obtained with L=40 and type='hilbert':

Note, however, that the FIR filter is Type IV in this case--the filter coefficients have odd symmetry.

这篇关于Python scipy.signal.remez高通滤波器设计产生奇怪的传递函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆