scipy信号巴特沃斯滤波器后Siganl频谱功率谱的振荡

问题描述

使用scipy Butterworth滤波器套件进行信号处理时,会有奇怪的振荡结果。希望有人可以帮助我找出原因。 我想对signal_deconv实施10-40Hz带通滤波器,可以在下图的黄线中看到。 Power spectrum before filter

我将过滤器可视化如下: filter

得到以下结果: filter results

如果我理解正确,那么应该只有一个原始信号样信号的功率谱,而没有更低和更高的截止频率分量。但是,这里是应该修复的区域充满起伏的结果。

过滤器代码

from scipy.signal import butter,lfilter

def butter_bandpass(lowcut,highcut,fs,order=5):
    nyq = 0.5 * fs
    low = lowcut / nyq
    high = highcut / nyq
    b,a = butter(order,[low,high],btype='band')
    return b,a


def butter_bandpass_filter(data,lowcut,order=5):
    b,a = butter_bandpass(lowcut,order=order)
    y = lfilter(b,a,data)
    return y


import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import freqz

# Sample rate and desired cutoff frequencies (in Hz).
fs = 500
lowcut = 10
highcut = 40

# Plot the frequency response for a few different orders.
plt.figure(1)
plt.clf()
for order in [3,6]:
    b,order=order)
    w,h = freqz(b,worN=250)
    plt.plot((fs * 0.5 / np.pi) * w,abs(h),label="order = %d" % order)

plt.plot([0,0.5 * fs],[np.sqrt(0.5),np.sqrt(0.5)],'--',label='sqrt(0.5)')

title = "Marine_BP1997_shot_" + str(num_shot) + "_receiver"+str(num_receiver)+"_deconv_FFT_filter"
plt.title(title)
plt.xlabel('Frequency (Hz)')
plt.ylabel('Gain')
plt.grid(True)
plt.legend(loc='best')
plt.savefig(path_save + title + '.png')
plt.show()

工具过滤器的代码

from scipy import signal
sig_extract = butter_bandpass_filter(sig_shift,order=6)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)