Reputation: 107
I have a signal in frequency domain.Then I took numpy.fft.ifft of signal.I got time domain signal.Again I took fft of same time signal properly I'm not getting negative and positive frequencies(Plot 3 in Figure).
time = np.arange(0, 10, .01)
N = len(time)
signal_td = np.cos(2.0*np.pi*2.0*time)
signal_fd = np.fft.fft(signal_td)
signal_fd2 = signal_fd[0:N/2]
inv_td2 = np.fft.ifft(signal_fd2)
fd2 = np.fft.fft(inv_td2)
Upvotes: 1
Views: 1742
Reputation: 1570
General comment: I avoid using time
as a variable name because IPython
loads it as a "magic" command.
Something I find at times confusing about matplotlib
is that when you plot
a complex
array, it actually plots the real part. In the code snippet:
tt = np.arange(0, 10, .01)
N = len(tt)
signal_td = np.cos(2.0*np.pi*2.0*tt)
signal_fd = np.fft.fft(signal_td)
signal_fd2 = signal_fd[0:N/2]
inv_td2 = np.fft.ifft(signal_fd2)
fd2 = np.fft.fft(inv_td2)
The following arrays have dtype
of float64
: tt
and signal_td
. The others are complex128
. The reason you only see one peak in fd2
is because it is a transform of exp(4j*np.pi*tt)
rather than cos(4*np.pi*tt)
.
Upvotes: 1