Commit 94b579d9 authored by Andreas Freise's avatar Andreas Freise
Browse files

Merge branch 'master' of gitlab.aei.uni-hannover.de:finesse/pykat

parents ed7b204a 1e674dc9
Pipeline #1719 passed with stage
in 21 seconds
......@@ -1464,7 +1464,7 @@ class kat(object):
except pkex.BasePyKatException as ex:
print (ex)
def run(self, plot=None, save_output=False, save_kat=False, kat_name=None, cmd_args=None, getTraceData=False, rethrowExceptions=False):
def run(self, plot=None, save_output=False, save_kat=False, kat_name=None, cmd_args=None, getTraceData=False, rethrowExceptions=False, usePipe=True):
"""
Runs the current simulation setup that has been built thus far.
It returns a katRun or katRun2D object which is populated with the various
......@@ -1480,6 +1480,9 @@ class kat(object):
are the x and y beam parameters. If no tracing is done a None
is returned.
usePipe - Version of Finesse 2.1 allow piping between kat and pykat for transfer data an progress.
Switching this off means some data and variables won't be populated, but it will work with
older versions of Finesse.
rethrowExceptions - if true exceptions will be thrown again rather than being excepted and calling sys.exit()
"""
start = time.time()
......@@ -1545,7 +1548,10 @@ class kat(object):
pipe_name = katfile.name + str(uuid.uuid4())
if usePipe:
cmd=[kat_exec, "--pykat=" + pipe_name]
else:
cmd=[kat_exec, "--perl1"]
if self.__time_code:
cmd.append('--perf-timing')
......@@ -1586,6 +1592,7 @@ class kat(object):
duration = 2 # Duration for searching for open pipe
try:
if usePipe == True:
while fifo is None:
try:
if time.time() < _start_kat + duration:
......@@ -1593,13 +1600,14 @@ class kat(object):
fifo = codecs.open(pipe_name, "r", "utf-8")
self.__looking = False
else:
raise pkex.BasePyKatException("Could not connect to pykat pipe in {0} seconds. Ensure you are using Finesse >= v2.1 and Pykat >= v1.0.0.".format(duration))
raise pkex.BasePyKatException("Could not connect to pykat pipe in {0} seconds. Ensure you are using Finesse >= v2.1 and Pykat >= v1.0.0. Or set usePipe=False when making kat object.".format(duration))
except FileNotFoundError as ex:
if self.verbose:
if not self.__looking:
print("Looking for pykat pipe...")
self.__looking = True
if fifo is not None:
for line in fifo:
#if (sys.version_info < (3, 0)):
......
......@@ -636,9 +636,6 @@ class surfacemap(object):
elif isinstance(m, list):
nVals = range(n,n+1)
mVals.append(m)
elif isinstance(m, range):
nVals = range(n,n+1)
mVals.append(m)
elif isinstance(m,int):
nVals = range(n,n+1)
mVals.append(range(m,m+1))
......@@ -1415,11 +1412,11 @@ class surfacemap(object):
Z = zernike(m[k], n, rho, phi)
self.data[self.notNan] = self.data[self.notNan]-A[k]*Z[self.notNan]
self.zernikeRemoved = (m[k], n, A[k])
elif isinstance(m, range):
for k in range(len(m)):
Z = zernike(m[k], n, rho, phi)
self.data[self.notNan] = self.data[self.notNan]-A[k]*Z[self.notNan]
self.zernikeRemoved = (m[k], n, A[k])
# elif isinstance(m, range):
# for k in range(len(m)):
# Z = zernike(m[k], n, rho, phi)
# self.data[self.notNan] = self.data[self.notNan]-A[k]*Z[self.notNan]
# self.zernikeRemoved = (m[k], n, A[k])
else:
Z = zernike(m, n, rho, phi)
self.data[self.notNan] = self.data[self.notNan]-A*Z[self.notNan]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment