Reputation: 355
I work with vibration, and I am trying to get the following information from a FFT amplitude:
I am performing an FFT on a simple sine wave function, considering a Hanning windowing. Note that the "full amplitude" from the sine wave function is 5, and running the code below the FFT gives me 2.5 amplitude result. So, in this case, I am getting the peak from FFT. What about peak to peak and RMS?
P.-S. - I am not interested in the RMS of a bandwidth frequency (i.e parsevall theorem). I am interested in the RMS from each peak, that is usually seen in vibration software.
import numpy as np
import matplotlib.pyplot as plt
f_s = 100.0 # Hz sampling frequency
f = 1.0 # Hz
time = np.arange(0.0, 10.0, 1/f_s)
x = 5 * np.sin(2*np.pi*f*time)
N = len(time)
T = 1/f_s
# apply hann window and take the FFT
win = np.hanning(len(x))
FFT = np.fft.fft(win * x)
n = len(FFT)
yf = np.linspace(0.0,1.0/(2.0*T),N//2)
plt.figure(1)
plt.plot(yf,2.0/N * np.abs(FFT[0:N//2]))
plt.grid()
plt.figure(2)
plt.plot(time,x)
plt.xlabel('time')
plt.ylabel('Amplitude')
plt.grid()
plt.show()
Upvotes: 1
Views: 5701
Reputation: 14577
You are getting a peak of 2.5 in the frequency-domain because that's the average amplitude of the windowed signal, and you are not compensating for the window weights. After normalizing the frequency-domain results to account for the window using the following:
plt.plot(yf,2.0/win.sum() * np.abs(FFT[0:N//2]))
you should get an amplitude of 5, just like in the time-domain. Note that this works provided that the input signal frequency is an exact multiple of f_s/N
(which in your case is 0.1Hz), and provided that the underlying assumption that the input signal is either a pure tone or comprised of tones which are sufficiently separated in frequency is valid.
The peak-to-peak value would simply be twice the amplitude, so 10 in your example.
For the RMS value, you are probably interested in the RMS value of the corresponding time-domain sinusoidal tone component (under the assumption the input signal is indeed composed of sinusoidal component whose frequencies are sufficiently separated in frequency). The RMS of a time-domain sinusoidal of amplitude A
is A/sqrt(2)
, so you simply need to divide by sqrt(2)
to get the corresponding equivalent RMS value from your amplitude values, so 5/sqrt(2) ~ 3.53
in your example.
Upvotes: 1