Skip to content
GitLab
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
d5ccc762
Commit
d5ccc762
authored
Apr 10, 2015
by
Andreas Freise
Browse files
starting to fix asc_test example
parent
6a372be9
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
examples/asc_test/master.py
View file @
d5ccc762
...
...
@@ -101,8 +101,8 @@ def pd_signal(tmpkat):
kat
.
parseKatCode
(
code1
)
kat
.
noxaxis
=
True
out
=
kat
.
run
()
print
" Cavity power: {0:.6f}W"
.
format
(
out
.
y
[
2
])
return
(
out
.
y
[
0
],
out
.
y
[
1
])
print
" Cavity power: {0:.6f}W"
.
format
(
out
.
y
[
2
,
0
])
return
(
out
.
y
[
0
,
0
],
out
.
y
[
0
,
1
])
def
pd_phase
(
tmpkat
):
...
...
@@ -164,7 +164,7 @@ def powers(tmpkat):
code1
=
code1
.
split
(
"
\n
"
)
for
i
in
range
(
len
(
out
.
y
)):
print
" %8s: %.4e"
%
(
out
.
ylabels
[
i
],
out
.
y
[
i
])
print
" %8s: %.4e"
%
(
out
.
ylabels
[
i
],
out
.
y
[
0
,
i
])
def
resonance
(
tmpkat
):
...
...
@@ -182,7 +182,7 @@ def resonance(tmpkat):
def
carrier_resonance
(
x
):
kat
.
ETM
.
phi
=
x
out
=
kat
.
run
()
phase
=
(
out
.
y
[
0
]
-
out
.
y
[
1
]
-
90
)
%
360
-
180
phase
=
(
out
.
y
[
0
,
0
]
-
out
.
y
[
0
,
1
]
-
90
)
%
360
-
180
print
'
\r
root finding: function value %g '
%
phase
,
sys
.
stdout
.
flush
()
return
phase
...
...
pykat/__init__.py
View file @
d5ccc762
...
...
@@ -2,14 +2,6 @@ __version__ = "0.6.2"
# This flag is used to switch on the gui features in pkat at import time
USE_GUI
=
False
HAS_OPTIVIS
=
False
import
imp
try
:
imp
.
find_module
(
'optivis'
)
HAS_OPTIVIS
=
True
except
ImportError
:
HAS_OPTIVIS
=
False
import
pykat.exceptions
as
pkex
...
...
@@ -20,7 +12,7 @@ import components
import
detectors
import
commands
from
pykat.optics.gaussian_beams
import
beam_param
from
pykat.
utilities.
optics.gaussian_beams
import
beam_param
...
...
pykat/commands.py
View file @
d5ccc762
...
...
@@ -4,18 +4,15 @@ Created on Mon Jan 28 11:58:09 2013
@author: Daniel
"""
from
__future__
import
print_function
import
numpy
from
numpy
import
min
,
max
import
pykat.external.six
as
six
if
six
.
PY2
:
import
exceptions
import
exceptions
from
components
import
*
from
structs
import
*
from
pykat.param
import
Param
,
putter
import
pykat.exceptions
as
pkex
from
collections
import
namedtuple
from
pykat.optics.gaussian_beams
import
beam_param
from
pykat.
utilities.
optics.gaussian_beams
import
beam_param
class
Command
(
object
):
__metaclass__
=
abc
.
ABCMeta
...
...
pykat/components.py
View file @
d5ccc762
...
...
@@ -4,29 +4,12 @@ Created on Mon Jan 28 11:10:01 2013
@author: Daniel
"""
from
__future__
import
print_function
from
pykat
import
USE_GUI
,
HAS_OPTIVIS
,
NoGUIException
import
pykat.external.six
as
six
if
six
.
PY2
:
import
exceptions
import
exceptions
import
pykat.exceptions
as
pkex
import
pykat
from
pykat.node_network
import
*
from
pykat.exceptions
import
*
import
abc
import
copy
from
collections
import
OrderedDict
if
HAS_OPTIVIS
:
import
optivis.bench.components
as
optivis_components
from
optivis.view.canvas
import
OptivisCanvasItemDataType
from
optivis.bench.labels
import
Label
as
optivis_label
from
optivis.geometry
import
Coordinates
as
optivis_coord
import
PyQt4
from
pykat.SIfloat
import
*
from
pykat.param
import
Param
,
AttrParam
...
...
@@ -35,6 +18,8 @@ import pykat.exceptions as pkex
next_component_id
=
1
from
pykat
import
USE_GUI
,
NoGUIException
if
USE_GUI
:
import
pykat.gui.resources
import
pykat.gui.graphics
...
...
@@ -82,16 +67,8 @@ class NodeGaussSetter(object):
class
Component
(
object
):
__metaclass__
=
abc
.
ABCMeta
def
__new__
(
cls
,
*
args
,
**
kwargs
):
# This creates an instance specific class for the component
# this enables us to add properties to instances rather than
# all classes
return
object
.
__new__
(
type
(
cls
.
__name__
,
(
cls
,),
{}),
*
args
,
**
kwargs
)
def
__init__
(
self
,
name
=
None
):
self
.
_optivis_component
=
None
def
__init__
(
self
,
name
):
self
.
__name
=
name
self
.
_svgItem
=
None
self
.
_requested_node_names
=
[]
...
...
@@ -100,26 +77,18 @@ class Component(object):
self
.
_params
=
[]
self
.
__removed
=
False
self
.
_default_fsig_param
=
None
self
.
optivisLabelContent
=
None
# store a unique ID for this component
global
next_component_id
self
.
__id
=
next_component_id
next_component_id
+=
1
def
__deepcopy__
(
self
,
memo
):
"""
When deep copying a kat object we need to take into account
the instance specific properties.
"""
result
=
self
.
__class__
.
__new__
(
self
.
__class__
)
result
.
__dict__
=
copy
.
deepcopy
(
self
.
__dict__
,
memo
)
result
.
__update_node_setters
return
result
# This creates an instance specific class for the component
# this enables us to add properties to instances rather than
# all classes
cls
=
type
(
self
)
self
.
__class__
=
type
(
cls
.
__name__
,
(
cls
,),
{})
def
_register_param
(
self
,
param
):
self
.
_params
.
append
(
param
)
...
...
@@ -229,38 +198,7 @@ class Component(object):
del
self
.
_params
[:]
self
.
__removed
=
True
def
getOptivisParameterDict
(
self
):
if
len
(
self
.
_params
)
==
0
:
return
None
d
=
OrderedDict
()
for
p
in
self
.
_params
:
d
[
p
.
name
]
=
OptivisCanvasItemDataType
.
TEXTBOX
return
d
def
getOptivisTooltip
(
self
):
tooltip
=
"Name: %s"
%
self
.
name
for
p
in
self
.
_params
:
if
p
.
value
is
not
None
:
tooltip
+=
"
\n
%s = %s"
%
(
p
.
name
,
str
(
p
.
value
))
return
tooltip
def
setOptivisLabelContent
(
self
):
"""
Sets default Optivis label contents
"""
if
self
.
optivisLabelContent
is
None
:
self
.
optivisLabelContent
=
{}
self
.
optivisLabelContent
[
"Name"
]
=
self
.
name
class
AbstractMirrorComponent
(
Component
):
__metaclass__
=
abc
.
ABCMeta
...
...
@@ -296,12 +234,12 @@ class AbstractMirrorComponent(Component):
self
.
__rxmech
=
AttrParam
(
"rxmech"
,
self
,
rxmech
)
self
.
__rymech
=
AttrParam
(
"rymech"
,
self
,
rymech
)
self
.
__z
=
Param
(
"z"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"z"
)
self
.
__rx
=
Param
(
"rx"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"rx"
)
self
.
__ry
=
Param
(
"ry"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"ry"
)
self
.
__Fz
=
Param
(
"Fz"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Fz"
)
self
.
__Frx
=
Param
(
"Frx"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Frx"
)
self
.
__Fry
=
Param
(
"Fry"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Fry"
)
self
.
__z
=
Param
(
"z"
,
self
,
0
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"z"
)
self
.
__rx
=
Param
(
"rx"
,
self
,
0
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"rx"
)
self
.
__ry
=
Param
(
"ry"
,
self
,
0
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"ry"
)
self
.
__Fz
=
Param
(
"Fz"
,
self
,
0
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Fz"
)
self
.
__Frx
=
Param
(
"Frx"
,
self
,
0
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Frx"
)
self
.
__Fry
=
Param
(
"Fry"
,
self
,
0
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Fry"
)
self
.
_default_fsig_param
=
self
.
__phi
...
...
@@ -487,37 +425,6 @@ class mirror(AbstractMirrorComponent):
rtn
.
extend
(
p
.
getFinesseText
())
return
rtn
def
getOptivisComponent
(
self
):
self
.
setOptivisLabelContent
()
if
self
.
_optivis_component
is
None
:
self
.
_optivis_component
=
optivis_components
.
CavityMirror
(
name
=
self
.
name
,
aoi
=
0
,
tooltip
=
self
.
getOptivisTooltip
,
paramList
=
self
.
getOptivisParameterDict
(),
pykatObject
=
weakref
.
ref
(
self
))
lbl
=
optivis_label
(
text
=
""
,
position
=
optivis_coord
(
0
,
-
1
),
item
=
self
.
_optivis_component
)
lbl
.
content
[
"Name"
]
=
self
.
name
self
.
_optivis_component
.
labels
.
append
(
lbl
)
return
self
.
_optivis_component
def
getOptivisNode
(
self
,
mode
,
kat_node
):
mode
=
mode
.
lower
()
if
mode
!=
"input"
and
mode
.
lower
()
!=
"output"
:
raise
pkex
.
BasePyKatException
(
"Mode must be either input or output not %s"
%
mode
)
if
mode
==
"input"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getInputNode
(
"fr"
)
else
:
return
self
.
_optivis_component
.
getInputNode
(
"bk"
)
elif
mode
==
"output"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getOutputNode
(
"fr"
)
else
:
return
self
.
_optivis_component
.
getOutputNode
(
"bk"
)
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
...
...
@@ -551,40 +458,7 @@ class beamSplitter(AbstractMirrorComponent):
self
.
alpha
=
values
[
key
]
else
:
raise
pkex
.
BasePyKatException
(
"No attribute {0} for mirrors"
.
format
(
key
))
def
getOptivisComponent
(
self
):
self
.
setOptivisLabelContent
()
if
self
.
_optivis_component
is
None
:
self
.
_optivis_component
=
optivis_components
.
BeamSplitter
(
name
=
self
.
name
,
aoi
=-
self
.
alpha
,
tooltip
=
self
.
getOptivisTooltip
,
paramList
=
self
.
getOptivisParameterDict
(),
pykatObject
=
weakref
.
ref
(
self
))
return
self
.
_optivis_component
def
getOptivisNode
(
self
,
mode
,
kat_node
):
mode
=
mode
.
lower
()
if
mode
!=
"input"
and
mode
.
lower
()
!=
"output"
:
raise
pkex
.
BasePyKatException
(
"Mode must be either input or output"
)
if
mode
==
"input"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getInputNode
(
"frA"
)
elif
kat_node
is
self
.
nodes
[
1
]:
return
self
.
_optivis_component
.
getInputNode
(
"frB"
)
elif
kat_node
is
self
.
nodes
[
2
]:
return
self
.
_optivis_component
.
getInputNode
(
"bkB"
)
elif
kat_node
is
self
.
nodes
[
3
]:
return
self
.
_optivis_component
.
getInputNode
(
"bkA"
)
elif
mode
==
"output"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getOutputNode
(
"frB"
)
elif
kat_node
is
self
.
nodes
[
1
]:
return
self
.
_optivis_component
.
getOutputNode
(
"frA"
)
elif
kat_node
is
self
.
nodes
[
2
]:
return
self
.
_optivis_component
.
getOutputNode
(
"bkA"
)
elif
kat_node
is
self
.
nodes
[
3
]:
return
self
.
_optivis_component
.
getOutputNode
(
"bkB"
)
@
staticmethod
def
parseFinesseText
(
text
):
values
=
text
.
split
()
...
...
@@ -681,18 +555,6 @@ class space(Component):
@
gy
.
setter
def
gy
(
self
,
value
):
self
.
__gy
.
value
=
SIfloat
(
value
)
def
connectingComponents
(
self
):
"""
Returns the two components that this space connects.
"""
a
=
list
(
self
.
nodes
[
0
].
components
+
self
.
nodes
[
1
].
components
)
a
=
[
value
for
value
in
a
if
value
!=
self
]
if
len
(
a
)
!=
2
:
raise
pkex
.
BasePyKatException
(
"Space should only connect 2 components"
)
return
a
def
parseAttributes
(
self
,
values
):
for
key
in
values
.
keys
():
...
...
@@ -916,33 +778,7 @@ class isolator(Component):
rtn
.
extend
(
p
.
getFinesseText
())
return
rtn
def
getOptivisComponent
(
self
):
self
.
setOptivisLabelContent
()
if
self
.
_optivis_component
is
None
:
self
.
_optivis_component
=
optivis_components
.
FaradayIsolator
(
name
=
self
.
name
,
tooltip
=
self
.
getOptivisTooltip
,
paramList
=
self
.
getOptivisParameterDict
(),
pykatObject
=
weakref
.
ref
(
self
))
return
self
.
_optivis_component
def
getOptivisNode
(
self
,
mode
,
kat_node
):
mode
=
mode
.
lower
()
if
mode
!=
"input"
and
mode
.
lower
()
!=
"output"
:
raise
pkex
.
BasePyKatException
(
"Mode must be either input or output"
)
if
mode
==
"input"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getInputNode
(
"fr"
)
elif
kat_node
is
self
.
nodes
[
1
]:
return
self
.
_optivis_component
.
getInputNode
(
"bk"
)
elif
mode
==
"output"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getnOutputNode
(
"fr"
)
elif
kat_node
is
self
.
nodes
[
1
]:
return
self
.
_optivis_component
.
getOutputNode
(
"bk"
)
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
...
...
@@ -987,32 +823,7 @@ class lens(Component):
rtn
.
extend
(
p
.
getFinesseText
())
return
rtn
def
getOptivisComponent
(
self
):
self
.
setOptivisLabelContent
()
if
self
.
_optivis_component
is
None
:
self
.
_optivis_component
=
optivis_components
.
ConvexLens
(
name
=
self
.
name
,
tooltip
=
self
.
getOptivisTooltip
,
paramList
=
self
.
getOptivisParameterDict
(),
pykatObject
=
weakref
.
ref
(
self
))
return
self
.
_optivis_component
def
getOptivisNode
(
self
,
mode
,
kat_node
):
mode
=
mode
.
lower
()
if
mode
!=
"input"
and
mode
.
lower
()
!=
"output"
:
raise
pkex
.
BasePyKatException
(
"Mode must be either input or output"
)
if
mode
==
"input"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getInputNode
(
"fr"
)
elif
kat_node
is
self
.
nodes
[
1
]:
return
self
.
_optivis_component
.
getInputNode
(
"bk"
)
elif
mode
==
"output"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getnOutputNode
(
"fr"
)
elif
kat_node
is
self
.
nodes
[
1
]:
return
self
.
_optivis_component
.
getOutputNode
(
"bk"
)
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
...
...
@@ -1094,31 +905,6 @@ class modulator(Component):
return
rtn
def
getOptivisComponent
(
self
):
self
.
setOptivisLabelContent
()
if
self
.
_optivis_component
is
None
:
self
.
_optivis_component
=
optivis_components
.
ElectroopticModulator
(
name
=
self
.
name
,
tooltip
=
self
.
getOptivisTooltip
,
paramList
=
self
.
getOptivisParameterDict
(),
pykatObject
=
weakref
.
ref
(
self
))
return
self
.
_optivis_component
def
getOptivisNode
(
self
,
mode
,
kat_node
):
mode
=
mode
.
lower
()
if
mode
!=
"input"
and
mode
.
lower
()
!=
"output"
:
raise
pkex
.
BasePyKatException
(
"Mode must be either input or output"
)
if
mode
==
"input"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getInputNode
(
"fr"
)
elif
kat_node
is
self
.
nodes
[
1
]:
return
self
.
_optivis_component
.
getInputNode
(
"bk"
)
elif
mode
==
"output"
:
if
kat_node
is
self
.
nodes
[
0
]:
return
self
.
_optivis_component
.
getnOutputNode
(
"fr"
)
elif
kat_node
is
self
.
nodes
[
1
]:
return
self
.
_optivis_component
.
getOutputNode
(
"bk"
)
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
...
...
@@ -1188,29 +974,7 @@ class laser(Component):
rtn
.
extend
(
p
.
getFinesseText
())
return
rtn
def
getOptivisComponent
(
self
):
self
.
setOptivisLabelContent
()
if
self
.
_optivis_component
is
None
:
self
.
_optivis_component
=
optivis_components
.
Laser
(
name
=
self
.
name
,
tooltip
=
self
.
getOptivisTooltip
,
paramList
=
self
.
getOptivisParameterDict
(),
pykatObject
=
weakref
.
ref
(
self
))
lbl
=
optivis_label
(
text
=
""
,
position
=
optivis_coord
(
0
,
-
1
),
item
=
self
.
_optivis_component
)
lbl
.
content
[
"Name"
]
=
self
.
name
self
.
_optivis_component
.
labels
.
append
(
lbl
)
return
self
.
_optivis_component
def
getOptivisNode
(
self
,
mode
,
kat_node
):
mode
=
mode
.
lower
()
if
mode
!=
"input"
and
mode
.
lower
()
!=
"output"
:
raise
pkex
.
BasePyKatException
(
"Mode must be either input or output"
)
if
mode
==
"input"
:
return
None
elif
mode
==
"output"
:
return
self
.
_optivis_component
.
getOutputNode
(
"out"
)
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
...
...
pykat/detectors.py
View file @
d5ccc762
...
...
@@ -4,13 +4,10 @@ Created on Fri Feb 01 0split()9:09:10 2013
@author: Daniel
"""
from
__future__
import
print_function
import
pykat.external.six
as
six
if
six
.
PY2
:
import
exceptions
import
exceptions
import
abc
from
pykat.node_network
import
*
from
pykat.param
import
Param
,
AttrParam
from
pykat.param
import
Param
from
pykat.SIfloat
import
SIfloat
import
collections
...
...
@@ -75,8 +72,6 @@ class BaseDetector(object) :
else
:
raise
pkex
.
BasePyKatException
(
"Nodes should be a list or tuple of node names or a singular node name as a string."
)
def
_register_param
(
self
,
param
):
self
.
_params
.
append
(
param
)
...
...
@@ -351,13 +346,7 @@ class bp(Detector1):
class
pd
(
Detector1
):
def
__new__
(
cls
,
*
args
,
**
kwargs
):
# This creates an instance specific class for the component
# this enables us to add properties to instances rather than
# all classes
return
object
.
__new__
(
type
(
cls
.
__name__
,
(
cls
,),
{}),
*
args
,
**
kwargs
)
def
__init__
(
self
,
name
=
None
,
num_demods
=
1
,
node_name
=
None
,
senstype
=
None
,
alternate_beam
=
False
,
pdtype
=
None
,
**
kwargs
):
def
__init__
(
self
,
name
,
num_demods
,
node_name
,
senstype
=
None
,
alternate_beam
=
False
,
pdtype
=
None
,
**
kwargs
):
BaseDetector
.
__init__
(
self
,
name
,
node_name
)
self
.
__num_demods
=
num_demods
...
...
@@ -402,28 +391,11 @@ class pd(Detector1):
elif
i
<
num_demods
-
1
:
raise
pkex
.
BasePyKatException
(
"Missing demodulation phase {0} (phi{0})"
.
format
(
i
+
1
))
# define new class for assigning new attributes
cls
=
type
(
self
)
self
.
__class__
=
type
(
cls
.
__name__
,
(
cls
,),
{})
self
.
__set_demod_attrs
()
def
__deepcopy__
(
self
,
memo
):
"""
When deep copying a kat object we need to take into account
the instance specific properties.
"""
result
=
pd
(
self
.
name
,
self
.
num_demods
,
self
.
node
.
name
)
memo
[
id
(
self
)]
=
result
result
.
__dict__
=
copy
.
deepcopy
(
self
.
__dict__
,
memo
)
# Find all properties in class we are copying
# and deep copy these to the new class instance
for
x
in
self
.
__class__
.
__dict__
.
items
():
if
isinstance
(
x
[
1
],
property
):
setattr
(
result
.
__class__
,
x
[
0
],
x
[
1
])
return
result
@
property
def
senstype
(
self
):
return
self
.
__senstype
...
...
@@ -683,7 +655,7 @@ class qnoised(pd):
class
qshot
(
pd
):
def
__init__
(
self
,
name
,
num_demods
,
node_name
,
alternate_beam
=
False
,
**
kwargs
):
super
(
q
shot
,
self
).
__init__
(
name
,
num_demods
,
node_name
,
alternate_beam
=
alternate_beam
,
pdtype
=
None
,
senstype
=
None
,
**
kwargs
)
super
(
q
noised
,
self
).
__init__
(
name
,
num_demods
,
node_name
,
alternate_beam
=
alternate_beam
,
pdtype
=
None
,
senstype
=
None
,
**
kwargs
)
@
pd
.
pdtype
.
setter
def
pdtype
(
self
,
value
):
...
...
@@ -906,4 +878,4 @@ class qhd(Detector2):
for
p
in
self
.
_params
:
rtn
.
extend
(
p
.
getFinesseText
())
return
rtn
return
rtn
\ No newline at end of file
pykat/exceptions.py
View file @
d5ccc762
from
__future__
import
print_function
import
pykat.external.six
as
six
if
six
.
PY2
:
import
exceptions
import
exceptions
import
os
class
BasePyKatException
(
Exception
):
...
...
pykat/finesse.py
View file @
d5ccc762
This diff is collapsed.
Click to expand it.
pykat/node_network.py
View file @
d5ccc762
...
...
@@ -4,7 +4,7 @@ Created on Sun Jan 27 10:02:41 2013
@author: Daniel
"""
from
__future__
import
print_function
from
pykat
import
USE_GUI
,
NoGUIException
if
USE_GUI
:
...
...
@@ -14,19 +14,10 @@ import pykat.exceptions as pkex
from
pykat.components
import
Component
,
NodeGaussSetter
from
pykat.detectors
import
BaseDetector
as
Detector
from
pykat.optics.gaussian_beams
import
beam_param
from
copy
import
deepcopy
from
pykat.utilities.optics.gaussian_beams
import
beam_param
class
NodeNetwork
(
object
):
def
__new__
(
cls
,
*
args
,
**
kwargs
):
# This creates an instance specific class for the component
# this enables us to add properties to instances rather than
# all classes
return
object
.
__new__
(
type
(
cls
.
__name__
,
(
cls
,),
{}),
*
args
,
**
kwargs
)
def
__init__
(
self
,
kat
):
self
.
__nodes
=
{}
self
.
__kat
=
kat
self
.
__nodeComponents
=
{}
# dictionary of tuples containing which components are connected to a node
...
...
@@ -34,8 +25,9 @@ class NodeNetwork(object):
self
.
__componentCallback
=
{}
self
.
__node_id
=
1
cls
=
type
(
self
)
self
.
__class__
=
type
(
cls
.
__name__
,
(
cls
,),
{})
@
property
def
kat
(
self
):
return
self
.
__kat
...
...
@@ -357,7 +349,7 @@ class NodeNetwork(object):
return
False
elif
isinstance
(
currcomp
,
pykat
.
components
.
isolator
):
print
(
"isol"
)
print
"isol"
elif
isinstance
(
currcomp
,
pykat
.
components
.
laser
):
# if we are at a laser then we can't go any further
# and it isn;t this node as we checked before
...
...
pykat/param.py
View file @
d5ccc762
from
__future__
import
print_function
import
abc
import
pykat.exceptions
as
pkex
import
weakref
...
...
@@ -151,7 +150,7 @@ class Param(putable, putter):
#if this param can be put somewhere we need to check if it is
if
self
.
isPutable
:
for
a
in
self
.
putees
:
print
(
"Removing put from {0} {1} to {2} {3}"
.
format
(
self
.
owner
.
name
,
self
.
name
,
a
.
owner
.
name
,
a
.
name
)
)
print
"Removing put from {0} {1} to {2} {3}"
.
format
(
self
.
owner
.
name
,
self
.
name
,
a
.
owner
.
name
,
a
.
name
)
a
.
_putter
=
None
self
.
put_count
-=
1
...
...
@@ -161,7 +160,7 @@ class Param(putable, putter):
# check if we have anything being put to us
if
self
.
isPutter
:
if
self
.
_putter
!=
None
:
print
(
"Removing put from {0} {1} to {2} {3}"
.
format
(
self
.
_putter
.
owner
.
name
,
self
.
_putter
.
name
,
self
.
owner
.
name
,
self
.
name
)
)