我想过滤频率,然后找到峰值频率。但是我得到的无关值不在频率范围内。我不知道我要去哪里错了。 Link to the project
w = np.fft.fft(data)
freqs = np.fft.fftfreq(len(w))
print(freqs.min(), freqs.max())
# (-0.5, 0.499975)
# I want to implement a bandpass filter here and I have tried this
'''
iw = butter_bandpass_filter(w, low_cut, high_cut, sample_rate, order=10)
w = np.fft.ifft(iw)
'''
# Find the peak in the coefficients
idx = np.argmax(np.abs(w))
freq = freqs[idx]
freq_in_hertz = abs(freq * frate)
print(freq_in_hertz)
# 439.8975