I placed vibrations of a component using accelerometers, then produced a dataframe with accelerations, that is, dataframe with the following columns: accX, accY and accZ. It is a variable in time, that is, a time series.
My idea is to transform the domain (time (s)) of this variable into the frequency domain (Hz) using fast transform furrier. And for that, I've been researching how I can do it, and one of the most used is fft from the numpy library. However, I couldn't bring it to mine.
I have been trying:
# Apply the FFT function to each column
fft_result_X = np.fft.fft(accX)
fft_result_Y = np.fft.fft(accY)
fft_result_Z = np.fft.fft(accZ)
# Calculate the magnitude of the power spectrum of each column
power_spectrum_X = np.abs(fft_result_X) ** 2
power_spectrum_Y = np.abs(fft_result_Y) ** 2
power_spectrum_Z = np.abs(fft_result_Z) ** 2
# Frequencies corresponding to the spectrum
frequencies = np.fft.fftfreq(len(accX), 1/62.5)
But, scaling up the accY power spectrum plot, there is a strange behavior in my eyes, see:
I've also been using:
data = dado['accX'].values
ps = np.abs(np.fft.fft(data))**2
time_step = 1 / 62.5 # sampling frequency
freqs = np.fft.fftfreq(data.size, time_step)
idx = np.argsort(freqs)
plt.plot(freqs[idx], ps[idx])
plt.show()