Commit 22c05c87 authored by Andreas Freise's avatar Andreas Freise
Browse files

updating FFT aLIGO example to work with current pykat

parent 62e4bea6
Pipeline #1645 passed with stage
in 22 seconds
...@@ -15,7 +15,7 @@ from pykat.components import * ...@@ -15,7 +15,7 @@ from pykat.components import *
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar, Timer from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar, Timer
from pykat.optics.maps import * from pykat.optics.maps import *
from pykat.optics.gaussian_beams import HG_beam, beam_param from pykat.optics.gaussian_beams import HG_mode, beam_param
from pykat.optics.fft import * from pykat.optics.fft import *
#from pykat.tools.plotting.tools import plot_field, plot_propagation #from pykat.tools.plotting.tools import plot_field, plot_propagation
...@@ -95,7 +95,7 @@ def main(): ...@@ -95,7 +95,7 @@ def main():
# generate roughly mode-matched input beam # generate roughly mode-matched input beam
global laser global laser
gx = beam_param(w0=w0, z=z0) gx = beam_param(w0=w0, z=z0)
beam = HG_beam(gx,gx,0,0) beam = HG_mode(gx,gx,0,0)
laser = beam.Unm(x,y) laser = beam.Unm(x,y)
# some debugging plots # some debugging plots
......
...@@ -10,81 +10,84 @@ import shelve ...@@ -10,81 +10,84 @@ import shelve
import pykat import pykat
from pykat.components import * from pykat.components import *
from pykat.utilities.plotting.tools import printPDF #from pykat.tools.plotting import printPDF
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar, Timer from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar, Timer
from pykat.utilities.plotting.tools import plot_setup import pykat.plotting
from pykat.optics.maps import * from pykat.optics.maps import *
from pykat.optics.gaussian_beams import HG_beam, beam_param from pykat.optics.gaussian_beams import HG_mode, beam_param
from pykat.optics.fft import * from pykat.optics.fft import *
from aligo import * from aligo import *
def main(): def main():
print(""" print("""
---------------------------------------- ----------------------------------------
""") """)
# loading kat file to get parameters (if needed) # loading kat file to get parameters (if needed)
global kat, out global kat, out
kat = pykat.finesse.kat() kat = pykat.finesse.kat()
kat.verbose = False kat.verbose = False
kat.loadKatFile('aligo_Xarm.kat') kat.loadKatFile('aligo_Xarm.kat')
Lambda=kat.lambda0 Lambda=kat.lambda0
k = 2.0*np.pi/Lambda k = 2.0*np.pi/Lambda
#filename='fround_mode_matched_no_map.npy' #filename='fround_mode_matched_no_map.npy'
#filename='fround_mode_matched_10map.npy' #filename='fround_mode_matched_10map.npy'
filename='fround-2014:12:29-19:55:28.npy' filename='fround-2014:12:29-19:55:28.npy'
print(" --- loading data from file {0} ---".format(filename)) filename='fround-2016:10:21-16:10:14.npy'
global f_round print(" --- loading data from file {0} ---".format(filename))
f_round=np.load(filename) global f_round
f_round=np.load(filename)
tmpresultfile = 'myshelf1.dat' tmpresultfile = 'myshelf1.dat'
# loading additional data saved by previous file # loading additional data saved by previous file
try: try:
tmpfile = shelve.open(tmpresultfile) tmpfile = shelve.open(tmpresultfile)
result=tmpfile['result'] result=tmpfile['result']
tmpfile.close() tmpfile.close()
except: raise Exception("Could not open temprary results file {0}".format(tmpresultfile)) except: raise Exception("Could not open temprary results file {0}".format(tmpresultfile))
scan_start = 0.0 scan_start = 0.0
scan_stop = Lambda scan_stop = Lambda
scan_points = 100 scan_points = 100
global scan global scan
scan = np.linspace(scan_start, scan_stop, scan_points) scan = np.linspace(scan_start, scan_stop, scan_points)
# number of roundtrips # number of roundtrips
global power global power
N = np.shape(f_round)[2] N = np.shape(f_round)[2]
f_temp=np.zeros(np.shape(f_round[:,:,0])) f_temp=np.zeros(np.shape(f_round[:,:,0]))
power=np.zeros(scan_points,dtype=np.double) power=np.zeros(scan_points,dtype=np.double)
print(" --- performing cavity scan --- ") print(" --- performing cavity scan --- ")
# This will take some time, let's show a progress bar # This will take some time, let's show a progress bar
p = ProgressBar(maxval=scan_points, widgets=["power:", Percentage(),"|", Timer(), "|", ETA(), Bar()]) p = ProgressBar(maxval=scan_points, widgets=["power:", Percentage(),"|", Timer(), "|", ETA(), Bar()])
global phases global phases
ns=np.linspace(0.0, N-1, N) ns=np.linspace(0.0, N-1, N)
for i in range(scan_points): for i in range(scan_points):
phases=np.exp(1j*2.0*k*scan[i]*ns) phases=np.exp(1j*2.0*k*scan[i]*ns)
f_temp=np.sum(f_round*phases,axis=-1) f_temp=np.sum(f_round*phases,axis=-1)
power[i] = field_power(f_temp,result['shape']) power[i] = field_power(f_temp,result['shape'])
p.update(i) p.update(i)
p.finish() p.finish()
fileName, fileExtension = os.path.splitext(filename) fileName, fileExtension = os.path.splitext(filename)
txtfile='power_{0}.txt'.format(fileName) txtfile='power_{0}.txt'.format(fileName)
np.savetxt(txtfile, power, fmt='%.18e', delimiter=' ') np.savetxt(txtfile, power, fmt='%.18e', delimiter=' ')
# plot scan # plot scan
ax,fig=plot_setup() #ax,fig=plot_setup()
ax.plot(power) fig=pykat.plotting.figure()
ax.set_yscale('log') ax=fig.add_subplot(111)
pl.draw() ax.plot(power)
pl.show(block=0) ax.set_yscale('log')
pl.draw()
pl.show(block=0)
def field_power(field, shape): def field_power(field, shape):
return np.sum(np.abs(field)**2)*shape.xstep*shape.ystep; return np.sum(np.abs(field)**2)*shape.xstep*shape.ystep;
if __name__ == '__main__': if __name__ == '__main__':
main() main()
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