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

working FFT aligo cavity scan, final tweaks for now

parent de678d02
......@@ -14,7 +14,7 @@ import pykat
from pykat.components import *
from pykat.utilities.plotting.tools import printPDF
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar, Timer
from pykat.optics.maps import *
from pykat.optics.gaussian_beams import HG_beam, beam_param
from pykat.optics.fft import *
......@@ -57,6 +57,7 @@ def main():
# loading kat file to get parameters and to compute input beam parameters
global kat, out
kat = pykat.finesse.kat()
kat.verbose = False
kat.loadKatFile('aligo_Xarm.kat')
Lambda = kat.lambda0
LX=kat.LX.L.value
......@@ -71,8 +72,8 @@ def main():
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
# apply measured map to etm, using 10 times larger distortions
etm.data = etm.data + surface.data*surface.scaling/etm.scaling*10.0
# setup grid for FFT propagation
[xpoints,ypoints] = surface.size
......@@ -119,7 +120,7 @@ def precompute_roundtrips(shape, laser, kat):
LX=kat.LX.L.value
R=kat.etmX.R.value*kat.itmX.R.value
Loss = 1-R
accuracy=100E-6
accuracy=1E-6
print("cavity loss: {0}".format(Loss))
N=int(required_roundtrips(Loss,accuracy))
print("required rountrips: {0} (for accuracy of {1})".format(N, accuracy))
......@@ -136,7 +137,7 @@ def precompute_roundtrips(shape, laser, kat):
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()])
p = ProgressBar(maxval=N, widgets=["f_circ:", Percentage(),"|", Timer(), "|", ETA(), Bar()])
for n in range(1,N):
f_circ = FFT_propagate(f_circ,shape,Lambda,LX,1)
......@@ -145,6 +146,7 @@ def precompute_roundtrips(shape, laser, kat):
f_circ = np.sqrt(kat.itmX.R.value)*FFT_apply_map(f_circ, itm, Lambda)
f_round[:,:,n] = f_circ;
p.update(n)
p.finish()
print(" --- saving data to file ---")
import time
......
......@@ -11,7 +11,7 @@ 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.external.progressbar import ProgressBar, ETA, Percentage, Bar, Timer
from pykat.utilities.plotting.tools import plot_setup
from pykat.optics.maps import *
from pykat.optics.gaussian_beams import HG_beam, beam_param
......@@ -27,24 +27,25 @@ def main():
# loading kat file to get parameters (if needed)
global kat, out
kat = pykat.finesse.kat()
kat.verbose = False
kat.loadKatFile('aligo_Xarm.kat')
Lambda=kat.lambda0
k = 2.0*np.pi/Lambda
filename='fround-2014:12:22-14:17:37.npy'
#filename='fround_mode_matched_no_map.npy'
filename='fround-2014:12:22-15:07:11.npy'
print(" --- loading data from file {0} ---".format(filename))
global f_round
f_round=np.load(filename)
tmpresultfile = 'myshelf1.dat'
# loading data saved by master.py
# loading additional data saved by previous file
try:
tmpfile = shelve.open(tmpresultfile)
result=tmpfile['result']
tmpfile.close()
except: raise Exception("Could not open temprary results file {0}".format(tmpresultfile))
scan_start = 0.0
scan_stop = Lambda
scan_points = 200
......@@ -59,19 +60,18 @@ def main():
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()])
p = ProgressBar(maxval=scan_points, widgets=["power:", Percentage(),"|", Timer(), "|", ETA(), Bar()])
global phases, f_x, f_round
global phases
ns=np.linspace(0.0, N-1, N)
for i in range(scan_points):
#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)
p.finish()
# plot scan
ax,fig=plot_setup()
ax.plot(power)
ax.set_yscale('log')
......
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