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
Sebastian Steinlechner
pykat
Commits
79579343
Commit
79579343
authored
Dec 06, 2014
by
Daniel Brown
Browse files
adding fsig parsing
parent
9511bc5c
Changes
3
Hide whitespace changes
Inline
Side-by-side
bin/test_fsig.py
View file @
79579343
...
...
@@ -28,7 +28,7 @@ put low_refl f $mx1
yaxis log re:im
fsig noise
9
fsig noise
m2 1 0
"""
kat
=
finesse
.
kat
(
kat_code
=
code
)
...
...
pykat/components.py
View file @
79579343
...
...
@@ -76,6 +76,7 @@ class Component(object):
self
.
tag
=
None
self
.
_params
=
[]
self
.
__removed
=
False
self
.
_default_fsig_param
=
None
# store a unique ID for this component
global
next_component_id
...
...
@@ -90,7 +91,21 @@ class Component(object):
def
_register_param
(
self
,
param
):
self
.
_params
.
append
(
param
)
def
_default_fsig
(
self
):
"""
Returns what Finesse internally determines as the default
fsig parameter. This is used mainly for parsing fsig command
lines where no target parameter is stated.
"""
if
self
.
_default_fsig_param
!=
None
:
if
not
self
.
_default_fsig_param
.
canFsig
:
raise
pkex
.
BasePyKatException
(
"Default fsig parameter %s is not possible to fsig"
%
(
self
.
__default_fsig_param
.
name
))
else
:
return
self
.
_default_fsig_param
else
:
return
None
def
_on_kat_add
(
self
,
kat
):
"""
Called when this component has been added to a kat object.
...
...
@@ -226,6 +241,8 @@ class AbstractMirrorComponent(Component):
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
@
property
def
z
(
self
):
return
self
.
__z
@
property
...
...
@@ -499,12 +516,14 @@ class space(Component):
self
.
_requested_node_names
.
append
(
node1
)
self
.
_requested_node_names
.
append
(
node2
)
self
.
_QItem
=
None
self
.
__L
=
Param
(
"L"
,
self
,
SIfloat
(
L
))
self
.
__L
=
Param
(
"L"
,
self
,
SIfloat
(
L
)
,
canFsig
=
True
,
fsig_name
=
"phase"
)
self
.
__n
=
Param
(
"n"
,
self
,
SIfloat
(
n
))
self
.
__gx
=
AttrParam
(
"gx"
,
self
,
gx
)
self
.
__gy
=
AttrParam
(
"gy"
,
self
,
gy
)
self
.
_default_fsig_param
=
self
.
__L
@
property
def
L
(
self
):
return
self
.
__L
@
L
.
setter
...
...
@@ -823,10 +842,11 @@ class modulator(Component):
self
.
_svgItem
=
None
self
.
__f
=
Param
(
"f"
,
self
,
SIfloat
(
f
))
self
.
__midx
=
Param
(
"midx"
,
self
,
SIfloat
(
midx
))
self
.
__phase
=
Param
(
"phase"
,
self
,
SIfloat
(
phase
))
self
.
__phase
=
Param
(
"phase"
,
self
,
SIfloat
(
phase
)
,
canFsig
=
True
,
fsig_name
=
"phase"
)
self
.
__order
=
order
self
.
type
=
modulation_type
self
.
_default_fsig_param
=
self
.
__phase
@
property
def
f
(
self
):
return
self
.
__f
...
...
@@ -906,6 +926,8 @@ class laser(Component):
self
.
__noise
=
AttrParam
(
"noise"
,
self
,
None
)
self
.
_svgItem
=
None
self
.
_default_fsig_param
=
self
.
__f_offset
@
property
def
P
(
self
):
return
self
.
__power
@
P
.
setter
...
...
pykat/finesse.py
View file @
79579343
...
...
@@ -248,7 +248,7 @@ class Signals(object):
self
.
__signal
=
signal
# unfortunatenly the target names for fsig are not the same as the
# various parameter names of the c
omponents, e.g. mirror xbeta is x
# various parameter names of the components, e.g. mirror xbeta is x
# for fsig. So we need to check here what type of component we are targetting
# and then based on the parameter specfied get the name
if
not
param
.
canFsig
:
...
...
@@ -347,8 +347,15 @@ class Signals(object):
for
t
in
self
.
targets
:
rtn
.
extend
(
t
.
getFinesseText
())
rtn
.
append
(
"fsig {name} {comp} {target} {frequency} {phase} {amplitude}"
.
format
(
name
=
t
.
name
,
comp
=
t
.
owner
,
target
=
t
.
target
,
frequency
=
str
(
self
.
f
),
phase
=
str
(
t
.
phase
),
amplitude
=
str
(
t
.
amplitude
)))
rtn
.
append
(
"fsig {name} {comp} {target} {frequency} {phase} {amplitude}"
.
format
(
name
=
t
.
name
,
comp
=
t
.
owner
,
target
=
t
.
target
,
frequency
=
str
(
self
.
f
),
phase
=
str
(
t
.
phase
),
amplitude
=
str
(
t
.
amplitude
if
t
.
amplitude
!=
None
else
""
)))
for
p
in
self
.
_params
:
rtn
.
extend
(
p
.
getFinesseText
())
...
...
@@ -703,8 +710,8 @@ class kat(object):
elif
(
first
==
"gnuterm"
or
first
==
"pyterm"
):
if
self
.
verbose
:
print
"Ignoring Gnuplot/Python terminal command '{0}'"
.
format
(
line
)
#
elif(first == "fsig"):
#
after_process.append(line)
elif
(
first
==
"fsig"
):
after_process
.
append
(
line
)
elif
(
first
==
"noplot"
):
obj
=
line
self
.
__blocks
[
self
.
__currentTag
].
contents
.
append
(
line
)
...
...
@@ -797,13 +804,41 @@ class kat(object):
v
=
line
.
split
()
if
v
[
2
]
in
self
.
__components
:
comp
=
self
.
__components
[
v
[
1
]]
else
:
raise
pkex
.
BasePyKatException
(
"Could not find the component '{0}'
for attr command in l
ine '{1}'"
.
format
(
v
[
1
],
line
))
name
=
str
(
v
[
1
])
if
v
[
2
]
not
in
self
.
__components
:
raise
pkex
.
BasePyKatException
(
"Could not find the component '{0}'
. L
ine
:
'{1}'"
.
format
(
v
[
2
],
line
))
comp
=
self
.
__components
[
v
[
2
]]
if
comp
.
_default_fsig
()
==
None
:
raise
pkex
.
BasePyKatException
(
"Component '{0}' cannot be fsig'd. Line: '{1}'"
.
format
(
comp
.
name
,
line
))
param
=
None
amp
=
None
if
len
(
v
)
==
5
:
param
==
None
freq
=
float
(
v
[
3
])
phase
=
float
(
v
[
4
])
elif
len
(
v
)
==
6
:
if
v
[
3
].
isdigit
():
freq
=
float
(
v
[
3
])
phase
=
float
(
v
[
4
])
amp
=
float
(
v
[
5
])
else
:
param
=
v
[
3
]
freq
=
float
(
v
[
4
])
phase
=
float
(
v
[
5
])
elif
len
(
v
)
==
7
:
param
=
v
[
3
]
freq
=
float
(
v
[
4
])
phase
=
float
(
v
[
5
])
amp
=
float
(
v
[
6
])
else
:
raise
pkex
.
BasePyKatException
(
"'{0}' isnot a valid fsig command"
.
format
(
line
))
#kat
.sig
a
nls.apply()
self
.
sign
a
ls
.
apply
(
comp
.
_default_fsig
(),
amp
,
phase
,
name
)
else
:
raise
pkex
.
BasePyKatException
(
"Haven't handled parsing of '{0}'"
.
format
(
line
))
...
...
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