很长一段时间以来,我一直在研究 python 中的插值。输入信号是以 933KHz 采样的正弦信号。我将信号上采样 5 倍,然后使用带有 Kaiser 窗口的 FIR 低通滤波器。
我在这里观察到两个问题:
- FIR 滤波器的输出被插值因子衰减。在我的情况下,乘以 5 倍。将 FIR 系数乘以插值因子正在修复它。但是,我想知道为什么会这样。
- 此外,截止频率似乎也移动了 5 倍。FIR 滤波器的截止频率约为 25KHz。但是上采样信号似乎只在 125Khz 之后才衰减。我通过过滤原始信号(没有上采样)验证了 FIR 设计是否正常,它似乎很好。当正弦波的频率高于 25Khz 时,如果频率低于 25Khz,我会看到衰减和零衰减。
我在这方面有点新手,任何进一步研究的建议也会有帮助。
代码片段:
Fin = 25 * 10 ** 3
Fs = 933.0 * 10 ** 3
N = 100
L = 7
### input signal
n = np.linspace(0, N, num=N)
x_input = np.sin(2 * np.pi * Fin * 1/Fs * n)
## upsampling
x_input_upsampled = up_sample(x_input, N, L) ===> just a module written by me. does simple matrix multiplication to achieve upsampling.
##### Kaiser window
# The Nyquist rate of the signal.
nyq_rate = Fs / 2.0
# The desired width of the transition from pass to stop,
# relative to the Nyquist rate. We'll design the filter
# with a 5 Hz transition width.
width = 5.0/nyq_rate
# The desired attenuation in the stop band, in dB.
ripple_db = 100.0
# Compute the order and Kaiser parameter for the FIR filter.
from scipy.signal import kaiserord
numtaps, beta = kaiserord(ripple_db, width)
window = ('kaiser', beta)
#### FIR filter
cutoff = 25 * 10 ** 3
cutoff_normalized = cutoff/nyq_rate
## firwin
h_windowed = signal.firwin(numtaps, cutoff_normalized, window=window)
interpolated_y = np.convolve(x_input_upsampled, h_windowed)
问候, Pradeep MC


