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
finesse
pykat
Commits
328f1b88
Commit
328f1b88
authored
Dec 05, 2013
by
Andreas Freise
Browse files
pd object still not working, just backing up.
parent
ab37de12
Changes
2
Hide whitespace changes
Inline
Side-by-side
pykat/detectors.py
View file @
328f1b88
...
...
@@ -48,56 +48,82 @@ class Detector(object) :
name
=
property
(
__getname
)
class
photodiode
(
Detector
):
class
f
(
list
):
def
__init__
(
self
,
values
=
None
):
print
"tadaaaaaaaaaaaaaaa"
if
values
is
None
:
self
.
values
=
[]
else
:
self
.
values
=
values
def
__getitem__
(
self
,
key
):
return
self
.
values
[
key
]
def
__setitem__
(
self
,
key
,
value
):
self
.
values
[
key
]
=
SIfloat
(
value
)
class
phi
(
list
):
def
__init__
(
self
,
values
=
None
):
print
values
if
values
is
None
:
self
.
values
=
[]
else
:
self
.
values
=
values
def
__getitem__
(
self
,
key
):
# probably not needed
print
"boom"
if
self
.
values
[
key
]
==
"max"
:
return
self
.
values
[
key
]
else
:
return
float
(
self
.
values
[
key
])
def
__init__
(
self
,
name
,
node
,
type
,
num_demods
,
demods
):
def
__setitem__
(
self
,
key
,
value
):
if
value
==
"max"
:
self
.
values
[
key
]
=
value
else
:
self
.
values
[
key
]
=
SIfloat
(
value
)
def
__init__
(
self
,
name
,
node
,
senstype
,
num_demods
,
demods
):
Detector
.
__init__
(
self
,
name
,
node
)
if
num_demods
>
2
:
raise
NotImplementedError
(
"pd with more than two demodulations not implemented yet"
)
self
.
num_demods
=
num_demods
self
.
type
=
type
self
@
property
def
num_demods
(
self
):
return
Param
(
'num_demods'
,
self
.
__num_demods
)
@
num_demods
.
setter
def
num_demods
(
self
,
value
):
self
.
__num_demods
=
int
(
value
)
@
property
def
type
(
self
):
return
Param
(
'type'
,
self
.
__type
)
@
type
.
setter
def
type
(
self
,
value
):
self
.
__type
=
value
@
property
def
f1
(
self
):
return
Param
(
'f1'
,
self
.
__f1
)
@
f1
.
setter
def
f1
(
self
,
value
):
self
.
__f1
=
SIfloat
(
value
)
@
property
def
phi1
(
self
):
return
Param
(
'phi1'
,
self
.
__phi1
)
@
phi1
.
setter
def
phi1
(
self
,
value
):
self
.
__phi1
=
SIfloat
(
value
)
self
.
senstype
=
senstype
# every second element into f (starting at 1)
self
.
f
(
demods
[::
2
])
print
self
.
f
[
1
]
# every second element into phi (starting at 2)
self
.
phi
([
1
,
2
])
print
self
.
phi
[
1
]
for
i
in
demods
[
1
::
2
]:
self
.
phi
.
append
(
i
)
@
staticmethod
def
parseFinesseText
(
text
):
values
=
text
.
split
(
" "
)
if
values
[
0
][
0
:
2
]
!=
"pd"
:
raise
exceptions
.
FinesseParse
(
"'{0}' not a valid photodiode command"
.
format
(
text
))
if
len
(
value
[
0
])
==
2
:
if
len
(
value
s
[
0
])
==
2
:
__num_demods
=
0
__type
=
""
elif
len
(
value
[
0
])
==
3
or
len
(
value
[
0
])
==
4
:
if
value
[
0
][
3
]
==
"S"
:
__type
=
"S"
elif
value
[
0
][
3
]
==
"N"
:
__type
=
"N"
__senstype
=
""
elif
len
(
values
[
0
])
==
3
or
len
(
values
[
0
])
==
4
:
print
len
(
values
[
0
])
if
values
[
0
][
2
]
==
"S"
:
__senstype
=
"S"
elif
values
[
0
][
2
]
==
"N"
:
__senstype
=
"N"
else
:
try
:
__num_demods
=
int
(
values
[
0
][
3
])
__type
=
""
__num_demods
=
int
(
values
[
0
][
2
])
__
sens
type
=
""
except
ValueError
:
raise
exceptions
.
FinesseParse
(
"'{0}' not a valid photodiode command"
.
format
(
text
))
if
len
(
value
[
0
])
==
4
:
if
len
(
value
s
[
0
])
==
4
:
try
:
__num_demods
=
int
(
values
[
0
][
4
])
__num_demods
=
int
(
values
[
0
][
3
])
except
ValueError
:
raise
exceptions
.
FinesseParse
(
"'{0}' not a valid photodiode command"
.
format
(
text
))
else
:
...
...
@@ -107,9 +133,9 @@ class photodiode(Detector):
raise
exceptions
.
FinesseParse
(
"'{0}' number of demodulations must be >0 and <5"
.
format
(
text
))
values
.
pop
(
0
)
# remove initial value
if
len
(
values
)
==
2
*
__num_demods
+
1
or
len
(
values
)
==
2
*
__num_demods
+
2
:
return
photodiode
(
value
[
0
],
values
[
-
1
],
__type
,
__num_demods
,
values
[
1
:
len
(
values
-
1
)
])
return
photodiode
(
value
s
[
0
],
values
[
-
1
],
__
sens
type
,
__num_demods
,
values
[
1
:
len
(
values
)
-
1
])
else
:
raise
exceptions
.
FinesseParse
(
"Photodiode code format incorrect '{0}'"
.
format
(
text
))
...
...
pykat/finesse.py
View file @
328f1b88
...
...
@@ -315,6 +315,7 @@ class kat(object):
def
add
(
self
,
obj
)
:
print
type
(
obj
)
try
:
obj
.
tag
=
self
.
__currentTag
if
isinstance
(
obj
,
Component
):
...
...
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