I'm trying to do Fourier transformation using Python.
There is nice library numpy
that have the function fft
that supposed according the doc to get series of dots and return the Fourier transformation of them.
Now I try to make it work - but it's looking wrong...
I created simple sine wave 1Hz
, Amplitude=1
.
I sample it with 8Hz
(so 8 samples)
These are the samples:
[0,0.707,1,0.707,0,-0.707,-1,-0.707]
Now I expect to get in return the ens. [0,4,0,0,0,0,0,4]
or [0,8,0,0]
that represents that the frequency is 1Hz
(depends if it's does the trimming needed according to Nyquist limit).
But in reality I get the following:
[0.00000000e+00+0.00000000e+00j, -2.22044605e-16-3.99969798e+00j,
0.00000000e+00+0.00000000e+00j, -2.22044605e-16+3.02022804e-04j,
0.00000000e+00+0.00000000e+00j, 2.22044605e-16-3.02022804e-04j,
0.00000000e+00+0.00000000e+00j, 2.22044605e-16+3.99969798e+00j]
This is my code:
import numpy
signal = numpy.array([0,0.707,1,0.707,0,-0.707,-1,-0.707], dtype=float)
f = numpy.fft.fft(signal)
print (f)
Why am I getting this results? What I do wrong?