python – Highest frequencies used in Signal (df column) with ftt
I am looking for the highest frequency of a signal_u (csv file, signal values stored in one column). Fourier transformation should be used, and find max frequency having a significant amplitude. There may be many frequencies with tiny amplitudes. Threshold can also be used to filter these out.
signal_u = csv file data:
time,s1
2017-08-29 10:30:00.000,15.12
2017-08-29 10:30:00.010,15.01
2017-08-29 10:30:00.020,14.51
2017-08-29 10:30:00.030,14.94
2017-08-29 10:30:00.040,14.96
2017-08-29 10:30:00.050,14.61
2017-08-29 10:30:00.060,14.56
2017-08-29 10:30:00.070,14.26
2017-08-29 10:30:00.080,13.95
2017-08-29 10:30:00.090,13.6
2017-08-29 10:30:00.100,13.76
2017-08-29 10:30:00.110,13.42
2017-08-29 10:30:00.120,13.62
I have tried the following:
import numpy.fft as fft{"n"}
import matplotlib.pyplot as plt
data = np.array(signal_u.iloc[:,1])
frate = 10000 #random
spectrum = np.fft.fft(data)
f_u = fft.fftfreq(len(spectrum))
print(f_u.min(), f_u.max())
print(f_u)
plt.plot(f_u, abs(spectrum))
idx = np.argmax(np.abs(spectrum))
freq = f_u[idx]
freq_in_hertz = abs(freq * frate)
print(freq_in_hertz)
Output:
-0.5 0.4999
[ 0. 0.0001 0.0002 ... -0.0003 -0.0002 -0.0001]
0.0>
The output looks wrong. What do i have to do to find the highest frequency?
Read more here: Source link