Skip to content
Snippets Groups Projects
Commit 043fa0c4 authored by Daniel Brown's avatar Daniel Brown
Browse files

adding kat file loading

parent 473c52a4
No related branches found
No related tags found
No related merge requests found
...@@ -58,9 +58,10 @@ class kat(object): ...@@ -58,9 +58,10 @@ class kat(object):
def __init__(self, katexe=""): def __init__(self, katexe=""):
self.scene = None # scene object for GUI self.scene = None # scene object for GUI
self.__components = {} self.__components = {} # dictionary of optical components
self.__detectors = {} self.__detectors = {} # dictionary of detectors
self.__commands = {} self.__commands = {} # dictionary of commands
self.__extra_lines = [] # an array of strings which are just normal finesse code to include when running
self.__gui = None self.__gui = None
self.nodes = NodeNetwork(self) self.nodes = NodeNetwork(self)
self.__katexe = katexe self.__katexe = katexe
...@@ -85,6 +86,16 @@ class kat(object): ...@@ -85,6 +86,16 @@ class kat(object):
@noxaxis.setter @noxaxis.setter
def noxaxis(self,value): self.__noxaxis = bool(value) def noxaxis(self,value): self.__noxaxis = bool(value)
def load(self, katfile):
"""
Loads the kat file specified which can then be run
"""
with open(katfile) as f:
for lines in f.readlines():
self.__extra_lines.append(lines)
def run(self, printout=1, printerr=1, save_output=False, save_kat=False,kat_name=None) : def run(self, printout=1, printerr=1, save_output=False, save_kat=False,kat_name=None) :
""" """
Runs the current simulation setup that has been built thus far. Runs the current simulation setup that has been built thus far.
...@@ -235,8 +246,6 @@ class kat(object): ...@@ -235,8 +246,6 @@ class kat(object):
def generateKatScript(self) : def generateKatScript(self) :
""" Generates the kat file which can then be run """ """ Generates the kat file which can then be run """
if len(self.__components) == 0 :
raise exceptions.RuntimeError("No components have been added")
out = [] out = []
...@@ -275,6 +284,15 @@ class kat(object): ...@@ -275,6 +284,15 @@ class kat(object):
if self.phase != None: out.append("phase {0}\n".format(self.phase)) if self.phase != None: out.append("phase {0}\n".format(self.phase))
if self.maxtem != None: out.append("maxtem {0}\n".format(self.maxtem)) if self.maxtem != None: out.append("maxtem {0}\n".format(self.maxtem))
# There maybe extra lines we want to include in the kat
# script which aren't parseable into components, detectors
# or commands. Typically when something hasn't been fully
# supported yet. So bung these extra lines on at the end
for lines in self.__extra_lines:
out.append(lines)
# ensure we don't do any plotting. That should be handled
# by user themselves
out.append("gnuterm no\n") out.append("gnuterm no\n")
out.append("pyterm no\n") out.append("pyterm no\n")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment