抽取产生了意想不到的高值?

时间:2018-05-18 15:11:19

标签: python numpy scipy signal-processing

我首先对我的数据应用了100 Hz低通滤波器,该数据以30000 Hz记录:

import numpy as np
from scipy import signal as ss
from scipy.signal import butter, lfilter, freqz
import matplotlib.pyplot as plt

def butter_lowpass(low_cutoff, fs, order=5):
    nyq = 0.5 * fs
    normal_low_cutoff = low_cutoff / nyq
    b_low, a_low = butter(order, normal_low_cutoff, btype='lowpass', analog=False)
    return b_low, a_low

def butter_lowpass_filter(data, low_cutoff, fs, order=5):
    b_low, a_low = butter_lowpass(low_cutoff, fs, order=order)
    y_low = ss.lfilter(b_low, a_low, data)
    return y_low

# Filter requirements.
order = 5
fs = 30000      # sample rate, Hz
low_cutoff = 100 # desired cutoff frequency of the filter, Hz

print('Filtering data')
filtered_array = butter_lowpass_filter(array, low_cutoff, fs, order)

然后我将我的数据从30000 Hz下采样到250 Hz

updated_array=ss.decimate(filtered_array, 12, ftype = 'fir')
newarray = ss.decimate(updated_array,10, ftype = 'fir')

然后将抽取的结果应用于频谱图:

frequencies, time, Sxx = ss.spectrogram(newarray,sampling_rate, ss.get_window('hamming', bin_size), noverlap=0, nfft=sampling_rate*4)

然而,结果图显示某些信号高于100Hz,即使我之前已经使用过低通道100Hz滤波器。

Plot for reference. X-axis is frequency (Hz), Y-axis is power density

对此有任何解释吗?

非常感谢!

编辑:这是未执行过滤的情节。

enter image description here

0 个答案:

没有答案