From f415451cf8fd125a56e9dc9c7699dbc44b93fc43 Mon Sep 17 00:00:00 2001
From: Andreas Freise <adf@star.bham.ac.uk>
Date: Fri, 10 Apr 2015 12:45:07 +0100
Subject: [PATCH] more fixes to asc_test example

---
 examples/asc_test/master.py  |  3 ++-
 examples/asc_test/master2.py |  7 ++++---
 examples/asc_test/master4.py | 14 ++++++++------
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/examples/asc_test/master.py b/examples/asc_test/master.py
index 920f80a..af5d878 100644
--- a/examples/asc_test/master.py
+++ b/examples/asc_test/master.py
@@ -100,8 +100,9 @@ def pd_signal(tmpkat):
         """
     kat.parseKatCode(code1)
     kat.noxaxis = True
+    #global out
     out = kat.run()
-    print " Cavity power: {0:.6f}W".format(out.y[2,0])
+    print " Cavity power: {0:.6f}W".format(out.y[0,2])
     return (out.y[0,0], out.y[0,1])
     
 def pd_phase(tmpkat):
diff --git a/examples/asc_test/master2.py b/examples/asc_test/master2.py
index d2dfe43..ec4fb5e 100644
--- a/examples/asc_test/master2.py
+++ b/examples/asc_test/master2.py
@@ -280,17 +280,18 @@ def tilt(tmpkat):
     
     def compute_tilt(tmpkat):
         kat = copy.deepcopy(tmpkat)
+        global out
         out = kat.run()
 
         # compute data x range in meters
-        beamsize = out["w0y"][0,0] 
+        beamsize = out["w0y"][0] 
         xrange = beamsize*(out.x.max()-out.x.min())
         stepsize=xrange/(len(out.x)-1)
         print " Beamsize %e m" % beamsize
         print " Measurement range: %e m, stepszie: %e m" % (xrange, stepsize)
         # compute difference in angle between wavefront of carrier and sidebands
-        diff_l = (out["PDrefl_low"][:,1]-out["PDrefl_car"][:,1])/stepsize
-        diff_u = (out["PDrefl_up"][:,1]-out["PDrefl_car"][:,1])/stepsize
+        diff_l = (out["PDrefl_low"]-out["PDrefl_car"])/stepsize
+        diff_u = (out["PDrefl_up"]-out["PDrefl_car"])/stepsize
         tilt_l = diff_l[1:-1]-diff_l[0:-2]
         tilt_u = diff_u[1:-1]-diff_u[0:-2]
         print " Tilt (upper  - car), mean: %e m/deg, stddev %e m/deg" % (np.mean(tilt_u), np.std(tilt_u))
diff --git a/examples/asc_test/master4.py b/examples/asc_test/master4.py
index 5c1e51f..d87e07a 100644
--- a/examples/asc_test/master4.py
+++ b/examples/asc_test/master4.py
@@ -187,11 +187,12 @@ def get_qs(tmpkat,f):
 
         # add thermal lens and propagate input beam to ITM
         kat = set_thermal_lens(kat, f)
+        global out
         out = kat.run(printout=0,printerr=0)
         
         # computing beam size at ITM 
         # and then we reflect of ITM, an set it as new startnode
-        q_in = complex(out['w1'][0],out['w1'][1])
+        q_in = out['w1']
         from pykat.optics.ABCD import apply, mirror_refl
         abcd = mirror_refl(1,-2500)
         q_out = apply(abcd,q_in,1,1)
@@ -207,13 +208,13 @@ def get_qs(tmpkat,f):
         out = kat.run(printout=0,printerr=0)
 
         # computing beam size at WFS1 and WFS2
-        q2 = complex(out['w2'][0],out['w2'][1])    
+        q2 = out['w2']
         beam2 = gauss_param(q=q2)    
-        q3 = complex(out['w3'][0],out['w3'][1])
+        q3 = out['w3']
         beam3 = gauss_param(q=q3)    
 
         # computing beam size at pick off
-        q4 = complex(out['w4'][0],out['w4'][1])    
+        q4 = out['w4']
         beam4 = gauss_param(q=q4)    
         print " Input mode beam size with thermal lens f={0}".format(f)
         print " - ITM  w={0:.6}cm  (w0={1}, z={2})".format(100.0*beam1.w,beam1.w0, beam1.z)
@@ -223,13 +224,14 @@ def get_qs(tmpkat,f):
         #raw_input("Press enter to continue")
         
         return [beam1, beam2, beam3, beam4]
-
+    global out, kat
+    print "".join(kat.generateKatScript())
     # run finesse with input laser mode matched to cavity (no thermal lens)
     out = kat.run(printout=0,printerr=0)
 
     # beam at laser when matched to cold cavity
     # (note the sign flip of the real part to change direction of gauss param)
-    q0 = complex(-1.0*out['w0'][0],out['w0'][1])
+    q0 = -1.0*out['w0'].conjugate()
     beam0 = gauss_param(q=q0)   
     # compute beam sizes when tracing this beam back through the system
     (beam1,beam2,beam3, beam4)=beam_size(kat,f,beam0)
-- 
GitLab