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
Snippets
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
Sean Leavey
pykat
Commits
bc77f025
Commit
bc77f025
authored
11 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
playing around with gui. Adding getMatrices() method to kat object to read in ifo matrices
parent
6a3e549f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
pykat/__init__.py
+1
-0
1 addition, 0 deletions
pykat/__init__.py
pykat/components.py
+67
-4
67 additions, 4 deletions
pykat/components.py
pykat/finesse.py
+58
-4
58 additions, 4 deletions
pykat/finesse.py
pykat/gui/graphics.py
+0
-4
0 additions, 4 deletions
pykat/gui/graphics.py
with
126 additions
and
12 deletions
pykat/__init__.py
+
1
−
0
View file @
bc77f025
...
@@ -4,3 +4,4 @@ import finesse
...
@@ -4,3 +4,4 @@ import finesse
import
components
import
components
import
detectors
import
detectors
import
commands
import
commands
This diff is collapsed.
Click to expand it.
pykat/components.py
+
67
−
4
View file @
bc77f025
...
@@ -858,13 +858,13 @@ class modulator(Component):
...
@@ -858,13 +858,13 @@ class modulator(Component):
return
self
.
_svgItem
return
self
.
_svgItem
class
laser
(
Component
):
class
laser
(
Component
):
def
__init__
(
self
,
name
,
node
,
P
=
1
,
f
_offset
=
0
,
phase
=
0
):
def
__init__
(
self
,
name
,
node
,
P
=
1
,
f
=
0
,
phase
=
0
):
Component
.
__init__
(
self
,
name
)
Component
.
__init__
(
self
,
name
)
self
.
_requested_node_names
.
append
(
node
)
self
.
_requested_node_names
.
append
(
node
)
self
.
__power
=
Param
(
"
P
"
,
self
,
SIfloat
(
P
),
canFsig
=
True
,
fsig_name
=
"
amp
"
)
self
.
__power
=
Param
(
"
P
"
,
self
,
SIfloat
(
P
),
canFsig
=
True
,
fsig_name
=
"
amp
"
)
self
.
__f_offset
=
Param
(
"
f
"
,
self
,
SIfloat
(
f
_offset
),
canFsig
=
True
,
fsig_name
=
"
f
"
)
self
.
__f_offset
=
Param
(
"
f
"
,
self
,
SIfloat
(
f
),
canFsig
=
True
,
fsig_name
=
"
f
"
)
self
.
__phase
=
Param
(
"
phase
"
,
self
,
SIfloat
(
phase
),
canFsig
=
True
,
fsig_name
=
"
phase
"
)
self
.
__phase
=
Param
(
"
phase
"
,
self
,
SIfloat
(
phase
),
canFsig
=
True
,
fsig_name
=
"
phase
"
)
self
.
__noise
=
AttrParam
(
"
noise
"
,
self
,
None
)
self
.
__noise
=
AttrParam
(
"
noise
"
,
self
,
None
)
self
.
_svgItem
=
None
self
.
_svgItem
=
None
...
@@ -902,9 +902,9 @@ class laser(Component):
...
@@ -902,9 +902,9 @@ class laser(Component):
values
.
pop
(
0
)
# remove initial value
values
.
pop
(
0
)
# remove initial value
if
len
(
values
)
==
5
:
if
len
(
values
)
==
5
:
return
laser
(
values
[
0
],
values
[
4
],
P
=
values
[
1
],
f
_offset
=
values
[
2
],
phase
=
values
[
3
])
return
laser
(
values
[
0
],
values
[
4
],
P
=
values
[
1
],
f
=
values
[
2
],
phase
=
values
[
3
])
elif
len
(
values
)
==
4
:
elif
len
(
values
)
==
4
:
return
laser
(
values
[
0
],
values
[
3
],
P
=
values
[
1
],
f
_offset
=
values
[
2
],
phase
=
0
)
return
laser
(
values
[
0
],
values
[
3
],
P
=
values
[
1
],
f
=
values
[
2
],
phase
=
0
)
else
:
else
:
raise
exceptions
.
FinesseParse
(
"
Laser Finesse code format incorrect
'
{0}
'"
.
format
(
text
))
raise
exceptions
.
FinesseParse
(
"
Laser Finesse code format incorrect
'
{0}
'"
.
format
(
text
))
...
@@ -922,3 +922,66 @@ class laser(Component):
...
@@ -922,3 +922,66 @@ class laser(Component):
return
self
.
_svgItem
return
self
.
_svgItem
class
squeezer
(
Component
):
def
__init__
(
self
,
name
,
node
,
f
=
0
,
db
=
0
,
angle
=
0
,
phase
=
0
):
Component
.
__init__
(
self
,
name
)
self
.
_requested_node_names
.
append
(
node
)
self
.
__f
=
Param
(
"
f
"
,
self
,
SIfloat
(
f
),
canFsig
=
True
,
fsig_name
=
"
f
"
)
self
.
__phase
=
Param
(
"
phase
"
,
self
,
SIfloat
(
phase
),
canFsig
=
True
,
fsig_name
=
"
phase
"
)
self
.
__db
=
Param
(
"
db
"
,
self
,
SIfloat
(
db
),
canFsig
=
False
,
fsig_name
=
"
r
"
)
self
.
__angle
=
Param
(
"
angle
"
,
self
,
SIfloat
(
angle
),
canFsig
=
False
,
fsig_name
=
"
angle
"
)
self
.
_svgItem
=
None
@property
def
db
(
self
):
return
self
.
__db
@db.setter
def
db
(
self
,
value
):
self
.
__db
.
value
=
float
(
value
)
@property
def
angle
(
self
):
return
self
.
__angle
@angle.setter
def
angle
(
self
,
value
):
self
.
__angle
.
value
=
float
(
value
)
@property
def
f
(
self
):
return
self
.
__f
@f.setter
def
f
(
self
,
value
):
self
.
__f
.
value
=
float
(
value
)
@property
def
phase
(
self
):
return
self
.
__phase
@phase.setter
def
phase
(
self
,
value
):
self
.
__phase
.
value
=
float
(
value
)
def
parseAttributes
(
self
,
values
):
pass
@staticmethod
def
parseFinesseText
(
text
):
values
=
text
.
split
()
if
values
[
0
]
!=
"
sq
"
:
raise
pkex
.
BasePyKatException
(
"'
{0}
'
not a valid Finesse squeezer command
"
.
format
(
text
))
values
.
pop
(
0
)
# remove initial value
if
len
(
values
)
==
5
:
return
squeezer
(
values
[
0
],
values
[
4
],
f
=
values
[
1
],
db
=
values
[
2
],
angle
=
values
[
3
])
else
:
raise
exceptions
.
FinesseParse
(
"
Squeezer Finesse code format incorrect
'
{0}
'"
.
format
(
text
))
def
getFinesseText
(
self
):
rtn
=
[
'
sq {0} {1} {2} {3} {4}
'
.
format
(
self
.
name
,
self
.
f
.
value
,
self
.
db
.
value
,
self
.
angle
.
value
,
self
.
nodes
[
0
].
name
)]
for
p
in
self
.
_params
:
rtn
.
extend
(
p
.
getFinesseText
())
return
rtn
def
getQGraphicsItem
(
self
):
if
self
.
_svgItem
==
None
:
self
.
_svgItem
=
pykat
.
gui
.
graphics
.
ComponentQGraphicsItem
(
"
:/resources/laser.svg
"
,
self
,
[(
65
,
25
,
self
.
nodes
[
0
])])
return
self
.
_svgItem
This diff is collapsed.
Click to expand it.
pykat/finesse.py
+
58
−
4
View file @
bc77f025
...
@@ -34,7 +34,6 @@ import pykat
...
@@ -34,7 +34,6 @@ import pykat
import
warnings
import
warnings
import
re
import
re
import
math
import
math
import
itertools
import
itertools
import
ctypes
import
ctypes
import
ctypes.util
import
ctypes.util
...
@@ -374,6 +373,8 @@ class kat(object):
...
@@ -374,6 +373,8 @@ class kat(object):
self
.
__signals
=
Signals
()
self
.
__signals
=
Signals
()
self
.
constants
=
{}
self
.
constants
=
{}
self
.
vacuum
=
[]
self
.
vacuum
=
[]
self
.
__prevrunfilename
=
None
self
.
printmatrix
=
None
# initialise default block
# initialise default block
self
.
__currentTag
=
NO_BLOCK
self
.
__currentTag
=
NO_BLOCK
...
@@ -589,6 +590,8 @@ class kat(object):
...
@@ -589,6 +590,8 @@ class kat(object):
obj
=
pykat
.
components
.
space
.
parseFinesseText
(
line
)
obj
=
pykat
.
components
.
space
.
parseFinesseText
(
line
)
elif
(
first
==
"
l
"
):
elif
(
first
==
"
l
"
):
obj
=
pykat
.
components
.
laser
.
parseFinesseText
(
line
)
obj
=
pykat
.
components
.
laser
.
parseFinesseText
(
line
)
elif
(
first
==
"
sq
"
):
obj
=
pykat
.
components
.
squeezer
.
parseFinesseText
(
line
)
elif
(
first
[
0
:
2
]
==
"
bs
"
):
elif
(
first
[
0
:
2
]
==
"
bs
"
):
obj
=
pykat
.
components
.
beamSplitter
.
parseFinesseText
(
line
)
obj
=
pykat
.
components
.
beamSplitter
.
parseFinesseText
(
line
)
elif
(
first
[
0
:
2
]
==
"
gr
"
):
elif
(
first
[
0
:
2
]
==
"
gr
"
):
...
@@ -909,6 +912,8 @@ class kat(object):
...
@@ -909,6 +912,8 @@ class kat(object):
print
err
print
err
sys
.
exit
(
1
)
sys
.
exit
(
1
)
self
.
__prevrunfilename
=
katfile
.
name
root
=
os
.
path
.
splitext
(
katfile
.
name
)
root
=
os
.
path
.
splitext
(
katfile
.
name
)
base
=
os
.
path
.
basename
(
root
[
0
])
base
=
os
.
path
.
basename
(
root
[
0
])
outfile
=
root
[
0
]
+
"
.out
"
outfile
=
root
[
0
]
+
"
.out
"
...
@@ -1019,6 +1024,52 @@ class kat(object):
...
@@ -1019,6 +1024,52 @@ class kat(object):
import
gc
import
gc
print
gc
.
get_referrers
(
obj
)
print
gc
.
get_referrers
(
obj
)
def
getMatrices
(
self
):
import
scipy
from
scipy.sparse
import
coo_matrix
prev
=
self
.
noxaxis
self
.
noxaxis
=
True
self
.
printmatrix
=
True
print
""
.
join
(
self
.
generateKatScript
())
self
.
verbose
=
True
self
.
run
(
printout
=
1
)
self
.
printmatrix
=
None
self
.
noxaxis
=
prev
if
self
.
__prevrunfilename
==
None
:
return
None
else
:
Mcarrier
=
None
Msignal
=
None
if
os
.
path
.
exists
(
"
klu_full_matrix_car.dat
"
):
M
=
np
.
loadtxt
(
"
klu_full_matrix_car.dat
"
)
if
M
.
size
>
0
:
row
=
M
[:,
0
]
-
1
col
=
M
[:,
1
]
-
1
data
=
M
[:,
2
]
+
1j
*
M
[:,
3
]
N
=
row
.
max
()
+
1
Mcarrier
=
coo_matrix
((
data
,(
row
,
col
)),
shape
=
(
N
,
N
))
if
os
.
path
.
exists
(
"
klu_full_matrix_sig.dat
"
):
M
=
np
.
loadtxt
(
"
klu_full_matrix_sig.dat
"
)
if
M
.
size
>
0
:
row
=
M
[:,
0
]
-
1
col
=
M
[:,
1
]
-
1
data
=
M
[:,
2
]
+
1j
*
M
[:,
3
]
N
=
row
.
max
()
+
1
Msignal
=
coo_matrix
((
data
,(
row
,
col
)),
shape
=
(
N
,
N
))
return
(
Mcarrier
,
Msignal
)
def
hasNamedObject
(
self
,
name
):
def
hasNamedObject
(
self
,
name
):
return
name
in
self
.
__components
or
name
in
self
.
__detectors
or
name
in
self
.
__commands
return
name
in
self
.
__components
or
name
in
self
.
__detectors
or
name
in
self
.
__commands
...
@@ -1201,6 +1252,9 @@ class kat(object):
...
@@ -1201,6 +1252,9 @@ class kat(object):
if
self
.
yaxis
!=
None
:
if
self
.
yaxis
!=
None
:
out
.
append
(
"
yaxis {0}
\n
"
.
format
(
self
.
yaxis
))
out
.
append
(
"
yaxis {0}
\n
"
.
format
(
self
.
yaxis
))
if
self
.
printmatrix
!=
None
and
self
.
printmatrix
==
True
:
out
.
append
(
"
printmatrix
\n
"
)
if
self
.
lambda0
!=
1064e-9
:
if
self
.
lambda0
!=
1064e-9
:
out
.
append
(
"
lambda {0}
\n
"
.
format
(
self
.
lambda0
))
out
.
append
(
"
lambda {0}
\n
"
.
format
(
self
.
lambda0
))
...
...
This diff is collapsed.
Click to expand it.
pykat/gui/graphics.py
+
0
−
4
View file @
bc77f025
...
@@ -140,7 +140,6 @@ class SpaceQGraphicsItem(QGraphicsLineItem):
...
@@ -140,7 +140,6 @@ class SpaceQGraphicsItem(QGraphicsLineItem):
self
.
setLine
(
p
.
x
(),
p
.
y
(),
p
.
x
()
+
x2
-
x1
,
p
.
y
()
+
y2
-
y1
)
self
.
setLine
(
p
.
x
(),
p
.
y
(),
p
.
x
()
+
x2
-
x1
,
p
.
y
()
+
y2
-
y1
)
self
.
setPen
(
QPen
(
Qt
.
red
,
3
))
self
.
setPen
(
QPen
(
Qt
.
red
,
3
))
class
ComponentQGraphicsItem
(
QGraphicsObject
):
#(QtSvg.QGraphicsSvgItem):
class
ComponentQGraphicsItem
(
QGraphicsObject
):
#(QtSvg.QGraphicsSvgItem):
def
__init__
(
self
,
svgfile
,
component
,
nodes
):
def
__init__
(
self
,
svgfile
,
component
,
nodes
):
...
@@ -153,8 +152,6 @@ class ComponentQGraphicsItem(QGraphicsObject): #(QtSvg.QGraphicsSvgItem):
...
@@ -153,8 +152,6 @@ class ComponentQGraphicsItem(QGraphicsObject): #(QtSvg.QGraphicsSvgItem):
self
.
__nodeGraphics
=
[]
self
.
__nodeGraphics
=
[]
self
.
__component
=
weakref
.
ref
(
component
)
self
.
__component
=
weakref
.
ref
(
component
)
# self.setRotation(432.34234)
# this signals the itemChange() method when this item is moved
# this signals the itemChange() method when this item is moved
# used for refreshing the spaces between components
# used for refreshing the spaces between components
self
.
setFlags
(
QGraphicsItem
.
ItemSendsGeometryChanges
)
self
.
setFlags
(
QGraphicsItem
.
ItemSendsGeometryChanges
)
...
@@ -181,7 +178,6 @@ class ComponentQGraphicsItem(QGraphicsObject): #(QtSvg.QGraphicsSvgItem):
...
@@ -181,7 +178,6 @@ class ComponentQGraphicsItem(QGraphicsObject): #(QtSvg.QGraphicsSvgItem):
return
self
.
__svggraphic
.
boundingRect
()
return
self
.
__svggraphic
.
boundingRect
()
def
paint
(
self
,
arg1
,
arg2
,
arg3
):
def
paint
(
self
,
arg1
,
arg2
,
arg3
):
self
.
__svggraphic
.
rotate
(
45
)
self
.
__svggraphic
.
rotate
(
45
)
self
.
__svggraphic
.
paint
(
arg1
,
arg2
,
arg3
)
self
.
__svggraphic
.
paint
(
arg1
,
arg2
,
arg3
)
...
...
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