Commit de678d02 authored by Andreas Freise's avatar Andreas Freise
Browse files

first working version of FFT scan

parent bcb877ba
......@@ -9,10 +9,12 @@ from collections import OrderedDict
import shelve
import pylab as pl
from pykat.utilities.plotting.tools import printPDF
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
import pykat
from pykat.components import *
from pykat.utilities.plotting.tools import printPDF
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
from pykat.optics.maps import *
from pykat.optics.gaussian_beams import HG_beam, beam_param
from pykat.optics.fft import *
......@@ -51,13 +53,23 @@ def main():
# w1 [cm] 5.3
# w2 [cm] 6.2
# z1 [m] -1834
Lambda = aligo.Lambda
# loading kat file to get parameters and to compute input beam parameters
global kat, out
kat = pykat.finesse.kat()
kat.loadKatFile('aligo_Xarm.kat')
Lambda = kat.lambda0
LX=kat.LX.L.value
kat.maxtem=0
out = kat.run()
w0=out.y[0]
z0=-out.y[1]
# load and create mirror maps
global itm, etm
surface=read_map('etm08_virtual.txt')
itm=curvedmap('itm_Rc',surface.size,surface.step_size, aligo.itmX_Rc)
etm=curvedmap('etm_Rc',surface.size,surface.step_size, aligo.etmX_Rc)
itm=curvedmap('itm_Rc',surface.size,surface.step_size, -1.0*abs(kat.itmX.Rc.value))
etm=curvedmap('etm_Rc',surface.size,surface.step_size, -1.0*abs(kat.etmX.Rc.value))
# apply measured map to etm
#etm.data = etm.data + surface.data
......@@ -65,7 +77,7 @@ def main():
# setup grid for FFT propagation
[xpoints,ypoints] = surface.size
xsize = xpoints * surface.step_size[0]
ysize = ypoints * surface.step_size[0]
ysize = ypoints * surface.step_size[1]
xoffset = 0.0
yoffset = 0.0
......@@ -73,30 +85,39 @@ def main():
shape = grid(xpoints, ypoints, xsize, ysize, xoffset, yoffset)
x = shape.xaxis
y = shape.yaxis
result['shape']=shape
global gx, gy, beam, laser
# generate roughly mode-matched input beam
gx = beam_param(w0=0.012, z=-1834.0)
gy = gx
beam = HG_beam(gx,gy,0,0)
global laser
gx = beam_param(w0=w0, z=z0)
beam = HG_beam(gx,gx,0,0)
laser = beam.Unm(x,y)
# some debugging plots
#plot_field(laser)
#Lrange= np.linspace(0,4000,200)
#plot_propagation(laser, shape, Lambda, 0, 1, Lrange, 1)
precompute_roundtrips(shape, laser)
"""
plot_field(laser)
Lrange= np.linspace(0,4000,200)
plot_propagation(laser, shape, Lambda, 0, 1, Lrange, 1)
laser1=FFT_propagate(laser,shape,Lambda,LX,1)
laser2=np.sqrt(kat.etmX.R.value)*FFT_apply_map(laser1, etm, Lambda)
laser3=FFT_propagate(laser2,shape,Lambda,LX,1)
Lrange= np.linspace(0,4000,200)
plot_propagation(laser2, shape, Lambda, 0, 1, Lrange, 1)
plot_field(laser3)
"""
precompute_roundtrips(shape, laser, kat)
# now save any `result' variables:
tmpfile = shelve.open(tmpresultfile)
tmpfile['result']=result
tmpfile.close()
def precompute_roundtrips(shape, laser):
R=aligo.etmX_R*aligo.itmX_R
def precompute_roundtrips(shape, laser, kat):
Lambda=kat.lambda0
LX=kat.LX.L.value
R=kat.etmX.R.value*kat.itmX.R.value
Loss = 1-R
accuracy=100E-6
print("cavity loss: {0}".format(Loss))
......@@ -109,19 +130,19 @@ def precompute_roundtrips(shape, laser):
f_round=np.zeros((shape.xpoints,shape.ypoints,N),dtype=np.complex128)
# move impinging field into cavity
f_circ = np.sqrt(aligo.itmX_T) * laser
f_circ = np.sqrt(kat.itmX.T.value) * laser
# this counts as the first (zeroth) roundtrip
f_round[:,:,1] = f_circ
f_round[:,:,0] = f_circ
print(" --- pre computing all rountrip fields ---")
# This will take some time, let's show a progress bar
p = ProgressBar(maxval=N, widgets=["computing f_circ:", Percentage(),"|", ETA(), Bar()])
for n in range(2,N):
f_circ = FFT_propagate(f_circ,shape,aligo.Lambda,aligo.LX,1)
f_circ = aligo.etmX_r*FFT_apply_map(f_circ, etm, aligo.Lambda)
f_circ = FFT_propagate(f_circ,shape,aligo.Lambda,aligo.LX,1)
f_circ = aligo.itmX_r*FFT_apply_map(f_circ, itm, aligo.Lambda)
for n in range(1,N):
f_circ = FFT_propagate(f_circ,shape,Lambda,LX,1)
f_circ = np.sqrt(kat.etmX.R.value)*FFT_apply_map(f_circ, etm, Lambda)
f_circ = FFT_propagate(f_circ,shape,Lambda,LX,1)
f_circ = np.sqrt(kat.itmX.R.value)*FFT_apply_map(f_circ, itm, Lambda)
f_round[:,:,n] = f_circ;
p.update(n)
......@@ -134,7 +155,7 @@ def precompute_roundtrips(shape, laser):
def FFT_apply_map(field, Map, Lambda):
k=2.0*np.pi/Lambda
return field*np.exp(-1j * k * Map.data*Map.scaling);
return field*np.exp(-1j * 2.0 * k * Map.data*Map.scaling);
if __name__ == '__main__':
main()
......
......@@ -6,11 +6,13 @@ import copy
from collections import namedtuple
from collections import OrderedDict
import pylab as pl
from pykat.utilities.plotting.tools import printPDF
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
import shelve
import pykat
from pykat.components import *
from pykat.utilities.plotting.tools import printPDF
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
from pykat.utilities.plotting.tools import plot_setup
from pykat.optics.maps import *
from pykat.optics.gaussian_beams import HG_beam, beam_param
from pykat.optics.fft import *
......@@ -22,9 +24,14 @@ def main():
""")
k = 2.0*np.pi/aligo.Lambda
# loading kat file to get parameters (if needed)
global kat, out
kat = pykat.finesse.kat()
kat.loadKatFile('aligo_Xarm.kat')
Lambda=kat.lambda0
k = 2.0*np.pi/Lambda
filename='fround-2014:12:21-13:38:52.npy'
filename='fround-2014:12:22-14:17:37.npy'
print(" --- loading data from file {0} ---".format(filename))
global f_round
f_round=np.load(filename)
......@@ -39,28 +46,38 @@ def main():
scan_start = 0.0
scan_stop = aligo.Lambda
scan_points = 80
scan_stop = Lambda
scan_points = 200
global scan
scan = np.linspace(scan_start, scan_stop, scan_points)
# number of roundtrips
global power
N = np.shape(f_round)[2]
f_temp=np.zeros(np.shape(f_round[:,:,1]))
f_temp=np.zeros(np.shape(f_round[:,:,0]))
power=np.zeros(scan_points,dtype=np.double)
print(" --- performing cavity scan --- ")
# This will take some time, let's show a progress bar
p = ProgressBar(maxval=scan_points, widgets=["computing power:", Percentage(),"|", ETA(), Bar()])
global phases, f_x, f_round
ns=np.linspace(0.0, N-1, N)
for i in range(scan_points):
f_temp[:,:]=0.0
for n in range(N):
f_temp = f_temp + f_round[:,:,n] * np.exp(1j*k* scan[i]*n);
power[i] = power[i] + field_power(f_temp,result['shape'])
#f_temp[:,:]=0.0
phases=np.exp(1j*2.0*k*scan[i]*ns)
f_temp=np.sum(f_round*phases,axis=-1)
#for n in range(N):
# f_temp = f_temp + np.multiply(f_round[:,:,n],np.exp(1j*k* 2.0*scan[i]*n));
power[i] = field_power(f_temp,result['shape'])
p.update(i)
ax,fig=plot_setup()
ax.plot(power)
ax.set_yscale('log')
pl.draw()
pl.show(block=0)
def field_power(field, shape):
return np.sum(np.abs(field)**2)*shape.xstep*shape.ystep;
......
Supports Markdown
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