Децимация породила неожиданно высокие значения? - PullRequest
0 голосов
/ 18 мая 2018

Сначала я применил фильтр низких частот 100 Гц к своим данным, который был записан с частотой 30000 Гц:

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 Гц до 250 Гц

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)

Тем не менее, полученный график показал некоторый сигнал выше 100 Гц, хотя я уже использовал фильтр нижних частот 100 Гц ранее.

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

Есть ли какое-либо объяснение этому?

Большое спасибо!

Редактировать: Это график, если фильтрация не проводилась.

enter image description here

...