In [45]:
push!(LOAD_PATH, "/home/ian/Grad/Research/Disks/DiskJockey/")
using constants
using visibilities
import PyPlot.plt
In [66]:
# Create an x-axis
#dx = 0.1
#xx = Float64[i*dx for i=-10:9];
n = 64
xx = fftspace(5, n)
dx = xx[2] - xx[1];
ss = fftshift(fftfreq(n, dx));
In [48]:
function Gauss(x::Vector{Float64})
exp(-pi * x.^2)
end
function GaussFT(s::Vector{Float64})
exp(-pi * s.^2)
end
Out[48]:
In [67]:
yy = Gauss(xx);
In [68]:
plt.plot(xx,yy, "o")
Out[68]:
In [69]:
YY = dx * fftshift(fft(fftshift(yy)))
Out[69]:
In [70]:
plt.plot(ss, YY, "o")
plt.plot(ss, GaussFT(ss))
Out[70]:
In [71]:
plt.plot(ss, YY - GaussFT(ss), "o")
Out[71]:
In [72]:
# 2D gaussian
function Gauss(x::Float64, y::Float64)
exp(-pi * (x.^2 + y.^2))
end
Out[72]:
In [76]:
# 2D Gaussian image vectorized over input arrays
function Gauss(x::Vector{Float64}, y::Vector{Float64})
nx = length(x)
ny = length(y)
out = Array(Float64, (ny, nx))
for j=1:ny
for i=1:nx
out[j,i] = Gauss(x[i], y[j])
end
end
return out
end
function GaussFT(u::Vector{Float64}, v::Vector{Float64})
nx = length(u)
ny = length(v)
out = Array(Float64, (ny, nx))
for j=1:ny
for i=1:nx
out[j,i] = Gauss(u[i], v[j])
end
end
return out
end
Out[76]:
In [77]:
img = Gauss(xx, xx)
Out[77]:
In [75]:
plt.imshow(img, interpolation="none", origin="upper", cmap=plt.get_cmap("Greys"))
Out[75]:
In [78]:
plt.imshow(fftshift(img), interpolation="none", origin="upper", cmap=plt.get_cmap("Greys"))
Out[78]:
In [89]:
imout = dx * dx * fftshift(fft(fftshift(img)))
Out[89]:
In [92]:
plt.imshow(real(imout), interpolation="none", origin="upper", cmap=plt.get_cmap("Greys"))
plt.colorbar()
Out[92]:
In [93]:
plt.imshow(imag(imout), interpolation="none", origin="upper", cmap=plt.get_cmap("Greys"))
plt.colorbar()
Out[93]:
In [94]:
imoutFT = GaussFT(ss, ss)
Out[94]:
In [95]:
plt.imshow(imoutFT, interpolation="none", origin="upper", cmap=plt.get_cmap("Greys"))
plt.colorbar()
Out[95]:
In [96]:
plt.imshow(real(imout) - imoutFT, interpolation="none", origin="upper", cmap=plt.get_cmap("Greys"))
plt.colorbar()
Out[96]:
In [ ]: