Luke's

import numpy as np
import matplotlib.pyplot as plt

# specify circle parameters: centre ij and radius
ci,cj=500,500 #centre point
z = np.zeros((2*ci,2*cj))
cr=200

# Create index arrays to z
I,J=np.meshgrid(np.arange(z.shape[0]),np.arange(z.shape[1]))

# np.sqrt((I-ci)**2+(J-cj)**2) calculates distance of all points to centre
# Assign value of 1 to those points where distance to centre is less that cr:
z[np.where(np.sqrt((I-ci)**2+(J-cj)**2)<cr)]=1

#Fast Fourier Transform of z
zhat=np.fft.fft2(z)
zhat=np.fft.fftshift(zhat)
y = np.fft.ifft2(zhat)    #y is check of re-inversed
y = np.real(y)
zhatabs=abs(zhat)
#zhat = np.log(zhat)
#print zhat

# show result in a simple plot
#fig=plt.figure()
#ax=fig.add_subplot(111)
#ax.pcolormesh(z)
#ax.set_aspect('equal')
#plt.show()

#fig2=plt.figure()
#ax=fig2.add_subplot(111)
'''
im = plt.imshow(zhat, cmap='hot')
plt.colorbar(im, orientation='horizontal')
plt.show()

new = plt.imshow(y, cmap='hot')
plt.colorbar(new, orientation='horizontal')
plt.show()
'''
lda = 0.18
#positions in km - ARBITARY LAMBDA = 0.18m
xpos = [10, 10, -10, -10]
ypos = [10, -10, 10, -10]
dx = []
dy = []

#this takes the positions and turns them into baselines (no rotation included yet), shifted so they correspond with centre of image
for i in range(len(xpos)):
    for j in range(len(ypos)):
        if i != j:
            dx.append(ci + int((xpos[i]-xpos[j])/lda))  #doesn't take into account rotation of earth or angle of object
            dy.append(cj + int((ypos[i]-ypos[j])/lda))

print dx
print dy

#create the measured array
image = np.zeros((2*ci,2*cj),'complex')

#this uses baseline positions to sample - dx/dy[i] gives baseline positions, which then sample the fourier space zhat
for i in range(len(dx)):
    image[dx[i], dy[i]] = zhat[dx[i], dy[i]]

#shows sample fourier image
image2 = abs(image)
image2 = plt.imshow(image2, cmap='hot')
plt.colorbar(image2, orientation='horizontal')
plt.show()

#shows inverse image
imageinv = np.fft.ifft2(image)
imageinv2 = abs(imageinv)
imageinv2 = plt.imshow(imageinv2, cmap='hot')
plt.colorbar(imageinv2, orientation='horizontal')
plt.show()