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

Merge branch 'master' of gitmaster.atlas.aei.uni-hannover.de:pykat/pykat

Conflicts:
	pykat/finesse.py
parents 8e51b3ba c7194e77
Branches
No related tags found
No related merge requests found
...@@ -33,9 +33,8 @@ import pickle ...@@ -33,9 +33,8 @@ import pickle
import pykat import pykat
import warnings import warnings
import re import re
import collections
from collections import namedtuple from collections import namedtuple, OrderedDict
from pykat.node_network import NodeNetwork from pykat.node_network import NodeNetwork
from pykat.detectors import Detector from pykat.detectors import Detector
...@@ -245,7 +244,7 @@ class kat(object): ...@@ -245,7 +244,7 @@ class kat(object):
self.scene = None # scene object for GUI self.scene = None # scene object for GUI
self.verbose = True self.verbose = True
self.__blocks = {} # dictionary of blocks that are used self.__blocks = OrderedDict() # dictionary of blocks that are used
self.__components = {} # dictionary of optical components self.__components = {} # dictionary of optical components
self.__detectors = {} # dictionary of detectors self.__detectors = {} # dictionary of detectors
self.__commands = {} # dictionary of commands self.__commands = {} # dictionary of commands
...@@ -394,7 +393,7 @@ class kat(object): ...@@ -394,7 +393,7 @@ class kat(object):
if values[1] == "FTblock": if values[1] == "FTblock":
newTag = values[2] newTag = values[2]
if self.__currentTag != None and newTag != self.__currentTag: if self.__currentTag != None and self.__currentTag != NO_BLOCK:
warnings.warn("found block {0} before block {1} ended".format(newTag, self.__currentTag)) warnings.warn("found block {0} before block {1} ended".format(newTag, self.__currentTag))
if newTag in self.__blocks: if newTag in self.__blocks:
...@@ -806,20 +805,11 @@ class kat(object): ...@@ -806,20 +805,11 @@ class kat(object):
print " ** removing line '{0}'".format(obj) print " ** removing line '{0}'".format(obj)
objs.remove(obj) objs.remove(obj)
def generateKatScript(self) : def generateKatScript(self) :
""" Generates the kat file which can then be run """ """ Generates the kat file which can then be run """
out = [] def writeBlock():
import datetime
strtoday = datetime.datetime.now()
out.append(strtoday.strftime("%% Generated by PyKat %d.%m.%Y %H:%M:%S\n") )
for key in self.__blocks:
objs = self.__blocks[key].contents
if key != NO_BLOCK:
out.append("%%% FTblock " + key + "\n")
for obj in objs: for obj in objs:
if isinstance(obj, str): if isinstance(obj, str):
out.append(obj + '\n') out.append(obj + '\n')
...@@ -834,9 +824,33 @@ class kat(object): ...@@ -834,9 +824,33 @@ class kat(object):
else: else:
out.append(txt + "\n") out.append(txt + "\n")
out = []
import datetime
strtoday = datetime.datetime.now()
out.append(strtoday.strftime("%% Generated by PyKat %d.%m.%Y %H:%M:%S\n") )
# write the FTblocks
for key in self.__blocks:
objs = self.__blocks[key].contents
if key != NO_BLOCK: if key != NO_BLOCK:
if np.size(objs)>0:
out.append("\n")
out.append("%%% FTblock " + key + "\n")
writeBlock()
out.append("%%% FTend " + key + "\n") out.append("%%% FTend " + key + "\n")
# write the NO_BLOCK blocks
for key in self.__blocks:
objs = self.__blocks[key].contents
if key == NO_BLOCK:
if np.size(objs)>0:
out.append("\n")
writeBlock()
# now loop through all the nodes and get any gauss commands # now loop through all the nodes and get any gauss commands
for key in self.nodes.getNodes(): for key in self.nodes.getNodes():
txt = self.nodes.getNodes()[key].getFinesseText() txt = self.nodes.getNodes()[key].getFinesseText()
...@@ -857,7 +871,6 @@ class kat(object): ...@@ -857,7 +871,6 @@ class kat(object):
else: else:
out.append(txt + "\n") out.append(txt + "\n")
if self.vacuum != None: if self.vacuum != None:
if isinstance(self.vacuum, collections.Container): if isinstance(self.vacuum, collections.Container):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment