I am trying to do a Fourier Transform and Inverse Fourier Transform. The problem is that I am not getting the original signal after inverse transform.
# set signal and transform constants
samples = 10000
t = np.arange(samples)
cf = 1000 # carrier frequency Hz
mf = 60 # modulation frequency Hz
# signal is a classic AM waveform
signal = lambda t: np.sin(2 * np.pi * cf * t / samples) \
* (1+(np.sin(2 * np.pi * mf * t / samples)))
fi = np.arange(5000)
fs = np.fft.fft(signal(t))[:5000]
sp2.plot(fi ,abs(fs) * 2 / samples, color = "#fb8072")
samples = 10000
t = np.arange(samples)
# declare an all-zeros frequency spectrum
s = np.zeros((samples,), dtype=complex)
# set the spectral lines
s[940] = 0.5
s[1000] = 1.0
s[1060] = 0.5
fs = np.fft.ifft(s)[:512]
sp2.plot(fi, fs * samples ,color='#fdb462')
plt.grid(color='grey', linestyle='-.', linewidth=0.5)
plt.show()
Why is the yellow time-domain signal not as the same as the original blue signal?