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
d8f29504
Commit
d8f29504
authored
10 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
fixing fsig target, adding in batch processor for multiple kat objects
parent
5b47eae8
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/test_fsig.py
+22
-24
22 additions, 24 deletions
bin/test_fsig.py
pykat/finesse.py
+69
-18
69 additions, 18 deletions
pykat/finesse.py
pykat/param.py
+3
-0
3 additions, 0 deletions
pykat/param.py
with
94 additions
and
42 deletions
bin/test_fsig.py
+
22
−
24
View file @
d8f29504
...
...
@@ -25,33 +25,31 @@ qd tran_Q 0 90 n4
qnoised qnd 1 $fs max n4
qshot qsd 1 $fs max n4
pd1 p1 $fs max n4
yaxis log re:im
pd1 p1 $fs max n4
fsig noise
m2
1 0
fsig noise
l1 amp
1 0
"""
kat
=
finesse
.
kat
(
kat_code
=
code
)
kat
.
removeLine
(
"
fsig noise 9
"
)
kat
.
signals
.
apply
(
kat
.
l1
.
P
,
1
,
0
)
kat
.
signals
.
apply
(
kat
.
m1
.
phi
,
1
,
90
)
kat
.
add
(
xaxis
(
'
log
'
,
[
1
,
1000
],
kat
.
signals
.
f
,
100
))
out
=
kat
.
run
(
printout
=
0
,
printerr
=
0
)
# using real and imag part compute the complex value of the upper and lower sidebands
a_up
=
out
.
y
[:,
0
]
+
out
.
y
[:,
1
]
*
1j
a_lo
=
out
.
y
[:,
2
]
+
out
.
y
[:,
3
]
*-
1j
pl
.
figure
(
1
)
pl
.
loglog
(
out
.
x
,
out
[
"
p1
"
])
pl
.
xlabel
(
out
.
xlabel
)
pl
.
title
(
"
Reflection quadratures with no relative carrier phase
"
)
pl
.
legend
([
"
Amplitude
"
,
"
Phase
"
])
pl
.
show
()
# kat.signals.apply(kat.m2.z, 1.0, 0.0)
# kat.yaxis = "re:im"
# kat.add(xaxis('log', [1, 1000], kat.signals.f, 1000))
#
# out = kat.run(printout=0, printerr=0)
#
# a_up = out[kat.up_refl]
# a_lo = out[kat.low_refl]
#
# pl.figure(1)
# ax = pl.subplot(111)
# pl.grid()
# ax.loglog(out.x, abs(a_up))
# ax = ax.twinx()
# ax.plot(out.x, np.rad2deg(np.angle(a_up)), 'r')
# pl.xlabel(out.xlabel)
#pl.show()
print
(
kat
.
generateKatScript
())
kat
.
remove
(
kat
.
signals
)
This diff is collapsed.
Click to expand it.
pykat/finesse.py
+
69
−
18
View file @
d8f29504
...
...
@@ -181,6 +181,46 @@ def f__lkat_trace_callback(lkat, trace_info, getCavities, getNodes, getSpaces):
trace_info
[
space
.
name
]
=
space_trace
(
gouyx
=
space
.
gouy_x
,
gouyy
=
space
.
gouy_y
)
class
KatBatch
(
object
):
"""
"""
def
__init__
(
self
):
from
IPython.parallel
import
Client
self
.
_c
=
Client
()
self
.
_lb
=
c
.
load_balanced_view
()
self
.
lb
.
block
=
False
self
.
_todo
=
[]
def
_run
(
dir
,
commands
,
**
kwargs
):
import
pykat
kat
=
pykat
.
finesse
.
kat
()
kat
.
verbose
=
False
kat
.
parseCommands
(
commands
)
kw
=
dict
()
if
"
cmd_args
"
in
kwargs
:
kw
[
"
cmd_args
"
]
=
kwargs
[
"
cmd_args
"
]
return
kat
.
run
(
printerr
=
1
,
**
kw
)
def
addKat
(
self
,
kat
,
**
kwargs
):
import
os
cdir
=
os
.
getcwd
()
script
=
"
\n
"
.
join
(
kat
.
generateKatScript
())
self
.
todo
.
append
(
self
.
lb
.
apply_async
(
self
.
_run
,
script
,
**
kwargs
))
return
self
.
todo
[
-
1
]
def
wait
(
self
):
return
self
.
lb
.
wait
(
self
.
todo
)
def
results
(
self
):
return
self
.
todo
def
GUILength
(
L
):
"""
...
...
@@ -971,7 +1011,7 @@ class kat(object):
if
comp
.
_default_fsig
()
is
None
:
raise
pkex
.
BasePyKatException
(
"
Component
'
{0}
'
cannot be fsig
'
d. Line:
'
{1}
'"
.
format
(
comp
.
name
,
line
))
param
=
None
param
_name
=
None
amp
=
None
if
len
(
v
)
==
5
:
...
...
@@ -984,11 +1024,12 @@ class kat(object):
phase
=
float
(
v
[
4
])
amp
=
float
(
v
[
5
])
else
:
param
=
v
[
3
]
param
_name
=
v
[
3
]
freq
=
float
(
v
[
4
])
phase
=
float
(
v
[
5
])
elif
len
(
v
)
==
7
:
param
=
v
[
3
]
param
_name
=
v
[
3
]
freq
=
float
(
v
[
4
])
phase
=
float
(
v
[
5
])
amp
=
float
(
v
[
6
])
...
...
@@ -996,7 +1037,17 @@ class kat(object):
raise
pkex
.
BasePyKatException
(
"'
{0}
'
isnot a valid fsig command
"
.
format
(
line
))
self
.
signals
.
f
=
freq
self
.
signals
.
apply
(
comp
.
_default_fsig
(),
amp
,
phase
,
name
)
if
param_name
is
None
:
param
=
comp
.
_default_fsig
()
else
:
for
p
in
comp
.
_params
:
if
p
.
canFsig
and
p
.
fsigName
==
param_name
:
param
=
p
break
self
.
signals
.
apply
(
param
,
amp
,
phase
,
name
)
else
:
raise
pkex
.
BasePyKatException
(
"
Haven
'
t handled parsing of
'
{0}
'"
.
format
(
line
))
...
...
@@ -1022,15 +1073,6 @@ class kat(object):
except
pkex
.
BasePyKatException
as
ex
:
print
(
ex
)
def
getProcess
(
self
,
callback
,
**
kwargs
):
"""
"""
cmd
=
"
\n
"
.
join
(
self
.
generateKatScript
())
return
Process
(
target
=
f__lkat_process
,
args
=
(
callback
,
cmd
,
kwargs
))
def
run
(
self
,
printout
=
0
,
printerr
=
0
,
plot
=
None
,
save_output
=
False
,
save_kat
=
False
,
kat_name
=
None
,
cmd_args
=
None
,
getTraceData
=
False
):
"""
Runs the current simulation setup that has been built thus far.
...
...
@@ -1404,7 +1446,7 @@ class kat(object):
except
pkex
.
BasePyKatException
as
ex
:
pkex
.
PrintError
(
"
Error on removing object:
"
,
ex
)
def
undumpNodes
(
self
):
def
undumpNodes
(
self
,
undumped_name_prefix
=
"
dump
"
):
"""
Loops through and removes all dump nodes. Required when running quantum noise
calculations using qnoised as noise must be injected in where losses occur, such as power
...
...
@@ -1416,13 +1458,13 @@ class kat(object):
"""
i
=
0
node_name
=
"
dump
%i
"
%
i
node_name
=
"
%s_
%i
"
%
(
str
(
undumped_name_prefix
),
i
)
for
c
in
self
.
components
.
values
():
for
n
in
c
.
nodes
:
if
n
.
isDump
:
while
hasattr
(
kat
.
nodes
,
node_name
):
node_name
=
"
dump
%i
"
%
i
node_name
=
"
%s_
%i
"
%
(
str
(
undumped_name_prefix
),
i
)
i
+=
1
self
.
nodes
.
replaceNode
(
c
,
n
,
self
.
nodes
.
createNode
(
node_name
%
i
))
...
...
@@ -1951,7 +1993,16 @@ class kat(object):
return
rtn
def
lkat_trace
(
self
,
getCavities
=
True
,
getNodes
=
True
,
getSpaces
=
True
):
def
_lkat_getProcess
(
self
,
callback
,
**
kwargs
):
"""
"""
cmd
=
"
\n
"
.
join
(
self
.
generateKatScript
())
return
Process
(
target
=
f__lkat_process
,
args
=
(
callback
,
cmd
,
kwargs
))
def
_lkat_trace
(
self
,
getCavities
=
True
,
getNodes
=
True
,
getSpaces
=
True
):
"""
Given the current state of the kat object a new FINESSE process is called and just
the beam tracing routine is run. The object that is returned contains all the information
...
...
This diff is collapsed.
Click to expand it.
pykat/param.py
+
3
−
0
View file @
d8f29504
...
...
@@ -111,6 +111,9 @@ class Param(putable, putter):
@property
def
fsig_name
(
self
):
return
self
.
__fsig_name
@property
def
fsigName
(
self
):
return
self
.
__fsig_name
@property
def
name
(
self
):
return
self
.
_name
...
...
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