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()

[((63, 107), 'sys.path.append', 'sys.path.append', (['"""../../../software/models/"""'], {}), "('../../../software/models/')\n", (78, 107), False, 'import sys\n'), ((164, 174), 'numpy.ones', 'np.ones', (['N'], {}), '(N)\n', (171, 174), True, 'import numpy as np\n'), ((229, 249), 'dftModel.dftAnal', 'DFT.dftAnal', (['x', 'w', 'N'], {}), '(x, w, N)\n', (240, 249), True, 'import dftModel as DFT\n'), ((254, 277), 'dftModel.dftSynth', 'DFT.dftSynth', (['mX', 'pX', 'N'], {}), '(mX, pX, N)\n', (266, 277), True, 'import dftModel as DFT\n'), ((279, 310), 'matplotlib.pyplot.figure', 'plt.figure', (['(1)'], {'figsize': '(9.5, 5)'}), '(1, figsize=(9.5, 5))\n', (289, 310), True, 'import matplotlib.pyplot as plt\n'), ((311, 327), 'matplotlib.pyplot.subplot', 'plt.subplot', (['(311)'], {}), '(311)\n', (322, 327), True, 'import matplotlib.pyplot as plt\n'), ((328, 384), 'matplotlib.pyplot.title', 'plt.title', (['"""positive freq. magnitude spectrum in dB: mX"""'], {}), "('positive freq. magnitude spectrum in dB: mX')\n", (337, 384), True, 'import matplotlib.pyplot as plt\n'), ((474, 490), 'matplotlib.pyplot.subplot', 'plt.subplot', (['(312)'], {}), '(312)\n', (485, 490), True, 'import matplotlib.pyplot as plt\n'), ((491, 537), 'matplotlib.pyplot.title', 'plt.title', (['"""positive freq. phase spectrum: pX"""'], {}), "('positive freq. phase spectrum: pX')\n", (500, 537), True, 'import matplotlib.pyplot as plt\n'), ((584, 621), 'matplotlib.pyplot.axis', 'plt.axis', (['[0, pX.size, -np.pi, np.pi]'], {}), '([0, pX.size, -np.pi, np.pi])\n', (592, 621), True, 'import matplotlib.pyplot as plt\n'), ((621, 637), 'matplotlib.pyplot.subplot', 'plt.subplot', (['(313)'], {}), '(313)\n', (632, 637), True, 'import matplotlib.pyplot as plt\n'), ((638, 676), 'matplotlib.pyplot.title', 'plt.title', (['"""inverse spectrum: IDFT(X)"""'], {}), "('inverse spectrum: IDFT(X)')\n", (647, 676), True, 'import matplotlib.pyplot as plt\n'), ((762, 780), 'matplotlib.pyplot.tight_layout', 'plt.tight_layout', ([], {}), '()\n', (778, 780), True, 'import matplotlib.pyplot as plt\n'), ((781, 804), 'matplotlib.pyplot.savefig', 'plt.savefig', (['"""idft.png"""'], {}), "('idft.png')\n", (792, 804), True, 'import matplotlib.pyplot as plt\n'), ((805, 815), 'matplotlib.pyplot.show', 'plt.show', ([], {}), '()\n', (813, 815), True, 'import matplotlib.pyplot as plt\n'), ((394, 412), 'numpy.arange', 'np.arange', (['mX.size'], {}), '(mX.size)\n', (403, 412), True, 'import numpy as np\n'), ((547, 565), 'numpy.arange', 'np.arange', (['pX.size'], {}), '(pX.size)\n', (556, 565), True, 'import numpy as np\n'), ((686, 710), 'numpy.arange', 'np.arange', (['(-N / 2)', '(N / 2)'], {}), '(-N / 2, N / 2)\n', (695, 710), True, 'import numpy as np\n'), ((199, 223), 'numpy.arange', 'np.arange', (['(-N / 2)', '(N / 2)'], {}), '(-N / 2, N / 2)\n', (208, 223), True, 'import numpy as np\n')]