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
452ab9f9
Commit
452ab9f9
authored
Dec 11, 2013
by
Daniel Brown
Browse files
Merge branch 'master' of gitmaster.atlas.aei.uni-hannover.de:pykat/pykat
parents
ba219bcc
0a7dda36
Changes
1
Hide whitespace changes
Inline
Side-by-side
pykat/components.py
View file @
452ab9f9
...
@@ -9,6 +9,7 @@ import pykat.exceptions as pkex
...
@@ -9,6 +9,7 @@ import pykat.exceptions as pkex
import
pykat
import
pykat
from
pykat.node_network
import
*
from
pykat.node_network
import
*
from
pykat.exceptions
import
*
from
pykat.exceptions
import
*
import
abc
import
pykat.gui.resources
import
pykat.gui.resources
import
pykat.gui.graphics
import
pykat.gui.graphics
...
@@ -48,7 +49,9 @@ class NodeGaussSetter(object):
...
@@ -48,7 +49,9 @@ class NodeGaussSetter(object):
def
qy
(
self
,
value
):
def
qy
(
self
,
value
):
self
.
__node
.
setGauss
(
self
.
__comp
,
self
.
qx
,
complex
(
value
))
self
.
__node
.
setGauss
(
self
.
__comp
,
self
.
qx
,
complex
(
value
))
class
Component
(
object
)
:
class
Component
(
object
):
__metaclass__
=
abc
.
ABCMeta
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
__name
=
name
self
.
__name
=
name
self
.
_svgItem
=
None
self
.
_svgItem
=
None
...
@@ -117,13 +120,17 @@ class Component(object) :
...
@@ -117,13 +120,17 @@ class Component(object) :
return
getattr
(
self
,
'__nodesetter_'
+
name
)
return
getattr
(
self
,
'__nodesetter_'
+
name
)
@
staticmethod
@
staticmethod
def
parseFinesseText
(
text
):
@
abc
.
abstractmethod
def
parseFinesseText
(
text
):
"""Parses Finesse syntax"""
raise
NotImplementedError
(
"This function is not implemented"
)
raise
NotImplementedError
(
"This function is not implemented"
)
@
staticmethod
@
abc
.
abstractmethod
def
getFinesseText
(
self
):
def
getFinesseText
(
self
):
""" Base class for individual
f
inesse optical components """
""" Base class for individual
F
inesse optical components """
raise
NotImplementedError
(
"This function is not implemented"
)
raise
NotImplementedError
(
"This function is not implemented"
)
def
getQGraphicsItem
(
self
):
def
getQGraphicsItem
(
self
):
return
None
return
None
...
@@ -136,8 +143,6 @@ class Component(object) :
...
@@ -136,8 +143,6 @@ class Component(object) :
@
property
@
property
def
id
(
self
):
return
self
.
__id
def
id
(
self
):
return
self
.
__id
class
Param
(
float
):
class
Param
(
float
):
def
__new__
(
self
,
name
,
value
):
def
__new__
(
self
,
name
,
value
):
return
float
.
__new__
(
self
,
SIfloat
(
value
))
return
float
.
__new__
(
self
,
SIfloat
(
value
))
...
@@ -146,18 +151,13 @@ class Param(float):
...
@@ -146,18 +151,13 @@ class Param(float):
self
.
__name
=
name
self
.
__name
=
name
name
=
property
(
lambda
self
:
self
.
__name
)
name
=
property
(
lambda
self
:
self
.
__name
)
class
mirror
(
Component
):
def
__init__
(
self
,
name
,
node1
,
node2
,
R
=
0
,
T
=
0
,
phi
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
,
r_ap
=
0
):
Component
.
__init__
(
self
,
name
)
self
.
_requested_node_names
.
append
(
node1
)
self
.
_requested_node_names
.
append
(
node2
)
class
AbstractMirrorComponent
(
Component
):
self
.
__r_ap
=
SIfloat
(
r_ap
)
__metaclass__
=
abc
.
ABCMeta
self
.
__mass
=
SIfloat
(
mass
)
def
__init__
(
self
,
name
,
R
=
0
,
T
=
0
,
phi
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
,
r_ap
=
0
):
super
(
AbstractMirrorComponent
,
self
).
__init__
(
name
)
self
.
__R
=
SIfloat
(
R
)
self
.
__R
=
SIfloat
(
R
)
self
.
__T
=
SIfloat
(
T
)
self
.
__T
=
SIfloat
(
T
)
self
.
__phi
=
SIfloat
(
phi
)
self
.
__phi
=
SIfloat
(
phi
)
...
@@ -165,7 +165,21 @@ class mirror(Component):
...
@@ -165,7 +165,21 @@ class mirror(Component):
self
.
__Rcy
=
SIfloat
(
Rcy
)
self
.
__Rcy
=
SIfloat
(
Rcy
)
self
.
__xbeta
=
SIfloat
(
xbeta
)
self
.
__xbeta
=
SIfloat
(
xbeta
)
self
.
__ybeta
=
SIfloat
(
ybeta
)
self
.
__ybeta
=
SIfloat
(
ybeta
)
self
.
__mass
=
SIfloat
(
mass
)
self
.
__r_ap
=
SIfloat
(
r_ap
)
def
getAttributeText
(
self
):
rtn
=
[]
if
self
.
Rcx
!=
0
:
rtn
.
append
(
"attr {0} Rcx {1}"
.
format
(
self
.
name
,
self
.
__Rcx
))
if
self
.
Rcy
!=
0
:
rtn
.
append
(
"attr {0} Rcy {1}"
.
format
(
self
.
name
,
self
.
__Rcy
))
if
self
.
xbeta
!=
0
:
rtn
.
append
(
"attr {0} xbeta {1}"
.
format
(
self
.
name
,
self
.
__xbeta
))
if
self
.
ybeta
!=
0
:
rtn
.
append
(
"attr {0} ybeta {1}"
.
format
(
self
.
name
,
self
.
__ybeta
))
if
self
.
mass
!=
0
:
rtn
.
append
(
"attr {0} mass {1}"
.
format
(
self
.
name
,
self
.
__mass
))
if
self
.
r_ap
!=
0
:
rtn
.
append
(
"attr {0} r_ap {1}"
.
format
(
self
.
name
,
self
.
__r_ap
))
return
rtn
@
property
@
property
def
r_ap
(
self
):
return
Param
(
'r_ap'
,
self
.
__r_ap
)
def
r_ap
(
self
):
return
Param
(
'r_ap'
,
self
.
__r_ap
)
@
r_ap
.
setter
@
r_ap
.
setter
...
@@ -222,6 +236,13 @@ class mirror(Component):
...
@@ -222,6 +236,13 @@ class mirror(Component):
def
Rc
(
self
,
value
):
def
Rc
(
self
,
value
):
self
.
Rcx
=
SIfloat
(
value
)
self
.
Rcx
=
SIfloat
(
value
)
self
.
Rcy
=
SIfloat
(
value
)
self
.
Rcy
=
SIfloat
(
value
)
class
mirror
(
AbstractMirrorComponent
):
def
__init__
(
self
,
name
,
node1
,
node2
,
R
=
0
,
T
=
0
,
phi
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
,
r_ap
=
0
):
super
(
mirror
,
self
).
__init__
(
name
,
R
,
T
,
phi
,
Rcx
,
Rcy
,
xbeta
,
ybeta
,
mass
,
r_ap
)
self
.
_requested_node_names
.
append
(
node1
)
self
.
_requested_node_names
.
append
(
node2
)
@
staticmethod
@
staticmethod
def
parseFinesseText
(
text
):
def
parseFinesseText
(
text
):
...
@@ -244,20 +265,14 @@ class mirror(Component):
...
@@ -244,20 +265,14 @@ class mirror(Component):
values
.
pop
(
0
)
# remove initial value
values
.
pop
(
0
)
# remove initial value
return
mirror
(
values
[
0
],
values
[
4
],
values
[
5
],
R
=
values
[
1
],
T
=
1.0
-
SIfloat
(
values
[
1
])
-
SIfloat
(
values
[
2
]),
phi
=
values
[
3
])
return
mirror
(
values
[
0
],
values
[
4
],
values
[
5
],
R
=
values
[
1
],
T
=
1.0
-
SIfloat
(
values
[
1
])
-
SIfloat
(
values
[
2
]),
phi
=
values
[
3
])
def
getFinesseText
(
self
):
def
getFinesseText
(
self
):
rtn
=
[]
rtn
=
[]
rtn
.
append
(
'm {0} {1} {2} {3} {4} {5}'
.
format
(
rtn
.
append
(
'm {0} {1} {2} {3} {4} {5}'
.
format
(
self
.
name
,
self
.
__
R
,
self
.
__
T
,
self
.
__
phi
,
self
.
name
,
self
.
R
,
self
.
T
,
self
.
phi
,
self
.
nodes
[
0
].
name
,
self
.
nodes
[
1
].
name
))
self
.
nodes
[
0
].
name
,
self
.
nodes
[
1
].
name
))
if
self
.
r_ap
!=
0
:
rtn
.
append
(
"attr {0} r_ap {1}"
.
format
(
self
.
name
,
self
.
__r_ap
))
rtn
.
append
(
super
(
mirror
,
self
).
getAttributeText
())
if
self
.
mass
!=
0
:
rtn
.
append
(
"attr {0} mass {1}"
.
format
(
self
.
name
,
self
.
__mass
))
if
self
.
Rcx
!=
0
:
rtn
.
append
(
"attr {0} Rcx {1}"
.
format
(
self
.
name
,
self
.
__Rcx
))
if
self
.
Rcy
!=
0
:
rtn
.
append
(
"attr {0} Rcy {1}"
.
format
(
self
.
name
,
self
.
__Rcy
))
if
self
.
xbeta
!=
0
:
rtn
.
append
(
"attr {0} xbeta {1}"
.
format
(
self
.
name
,
self
.
__xbeta
))
if
self
.
ybeta
!=
0
:
rtn
.
append
(
"attr {0} ybeta {1}"
.
format
(
self
.
name
,
self
.
__ybeta
))
return
rtn
return
rtn
...
@@ -267,76 +282,22 @@ class mirror(Component):
...
@@ -267,76 +282,22 @@ class mirror(Component):
return
self
.
_svgItem
return
self
.
_svgItem
class
beamSplitter
(
Component
):
class
beamSplitter
(
AbstractMirror
Component
):
def
__init__
(
self
,
name
,
node1
,
node2
,
node3
,
node4
,
R
=
0
,
T
=
0
,
phi
=
0
,
alpha
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
):
def
__init__
(
self
,
name
,
node1
,
node2
,
node3
,
node4
,
R
=
0
,
T
=
0
,
phi
=
0
,
alpha
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
,
r_ap
=
0
):
Component
.
__init__
(
self
,
name
)
super
(
beamSplitter
,
self
).
__init__
(
name
,
R
,
T
,
phi
,
Rcx
,
Rcy
,
xbeta
,
ybeta
,
mass
,
r_ap
)
self
.
_requested_node_names
.
append
(
node1
)
self
.
_requested_node_names
.
append
(
node1
)
self
.
_requested_node_names
.
append
(
node2
)
self
.
_requested_node_names
.
append
(
node2
)
self
.
_requested_node_names
.
append
(
node3
)
self
.
_requested_node_names
.
append
(
node3
)
self
.
_requested_node_names
.
append
(
node4
)
self
.
_requested_node_names
.
append
(
node4
)
self
.
__R
=
SIfloat
(
R
)
self
.
__T
=
SIfloat
(
T
)
self
.
__alpha
=
SIfloat
(
alpha
)
self
.
__alpha
=
SIfloat
(
alpha
)
self
.
__phi
=
SIfloat
(
phi
)
self
.
__Rcx
=
SIfloat
(
Rcx
)
self
.
__Rcy
=
SIfloat
(
Rcy
)
self
.
__xbeta
=
SIfloat
(
xbeta
)
self
.
__ybeta
=
SIfloat
(
ybeta
)
@
property
def
R
(
self
):
return
Param
(
'R'
,
self
.
__R
)
@
R
.
setter
def
R
(
self
,
value
):
self
.
__R
=
SIfloat
(
value
)
@
property
def
T
(
self
):
return
Param
(
'T'
,
self
.
__T
)
@
T
.
setter
def
T
(
self
,
value
):
self
.
__T
=
SIfloat
(
value
)
@
property
def
phi
(
self
):
return
Param
(
'phi'
,
self
.
__phi
)
@
phi
.
setter
def
phi
(
self
,
value
):
self
.
__phi
=
SIfloat
(
value
)
@
property
@
property
def
alpha
(
self
):
return
Param
(
'alpha'
,
self
.
__alpha
)
def
alpha
(
self
):
return
Param
(
'alpha'
,
self
.
__alpha
)
@
alpha
.
setter
@
alpha
.
setter
def
alpha
(
self
,
value
):
self
.
__alpha
=
SIfloat
(
value
)
def
alpha
(
self
,
value
):
self
.
__alpha
=
SIfloat
(
value
)
@
property
def
Rcx
(
self
):
return
Param
(
'Rcx'
,
self
.
__Rcx
)
@
Rcx
.
setter
def
Rcx
(
self
,
value
):
self
.
__Rcx
=
SIfloat
(
value
)
@
property
def
Rcy
(
self
):
return
Param
(
'Rcy'
,
self
.
__Rcy
)
@
Rcy
.
setter
def
Rcy
(
self
,
value
):
self
.
__Rcy
=
SIfloat
(
value
)
@
property
def
xbeta
(
self
):
return
Param
(
'xbeta'
,
self
.
__xbeta
)
@
xbeta
.
setter
def
xbeta
(
self
,
value
):
self
.
__xbeta
=
SIfloat
(
value
)
@
property
def
ybeta
(
self
):
return
Param
(
'ybeta'
,
self
.
__ybeta
)
@
ybeta
.
setter
def
ybeta
(
self
,
value
):
self
.
__ybeta
=
SIfloat
(
value
)
@
property
def
Rc
(
self
):
if
self
.
Rcx
==
self
.
Rcy
:
return
self
.
Rcx
else
:
return
[
self
.
Rcx
,
self
.
Rcy
]
@
Rc
.
setter
def
Rc
(
self
,
value
):
self
.
Rcx
=
SIfloat
(
value
)
self
.
Rcy
=
SIfloat
(
value
)
@
staticmethod
@
staticmethod
def
parseFinesseText
(
text
):
def
parseFinesseText
(
text
):
values
=
text
.
split
(
" "
)
values
=
text
.
split
(
" "
)
...
@@ -358,19 +319,16 @@ class beamSplitter(Component):
...
@@ -358,19 +319,16 @@ class beamSplitter(Component):
values
.
pop
(
0
)
# remove initial value
values
.
pop
(
0
)
# remove initial value
return
beamSplitter
(
values
[
0
],
values
[
5
],
values
[
6
],
values
[
7
],
values
[
8
],
values
[
1
],
1.0
-
SIfloat
(
values
[
1
])
-
SIfloat
(
values
[
2
]),
values
[
3
],
values
[
4
])
return
beamSplitter
(
values
[
0
],
values
[
5
],
values
[
6
],
values
[
7
],
values
[
8
],
values
[
1
],
1.0
-
SIfloat
(
values
[
1
])
-
SIfloat
(
values
[
2
]),
values
[
3
],
values
[
4
])
def
getFinesseText
(
self
):
def
getFinesseText
(
self
):
rtn
=
[]
rtn
=
[]
rtn
.
append
(
'bs {0} {1} {2} {3} {4} {5} {6} {7} {8}'
.
format
(
rtn
.
append
(
'bs {0} {1} {2} {3} {4} {5} {6} {7} {8}'
.
format
(
self
.
name
,
self
.
__
R
,
self
.
__
T
,
self
.
__
phi
,
self
.
name
,
self
.
R
,
self
.
T
,
self
.
phi
,
self
.
__
alpha
,
self
.
nodes
[
0
].
name
,
self
.
alpha
,
self
.
nodes
[
0
].
name
,
self
.
nodes
[
1
].
name
,
self
.
nodes
[
2
].
name
,
self
.
nodes
[
1
].
name
,
self
.
nodes
[
2
].
name
,
self
.
nodes
[
3
].
name
))
self
.
nodes
[
3
].
name
))
if
self
.
Rcx
!=
0
:
rtn
.
append
(
"attr {0} Rcx {1}"
.
format
(
self
.
name
,
self
.
__Rcx
))
rtn
.
append
(
super
(
beamSplitter
,
self
).
getAttributeText
())
if
self
.
Rcy
!=
0
:
rtn
.
append
(
"attr {0} Rcy {1}"
.
format
(
self
.
name
,
self
.
__Rcy
))
if
self
.
xbeta
!=
0
:
rtn
.
append
(
"attr {0} xbeta {1}"
.
format
(
self
.
name
,
self
.
__xbeta
))
if
self
.
ybeta
!=
0
:
rtn
.
append
(
"attr {0} ybeta {1}"
.
format
(
self
.
name
,
self
.
__ybeta
))
return
rtn
return
rtn
...
...
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