diff --git a/examples/asc_test/README b/examples/asc_test/README new file mode 100644 index 0000000000000000000000000000000000000000..0167fc38429f88fb46ed7a6caaf8ae6da33f8e33 --- /dev/null +++ b/examples/asc_test/README @@ -0,0 +1,45 @@ + +This folder is part of the PyKat package and contains a set of +files python files which together run through the various +Finesse simulations. + +Finesse: http://www.gwoptics.org/finesse +PyKat: http://www.gwoptics.org/pykat + +The master*py files can be used to generate the Finesse +results reported in the document: +`Comparing Finesse simulations, analytical solutions and OSCAR +simulations of Fabry-Perot alignment signals', LIGO-T1300345. +The tasks described in that note were suggested and started at +the an international workshop for commissioning graviational +wave detectors (28.01.2013 - 02.02.2013, Lousiana, US). + +The files are provided as part of PyKat because they provide a +rich example for using PyKat to automate Finesse simulations. + +To run these files you need to have PyKat installed and +the required dependcies (numpy, scipy, matplotlib, pylab). + +We recommend to run the files from ipython. To do so, +start ipython and change your system path to include +PyKat, for example: +import sys,os +sys.path.append("/home/work/git/pykat") + +The files must be run in sequence starting with 'master.py': +type `run master.py', which should print various result +to screen. It will also save temporary data files which are +needed for running master2.py. Similarly running master2.py +will print further result and save temporary data files. +master3.py and master4.py both read those temporary files +saved by master2. Both files perform longer running simulations. +Some of the data from these simulations is saved regularly to +output files which can be plotted (afterwards, or at the +same time using a second ipython session) with the files +master3_plot.py and master4_plot.py. + +Andreas Freise 16.01.2014 + + + + diff --git a/examples/asc_test/asc_base.kat b/examples/asc_test/asc_base.kat index fab52ecdd50d951715bef49c7034a196e37da87f..ab51b5d9aab08f5ee6a2be936d655d68ed016a02 100644 --- a/examples/asc_test/asc_base.kat +++ b/examples/asc_test/asc_base.kat @@ -2,9 +2,12 @@ #----------------------------------------------------------------------- # asc_base.kat # -# This file is an part of the Finesse ASC signal validation. +# This file is part of a collection for an alignment signal +# validation as reported in the LIGO document: +# `Comparing Finesse simulations, analytical solutions and OSCAR +# simulations of Fabry-Perot alignment signals', LIGO-T1300345 # -# This file is a Finesse input file mean to be read by +# This file is a Finesse input file meant to be read by # master.py, which is part of PyKat, see # http://www.gwoptics.org/pykat # http://www.gwoptics.org/finesse diff --git a/examples/asc_test/asc_base_bs.kat b/examples/asc_test/asc_base_bs.kat index 7ca872507b968cf36d38aef43bb35edd7d9aaa3c..ccd84d3d9384a6abbae80d2d6e50b3b83ec6e15f 100644 --- a/examples/asc_test/asc_base_bs.kat +++ b/examples/asc_test/asc_base_bs.kat @@ -49,8 +49,3 @@ lens L1 1250 nL1_in nL1_out s spo2 5000 nL1_out nWFS2 phase 0 - -%ad ad1 0 nITM2 -%xaxis ETM phi lin 20 24 90 -%noxaxis -%gnuterm x11 \ No newline at end of file diff --git a/examples/asc_test/master.py b/examples/asc_test/master.py index b2a443167950e57463ba4965ae319da9b80535db..00b115ce0f7e33e1e5129171191bae482f9bda83 100644 --- a/examples/asc_test/master.py +++ b/examples/asc_test/master.py @@ -13,21 +13,23 @@ def main(): Finesse: http://www.gwoptics.org/finesse PyKat: http://www.gwoptics.org/pykat - The file runs through the various pykat files which are used + The file runs through the various Finesse simulations to generate the Finesse results reported in the document: `Comparing Finesse simulations, analytical solutions and OSCAR simulations of Fabry-Perot alignment signals', LIGO-T1300345 + + This file is part of a collection; it outputs the results + shown the document's sections 3 and 4 and saves temporary + data and a new Finesse input file to be read by master2.py. - This file is part of a collection. - - Andreas Freise 06.12.2013 + Andreas Freise 16.01.2014 -------------------------------------------------------------- """ # for debugging we might need to see the temporay file: kat = finesse.kat(tempdir=".",tempname="test") kat.verbose = False - kat.loadKatFile('asc_base_bs.kat') + kat.loadKatFile('asc_base.kat') kat.maxtem=3 Lambda=1064.0e-9 result = {} diff --git a/examples/asc_test/master2.py b/examples/asc_test/master2.py index d947ff9158034b867783f2ea2c09e0e1f75e188f..a61544ffa7e8a3d0a71505ec466c4da4f91f8bfe 100644 --- a/examples/asc_test/master2.py +++ b/examples/asc_test/master2.py @@ -15,15 +15,18 @@ def main(): Example file for using PyKat to automate Finesse simulations Finesse: http://www.gwoptics.org/finesse PyKat: http://www.gwoptics.org/pykat - - The file runs through the various pykat files which are used + + The file runs through the various Finesse simulations to generate the Finesse results reported in the document: `Comparing Finesse simulations, analytical solutions and OSCAR simulations of Fabry-Perot alignment signals', LIGO-T1300345 + + This file is part of a collection; it outputs the results + shown the document's sections 5 and 6 and saves temporary + data and a new Finesse input file to be read by master3.py, + and master4.py. - This file is part of a collection. - - Andreas Freise 06.12.2013 + Andreas Freise 16.01.2014 -------------------------------------------------------------- """ @@ -63,7 +66,7 @@ def main(): tilt(kat) print "--------------------------------------------------------" - print " 6. compute beam tilt from center of gravity calculation" + print " 6. compute beam tilt from beam propogation" gravity_tilt(kat) print "--------------------------------------------------------" @@ -194,8 +197,6 @@ def asc_phases(tmpkat): kat.ITM.ybeta=1e-10 kat.ETM.ybeta=0.0 - # minimize_scaler is only available in newer scipy versions - #res = minimize_scalar(demod_phase1, method='brent') res = fmin(demod_phase1, [0.0], xtol=1e-8, disp=False) WFS1_phase = res[0] print "" diff --git a/examples/asc_test/master3.py b/examples/asc_test/master3.py index 8dff3e39981f06ba70b30e1b9955230d369ef8ca..b8e42ab32fd337ff52fbb63d97ed6b26db7d3456 100644 --- a/examples/asc_test/master3.py +++ b/examples/asc_test/master3.py @@ -13,19 +13,17 @@ def main(): Example file for using PyKat to automate Finesse simulations Finesse: http://www.gwoptics.org/finesse PyKat: http://www.gwoptics.org/pykat - - The file runs through the various pykat files which are used + + The file runs through the various Finesse simulations to generate the Finesse results reported in the document: `Comparing Finesse simulations, analytical solutions and OSCAR simulations of Fabry-Perot alignment signals', LIGO-T1300345 - This file is part of a collection. Run this after master2.py - - Run this file to create the data and master3_plot.py to plot - the results. Results are saved after each step and plots can - be created at any time. + Run this file after master2.py to create data which can be + plotted using master3_plot.py. Results are saved after + each step and plots can be created at any time. - Andreas Freise 06.12.2013 + Andreas Freise 16.01.2014 -------------------------------------------------------------- """ @@ -55,13 +53,20 @@ def main(): print "--------------------------------------------------------" print " 9. ASC signals for large misalignments (ITM)" - asc_large(kat) + asc_large(kat, 'ITM') + + print "--------------------------------------------------------" + print " 10. ASC signals for large misalignments (ETM)" + asc_large(kat, 'ETM') + #----------------------------------------------------------------------------------- -def asc_large(tmpkat): +def asc_large(tmpkat, mir_name): kat = copy.deepcopy(tmpkat) + assert(mir_name == 'ITM' or mir_name == 'ETM') + code_lock = """ set err PDrefl_p re lock z $err 900 1p @@ -71,20 +76,20 @@ def asc_large(tmpkat): kat.parseKatCode(code_lock) kat.parseKatCode('yaxis abs') - kat.parseKatCode('xaxis ITM ybeta lin 0 1u 100') + kat.parseKatCode('xaxis {0} ybeta lin 0 1u 100'.format(mir_name)) maxtems = [1, 3, 5] #kat.verbose=1 xscale = 1e6 yscale = 1e6 global out - tmpfilename = "datashelf1.dat" - backupname = "datashelf1.dat.bck" + tmpfilename = "datashelf_{0}.dat".format(mir_name) + backupname = "datashelf_{0}.dat.bck".format(mir_name) out={} done_maxtems = [] for tem in maxtems: done_maxtems.append(tem) - print " Calculating maxtem = %d " % tem + print " Calculating maxtem = %d " % tem kat.maxtem = tem out[str(tem)] = kat.run(printout=0,printerr=1) import os.path diff --git a/examples/asc_test/master3_plot.py b/examples/asc_test/master3_plot.py index d44becb451c031c2472c2a7b9a96a457ce48edf8..6f64ce987a473e36d3005111e4969ef833d23e18 100644 --- a/examples/asc_test/master3_plot.py +++ b/examples/asc_test/master3_plot.py @@ -10,8 +10,8 @@ formatter = matplotlib.ticker.EngFormatter(unit='', places=0) formatter.ENG_PREFIXES[-6] = 'u' import matplotlib.backends.backend_pdf -def printPDF(self): - pdfp = matplotlib.backends.backend_pdf.PdfPages('large_ITM.pdf') +def printPDF(self, filename): + pdfp = matplotlib.backends.backend_pdf.PdfPages(filename) pdfp.savefig(self,dpi=300,bbox_inches='tight') pdfp.close() @@ -21,15 +21,10 @@ def main(): Example file for using PyKat to automate Finesse simulations Finesse: http://www.gwoptics.org/finesse PyKat: http://www.gwoptics.org/pykat - - The file runs through the various pykat files which are used - to generate the Finesse results reported in the document: - `Comparing Finesse simulations, analytical solutions and OSCAR - simulations of Fabry-Perot alignment signals', LIGO-T1300345 - + Run this file to plot the data generated with master3.py. - Andreas Freise 06.12.2013 + Andreas Freise 16.01.2014 -------------------------------------------------------------- """ @@ -44,15 +39,21 @@ def main(): #global result print "--------------------------------------------------------" - print " 9. Plotting ASC signals for large misalignments" - asc_large() + print " Plotting ASC signals for large misalignments" + asc_large('ITM') + asc_large('ETM') -def asc_large(): +def asc_large(mir_name): xscale = 1e6 yscale = 1e6 - tmpfilename = "datashelf1.dat" - backupname = "datashelf1.dat.bck" + if mir_name == 'ITM': + ysign = 1.0 + else: + ysign = -1.0 + + tmpfilename = "datashelf_{0}.dat".format(mir_name) + backupname = "datashelf_{0}.dat.bck".format(mir_name) try: tmpfile = shelve.open(tmpfilename) @@ -71,29 +72,33 @@ def asc_large(): data=out[str(tem)] WFS1_idx=data.ylabels.index("WFS1_I") WFS2_idx=data.ylabels.index("WFS2_I") - pl.plot(xscale*data.x,yscale*data.y[:,WFS1_idx],'-', color= color_cycle[i], linewidth=lw[i], label='maxtem {0}'.format(tem)) - line, = pl.plot(xscale*data.x,yscale*data.y[:,WFS2_idx],'-', color = color_cycle[i], linewidth=lw[i]) + pl.plot(xscale*data.x,ysign*yscale*data.y[:,WFS1_idx],'-', color= color_cycle[i], linewidth=lw[i], label='maxtem {0}'.format(tem)) + line, = pl.plot(xscale*data.x,ysign*yscale*data.y[:,WFS2_idx],'-', color = color_cycle[i], linewidth=lw[i]) #line.set_dashes([12, 4]) - osc1=np.loadtxt("OSCAR_large_tilt_ITM.txt",comments='%') + osc1=np.loadtxt("OSCAR_large_tilt_{0}.txt".format(mir_name),comments='%') x=xscale*osc1[:,0] y=yscale*osc1[:,1] pl.scatter(x,y,s=80,facecolors='none', edgecolors='k', label='OSCAR') y=yscale*osc1[:,2] pl.scatter(x,y,s=80,facecolors='none', edgecolors='k') - pl.xlabel("ITM vertical misalignment [urad]") + pl.xlabel("{0} vertical misalignment [urad]".format(mir_name)) pl.ylabel("Alignment signal [uW]") - pl.annotate('WFS1',xy=[0.42,70]) - pl.annotate('WFS2',xy=[0.62,5]) + if mir_name == 'ITM': + pl.annotate('WFS1',xy=[0.42,70]) + pl.annotate('WFS2',xy=[0.62,5]) + pl.legend(loc=2) + else: + pl.annotate('WFS1',xy=[0.42,10]) + pl.annotate('WFS2',xy=[0.62,-70]) + pl.legend(loc=3) pl.xlim([0,1]) - pl.legend(loc=2) pl.grid() pl.draw() pl.show(block=0) - printPDF(fig) + printPDF(fig, "large_{0}.pdf".format(mir_name)) - if __name__ == '__main__': main() diff --git a/examples/asc_test/master4.py b/examples/asc_test/master4.py index 1529a87fcd52dab1eba25b23a484f23816e936fe..b284dff00929c2e1f0c15efc35d8a3b4326ca3d7 100644 --- a/examples/asc_test/master4.py +++ b/examples/asc_test/master4.py @@ -1,31 +1,40 @@ from pykat import finesse from pykat.commands import * +from pykat.utilities.optics.gaussian_beams import gauss_param + +import pylab as pl +import scipy +from scipy.optimize import minimize_scalar import numpy as np import shelve import copy import sys -import shutil +def set_thermal_lens(kat, f): + kat.ITM_TL.f=f + # if a bs-based cavity is used, we need to set second lens + if "ITM_TL_r" in kat._kat__components: + kat.ITM_TL_r.f=f + return (kat) def main(): + print """ -------------------------------------------------------------- Example file for using PyKat to automate Finesse simulations Finesse: http://www.gwoptics.org/finesse - PyKat: http://www.gwoptics.org/pykat - - The file runs through the various pykat files which are used + PyKat: https://pypi.python.org/pypi/PyKat/ + + The file runs through the various Finesse simulations to generate the Finesse results reported in the document: `Comparing Finesse simulations, analytical solutions and OSCAR simulations of Fabry-Perot alignment signals', LIGO-T1300345 - This file is part of a collection. Run this after master2.py - - Run this file to create the data and master4_plot.py to plot - the results. Results are saved after each step and plots can - be created at any time. - - Andreas Freise 06.12.2013 + Run this file after master2.py to create data which can be + plotted using master4_plot.py. Results are saved after + each step and plots can be created at any time. + + Andreas Freise 16.01.2014 -------------------------------------------------------------- """ @@ -35,10 +44,10 @@ def main(): # making these global during testing and debugging #global kat #global out - + kat = finesse.kat(tempdir=".",tempname="test") kat.verbose = False - + tmpresultfile = 'myshelf2.dat' # loading data saved by master.py @@ -49,16 +58,184 @@ def main(): tmpfile.close() except: raise Exception("Could not open temprary results file {0}".format(tmpresultfile)) + # this does not work yet due to the scale command + kat.PDrefl_p.enabled = False kat.PDrefl_q.enabled = False - kat.WFS1_Q.enables = False - kat.WFS2_Q.enables = False + kat.WFS1_I.enabled = False + kat.WFS1_Q.enabled = False + kat.WFS2_I.enabled = False + kat.WFS2_Q.enabled = False + + kat.ETM.phi=result['phi_tuned'] + + print "--------------------------------------------------------" + print " 11. Do beam tracing to measure beam parameters" + # get beam parameters at nodes: "npsl", "nITM1", "nWFS1", "nWFS2", "npo2" + beam1 = get_qs(kat,1e13) + beam2 = get_qs(kat,50e3) + beam3 = get_qs(kat,5e3) + + # starting with cold beam at npsl + kat.psl.npsl.node.setGauss(kat.psl, beam1[0]) + kat.parseKatCode("startnode npsl") + global beam1, beam2, beam3 + + # if we use bs-based cavity we try to set good beam + # parameter for reflected beam, first by + # computing 'average' beam from cold and hot beams + x1=0.70 + x2=0.30 + if "ITM_TL_r" in kat._kat__components: + beam50 = gauss_param(z=(x1*beam1[1].z+x2*beam2[1].z), w0=(x1*beam1[1].w0+x2*beam2[1].w0)) + beam5 = gauss_param(z=(x1*beam1[1].z+x2*beam3[1].z), w0=(x1*beam1[1].w0+x2*beam3[1].w0)) + node_text = "at ITM->nITM1r" + t_comp=kat.ITM + t_node=kat.ITM.nITM1r + else: + beam50 = gauss_param(z=(x1*beam1[4].z+x2*beam2[4].z), w0=(x1*beam1[4].w0+x2*beam2[4].w0)) + beam5 = gauss_param(z=(x1*beam1[4].z+x2*beam3[4].z), w0=(x1*beam1[4].w0+x2*beam3[4].w0)) + node_text = "at s2->npo2" + t_comp=kat.s2 + t_node=kat.s2.npo2 + + kat = set_thermal_lens(kat,50e3) print "--------------------------------------------------------" - print " 10. ASC signals for large misalignments (ETM)" - asc_large(kat) + print " 12. computing beam tilt with thermal lens (f={0})".format(kat.ITM_TL.f) + + print " Setting compromise beam parameter {0}: w0={1}, z={2}".format(node_text, beam50.w0, beam50.z) + t_node.node.setGauss(t_comp, beam50) + kat.maxtem=8 + print " Calculating maxtem = %d " % kat.maxtem + tmp = gravity_tilt(kat) + + kat = set_thermal_lens(kat,5e3) + print "--------------------------------------------------------" + print " 13. computing beam tilt with thermal lens (f={0})".format(kat.ITM_TL.f) + print " Setting compromise beam parameter {0}: w0={1}, z={2}".format(node_text, beam5.w0, beam5.z) + t_node.node.setGauss(t_comp, beam5) + #maxtems = [1, 3, 5, 9, 11, 13, 15, 19, 23, 25, 27, 29] + maxtems = [1, 3, 5, 7] + converge_tilt(kat, maxtems) + + kat.PDrefl_p.enabled = True + kat.WFS1_I.enabled = True + kat.WFS2_I.enabled = True + + kat = set_thermal_lens(kat,50e3) + print "--------------------------------------------------------" + print " 12. computing alignment signal with thermal lens (f={0})".format(kat.ITM_TL.f) + t_node.node.setGauss(t_comp, beam50) + #maxtems = [1, 3, 5, 9, 11, 13, 15, 17, 19] + maxtems = [1, 3, 5, 7] + converge_asc(kat, maxtems, 'asc_signals_50.txt') + + kat = set_thermal_lens(kat,5e3) + print "--------------------------------------------------------" + print " 13. computing alignment signal with thermal lens (f={0})".format(kat.ITM_TL.f) + t_node.node.setGauss(t_comp, beam5) + #maxtems = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31] + maxtems = [1, 3, 5, 7] + converge_asc(kat, maxtems, 'asc_signals_5.txt') + +#----------------------------------------------------------------------------------- + +def converge_asc(tmpkat, maxtems, filename): + kat = copy.deepcopy(tmpkat) + savedata = np.zeros([len(maxtems),5]) + for idx, tem in enumerate(maxtems): + savedata[idx,0]=tem + print " Calculating maxtem = %d " % tem + kat.maxtem = tem + tmp = asc_signal(kat) + savedata[idx,1:5]=tmp.reshape([1,4]) + print " Saving results in file: {0}".format(filename) + np.savetxt(filename, savedata[0:idx+1,:], fmt='%.18e', delimiter=' ') + +def converge_tilt(tmpkat, maxtems): + kat = copy.deepcopy(tmpkat) + savedata = np.zeros([len(maxtems),5]) + filename = "thermal_gravity.txt" + for idx, tem in enumerate(maxtems): + savedata[idx,0]=tem + print " Calculating maxtem = %d " % tem + kat.maxtem = tem + tmp = gravity_tilt(kat) + savedata[idx,1:5]=tmp + print " Saving results in file: {0}".format(filename) + np.savetxt(filename, savedata[0:idx+1,:], fmt='%.18e', delimiter=' ') + +def get_qs(tmpkat,f): + kat = copy.deepcopy(tmpkat) + + # measure beam parameter for the 'cold beam' i.e. the laser beam + # matched to the cavity without any thermal lens + nodenames=["npsl", "nITM1", "nWFS1", "nWFS2", "npo2"] + for idx, nname in enumerate(nodenames): + kat.parseKatCode('bp w{0} y q {1}'.format(idx, nname)) + + kat.parseKatCode('yaxis re:im') + kat.noxaxis = True + kat.maxtem=0 + + def beam_size(tmpkat, f, beam0): + kat = copy.deepcopy(tmpkat) + + kat.psl.npsl.node.setGauss(kat.psl, beam0) + kat.parseKatCode("startnode npsl") + + # add thermal lens and propagate input beam to ITM + kat = set_thermal_lens(kat, f) + 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]) + from pykat.utilities.optics.ABCD import apply, mirror_refl + abcd = mirror_refl(1,-2500) + q_out = apply(abcd,q_in,1,1) + beam1 = gauss_param(q=q_out) + kat.removeLine("startnode") + kat.psl.npsl.node.removeGauss() + if "ITM_TL_r" in kat._kat__components: + kat.ITM.nITM1r.node.setGauss(kat.ITM, beam1) + kat.parseKatCode("startnode nITM1r") + else: + kat.ITM.nITM1.node.setGauss(kat.ITM, beam1) + kat.parseKatCode("startnode nITM1") + out = kat.run(printout=0,printerr=0) + + # computing beam size at WFS1 and WFS2 + q2 = complex(out['w2'][0],out['w2'][1]) + beam2 = gauss_param(q=q2) + q3 = complex(out['w3'][0],out['w3'][1]) + beam3 = gauss_param(q=q3) + + # computing beam size at pick off + q4 = complex(out['w4'][0],out['w4'][1]) + 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) + print " - WFS1 w={0:.6}cm (w0={1}, z={2})".format(100.0*beam2.w,beam2.w0, beam2.z) + print " - WFS2 w={0:.6}cm (w0={1}, z={2})".format(100.0*beam3.w,beam3.w0, beam3.z) + print " - npo2 w={0:.6}cm (w0={1}, z={2})".format(100.0*beam4.w,beam4.w0, beam4.z) + #raw_input("Press enter to continue") + + return [beam1, beam2, beam3, beam4] + + # 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]) + 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) + return (beam0, beam1, beam2,beam3, beam4) -def asc_large(tmpkat): +def asc_signal(tmpkat): kat = copy.deepcopy(tmpkat) code_lock = """ @@ -67,33 +244,102 @@ def asc_large(tmpkat): put* ETM phi $z noplot z """ - + kat.parseKatCode(code_lock) kat.parseKatCode('yaxis abs') - kat.parseKatCode('xaxis ETM ybeta lin 0 1u 100') - maxtems = [1, 3, 5, 7] - #kat.verbose=1 - xscale = 1e6 - yscale = 1e6 - tmpfilename = "datashelf2.dat" - backupname = "datashelf2.dat.bck" - out={} - done_maxtems = [] + kat.noxaxis = True + + signal=np.zeros((2, 2)) + kat.ITM.ybeta=1e-10 + kat.ETM.ybeta=0.0 + out = kat.run(printout=0,printerr=0) + WFS1_idx=out.ylabels.index("WFS1_I") + WFS2_idx=out.ylabels.index("WFS2_I") + signal[0,0] = out.y[WFS1_idx] + signal[1,0] = out.y[WFS2_idx] + + kat.ITM.ybeta=0.0 + kat.ETM.ybeta=-1e-10 + out = kat.run(printout=0,printerr=0) + signal[0,1] = out.y[WFS1_idx] + signal[1,1] = out.y[WFS2_idx] + signal = signal *1e10 + sensors=('WFS1', 'WFS2') + mirrors=('ITM', 'ETM') + print " ASC Matrix:" + for i in range(2): + print " ", sensors[i], " ", + for j in range(2): + print "%12.10g" % signal[i,j], + print mirrors[i] + return signal - for tem in maxtems: - done_maxtems.append(tem) - print " Calculating maxtem = %d " % tem - kat.maxtem = tem - out[str(tem)] = kat.run(printout=0,printerr=1) - import os.path - if os.path.isfile(tmpfilename): - shutil.copyfile(tmpfilename, backupname) - - print " current results saved in: {0}".format(tmpfilename) - tmpfile = shelve.open(tmpfilename) - tmpfile['out']=out - tmpfile['maxtems']=done_maxtems - tmpfile.close() +def gravity_tilt(tmpkat): + kat = copy.deepcopy(tmpkat) + + def compute_gravity_tilt(tmpkat): + kat = copy.deepcopy(tmpkat) + out = kat.run(printout=0,printerr=0) + + y1 = out["b1"] + y2 = out["b1_1k"] + # shift of beam center on detector 1 (as m/w0y) + x1 = np.sum(out.x*y1)/np.sum(y1) + # shift of beam center on detector 2 (as m/w0y) + x2 = np.sum(out.x*y2)/np.sum(y2) + # calibrate this in meter by mutliplying with w0y + # and compute the angle geometrically + w0=out["w0y"][0] + detector_distance = 1000.0 + tilt=w0*(x2-x1)/detector_distance + #print " Wavefront tilt : %g nrad" % tilt + return tilt + + code_WFS1 = """ + beam b1 nWFS1 + beam b1_1k nL1_in + bp w0y y w0 nWFS1 + """ + + code_WFS2 = """ + m md 0 1 0 nWFS2 nWFS2b + s sd 1k nWFS2b nWFS2c + beam b1 nWFS2* + beam b1_1k nWFS2c + bp w0y y w0 nWFS2 + """ + + code_xaxis= """ + xaxis b1 y lin -40 40 800 + put b1_1k y $x1 + yaxis abs + """ + kat.parseKatCode(code_WFS1) + kat.parseKatCode(code_xaxis) + kat.spo1.L=1000.0 + kat.ITM.ybeta=1e-10 + kat.ETM.ybeta=0.0 + t1=compute_gravity_tilt(kat) + kat.ITM.ybeta=0.0 + kat.ETM.ybeta=-1e-10 + t2=compute_gravity_tilt(kat) + + kat = copy.deepcopy(tmpkat) + kat.parseKatCode(code_WFS2) + kat.parseKatCode(code_xaxis) + kat.spo1.L=1.0e-9 + kat.ITM.ybeta=1e-10 + kat.ETM.ybeta=0.0 + t3=compute_gravity_tilt(kat) + kat.ITM.ybeta=0.0 + kat.ETM.ybeta=-1e-10 + t4=compute_gravity_tilt(kat) + print " WFS1 ITM {0:.4} nrad".format(t1*1e9) + print " WFS2 ITM {0:.4} nrad".format(t3*1e9) + print " WFS1 ETM {0:.4} nrad".format(t2*1e9) + print " WFS2 ETM {0:.4} nrad".format(t4*1e9) + return [t1,t2,t3,t4] if __name__ == '__main__': main() + diff --git a/examples/asc_test/master4_plot.py b/examples/asc_test/master4_plot.py index ca9679d6e42cbd522d9a597615df38d63a58a1a4..a65e393a1b562a5c4db882297dbc20ffe704a323 100644 --- a/examples/asc_test/master4_plot.py +++ b/examples/asc_test/master4_plot.py @@ -2,7 +2,6 @@ from pykat import finesse from pykat.commands import * import pylab as pl import numpy as np -import shelve import sys import matplotlib @@ -10,8 +9,8 @@ formatter = matplotlib.ticker.EngFormatter(unit='', places=0) formatter.ENG_PREFIXES[-6] = 'u' import matplotlib.backends.backend_pdf -def printPDF(self): - pdfp = matplotlib.backends.backend_pdf.PdfPages('large_ETM.pdf') +def printPDF(self, filename): + pdfp = matplotlib.backends.backend_pdf.PdfPages(filename) pdfp.savefig(self,dpi=300,bbox_inches='tight') pdfp.close() @@ -21,15 +20,10 @@ def main(): Example file for using PyKat to automate Finesse simulations Finesse: http://www.gwoptics.org/finesse PyKat: http://www.gwoptics.org/pykat - - The file runs through the various pykat files which are used - to generate the Finesse results reported in the document: - `Comparing Finesse simulations, analytical solutions and OSCAR - simulations of Fabry-Perot alignment signals', LIGO-T1300345 - + Run this file to plot the data generated with master4.py. - Andreas Freise 06.12.2013 + Andreas Freise 16.01.2014 -------------------------------------------------------------- """ @@ -37,61 +31,79 @@ def main(): # %reset -f # maybe close all plot windows? # close('all') - - # making these global during testing and debugging - #global kat - #global out - #global result - + print "--------------------------------------------------------" - print " 10. Plotting ASC signals for large misalignments (ETM)" - asc_large() - - -def asc_large(): - xscale = 1e6 - yscale = -1e6 - tmpfilename = "datashelf2.dat" - backupname = "datashelf2.dat.bck" + print " Plotting beam tilt with thermal lens " + gravity_tilt() - try: - tmpfile = shelve.open(tmpfilename) - out=tmpfile['out'] - maxtems=tmpfile['maxtems'] - tmpfile.close() - except: raise Exception("Could not open temprary results file {0}".format(tmpfilename)) + print "--------------------------------------------------------" + print " Plotting WFS signal with thermal lens " + asc_signal('asc_signals_5.txt', (0.3,0.15)) + asc_signal('asc_signals_50.txt', (0.3,0.15)) +def asc_signal(filename,loc): + xscale = 1.0 + yscale = 1.0 + data=np.loadtxt(filename) + # extracting only nonzero rows + data = data[~np.all(data == 0, axis=1)] + maxtems = data[:,0] + [rows,cols] = data.shape fig=pl.figure() color_cycle=['b', 'c', 'r', 'k'] - N=len(maxtems) - lw=np.ones(N)*3 + labels=['ITM WFS1', 'ETM WFS1','ITM WFS2', 'ETM WFS2'] + lw=np.ones(rows+1)*3 lw[-2]=2 lw[-1]=1 - for i, tem in zip(range(len(maxtems)), maxtems): - data=out[str(tem)] - WFS1_idx=data.ylabels.index("WFS1_I") - WFS2_idx=data.ylabels.index("WFS2_I") - pl.plot(xscale*data.x,yscale*data.y[:,WFS1_idx],'-', color= color_cycle[i], linewidth=lw[i], label='maxtem {0}'.format(tem)) - line, = pl.plot(xscale*data.x,yscale*data.y[:,WFS2_idx],'-', color = color_cycle[i], linewidth=lw[i]) - #line.set_dashes([12, 4]) + global data + global cols + global lw + for i in [0,2,1,3]: + pl.scatter(data[:,0],yscale*data[:,i+1],s=80,facecolors='none', edgecolors=color_cycle[i], label=labels[i]+"={0:.4} W/rad".format(data[-1,i+1]*yscale)) + pl.plot(data[:,0],yscale*data[:,i+1],'-',color=color_cycle[i], linewidth=1) - osc1=np.loadtxt("OSCAR_large_tilt_ETM.txt",comments='%') + pl.xlabel("maxtem") + pl.ylabel("sensing matrix element [W/rad]") + pl.xlim([0,max(maxtems)+1]) + #pl.ylim([-180,100]) + pl.legend(loc=loc) + pl.grid() + pl.draw() + pl.show(block=0) + pdfname=filename.split('.')[0]+'.pdf' + printPDF(fig,pdfname) + + +def gravity_tilt(): + xscale = 1.0 + yscale = 1.0e9 + data=np.loadtxt("thermal_gravity.txt") + # extracting only nonzero rows + data = data[~np.all(data == 0, axis=1)] + maxtems = data[:,0] + [rows,cols] = data.shape + fig=pl.figure() + color_cycle=['b', 'c', 'r', 'k'] + labels=['ITM WFS1', 'ETM WFS1','ITM WFS2', 'ETM WFS2'] + lw=np.ones(rows+1)*3 + lw[-2]=2 + lw[-1]=1 + global data + global cols + global lw + for i in [0,2,1,3]: + pl.scatter(data[:,0],yscale*data[:,i+1],s=80,facecolors='none', edgecolors=color_cycle[i], label=labels[i]+"={0:.4} nrad".format(data[-1,i+1]*yscale)) + pl.plot(data[:,0],yscale*data[:,i+1],'-',color=color_cycle[i], linewidth=1) - x=xscale*osc1[:,0] - y=-1.0*yscale*osc1[:,1] - pl.scatter(x,y,s=80,facecolors='none', edgecolors='k', label='OSCAR') - y=-1.0*yscale*osc1[:,2] - pl.scatter(x,y,s=80,facecolors='none', edgecolors='k') - pl.xlabel("ETM vertical misalignment [urad]") - pl.ylabel("Alignment signal [uW]") - pl.annotate('WFS1',xy=[0.42,10]) - pl.annotate('WFS2',xy=[0.62,-70]) - pl.xlim([0,1]) + pl.xlabel("maxtem") + pl.ylabel("beam tilt [nrad]") + pl.xlim([0,max(maxtems)+1]) + pl.ylim([-8,4]) pl.legend(loc=3) pl.grid() pl.draw() pl.show(block=0) - printPDF(fig) + printPDF(fig,'gravity_lens.pdf') diff --git a/examples/asc_test/master5.py b/examples/asc_test/master5.py deleted file mode 100644 index 5ce6edc051a86253fb1e1331ba372d2b41286d89..0000000000000000000000000000000000000000 --- a/examples/asc_test/master5.py +++ /dev/null @@ -1,382 +0,0 @@ -from pykat import finesse -from pykat.commands import * -from pykat.utilities.optics.gaussian_beams import gauss_param - -import pylab as pl -import scipy -from scipy.optimize import minimize_scalar -import numpy as np -import shelve -import copy -import sys - -def set_thermal_lens(kat, f): - kat.ITM_TL.f=f - if "ITM_TL_r" in kat._kat__components: - kat.ITM_TL_r.f=f - return (kat) - -def main(): - - print """ - -------------------------------------------------------------- - Example file for using PyKat to automate Finesse simulations - Finesse: http://www.gwoptics.org/finesse - PyKat: https://pypi.python.org/pypi/PyKat/ - - The file runs through the various pykat files which are used - to generate the Finesse results reported in the document: - `Comparing Finesse simulations, analytical solutions and OSCAR - simulations of Fabry-Perot alignment signals', LIGO-T1300345 - - This file is part of a collection. Run this after master2.py - - Andreas Freise 06.12.2013 - -------------------------------------------------------------- - """ - - # shall we clear the workspace? - # %reset -f - - # making these global during testing and debugging - global kat - global out - - kat = finesse.kat(tempdir=".",tempname="test") - kat.verbose = False - - tmpresultfile = 'myshelf2.dat' - - # loading data saved by master.py - kat.loadKatFile('asc_base3.kat') - try: - tmpfile = shelve.open(tmpresultfile) - result=tmpfile['result'] - tmpfile.close() - except: raise Exception("Could not open temprary results file {0}".format(tmpresultfile)) - - - # overwriting some variables - Lambda=1064.0e-9 - - # this does not work yet due to the scale command - kat.PDrefl_p.enabled = False - kat.PDrefl_q.enabled = False - kat.WFS1_I.enabled = False - kat.WFS1_Q.enabled = False - kat.WFS2_I.enabled = False - kat.WFS2_Q.enabled = False - - kat.ETM.phi=result['phi_tuned'] - - - (beam1, beam2, beam3) = get_qs(kat) - - if "ITM_TL_r" in kat._kat__components: - kat.ITM.nITM1r.node.setGauss(kat.ITM, beam3) - kat.parseKatCode("startnode nITM1r") - else: - kat.ITM.nITM1.node.setGauss(kat.ITM, beam3) - kat.parseKatCode("startnode nITM1") - - kat = set_thermal_lens(kat,5e3) - kat.maxtem = 10 - print "--------------------------------------------------------" - print " 11. computing beam tilt with thermal lens (f={0})".format(kat.ITM_TL.f) - - maxtems = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25] - savedata = np.zeros([len(maxtems),5]) - for idx, tem in enumerate(maxtems): - print tem - print idx - savedata[idx,0]=tem - print " Calculating maxtem = %d " % tem - kat.maxtem = tem - tmp = gravity_tilt(kat) - savedata[idx,1:5]=tmp - np.savetxt("thermal_gravity.txt", savedata, fmt='%.18e', delimiter=' ') - - print "--------------------------------------------------------" - print " 12. computing beam tilt with thermal lens (f={0}, maxtem={1})".format(kat.ITM_TL.f, kat.maxtem) - #gravity_tilt(kat) - - - print "--------------------------------------------------------" - print " Saving results in temp. files to be read by master6.py" - tmpkatfile = "asc_base4.kat" - tmpresultfile = "myshelf3.dat" - print " kat object saved in: {0}".format(tmpkatfile) - print " current results saved in: {0}".format(tmpresultfile) - # first the current kat file - kat.saveScript(tmpkatfile) - # now the result variables: - tmpfile = shelve.open(tmpresultfile) - tmpfile['result']=result - tmpfile.close() - - -#----------------------------------------------------------------------------------- - - -def get_qs(tmpkat): - kat = copy.deepcopy(tmpkat) - nodename0="npsl" - nodename1="nITM1" - nodename2="nWFS1" - nodename3="nWFS2" - # measure beam parameter for the 'cold beam' i.e. the laser beam - # matched to the cavity without any thermal lens - code_bp = "bp w0 y q {0}\nbp w1 y q {1}\nbp w2 y q {2}\nbp w3 y q {3}".format(nodename0,nodename1,nodename2,nodename3) - - kat.parseKatCode(code_bp) - kat.parseKatCode('yaxis re:im') - kat.noxaxis = True - kat.maxtem=0 - - def beam_size(tmpkat, f): - kat = copy.deepcopy(tmpkat) - # 1. 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]) - beam0 = gauss_param(q=q0) - kat.psl.npsl.node.setGauss(kat.psl, beam0) - kat.parseKatCode("startnode npsl") - - # add thermal lens and propagate input beam to ITM - kat = set_thermal_lens(kat, f) - 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]) - from pykat.utilities.optics.ABCD import apply, mirror_refl - abcd = mirror_refl(1,-2500) - q_out = apply(abcd,q_in,1,1) - beam1 = gauss_param(q=q_out) - kat.removeLine("startnode") - kat.psl.npsl.node.removeGauss() - if "ITM_TL_r" in kat._kat__components: - kat.ITM.nITM1r.node.setGauss(kat.ITM, beam1) - kat.parseKatCode("startnode nITM1r") - else: - kat.ITM.nITM1.node.setGauss(kat.ITM, beam1) - kat.parseKatCode("startnode nITM1") - out = kat.run(printout=0,printerr=0) - - # computing beam size at WFS1 and WFS2 - q2 = complex(out['w2'][0],out['w2'][1]) - beam2 = gauss_param(q=q2) - q3 = complex(out['w3'][0],out['w3'][1]) - beam3 = gauss_param(q=q3) - print " Input mode beam size with thermal lens f={0}".format(f) - print " - ITM w={0:.6}cm (w0={0}, z={1})".format(100.0*beam1.w,beam1.w0, beam1.z) - print " - WFS1 w={0:.6}cm (w0={0}, z={1})".format(100.0*beam2.w,beam2.w0, beam2.z) - print " - WFS2 w={0:.6}cm (w0={0}, z={1})".format(100.0*beam3.w,beam3.w0, beam3.z) - #raw_input("Press enter to continue") - - return(beam1, beam2, beam3) - - f=1e13 - (beam10,beam2,beam3)=beam_size(kat,f) - - f=50e3 - (beam11,beam2,beam3)=beam_size(kat,f) - - f=5e3 - (beam12,beam2,beam3)=beam_size(kat,f) - - - return (beam10, beam11,beam12) - -def asc_signal(tmpkat): - kat = copy.deepcopy(tmpkat) - - code_lock = """ - set err PDrefl_p re - lock z $err 900 1p - put* ETM phi $z - noplot z - """ - - kat.parseKatCode(code_lock) - kat.parseKatCode('yaxis abs') - kat.noxaxis = True - kat.maxtem=1 - - signal=np.zeros((2, 2)) - kat.ITM.ybeta=1e-10 - kat.ETM.ybeta=0.0 - out = kat.run(printout=0,printerr=0) - WFS1_idx=out.ylabels.index("WFS1_I") - WFS2_idx=out.ylabels.index("WFS2_I") - signal[0,0] = out.y[WFS1_idx] - signal[1,0] = out.y[WFS2_idx] - - kat.ITM.ybeta=0.0 - kat.ETM.ybeta=-1e-10 - out = kat.run(printout=0,printerr=0) - signal[0,1] = out.y[WFS1_idx] - signal[1,1] = out.y[WFS2_idx] - signal = signal *1e10 - sensors=('WFS1', 'WFS2') - mirrors=('ITM', 'ETM') - print " ASC Matrix:" - for i in range(2): - print " ", sensors[i], " ", - for j in range(2): - print "%12.10g" % signal[i,j], - print mirrors[i] - return signal - - -def asc_phases(tmpkat): - kat = copy.deepcopy(tmpkat) - - kat.parseKatCode('yaxis abs') - kat.noxaxis = True - kat.maxtem=1 - - def demod_phase1(x): - kat.WFS1_I.phi[0]=x - out = kat.run(printout=0,printerr=0) - WFS1_idx=out.ylabels.index("WFS1_I") - signal = out.y[WFS1_idx] - print '\r minimising: function value %g ' % signal , - sys.stdout.flush() - return -1*abs(signal) - - def demod_phase2(x): - kat.WFS2_I.phi[0]=x - out = kat.run(printout=0,printerr=0) - WFS2_idx=out.ylabels.index("WFS2_I") - signal = out.y[WFS2_idx] - print '\r minimising: function value %g ' % signal , - sys.stdout.flush() - return -1*abs(signal) - - kat.ITM.ybeta=1e-10 - kat.ETM.ybeta=0.0 - res = minimize_scalar(demod_phase1, method='brent') - WFS1_phase = res.x - print "" - print " WFS1 demod phase : %.10g deg" % WFS1_phase - - kat.ITM.ybeta=0.0 - kat.ETM.ybeta=-1e-10 - res = minimize_scalar(demod_phase2, method='brent') - WFS2_phase = res.x - print "" - print " WFS2 demod phase : %.10g deg" % WFS2_phase - return(WFS1_phase, WFS2_phase) - -def gravity_tilt(tmpkat): - kat = copy.deepcopy(tmpkat) - - def compute_gravity_tilt(tmpkat): - kat = copy.deepcopy(tmpkat) - out = kat.run(printout=0,printerr=0) - - y1 = out["b1"] - y2 = out["b1_1k"] - # shift of beam center on detector 1 (as m/w0y) - x1 = np.sum(out.x*y1)/np.sum(y1) - # shift of beam center on detector 2 (as m/w0y) - x2 = np.sum(out.x*y2)/np.sum(y2) - # calibrate this in meter by mutliplying with w0y - # and compute the angle geometrically - w0=out["w0y"][0] - detector_distance = 1000.0 - tilt=w0*(x2-x1)/detector_distance - print " Wavefront tilt : %g nrad" % tilt - return tilt - - code_WFS1 = """ - beam b1 nWFS1 - beam b1_1k nL1_in - bp w0y y w0 nWFS1 - """ - - code_WFS2 = """ - m md 0 1 0 nWFS2 nWFS2b - s sd 1k nWFS2b nWFS2c - beam b1 nWFS2* - beam b1_1k nWFS2c - bp w0y y w0 nWFS2 - """ - - code_xaxis= """ - xaxis b1 y lin -40 40 800 - put b1_1k y $x1 - yaxis abs - """ - print " WFS1:" - print " ITM ybeta 0.1nm" - kat.parseKatCode(code_WFS1) - kat.parseKatCode(code_xaxis) - kat.spo1.L=1000.0 - kat.ITM.ybeta=1e-10 - kat.ETM.ybeta=0.0 - t1=compute_gravity_tilt(kat) - print " ETM ybeta -0.1nm" - kat.ITM.ybeta=0.0 - kat.ETM.ybeta=-1e-10 - t2=compute_gravity_tilt(kat) - - print " WFS2:" - print " ITM ybeta 0.1nm" - kat = copy.deepcopy(tmpkat) - kat.parseKatCode(code_WFS2) - kat.parseKatCode(code_xaxis) - kat.spo1.L=1.0e-9 - kat.ITM.ybeta=1e-10 - kat.ETM.ybeta=0.0 - t3=compute_gravity_tilt(kat) - print " ETM ybeta -0.1nm" - kat.ITM.ybeta=0.0 - kat.ETM.ybeta=-1e-10 - t4=compute_gravity_tilt(kat) - return [t1,t2,t3,t4] - -def beam_size(tmpkat, beam2, beam3): - kat = copy.deepcopy(tmpkat) - - global out - code_bps = """ - bp wWFS1 y w nWFS1 - bp wWFS2 y w nWFS2 - """ - kat.parseKatCode(code_bps) - kat.maxtem = 0 - kat.ITM.R=1.0 - kat.ITM.T=0.0 - - kat.noxaxis = True - kat = set_thermal_lens(kat, 50e3) - kat.po.nWFS1.node.setGauss(kat.po,beam2) - out = kat.run(printout=0,printerr=0) - - WFS1_idx=out.ylabels.index("wWFS1") - WFS2_idx=out.ylabels.index("wWFS2") - - y1 = out.y[WFS1_idx] - y2 = out.y[WFS2_idx] - print " Beam size with thermal lens f={0}".format(kat.ITM_TL.f) - print " WFS1: {0}cm".format(y1*100.0) - print " WFS2: {0}cm".format(y2*100.0) - - kat = set_thermal_lens(kat, 5e3) - kat.po.nWFS1.node.setGauss(kat.po,beam3) - out = kat.run(printout=0,printerr=0) - y1 = out.y[WFS1_idx] - y2 = out.y[WFS2_idx] - print " Beam size with thermal lens f={0}".format(kat.ITM_TL.f) - print " WFS1: {0}cm".format(y1*100.0) - print " WFS2: {0}cm".format(y2*100.0) - - -if __name__ == '__main__': - main() - diff --git a/examples/asc_test/master5_plot.py b/examples/asc_test/master5_plot.py deleted file mode 100644 index 39cd26defa86e151a7e581922f75808be603fdb2..0000000000000000000000000000000000000000 --- a/examples/asc_test/master5_plot.py +++ /dev/null @@ -1,85 +0,0 @@ -from pykat import finesse -from pykat.commands import * -import pylab as pl -import numpy as np -import shelve -import sys - -import matplotlib -formatter = matplotlib.ticker.EngFormatter(unit='', places=0) -formatter.ENG_PREFIXES[-6] = 'u' - -import matplotlib.backends.backend_pdf -def printPDF(self, filename): - pdfp = matplotlib.backends.backend_pdf.PdfPages('filename') - pdfp.savefig(self,dpi=300,bbox_inches='tight') - pdfp.close() - -def main(): - print """ - -------------------------------------------------------------- - Example file for using PyKat to automate Finesse simulations - Finesse: http://www.gwoptics.org/finesse - PyKat: http://www.gwoptics.org/pykat - - The file runs through the various pykat files which are used - to generate the Finesse results reported in the document: - `Comparing Finesse simulations, analytical solutions and OSCAR - simulations of Fabry-Perot alignment signals', LIGO-T1300345 - - Run this file to plot the data generated with master5.py. - - Andreas Freise 06.12.2013 - -------------------------------------------------------------- - """ - - # shall we clear the workspace? - # %reset -f - # maybe close all plot windows? - # close('all') - - # making these global during testing and debugging - #global kat - #global out - #global result - - print "--------------------------------------------------------" - print " 12. Plotting beam tilt with thermal lens " - gravity_tilt() - -def gravity_tilt(): - xscale = 1.0 - yscale = 1.0e9 - data=np.loadtxt("thermal_gravity.txt") - maxtems = data[:,0] - rows = len(maxtems) - cols = len(data[0,:]) - fig=pl.figure() - color_cycle=['b', 'c', 'r', 'k'] - lw=np.ones(rows+1)*3 - lw[-2]=2 - lw[-1]=1 - global data - global cols - global lw - for i in range(cols-1): - #print i - #pl.plot(maxtems,yscale*data[:,i+1],'-', color= color_cycle[i], linewidth=lw[i], label='ETM1') - pl.scatter(maxtems,yscale*data[:,i+1],s=80,facecolors='none', edgecolors=color_cycle[i], label='xxx') - - - pl.xlabel("maxtem") - pl.ylabel("beam tilt [urad]") - #pl.annotate('WFS1',xy=[0.42,70]) - #pl.annotate('WFS2',xy=[0.62,5]) - #pl.xlim([0,1]) - #pl.legend(loc=2) - pl.grid() - pl.draw() - pl.show(block=0) - printPDF(fig,'gravity_lens.pdf') - - - -if __name__ == '__main__': - main()