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
a26a5349
Commit
a26a5349
authored
Apr 10, 2015
by
Andreas Freise
Browse files
starting cnversion to pykat2 and 3 compatibility
parent
b70b028d
Changes
12
Hide whitespace changes
Inline
Side-by-side
pykat/SIfloat.py
View file @
a26a5349
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
os
import
re
import
pykat.exceptions
as
pkex
...
...
pykat/colours.py
View file @
a26a5349
...
...
@@ -4,6 +4,10 @@ Created on Mon Jan 28 10:43:18 2013
@author: Daniel
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
class
colours
:
HEADER
=
'
\033
[95m'
...
...
@@ -19,4 +23,4 @@ class colours:
self
.
OKGREEN
=
''
self
.
WARNING
=
''
self
.
FAIL
=
''
self
.
ENDC
=
''
\ No newline at end of file
self
.
ENDC
=
''
pykat/commands.py
View file @
a26a5349
...
...
@@ -4,11 +4,19 @@ Created on Mon Jan 28 11:58:09 2013
@author: Daniel
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
numpy
from
numpy
import
min
,
max
import
exceptions
from
components
import
*
from
structs
import
*
import
pykat.external.six
as
six
if
six
.
PY2
:
import
exceptions
from
pykat.components
import
*
from
pykat.structs
import
*
from
pykat.param
import
Param
,
putter
import
pykat.exceptions
as
pkex
from
collections
import
namedtuple
...
...
pykat/components.py
View file @
a26a5349
...
...
@@ -4,7 +4,18 @@ Created on Mon Jan 28 11:10:01 2013
@author: Daniel
"""
import
exceptions
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
from
pykat
import
USE_GUI
,
HAS_OPTIVIS
,
NoGUIException
import
pykat.external.six
as
six
if
six
.
PY2
:
import
exceptions
import
pykat.exceptions
as
pkex
import
pykat
from
pykat.node_network
import
*
...
...
pykat/detectors.py
View file @
a26a5349
...
...
@@ -4,14 +4,24 @@ Created on Fri Feb 01 0split()9:09:10 2013
@author: Daniel
"""
import
exceptions
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
pykat.external.six
as
six
if
six
.
PY2
:
import
exceptions
import
abc
from
pykat.node_network
import
*
from
pykat.param
import
Param
from
pykat.SIfloat
import
SIfloat
import
collections
import
pykat.external.six
as
six
import
pykat.exceptions
as
pkex
import
collections
import
warnings
import
copy
...
...
@@ -60,7 +70,7 @@ class BaseDetector(object) :
self
.
_alternate_beam
.
append
(
False
)
self
.
_requested_nodes
.
append
(
n
)
elif
isinstance
(
nodes
,
s
tr
):
elif
isinstance
(
nodes
,
s
ix
.
string_types
):
# if we don't have a collection
if
nodes
[
-
1
]
==
'*'
:
self
.
_alternate_beam
.
append
(
True
)
...
...
@@ -146,7 +156,7 @@ class BaseDetector(object) :
def
_getScaleCmds
(
self
,
rtn
):
if
self
.
scale
!=
None
:
if
isinstance
(
self
.
scale
,
s
tr
):
if
isinstance
(
self
.
scale
,
s
ix
.
string_types
):
rtn
.
append
(
"scale {1} {0}"
.
format
(
self
.
name
,
self
.
scale
))
elif
isinstance
(
self
.
scale
,
(
list
,
tuple
)):
for
s
in
self
.
scale
:
...
...
@@ -372,9 +382,11 @@ class pd(Detector1):
fs
=
[
self
.
__f1
,
self
.
__f2
,
self
.
__f3
,
self
.
__f4
,
self
.
__f5
]
ps
=
[
self
.
__phi1
,
self
.
__phi2
,
self
.
__phi3
,
self
.
__phi4
,
self
.
__phi5
]
print
(
"-------------------------------------------------------"
)
for
i
in
range
(
num_demods
):
f
=
'f{0}'
.
format
(
i
+
1
)
print
(
"i {0} fs {1} f {2} keys {3}"
.
format
(
i
,
len
(
fs
),
f
,
kwargs
.
keys
()))
if
f
in
kwargs
:
fs
[
i
].
value
=
kwargs
[
f
]
...
...
@@ -434,7 +446,7 @@ class pd(Detector1):
# check if we are setting no phase that this is only on the last
# demodulation phase.
raise
pkex
.
BasePyKatException
(
"Only last demodulation phase can be set to None"
)
elif
isinstance
(
value
,
s
tr
)
and
not
isinstance
(
value
,
float
)
and
value
.
lower
()
!=
"max"
:
elif
isinstance
(
value
,
s
ix
.
string_types
)
and
not
isinstance
(
value
,
float
)
and
value
.
lower
()
!=
"max"
:
raise
pkex
.
BasePyKatException
(
"Demodulation phase can only be set to a 'max' or a number (or None if the last demodulation phase)"
)
setattr
(
self
,
'_'
+
self
.
__class__
.
__name__
+
'__phi'
+
num
,
value
)
...
...
@@ -878,4 +890,4 @@ class qhd(Detector2):
for
p
in
self
.
_params
:
rtn
.
extend
(
p
.
getFinesseText
())
return
rtn
\ No newline at end of file
return
rtn
pykat/exceptions.py
View file @
a26a5349
import
exceptions
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
pykat.external.six
as
six
if
six
.
PY2
:
import
exceptions
import
os
class
BasePyKatException
(
Exception
):
...
...
pykat/finesse.py
View file @
a26a5349
...
...
@@ -23,6 +23,11 @@ Contact at ddb@star.sr.bham.ac.uk
@author: Daniel Brown
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
sys
import
os
import
subprocess
...
...
@@ -50,6 +55,8 @@ from pykat.commands import Command, xaxis
from
pykat.SIfloat
import
*
from
pykat.param
import
Param
,
AttrParam
import
pykat.external.six
as
six
import
pykat.exceptions
as
pkex
from
pykat
import
USE_GUI
,
NoGUIException
...
...
@@ -737,7 +744,7 @@ class kat(object):
# manually add the line to the block contents
self
.
__blocks
[
self
.
__currentTag
].
contents
.
append
(
line
)
if
obj
!=
None
and
not
isinstance
(
obj
,
s
tr
):
if
obj
!=
None
and
not
isinstance
(
obj
,
s
ix
.
string_types
):
if
self
.
hasNamedObject
(
obj
.
name
):
getattr
(
self
,
obj
.
name
).
remove
()
print
"Removed existing object '{0}' of type {1} to add line '{2}'"
.
format
(
obj
.
name
,
obj
.
__class__
,
line
)
...
...
@@ -1049,13 +1056,14 @@ class kat(object):
r
.
xlabel
=
hdr
[
0
]
r
.
ylabel
=
hdr
[
1
]
r
.
zlabels
=
map
(
str
.
strip
,
hdr
[
2
:]
)
r
.
zlabels
=
[
s
.
strip
for
s
in
hdr
[
2
:]
]
#r.zlabels = map(str.strip, hdr[2:])
else
:
[
r
.
x
,
r
.
y
,
hdr
]
=
self
.
readOutFile
(
outfile
)
r
.
xlabel
=
hdr
[
0
]
r
.
ylabels
=
map
(
str
.
strip
,
hdr
[
1
:])
r
.
ylabels
=
[
s
.
strip
for
s
in
hdr
[
1
:]]
#r.ylabels = map(str.strip, hdr[1:]) // replaced 090415 adf
if
save_kat
:
if
kat_name
==
None
:
...
...
@@ -1271,7 +1279,7 @@ class kat(object):
for
key
in
self
.
__blocks
:
objs
=
self
.
__blocks
[
key
].
contents
for
obj
in
objs
:
if
isinstance
(
obj
,
str
):
if
isinstance
(
obj
,
six
.
string_types
):
if
fragment
in
obj
:
print
" ** removing line '{0}'"
.
format
(
obj
)
objs
.
remove
(
obj
)
...
...
@@ -1284,13 +1292,33 @@ class kat(object):
pykat object that create similar commands so becareful.
"""
self
.
__blocks
[
block
].
contents
.
append
(
line
)
def
printExtraLines
(
self
):
"""
This prints all the Finesse commands that have not been parsed
into pykat objects. This should be used for reference only. To
add or remove extra lines use the addLine and removeLine methods.
"""
found
=
False
for
key
in
self
.
__blocks
:
objs
=
self
.
__blocks
[
key
].
contents
for
obj
in
objs
:
if
isinstance
(
obj
,
six
.
string_types
):
print
(
obj
)
found
=
True
if
not
found
:
print
(
"No extra lines were found"
)
>>>>>>>
starting
cnversion
to
pykat2
and
3
compatibility
def
generateKatScript
(
self
)
:
""" Generates the kat file which can then be run """
def
writeBlock
():
for
obj
in
objs
:
if
isinstance
(
obj
,
s
tr
):
if
isinstance
(
obj
,
s
ix
.
string_types
):
out
.
append
(
obj
+
'
\n
'
)
elif
isinstance
(
obj
,
Component
)
or
isinstance
(
obj
,
Detector
)
or
isinstance
(
obj
,
Command
):
...
...
@@ -1364,7 +1392,7 @@ class kat(object):
out
.
append
(
"vacuum {0}
\n
"
.
format
(
" "
.
join
(
objs
)))
elif
isinstance
(
self
.
vacuum
,
s
tr
):
elif
isinstance
(
self
.
vacuum
,
s
ix
.
string_types
):
out
.
append
(
"vacuum {0}
\n
"
.
format
(
self
.
vacuum
))
else
:
pkex
.
BasePyKatException
(
"Couldn't understand vacuum input list"
)
...
...
pykat/node_network.py
View file @
a26a5349
...
...
@@ -4,6 +4,10 @@ Created on Sun Jan 27 10:02:41 2013
@author: Daniel
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
from
pykat
import
USE_GUI
,
NoGUIException
...
...
pykat/param.py
View file @
a26a5349
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
abc
import
pykat.exceptions
as
pkex
import
weakref
...
...
pykat/plotting.py
View file @
a26a5349
...
...
@@ -4,6 +4,10 @@ Created on Sat Feb 02 10:35:04 2013
@author: Daniel
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
numpy
as
np
import
matplotlib
...
...
@@ -80,4 +84,4 @@ class pp():
# for Palatino and other serif fonts use:
#font = {'family':'serif','serif':['Palatino']}
SCREEN_TITLE
=
True
# show title on screen?
PRINT_TITLE
=
False
# show title in saved file?
\ No newline at end of file
PRINT_TITLE
=
False
# show title in saved file?
pykat/profiling.py
View file @
a26a5349
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
numpy
as
np
import
pylab
as
pl
...
...
@@ -24,4 +29,4 @@ def plotReducedPerformanceData(perfdata, ordered=False):
pl
.
xlabel
(
"Time [s]"
)
pl
.
title
(
"Timing data for FINESSE"
)
return
labels
,
times
,
fig
\ No newline at end of file
return
labels
,
times
,
fig
pykat/structs.py
View file @
a26a5349
...
...
@@ -4,7 +4,11 @@ Created on Mon Jan 28 12:00:29 2013
@author: Daniel
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
class
Scale
:
linear
=
'lin'
logarithmic
=
'log'
\ No newline at end of file
logarithmic
=
'log'
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment