Commit 41c70111 authored by Andreas Freise's avatar Andreas Freise
Browse files

adding some convenience stuff to fft

parent db290a29
......@@ -15,10 +15,6 @@ from __future__ import unicode_literals
import numpy as np
import math
def FFT_apply_map(field, Map, Lambda):
k=2.0*np.pi/Lambda
return field*np.exp(-1j * k * Map.data*Map.scaling);
def apply_lens(field, grid, Lambda, f):
# apply a phase factor representing a lens
k= 2.0*np.pi/Lambda
......@@ -28,7 +24,7 @@ def apply_thin_lens(field, grid, Lambda, f):
# apply a phase factor representing a thin lens
k= 2.0*np.pi/Lambda
return field*(np.exp(1.0 * 1j * k * grid.r_squared/(2.0*f)))
def FFT_propagate(field, grid, Lambda, distance, nr):
# FFT propagation code in a fixed grid
......
......@@ -30,6 +30,37 @@ def printPDF(fig, filename):
pdfp.savefig(fig, dpi=300,bbox_inches='tight')
pdfp.close()
def plot_field(field):
ax,fig=plot_setup()
im = ax.imshow(np.abs(field),origin='lower', aspect='auto')
cb = fig.colorbar(im, format="%.4g")
#cb.set_clim(-1.0*zlimit, zlimit)
ax.autoscale(False)
plt.show(block=0)
def plot_propagation(field, grid, Lambda, axis, normalise, Lrange, nr):
# axis = 0 for x and =1 for y crosssection
# if normalise = 1, each slice is normalises to peak intensity
[n,m]=field.shape
slices = np.zeros((n,np.size(Lrange)))
from pykat.optics.fft import FFT_propagate
for idx, L in enumerate(Lrange):
field2 = FFT_propagate(field,grid, Lambda, L, nr)
if axis==0:
slices[:,idx]=np.abs(field2[:,int(m/2)])**2
else:
slices[:,idx]=np.abs(field2[int(n/2),:])**2
if normalise==1:
peak_intensity= np.abs(field2[int(n/2),int(m/2)])**2
slices[:,idx]=slices[:,idx]/peak_intensity
ax,fig=plot_setup()
im = ax.imshow(slices, aspect='auto')
cb = fig.colorbar(im, format="%.4g")
#cb.set_clim(-1.0*zlimit, zlimit)
ax.autoscale(False)
plt.show(block=0)
def plot_power_contour(x,y,z,xlabel, ylabel, clabel, title='', filename=''):
ax,fig=plot_setup()
xm,ym=np.meshgrid(x,y)
......@@ -54,7 +85,6 @@ def plot_power_contour(x,y,z,xlabel, ylabel, clabel, title='', filename=''):
printPDF(fig, filename)
def plot_error_contour(x,y,z,xlabel, ylabel, clabel, title='', filename=''):
global fig, ax, cb, ct, data
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment