import matplotlib.pyplot as plt
import numpy as np
import sys

sys.path.append('../../../software/models/')
import dftModel as DFT
import math

k0 = 8.5
N = 64
w = np.ones(N)
x = np.cos(2*np.pi*k0/N*np.arange(-N/2,N/2))
mX, pX = DFT.dftAnal(x, w, N)
y = DFT.dftSynth(mX, pX, N)

plt.figure(1, figsize=(9.5, 5))
plt.subplot(311)
plt.title('positive freq. magnitude spectrum in dB: mX')
plt.plot(np.arange(mX.size), mX, 'r', lw=1.5)
plt.axis([0,mX.size, min(mX), max(mX)+1])

plt.subplot(312)
plt.title('positive freq. phase spectrum: pX')
plt.plot(np.arange(pX.size), pX, 'c', lw=1.5)
plt.axis([0, pX.size,-np.pi,np.pi])

plt.subplot(313)
plt.title('inverse spectrum: IDFT(X)')
plt.plot(np.arange(-N/2, N/2), y,'b', lw=1.5)
plt.axis([-N/2,N/2-1,min(y), max(y)])

plt.tight_layout()
plt.savefig('idft.png')
plt.show()

[((5, 0, 5, 44), 'sys.path.append', 'sys.path.append', ({(5, 16, 5, 43): '"""../../../software/models/"""'}, {}), "('../../../software/models/')", False, 'import sys\n'), ((11, 4, 11, 14), 'numpy.ones', 'np.ones', ({(11, 12, 11, 13): 'N'}, {}), '(N)', True, 'import numpy as np\n'), ((13, 9, 13, 29), 'dftModel.dftAnal', 'DFT.dftAnal', ({(13, 21, 13, 22): 'x', (13, 24, 13, 25): 'w', (13, 27, 13, 28): 'N'}, {}), '(x, w, N)', True, 'import dftModel as DFT\n'), ((14, 4, 14, 27), 'dftModel.dftSynth', 'DFT.dftSynth', ({(14, 17, 14, 19): 'mX', (14, 21, 14, 23): 'pX', (14, 25, 14, 26): 'N'}, {}), '(mX, pX, N)', True, 'import dftModel as DFT\n'), ((16, 0, 16, 31), 'matplotlib.pyplot.figure', 'plt.figure', (), '', True, 'import matplotlib.pyplot as plt\n'), ((17, 0, 17, 16), 'matplotlib.pyplot.subplot', 'plt.subplot', ({(17, 12, 17, 15): '(311)'}, {}), '(311)', True, 'import matplotlib.pyplot as plt\n'), ((18, 0, 18, 56), 'matplotlib.pyplot.title', 'plt.title', ({(18, 10, 18, 55): '"""positive freq. magnitude spectrum in dB: mX"""'}, {}), "('positive freq. magnitude spectrum in dB: mX')", True, 'import matplotlib.pyplot as plt\n'), ((22, 0, 22, 16), 'matplotlib.pyplot.subplot', 'plt.subplot', ({(22, 12, 22, 15): '(312)'}, {}), '(312)', True, 'import matplotlib.pyplot as plt\n'), ((23, 0, 23, 46), 'matplotlib.pyplot.title', 'plt.title', ({(23, 10, 23, 45): '"""positive freq. phase spectrum: pX"""'}, {}), "('positive freq. phase spectrum: pX')", True, 'import matplotlib.pyplot as plt\n'), ((25, 0, 25, 35), 'matplotlib.pyplot.axis', 'plt.axis', ({(25, 9, 25, 34): '[0, pX.size, -np.pi, np.pi]'}, {}), '([0, pX.size, -np.pi, np.pi])', True, 'import matplotlib.pyplot as plt\n'), ((27, 0, 27, 16), 'matplotlib.pyplot.subplot', 'plt.subplot', ({(27, 12, 27, 15): '(313)'}, {}), '(313)', True, 'import matplotlib.pyplot as plt\n'), ((28, 0, 28, 38), 'matplotlib.pyplot.title', 'plt.title', ({(28, 10, 28, 37): '"""inverse spectrum: IDFT(X)"""'}, {}), "('inverse spectrum: IDFT(X)')", True, 'import matplotlib.pyplot as plt\n'), ((32, 0, 32, 18), 'matplotlib.pyplot.tight_layout', 'plt.tight_layout', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((33, 0, 33, 23), 'matplotlib.pyplot.savefig', 'plt.savefig', ({(33, 12, 33, 22): '"""idft.png"""'}, {}), "('idft.png')", True, 'import matplotlib.pyplot as plt\n'), ((34, 0, 34, 10), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((19, 9, 19, 27), 'numpy.arange', 'np.arange', ({(19, 19, 19, 26): 'mX.size'}, {}), '(mX.size)', True, 'import numpy as np\n'), ((24, 9, 24, 27), 'numpy.arange', 'np.arange', ({(24, 19, 24, 26): 'pX.size'}, {}), '(pX.size)', True, 'import numpy as np\n'), ((29, 9, 29, 29), 'numpy.arange', 'np.arange', ({(29, 19, 29, 23): '(-N / 2)', (29, 25, 29, 28): '(N / 2)'}, {}), '(-N / 2, N / 2)', True, 'import numpy as np\n'), ((12, 24, 12, 43), 'numpy.arange', 'np.arange', ({(12, 34, 12, 38): '-N / 2', (12, 39, 12, 42): 'N / 2'}, {}), '(-N / 2, N / 2)', True, 'import numpy as np\n')]