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
finesse
pykat
Commits
b871e9a5
Commit
b871e9a5
authored
11 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
removing print outputs
parent
d9f9af21
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pykat/components.py
+33
-11
33 additions, 11 deletions
pykat/components.py
pykat/node_network.py
+41
-22
41 additions, 22 deletions
pykat/node_network.py
with
74 additions
and
33 deletions
pykat/components.py
+
33
−
11
View file @
b871e9a5
...
...
@@ -23,17 +23,37 @@ class NodeGaussSetter:
if
not
isinstance
(
component
,
Component
):
raise
pkex
.
BasePyKatException
(
"
Value passed is not a Component
"
)
if
not
isinstance
(
node
,
Node
):
if
not
isinstance
(
node
,
pykat
.
node_network
.
Node
):
raise
pkex
.
BasePyKatException
(
"
Value passed is not a Node
"
)
self
.
_comp
=
component
self
.
_node
=
node
self
.
__comp
=
component
self
.
__node
=
node
@property
def
node
(
self
):
return
self
.
__node
@property
def
q
(
self
):
return
self
.
__node
.
qx
@q.setter
def
q
(
self
,
value
):
node
.
setGauss
(
self
.
__comp
,
value
)
@property
def
qx
(
self
):
return
self
.
__node
.
qx
@qx.setter
def
qx
(
self
,
value
):
node
.
setGauss
(
self
.
__comp
,
value
)
@property
def
qy
(
self
):
return
self
.
__node
.
qy
@qy.setter
def
qy
(
self
,
value
):
node
.
setGauss
(
self
.
__comp
,
self
.
qx
,
value
)
class
Component
(
object
)
:
def
__init__
(
self
,
name
):
self
.
__name
=
name
self
.
_svgItem
=
None
self
.
_nodes
=
None
self
.
_requested_node_names
=
[]
self
.
_kat
=
None
self
.
tag
=
None
...
...
@@ -59,32 +79,34 @@ class Component(object) :
def
__on_node_change
(
self
):
# need to update the node gauss parameter setter members
#self.__update_node_setters()
return
self
.
__update_node_setters
()
def
__update_node_setters
(
self
):
# check if any node setters have already been added. If so we
# need to remove them. This function should get called if the nodes
# are updated, either by some function call or the GUI
key_rm
=
[
k
for
k
in
self
.
__dict__
if
k
.
startswith
(
"
__nodesetter_
"
,
0
,
13
)]
# now we have a list of which to remove
for
key
in
key_rm
:
ns
=
self
.
__dict__
[
key
]
detattr
(
self
,
'
__nodesetter_
'
+
ns
.
_node
.
name
)
delattr
(
self
.
__class__
,
ns
.
_node
.
name
)
delattr
(
self
,
ns
.
_node
.
name
)
for
node
in
self
.
nodes
:
self
.
__add_node_setter
(
NodeGaussSetter
(
self
,
node
))
if
type
(
node
)
!=
pykat
.
node_network
.
DumpNode
:
ns
=
NodeGaussSetter
(
self
,
node
)
self
.
__add_node_setter
(
ns
)
def
__add_node_setter
(
self
,
ns
):
if
not
isinstance
(
ns
,
NodeGaussSetter
):
raise
exceptions
.
ValueError
(
"
Argument is not of type NodeGaussSetter
"
)
name
=
ns
.
__class__
.
__
name
__
name
=
ns
.
node
.
name
fget
=
lambda
self
:
self
.
__get_node_setter
(
name
)
setattr
(
self
.
__class__
,
name
,
property
(
fget
))
setattr
(
self
,
name
,
property
(
fget
))
setattr
(
self
,
'
__nodesetter_
'
+
name
,
ns
)
def
__get_node_setter
(
self
,
name
):
...
...
This diff is collapsed.
Click to expand it.
pykat/node_network.py
+
41
−
22
View file @
b871e9a5
...
...
@@ -141,7 +141,7 @@ class NodeNetwork(object):
name
=
node
.
name
fget
=
lambda
self
:
self
.
__get_node_attr
(
name
)
setattr
(
self
.
__class__
,
name
,
property
(
fget
))
setattr
(
self
,
name
,
property
(
fget
))
setattr
(
self
,
'
__node_
'
+
name
,
node
)
def
__remove_node_attr
(
self
,
node
):
...
...
@@ -150,23 +150,21 @@ class NodeNetwork(object):
name
=
node
.
name
detattr
(
self
,
'
__node_
'
+
name
)
delattr
(
self
.
__class__
,
name
)
delattr
(
self
,
name
)
def
__get_node_attr
(
self
,
name
):
return
getattr
(
self
,
'
__node_
'
+
name
)
class
Node
(
object
):
class
gauss_version
:
w0_z
=
1
z_zR
=
2
def
__init__
(
self
,
name
,
network
,
id
):
self
.
_detectors
=
[]
self
.
__name
=
name
self
.
_item
=
None
self
.
_network
=
network
self
.
__gauss
=
None
self
.
__gauss_version
=
None
self
.
__q_x
=
None
self
.
__q_y
=
None
self
.
__q_comp
=
None
self
.
__id
=
id
@property
...
...
@@ -179,25 +177,46 @@ class Node(object):
def
components
(
self
):
return
self
.
_network
.
getNodeComponents
(
self
)
@property
def
gauss
(
self
):
return
self
.
__gauss
def
q
(
self
):
if
self
.
__q_x
==
self
.
__q_y
:
return
self
.
__q_x
else
:
return
(
self
.
__q_x
,
self
.
__q_y
)
@property
def
qx
(
self
):
return
self
.
__q_x
@property
def
qy
(
self
):
return
self
.
__q_y
def
removeGauss
():
self
.
__gauss_version
=
None
self
.
__gauss
=
None
self
.
__q_x
=
None
self
.
__q_y
=
None
self
.
__q_comp
=
None
def
setGauss
(
self
,
component
,
*
args
):
self
.
__q_comp
=
component
if
len
(
args
)
==
1
:
self
.
__q_x
=
args
[
0
]
self
.
__q_y
=
args
[
0
]
elif
len
(
args
)
==
2
:
self
.
__q_x
=
args
[
0
]
self
.
__q_y
=
args
[
1
]
else
:
raise
pkex
.
BasePyKatException
(
"
Must specify either 1 Gaussian beam parameter or 2 for astigmatic beams
"
)
def
gauss_w0_z
(
self
,
w0
,
z
,
w0y
=
None
,
zy
=
None
):
self
.
__gauss
=
[]
self
.
__gauss
.
append
(
w0
)
self
.
__gauss
.
append
(
z
)
def
getFinesseText
(
self
):
if
self
.
__q_x
is
None
or
self
.
__q_y
is
None
or
self
.
__q_comp
is
None
:
return
[]
if
w0y
!=
None
and
zy
!=
None
:
self
.
__gauss
.
append
(
w0y
)
self
.
__gauss
.
append
(
zy
)
rtn
=
[]
self
.
__gauss_version
=
Node
.
gauss_version
.
w0_z
if
self
.
__q_x
==
self
.
__q_y
:
rtn
.
append
(
"
gauss* g_{node} {comp} {node} {z} {zr}
"
.
format
(
node
=
self
.
name
,
comp
=
self
.
__q_comp
.
name
,
z
=
self
.
__q_x
.
real
,
zr
=
self
.
__q_x
.
imag
))
else
:
rtn
.
append
(
"
gauss* g_{node} {comp} {node} {zx} {zrx} {zy} {zry}
"
.
format
(
node
=
self
.
name
,
comp
=
self
.
__q_comp
.
name
,
zx
=
self
.
__q_x
.
real
,
zrx
=
self
.
__q_x
.
imag
,
zy
=
self
.
__q_y
.
real
,
zry
=
self
.
__q_y
.
imag
))
def
getFinesseText
(
self
):
return
[]
return
rtn
def
isConnected
(
self
):
if
(
self
.
components
[
0
]
is
not
None
)
and
(
self
.
self
.
components
[
1
]
is
not
None
):
...
...
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