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
897c2f39
Commit
897c2f39
authored
Apr 10, 2015
by
Andreas Freise
Browse files
starting cnversion to pykat2 and 3 compatibility
parent
6a372be9
Changes
12
Hide whitespace changes
Inline
Side-by-side
pykat/SIfloat.py
View file @
897c2f39
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 @
897c2f39
...
...
@@ -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 @
897c2f39
...
...
@@ -4,14 +4,18 @@ 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
pykat.external.six
as
six
if
six
.
PY2
:
import
exceptions
from
components
import
*
from
structs
import
*
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 @
897c2f39
...
...
@@ -4,7 +4,10 @@ Created on Mon Jan 28 11:10:01 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
,
HAS_OPTIVIS
,
NoGUIException
...
...
pykat/detectors.py
View file @
897c2f39
...
...
@@ -4,7 +4,11 @@ Created on Fri Feb 01 0split()9:09:10 2013
@author: Daniel
"""
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
...
...
@@ -13,8 +17,10 @@ from pykat.node_network import *
from
pykat.param
import
Param
,
AttrParam
from
pykat.SIfloat
import
SIfloat
import
collections
import
pykat.external.six
as
six
import
pykat.exceptions
as
pkex
import
collections
import
warnings
import
copy
...
...
@@ -63,7 +69,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
)
...
...
@@ -151,7 +157,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
:
...
...
@@ -383,9 +389,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
]
...
...
@@ -462,7 +470,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
)
...
...
pykat/exceptions.py
View file @
897c2f39
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
...
...
pykat/finesse.py
View file @
897c2f39
...
...
@@ -23,7 +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
...
...
@@ -52,6 +56,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
,
HAS_OPTIVIS
,
NoGUIException
...
...
@@ -772,7 +778,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
))
...
...
@@ -1142,13 +1148,15 @@ 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
:
...
...
@@ -1376,7 +1384,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
)
...
...
@@ -1405,7 +1413,7 @@ class kat(object):
for
key
in
self
.
__blocks
:
objs
=
self
.
__blocks
[
key
].
contents
for
obj
in
objs
:
if
isinstance
(
obj
,
s
tr
):
if
isinstance
(
obj
,
s
ix
.
string_types
):
print
(
obj
)
found
=
True
...
...
@@ -1418,7 +1426,7 @@ class kat(object):
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
):
...
...
@@ -1492,7 +1500,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 @
897c2f39
...
...
@@ -4,7 +4,11 @@ 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
if
USE_GUI
:
...
...
pykat/param.py
View file @
897c2f39
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 @
897c2f39
...
...
@@ -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 @
897c2f39
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 @
897c2f39
...
...
@@ -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