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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Steinlechner
pykat
Commits
8f83578f
Commit
8f83578f
authored
11 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
adding parsing of attr commands
parent
e634953f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/test_plot.py
+2
-0
2 additions, 0 deletions
bin/test_plot.py
pykat/components.py
+72
-6
72 additions, 6 deletions
pykat/components.py
pykat/finesse.py
+26
-0
26 additions, 0 deletions
pykat/finesse.py
with
100 additions
and
6 deletions
bin/test_plot.py
+
2
−
0
View file @
8f83578f
...
...
@@ -20,6 +20,8 @@ yaxis abs:deg
pd pd_cav n3
cav c1 m1 n3 m2 n4
attr m1 Rc 1
"""
kat
=
finesse
.
kat
()
...
...
This diff is collapsed.
Click to expand it.
pykat/components.py
+
72
−
6
View file @
8f83578f
...
...
@@ -243,6 +243,30 @@ class AbstractMirrorComponent(Component):
self
.
Rcx
.
value
=
SIfloat
(
value
)
self
.
Rcy
.
value
=
SIfloat
(
value
)
def
parseAttribute
(
self
,
key
,
value
):
if
key
in
[
"
Rcx
"
,
"
Rx
"
,
"
ROCx
"
,
"
rx
"
,
"
rcx
"
,
"
rocx
"
]:
self
.
Rcx
=
value
elif
key
in
[
"
Rcy
"
,
"
Ry
"
,
"
ROCy
"
,
"
ry
"
,
"
rcy
"
,
"
rocy
"
]:
self
.
Rcy
=
value
elif
key
in
[
"
Rc
"
,
"
ROC
"
,
"
r
"
,
"
rc
"
,
"
roc
"
]:
self
.
Rc
=
value
elif
key
in
[
"
M, m, Mass, mass
"
]:
self
.
mass
=
value
elif
key
in
[
"
xbeta, xBeta
"
]:
self
.
xbeta
=
value
elif
key
in
[
"
ybeta, yBeta
"
]:
self
.
ybeta
=
value
elif
key
in
[
"
x_off
"
]:
self
.
x_offset
=
value
elif
key
in
[
"
y_off
"
]:
self
.
y_offset
=
value
elif
key
in
[
"
r_ap
"
]:
self
.
r_ap
=
value
else
:
return
False
return
True
class
mirror
(
AbstractMirrorComponent
):
def
__init__
(
self
,
name
,
node1
,
node2
,
R
=
None
,
T
=
None
,
L
=
None
,
phi
=
0
,
Rcx
=
None
,
Rcy
=
None
,
xbeta
=
None
,
ybeta
=
None
,
mass
=
None
,
r_ap
=
None
):
super
(
mirror
,
self
).
__init__
(
name
,
R
,
T
,
L
,
phi
,
Rcx
,
Rcy
,
xbeta
,
ybeta
,
mass
,
r_ap
)
...
...
@@ -250,6 +274,12 @@ class mirror(AbstractMirrorComponent):
self
.
_requested_node_names
.
append
(
node1
)
self
.
_requested_node_names
.
append
(
node2
)
def
parseAttributes
(
self
,
values
):
for
key
in
values
.
keys
():
if
not
self
.
parseAttribute
(
key
,
values
[
key
]):
raise
pkex
.
BasePyKatException
(
"
No attribute {0} for mirrors
"
.
format
(
key
))
@staticmethod
def
parseFinesseText
(
text
):
values
=
text
.
split
()
...
...
@@ -301,13 +331,22 @@ class beamSplitter(AbstractMirrorComponent):
self
.
_requested_node_names
.
append
(
node3
)
self
.
_requested_node_names
.
append
(
node4
)
self
.
__alpha
=
Param
(
"
alpha
"
,
self
,
SIfloat
(
alpha
))
self
.
__alpha
=
Attr
Param
(
"
alpha
"
,
self
,
SIfloat
(
alpha
))
@property
def
alpha
(
self
):
return
self
.
__alpha
@alpha.setter
def
alpha
(
self
,
value
):
self
.
__alpha
.
value
=
SIfloat
(
value
)
def
parseAttributes
(
self
,
values
):
for
key
in
values
.
keys
():
if
not
self
.
parseAttribute
(
key
,
values
[
key
]):
if
key
==
"
alpha
"
:
self
.
alpha
=
values
[
key
]
else
:
raise
pkex
.
BasePyKatException
(
"
No attribute {0} for mirrors
"
.
format
(
key
))
@staticmethod
def
parseFinesseText
(
text
):
values
=
text
.
split
()
...
...
@@ -365,7 +404,6 @@ class space(Component):
self
.
__L
=
Param
(
"
L
"
,
self
,
SIfloat
(
L
))
self
.
__n
=
Param
(
"
n
"
,
self
,
SIfloat
(
n
))
self
.
__g
=
AttrParam
(
"
g
"
,
self
,
g
)
self
.
__gx
=
AttrParam
(
"
gx
"
,
self
,
gx
)
self
.
__gy
=
AttrParam
(
"
gy
"
,
self
,
gy
)
...
...
@@ -379,9 +417,16 @@ class space(Component):
def
n
(
self
,
value
):
self
.
__n
.
value
=
SIfloat
(
value
)
@property
def
g
(
self
):
return
self
.
__g
def
g
(
self
):
if
self
.
__gx
.
value
==
self
.
__gy
.
value
:
return
self
.
__g
else
:
raise
pkex
.
BasePyKatException
(
"
Gouy phase in x and y directions are different, use gx and gy properties instead
"
)
@g.setter
def
g
(
self
,
value
):
self
.
__g
.
value
=
SIfloat
(
value
)
def
g
(
self
,
value
):
self
.
__gx
.
value
=
SIfloat
(
value
)
self
.
__gy
.
value
=
SIfloat
(
value
)
@property
def
gx
(
self
):
return
self
.
__gx
...
...
@@ -393,6 +438,19 @@ class space(Component):
@gy.setter
def
gy
(
self
,
value
):
self
.
__gy
.
value
=
SIfloat
(
value
)
def
parseAttributes
(
self
,
values
):
for
key
in
values
.
keys
():
if
key
in
[
"
gx
"
,
"
gouyx
"
]:
self
.
__gx
.
value
=
values
[
key
]
elif
key
in
[
"
gy
"
,
"
gouyy
"
]:
self
.
__gy
.
value
=
values
[
key
]
elif
key
in
[
"
g, gouy
"
]:
self
.
__gx
.
value
=
values
[
key
]
self
.
__gy
.
value
=
values
[
key
]
else
:
raise
pkex
.
BasePyKatException
(
"
No attribute {0} for spaces
"
.
format
(
key
))
@staticmethod
def
parseFinesseText
(
text
):
values
=
text
.
split
()
...
...
@@ -747,6 +805,14 @@ class laser(Component):
@phase.setter
def
phase
(
self
,
value
):
self
.
__phase
.
value
=
float
(
value
)
def
parseAttributes
(
self
,
values
):
for
key
in
values
.
keys
():
if
key
==
"
noise
"
:
self
.
__noise
.
value
=
values
[
key
]
else
:
raise
pkex
.
BasePyKatException
(
"
No attribute {0} at laser
"
.
format
(
key
))
@staticmethod
def
parseFinesseText
(
text
):
values
=
text
.
split
()
...
...
This diff is collapsed.
Click to expand it.
pykat/finesse.py
+
26
−
0
View file @
8f83578f
...
...
@@ -34,6 +34,9 @@ import pykat
import
warnings
import
re
import
itertools
import
collections
from
collections
import
namedtuple
,
OrderedDict
from
pykat.node_network
import
NodeNetwork
...
...
@@ -452,6 +455,8 @@ class kat(object):
after_process
.
append
(
line
)
elif
(
first
==
"
pdtype
"
):
after_process
.
append
(
line
)
elif
(
first
==
"
attr
"
):
after_process
.
append
(
line
)
elif
(
first
==
"
noxaxis
"
):
self
.
noxaxis
=
True
elif
(
first
==
"
phase
"
):
...
...
@@ -522,6 +527,27 @@ class kat(object):
raise
pkex
.
BasePyKatException
(
"
pdtype command `{0}` refers to non-existing detector
"
.
format
(
component_name
))
else
:
raise
pkex
.
BasePyKatException
(
"
pdtype command `{0}` is incorrect.
"
.
format
(
line
))
elif
(
first
==
"
attr
"
):
v
=
line
.
split
()
if
len
(
v
)
<
4
:
raise
pkex
.
BasePyKatException
(
"
attr command `{0}` is incorrect.
"
.
format
(
line
))
else
:
# get the component/detector in question
if
v
[
1
]
in
self
.
__components
:
comp
=
self
.
__components
[
v
[
1
]]
elif
v
[
1
]
in
self
.
__detectors
:
comp
=
self
.
__detectors
[
v
[
1
]]
else
:
raise
pkex
.
BasePyKatException
(
"
Could not find the component
'
{0}
'
for attr command in line
'
{1}
'"
.
format
(
v
[
1
],
line
))
if
len
(
v
[
2
:])
%
2
==
1
:
raise
pkex
.
BasePyKatException
(
"
Attr command
'
{0}
'
must specify both parameter and value pairs
"
.
format
(
line
))
# convert split list to key value pairs
kv
=
dict
(
itertools
.
izip_longest
(
*
[
iter
(
v
[
2
:])]
*
2
,
fillvalue
=
None
))
comp
.
parseAttributes
(
kv
)
self
.
__currentTag
=
NO_BLOCK
...
...
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