Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pykat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Steinlechner
pykat
Commits
404b7fb2
Commit
404b7fb2
authored
11 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
adding lkat tracing example
parent
f25ea454
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/lkat_trace.py
+28
-0
28 additions, 0 deletions
examples/lkat_trace.py
pykat/finesse.py
+76
-3
76 additions, 3 deletions
pykat/finesse.py
with
104 additions
and
3 deletions
examples/lkat_trace.py
0 → 100644
+
28
−
0
View file @
404b7fb2
import
pykat
cmd
=
"""
l l1 1 0 n1
s s1 1 n1 n2
m m1 0.99 0.01 0 n2 n3
s s2 100 n3 n4
m m2 0.99 0.01 0 n4 n5
pd circ n3
noxaxis
maxtem 2
attr m1 Rc -1000
attr m2 Rc 1000
cav c1 m1 n3 m2 n4
"""
kat
=
pykat
.
finesse
.
kat
()
kat
.
parseCommands
(
cmd
)
info
=
kat
.
lkat_trace
()
print
"
n1 qx =
"
,
info
[
"
n1
"
].
qx
print
"
Cavity info
"
,
info
[
"
c1
"
]
This diff is collapsed.
Click to expand it.
pykat/finesse.py
+
76
−
3
View file @
404b7fb2
...
...
@@ -36,6 +36,7 @@ import re
import
itertools
import
ctypes
import
ctypes.util
import
collections
from
collections
import
namedtuple
,
OrderedDict
...
...
@@ -58,10 +59,21 @@ NO_GUI = False
NO_BLOCK
=
"
NO_BLOCK
"
pykat_web
=
"
www.gwoptics.org/pykat
"
# containers used in the trace routine
space_trace
=
namedtuple
(
"
space_trace
"
,
[
'
gouyx
'
,
'
gouyy
'
])
node_trace
=
namedtuple
(
"
node_trace
"
,
[
'
qx
'
,
'
qy
'
])
cav_trace
=
namedtuple
(
"
cav_trace
"
,
[
'
isStable
'
,
'
gx
'
,
'
gy
'
,
'
qx
'
,
'
qy
'
,
'
finesse
'
,
'
loss
'
,
'
length
'
,
'
FSR
'
,
'
FWHM
'
,
'
pole
'
])
lkat_location
=
ctypes
.
util
.
find_library
(
"
kat
"
)
def
f__lkat_process
(
callback
,
cmd
,
kwargs
):
"""
"""
lkat
=
ctypes
.
PyDLL
(
"
libkat.so.0
"
)
if
lkat_location
==
None
:
raise
RuntimeError
(
"
Could not find shared library
'
libkat
'
, please install to a system location or copy to the same directory as this script
"
)
lkat
=
ctypes
.
PyDLL
(
lkat_location
)
try
:
lkat
.
_pykat_preInit
()
# must always be called, sets up
...
...
@@ -80,6 +92,56 @@ def f__lkat_process(callback, cmd, kwargs):
# This should always be called no matter what
lkat
.
_pykat_finish
(
0
)
def
f__lkat_trace_callback
(
lkat
,
trace_info
):
"""
lkat callback for computing the beam traces through a setup.
Returns a dictionary of nodes, spaces and cavities and the
various outputs of the tracing algorithm.
"""
import
pylibkat
# first we need to get a handle on the internals of Finesse
inter
=
pylibkat
.
interferometer
.
in_dll
(
lkat
,
"
inter
"
)
lkat
.
_pykat_step
()
for
n
in
range
(
0
,
inter
.
num_nodes
):
node
=
inter
.
node_list
[
n
]
node_info
=
node_trace
(
qx
=
complex
(
node
.
qx
.
re
,
node
.
qx
.
im
),
qy
=
complex
(
node
.
qy
.
re
,
node
.
qy
.
im
)
)
trace_info
[
node
.
name
]
=
node_info
for
c
in
range
(
0
,
inter
.
num_cavities
):
cav
=
inter
.
cavity_list
[
c
]
cav_info
=
cav_trace
(
isStable
=
(
cav
.
stable
==
1
),
gx
=
cav
.
stability_x
,
gy
=
cav
.
stability_y
,
qx
=
complex
(
cav
.
qx
.
re
,
cav
.
qx
.
im
),
qy
=
complex
(
cav
.
qy
.
re
,
cav
.
qy
.
im
),
finesse
=
cav
.
finesse
,
FSR
=
cav
.
FSR
,
FWHM
=
cav
.
FWHM
,
loss
=
cav
.
loss
,
length
=
cav
.
length
,
pole
=
cav
.
pole
)
trace_info
[
cav
.
name
]
=
cav_info
for
s
in
range
(
0
,
inter
.
num_spaces
):
space
=
inter
.
space_list
[
s
]
trace_info
[
space
.
name
]
=
space_trace
(
gouyx
=
space
.
gouy_x
,
gouyy
=
space
.
gouy_y
)
class
katRun
(
object
):
def
__init__
(
self
):
self
.
runDateTime
=
datetime
.
datetime
.
now
()
...
...
@@ -1097,6 +1159,17 @@ class kat(object):
return
rtn
def
lkat_trace
(
self
):
if
lkat_location
==
None
:
raise
RuntimeError
(
"
Could not find shared library
'
libkat
'
, please install to a system location or copy to the same directory as this script
"
)
trace_info
=
Manager
().
dict
()
p
=
self
.
getProcess
(
f__lkat_trace_callback
,
trace_info
=
trace_info
)
p
.
start
()
p
.
join
()
return
trace_info
def
__add_detector
(
self
,
det
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment