import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
fig = plt.gcf()
fig.set_size_inches(8,8)
# set signal and transform constants
samples = 10000
t = np.arange(samples)
# declare an all-zeros frequency spectrum
s = np.linspace(0.0,0.0,samples)
# set the spectral lines
s[940] = 0.5
s[1000] = 1.0
s[1060] = 0.5
plt.grid(True)
sp1 = plt.subplot(211)
sp1.set_xlim(500,1500)
sp1.grid(True)
sp1.set_ylabel('Amplitude')
sp1.set_title('Frequency Domain')
sp1.plot(t,s,color='#008000')
sp2 = plt.subplot(212)
sp2.set_ylabel('Amplitude')
sp2.set_title('Time Domain')
sp2.set_ylim(-2,2)
sp2.grid(True)
fi = np.arange(1000)
fs = np.fft.irfft(s)[:1000]
sp2.plot(fi, fs * samples,color='#008000')
plt.show()