Python Forum

Full Version: FFT - sum of amplitudes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I have 30k samples and I make FFT.
Size of amplitudes in FFT is ok.
But I want make sum of all amplitudes and here I can see wrong number. For example here:

SAMPLES = 30000
T = 1 / 30000

x = np.linspace(0.0, SAMPLES*T, SAMPLES, endpoint=False)
y = v_data  # v_data are from csv file, attached
yf = fft(y)
xf = fftfreq(SAMPLES, T)[:SAMPLES//2]
self.canvas.axes.cla()
self.canvas.axes.set_ylabel("Amplitude in g RMS")
self.canvas.axes.set_xlabel("Frequency in Hz")
self.canvas.axes.plot(xf, 2.0/SAMPLES * np.abs(yf[0:SAMPLES//2]))
print(sum(2.0/SAMPLES * np.abs(yf[0:SAMPLES//2])))
FFT picture:
https://ibb.co/Z1tgjBs

FFT seems OK.
If I use
print(sum(2.0/SAMPLES * np.abs(yf[0:SAMPLES//2])))
I can see number 14.39 and it is nonsense. I need to see something about 1.
What I do wrong? How to correctly sum all amplitudes from FFT?


Data file excel:
https://file.io/YBMdA8plul3N

Any idea?
Thanks.