Python scipy.signal.remez高通滤波器设计产生奇怪的传递函数 [英] Python scipy.signal.remez high pass filter design yields strange transfer function
问题描述
#!/ 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>
remez
参数 type ='bandpass'
,使用奇数的水龙头。在偶数的情况下, remez
创建一个II型滤波器,其奈奎斯特频率为零。该算法很难创建一个具有这种约束的高通滤波器。 下面是当 OR 使用偶数的水龙头, 但是,请注意,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): Can anybody explain to me what's going on? Cheers, Christian For a highpass filter with the default Here's a plot of the gain when OR use an even number of taps, and Note, however, that the FIR filter is Type IV in this case--the filter coefficients have odd symmetry. 这篇关于Python scipy.signal.remez高通滤波器设计产生奇怪的传递函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! L = 41 $ c时的增益图$ c $:b
$ b
$ b type ='hilbert'
。下面显示了用 L = 40
和 type ='hilbert'
获得的结果:
#!/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()
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.L = 41
:type='hilbert'
. The following shows the result obtained with L=40
and type='hilbert'
: