In [9]:
import sys,os
%matplotlib inline
ia898path = os.path.abspath('/etc/jupyterhub/ia898_1s2017/')
if ia898path not in sys.path:
sys.path.append(ia898path)
import ia898.src as ia
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from numpy.fft import fft2
from numpy.fft import ifft2
In [12]:
def iadftmatrix(N):
x = np.arange(N).reshape(N,1)
u = x
Wn = np.exp(-1j*2*np.pi/N)
A = (1./np.sqrt(N)) * (Wn ** np.dot(u, x.T))
return A
In [13]:
A = iadftmatrix(128)
plt.figure(1)
plt.imshow((A.real),cmap='gray')
plt.title('A.real')
plt.colorbar()
plt.figure(2)
plt.imshow((A.imag),cmap='gray')
plt.title('A.imag')
plt.colorbar()
Out[13]:
In [7]:
plt.figure(1, figsize=(10,10))
plt.subplot(2,2,1)
plt.title('u = 0')
plt.plot(A.real[0,:], 'r')
plt.plot(A.imag[0,:], 'g')
plt.subplot(2,2,2)
plt.title('u = 1')
plt.plot(A.real[1,:], 'r')
plt.plot(A.imag[1,:], 'g')
plt.subplot(2,2,3)
plt.title('u = 2')
plt.plot(A.real[2,:], 'r')
plt.plot(A.imag[2,:], 'g')
plt.subplot(2,2,4)
plt.title('u = 3')
plt.plot(A.real[3,:], 'r')
plt.plot(A.imag[3,:], 'g')
plt.show()
In [8]:
plt.figure(1, figsize=(10,10))
plt.subplot(2,2,1)
plt.title('u = 0')
plt.plot(A.real[ 0,:], 'r')
plt.plot(A.imag[ 0,:], 'g')
plt.subplot(2,2,2)
plt.title('u = -1')
plt.plot(A.real[-1,:], 'r')
plt.plot(A.imag[-1,:], 'g')
plt.subplot(2,2,3)
plt.title('u = -2')
plt.plot(A.real[-2,:], 'r')
plt.plot(A.imag[-2,:], 'g')
plt.subplot(2,2,4)
plt.title('u = -3')
plt.plot(A.real[-3,:], 'r')
plt.plot(A.imag[-3,:], 'g')
plt.show()