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
finesse
pykat
Commits
29c767af
Commit
29c767af
authored
May 26, 2015
by
Daniel Brown
Browse files
fixing beam trace code of py2->py3 errors
parent
888d777e
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/beam_trace.py
0 → 100644
View file @
29c767af
import
pykat
from
pykat.tools.plotting.beamtrace
import
plot_beam_trace
import
numpy
as
np
import
pylab
import
copy
kat
=
pykat
.
finesse
.
kat
()
cmds
=
"""
l l1 1 0 n0
s s0 1000 n0 n1
m m1 0.5 0.5 0 n1 n2
s s1 10 n2 n3
m m2 0.5 0.5 0 n3 n4
s s2 20 n4 n5
bs bs1 0.5 0.5 0 0 n5 n6 n7 n8
s s3 20 n6 n9
s s4 20 n7 n10
s s5 20 n8 n11
bs bs2 0.5 0.5 0 0 n9 n12 n13 n14
s s6 3 n12 n15
lens lens1 20 n15 n16
s s7 500 n16 n17
gouy g1 x s0 s1 s2
bp bp1 x w0 n5
gauss g1 l1 n0 8e-3 -1000 4e-3 -1200
noxaxis
maxtem 0
"""
kat
.
parseCommands
(
cmds
)
plot_beam_trace
(
kat
,
'n0'
,
'n17'
)
\ No newline at end of file
pykat/node_network.py
View file @
29c767af
...
...
@@ -9,6 +9,7 @@ from __future__ import division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
pykat
from
pykat
import
USE_GUI
,
NoGUIException
if
USE_GUI
:
...
...
@@ -465,17 +466,17 @@ class NodeNetwork(object):
if
to_node
==
from_node
:
return
[]
if
from_node
not
in
self
.
__nodes
:
if
from_node
.
name
not
in
self
.
__nodes
:
raise
pkex
.
BasePyKatException
(
"Node {0} cannot be found in this kat object"
.
format
(
from_node
))
if
to_node
not
in
self
.
__nodes
:
if
to_node
.
name
not
in
self
.
__nodes
:
raise
pkex
.
BasePyKatException
(
"Node {0} cannot be found in this kat object"
.
format
(
to_node
))
branches
=
[]
fn
=
self
.
__nodes
[
from_node
]
tn
=
self
.
__nodes
[
to_node
]
fn
=
self
.
__nodes
[
from_node
.
name
]
tn
=
self
.
__nodes
[
to_node
.
name
]
branches
.
append
([
False
,
False
,
fn
,
fn
.
components
[
1
],
[]])
branches
.
append
([
False
,
False
,
fn
,
fn
.
components
[
0
],
[]])
...
...
pykat/tools/plotting/beamtrace.py
View file @
29c767af
...
...
@@ -32,13 +32,11 @@ def plot_beam_trace(_kat, from_node, to_node):
v
=
[
c
for
c
in
zip
(
components
,
nodes
)
if
isinstance
(
c
[
0
],
pykat
.
components
.
space
)]
spaces
=
[
d
[
0
]
for
d
in
v
]
nodes2
=
[
d
[
1
]
for
d
in
v
]
print
[
n
.
name
for
n
in
spaces
]
pylab
.
figure
()
if
len
(
spaces
)
>
0
:
print
"Plotting beam along spaces"
,
", "
.
join
([
s
.
name
for
s
in
spaces
])
print
(
"Plotting beam along spaces"
,
", "
.
join
([
s
.
name
for
s
in
spaces
])
)
for
d
in
kat
.
detectors
.
values
():
d
.
remove
()
...
...
@@ -105,7 +103,7 @@ def plot_beam_trace(_kat, from_node, to_node):
pylab
.
ylabel
(
"Phase accumulation [deg]"
)
pylab
.
xlabel
(
"Distance [m]"
)
pylab
.
xlim
(
min
(
L
),
max
(
L
))
pylab
.
legend
([
'x'
,
'y'
],
0
)
pylab
.
legend
([
'x'
,
'y'
],
loc
=
0
)
pylab
.
tight_layout
()
pylab
.
show
()
\ No newline at end of file
Write
Preview
Markdown
is supported
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