Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sean Leavey
pykat
Commits
22c05c87
Commit
22c05c87
authored
Oct 22, 2016
by
Andreas Freise
Browse files
updating FFT aLIGO example to work with current pykat
parent
62e4bea6
Changes
2
Hide whitespace changes
Inline
Side-by-side
work_in_progress/aligo/FFT_ArmCavity_precompute.py
View file @
22c05c87
...
...
@@ -15,7 +15,7 @@ from pykat.components import *
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.gaussian_beams
import
HG_
mode
,
beam_param
from
pykat.optics.fft
import
*
#from pykat.tools.plotting.tools import plot_field, plot_propagation
...
...
@@ -95,7 +95,7 @@ def main():
# generate roughly mode-matched input beam
global
laser
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
)
# some debugging plots
...
...
work_in_progress/aligo/FFT_ArmCavity_scan.py
View file @
22c05c87
...
...
@@ -10,81 +10,84 @@ import shelve
import
pykat
from
pykat.components
import
*
from
pykat.
utilitie
s.plotting
.tools
import
printPDF
#
from pykat.
tool
s.plotting import printPDF
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.gaussian_beams
import
HG_
beam
,
beam_param
from
pykat.optics.gaussian_beams
import
HG_
mode
,
beam_param
from
pykat.optics.fft
import
*
from
aligo
import
*
def
main
():
print
(
"""
----------------------------------------
"""
)
print
(
"""
----------------------------------------
"""
)
# 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
# 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_mode_matched_no_map.npy'
#filename='fround_mode_matched_10map.npy'
filename
=
'fround-2014:12:29-19:55:28.npy'
print
(
" --- loading data from file {0} ---"
.
format
(
filename
))
global
f_round
f_round
=
np
.
load
(
filename
)
#filename='fround_mode_matched_no_map.npy'
#filename='fround_mode_matched_10map.npy'
filename
=
'fround-2014:12:29-19:55:28.npy'
filename
=
'fround-2016:10:21-16:10:14.npy'
print
(
" --- loading data from file {0} ---"
.
format
(
filename
))
global
f_round
f_round
=
np
.
load
(
filename
)
tmpresultfile
=
'myshelf1.dat'
# 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
))
tmpresultfile
=
'myshelf1.dat'
# 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
=
100
global
scan
scan
=
np
.
linspace
(
scan_start
,
scan_stop
,
scan_points
)
scan_start
=
0.0
scan_stop
=
Lambda
scan_points
=
100
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
[:,:,
0
]))
power
=
np
.
zeros
(
scan_points
,
dtype
=
np
.
double
)
# number of roundtrips
global
power
N
=
np
.
shape
(
f_round
)[
2
]
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
=
[
"power:"
,
Percentage
(),
"|"
,
Timer
(),
"|"
,
ETA
(),
Bar
()])
print
(
" --- performing cavity scan --- "
)
# This will take some time, let's show a progress bar
p
=
ProgressBar
(
maxval
=
scan_points
,
widgets
=
[
"power:"
,
Percentage
(),
"|"
,
Timer
(),
"|"
,
ETA
(),
Bar
()])
global
phases
ns
=
np
.
linspace
(
0.0
,
N
-
1
,
N
)
for
i
in
range
(
scan_points
):
phases
=
np
.
exp
(
1j
*
2.0
*
k
*
scan
[
i
]
*
ns
)
f_temp
=
np
.
sum
(
f_round
*
phases
,
axis
=-
1
)
power
[
i
]
=
field_power
(
f_temp
,
result
[
'shape'
])
p
.
update
(
i
)
p
.
finish
()
global
phases
ns
=
np
.
linspace
(
0.0
,
N
-
1
,
N
)
for
i
in
range
(
scan_points
):
phases
=
np
.
exp
(
1j
*
2.0
*
k
*
scan
[
i
]
*
ns
)
f_temp
=
np
.
sum
(
f_round
*
phases
,
axis
=-
1
)
power
[
i
]
=
field_power
(
f_temp
,
result
[
'shape'
])
p
.
update
(
i
)
p
.
finish
()
fileName
,
fileExtension
=
os
.
path
.
splitext
(
filename
)
txtfile
=
'power_{0}.txt'
.
format
(
fileName
)
np
.
savetxt
(
txtfile
,
power
,
fmt
=
'%.18e'
,
delimiter
=
' '
)
fileName
,
fileExtension
=
os
.
path
.
splitext
(
filename
)
txtfile
=
'power_{0}.txt'
.
format
(
fileName
)
np
.
savetxt
(
txtfile
,
power
,
fmt
=
'%.18e'
,
delimiter
=
' '
)
# plot scan
ax
,
fig
=
plot_setup
()
ax
.
plot
(
power
)
ax
.
set_yscale
(
'log'
)
pl
.
draw
()
pl
.
show
(
block
=
0
)
# plot scan
#ax,fig=plot_setup()
fig
=
pykat
.
plotting
.
figure
()
ax
=
fig
.
add_subplot
(
111
)
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
;
return
np
.
sum
(
np
.
abs
(
field
)
**
2
)
*
shape
.
xstep
*
shape
.
ystep
;
if
__name__
==
'__main__'
:
main
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment