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
Sebastian Steinlechner
pykat
Commits
7ec0e7db
Commit
7ec0e7db
authored
Jan 06, 2014
by
Andreas Freise
Browse files
finishe large alignment ASC signals. Only one plot missing. :)
parent
a9f61348
Changes
5
Hide whitespace changes
Inline
Side-by-side
examples/asc_test/master2.py
View file @
7ec0e7db
...
...
@@ -115,6 +115,8 @@ def main():
tmpfile
.
close
()
#-----------------------------------------------------------------------------------
def
asc_signal
(
tmpkat
):
kat
=
copy
.
deepcopy
(
tmpkat
)
...
...
examples/asc_test/master3.py
View file @
7ec0e7db
...
...
@@ -40,9 +40,8 @@ def main():
# %reset -f
# making these global during testing and debugging
global
kat
global
out
global
result
#global kat
#global out
kat
=
finesse
.
kat
(
tempdir
=
"."
,
tempname
=
"test"
)
kat
.
verbose
=
False
...
...
@@ -57,12 +56,8 @@ def main():
tmpfile
.
close
()
except
:
raise
Exception
(
"Could not open temprary results file {0}"
.
format
(
tmpresultfile
))
# overwriting some variables
kat
.
maxtem
=
3
Lambda
=
1064.0e-9
print
"--------------------------------------------------------"
print
" 9. ASC signals for large misalignments"
print
" 9. ASC signals for large misalignments
(ITM)
"
asc_large
(
kat
)
...
...
examples/asc_test/master3_plot.py
View file @
7ec0e7db
...
...
@@ -60,7 +60,7 @@ def main():
except
:
raise
Exception
(
"Could not open temprary results file {0}"
.
format
(
tmpresultfile
))
print
"--------------------------------------------------------"
print
" 9. ASC signals for large misalignments"
print
" 9.
Plotting
ASC signals for large misalignments"
asc_large
()
...
...
examples/asc_test/master4.py
0 → 100644
View file @
7ec0e7db
from
pykat
import
finesse
from
pykat.commands
import
*
import
pylab
as
pl
import
numpy
as
np
import
shelve
import
copy
import
sys
import
shutil
from
itertools
import
cycle
import
matplotlib
from
matplotlib
import
rc
import
matplotlib.pyplot
as
plt
formatter
=
matplotlib
.
ticker
.
EngFormatter
(
unit
=
''
,
places
=
0
)
formatter
.
ENG_PREFIXES
[
-
6
]
=
'u'
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
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
--------------------------------------------------------------
"""
# 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
))
print
"--------------------------------------------------------"
print
" 10. ASC signals for large misalignments (ETM)"
asc_large
(
kat
)
def
asc_large
(
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
.
parseKatCode
(
'xaxis ETM ybeta lin 0 1u 100'
)
maxtems
=
[
1
,
3
,
7
,
20
]
#kat.verbose=1
xscale
=
1e6
yscale
=
1e6
global
out
tmpfilename
=
"datashelf2.dat"
backupname
=
"datashelf2.dat.bck"
out
=
{}
done_maxtems
=
[]
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
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
if
__name__
==
'__main__'
:
main
()
examples/asc_test/master4_plot.py
0 → 100644
View file @
7ec0e7db
from
pykat
import
finesse
from
pykat.commands
import
*
import
pylab
as
pl
import
numpy
as
np
import
shelve
import
copy
import
sys
import
shutil
from
itertools
import
cycle
import
matplotlib
from
matplotlib
import
rc
import
matplotlib.pyplot
as
plt
formatter
=
matplotlib
.
ticker
.
EngFormatter
(
unit
=
''
,
places
=
0
)
formatter
.
ENG_PREFIXES
[
-
6
]
=
'u'
import
matplotlib.backends.backend_pdf
def
printPDF
(
self
):
filename
=
'test.pdf'
pdfp
=
matplotlib
.
backends
.
backend_pdf
.
PdfPages
(
'large_ETM.pdf'
)
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: 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
Run this file to plot the data generated with master4.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
tmpresultfile
=
'myshelf2.dat'
# loading data saved by master.py
try
:
tmpfile
=
shelve
.
open
(
tmpresultfile
)
result
=
tmpfile
[
'result'
]
tmpfile
.
close
()
except
:
raise
Exception
(
"Could not open temprary results file {0}"
.
format
(
tmpresultfile
))
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"
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
))
fig
=
pl
.
figure
()
color_cycle
=
[
'b'
,
'c'
,
'r'
,
'k'
]
N
=
len
(
maxtems
)
lw
=
np
.
ones
(
N
)
*
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])
osc1
=
np
.
loadtxt
(
"OSCAR_large_tilt_ETM.txt"
,
comments
=
'%'
)
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 ybeta [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
.
legend
(
loc
=
3
)
pl
.
grid
()
pl
.
draw
()
pl
.
show
(
block
=
0
)
printPDF
(
fig
)
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