From a76f88c16370e3db396376d1b684d24aa7f00c89 Mon Sep 17 00:00:00 2001
From: Andreas Freise <adf@star.bham.ac.uk>
Date: Mon, 10 Mar 2014 16:57:30 +0000
Subject: [PATCH] adding the possibility to run finesse with plotting.

---
 pykat/finesse.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/pykat/finesse.py b/pykat/finesse.py
index 9abd7aa..0c69a64 100644
--- a/pykat/finesse.py
+++ b/pykat/finesse.py
@@ -704,7 +704,7 @@ class kat(object):
         
         return Process(target=f__lkat_process, args=(callback, cmd, kwargs))
            
-    def run(self, printout=0, printerr=0, 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) :
         """ 
         Runs the current simulation setup that has been built thus far.
         It returns a katRun or katRun2D object which is populated with the various
@@ -750,6 +750,14 @@ class kat(object):
                 r = katRun()
                 
             r.katScript = "".join(self.generateKatScript())   
+
+            if (plot==None):
+                # ensure we don't do any plotting. That should be handled
+                # by user themselves
+                r.katScript+=("gnuterm no\n")
+                r.katScript+=("pyterm no\n")
+            else:
+                r.katScript+=(plot+"\n")
             
             # create a kat file which we will write the script into
             if self.__tempname == None:
@@ -761,7 +769,7 @@ class kat(object):
             katfile.writelines(r.katScript)
             katfile.flush()
 
-            if printout == 1:
+            if printout == 1 or plot != None:
                 cmd=[kat_exec]
             else:
                 cmd=[kat_exec, '--perl1']
@@ -1111,11 +1119,6 @@ class kat(object):
 
         if self.noxaxis == True:
             out.append("noxaxis\n")
-
-        # ensure we don't do any plotting. That should be handled
-        # by user themselves
-        out.append("gnuterm no\n")
-        out.append("pyterm no\n")
         
         return out
         
-- 
GitLab