From 95c2aff83bc59a8e0928c12d62eb5af255011d49 Mon Sep 17 00:00:00 2001 From: Daniel Brown <ddb@star.sr.bham.ac.uk> Date: Tue, 28 Oct 2014 19:34:25 +0000 Subject: [PATCH] fixing mod order setting, adding in new progress parsing so less error prone, must be used with latest kat version, adding cmd_ags option so that other flags can be passed to kat.run(), like enabling coupling reduction --- pykat/components.py | 2 +- pykat/finesse.py | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pykat/components.py b/pykat/components.py index 67b2233..5684525 100644 --- a/pykat/components.py +++ b/pykat/components.py @@ -822,7 +822,7 @@ class modulator(Component): def order(self): return self.__order @order.setter def order(self, value): - if order <= 1 and order > 6: + if value <= 1 and value > 6: raise pkex.BasePyKatException("modulator order must be between 1 and 6") self.__order = int(value) diff --git a/pykat/finesse.py b/pykat/finesse.py index 1ea7aaf..82db500 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -808,13 +808,18 @@ class kat(object): return Process(target=f__lkat_process, args=(callback, cmd, kwargs)) - def run(self, printout=0, printerr=0, plot=None, save_output=False, save_kat=False, kat_name=None) : + def run(self, printout=0, printerr=0, plot=None, save_output=False, save_kat=False, kat_name=None, cmd_args=None) : """ Runs the current simulation setup that has been built thus far. It returns a katRun or katRun2D object which is populated with the various data from the simulation run. printout=1 prints the Finesse banner printerr shows the Finesse progress (set kat.verbose=1 to see warnings and errors) + plot (string) - Sets gnuterm for plotting + save_output (bool) - if true does not delete out file + save_kat (bool) - if true does not delete kat file + kat_name (string) - name of kat file if needed, will be randomly generated otherwise + cmd_args (list of strings) - command line flags to pass to FINESSE """ start = datetime.datetime.now() @@ -881,7 +886,10 @@ class kat(object): if self.__time_code: cmd.append('--perf-timing') - + + if cmd_args != None: + cmd.extend(cmd_args) + cmd.append('--no-backspace') # set default format so that less repeated numbers are printed to the # output file, should speed up running and parsing of output files @@ -901,17 +909,16 @@ class kat(object): # warnings and errors start with an asterisk # so if verbose show them - if line.lstrip().startswith('*'): - if self.verbose: sys.stdout.write(line) - - elif line.rstrip().endswith('s') and '%' in line: - vals = line.split("-") + if line.lstrip().startswith('*PROG*'): + line = line[8:-1] + vals = line.split("-",1) action = vals[0].strip() prc = vals[1].strip()[:] if printerr == 1: sys.stdout.write("\r{0} {1}".format(action, prc)) - + elif line.lstrip().startswith('*'): + if self.verbose: sys.stdout.write(line) elif line.rstrip().endswith('%'): vals = line.split("-") action = vals[0].strip() -- GitLab