I can not understand this behavior scipy. From the scipy.fftpackdocs, I learn that the output fftis obviously complex and takes the form:
[y(0),y(1),..,y(n/2),y(1-n/2),...,y(-1)] if n is even
[y(0),y(1),..,y((n-1)/2),y(-(n-1)/2),...,y(-1)] if n is odd
so if you draw something like np.abs(fft(signal)), you get the FFT value.
If my signal is real-valued, then the negative frequencies do not give any information, and therefore can be used rfftto speed up the work. And then comes what I donโt understand: why the result is rfftreal, and has a strange form:
[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2))] if n is even
[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2)),Im(y(n/2))] if n is odd
In fact, with this definition np.abs(rfft(signal))it gives you trash (you get the absolute value of the real and imaginary parts of the FFT one by one ...), and you need to hack to get the FFT value. Why doesnโt rfftit just display a complex meaning y(j)like:
[y(0),y(1),..,y(n/2)] if n is even
[y(0),y(1),..,y((n-1)/2)] if n is odd
so that everything works exactly as fft(as expected)?
What am I missing?
EDIT: discussed issue here