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
No related branches found
No related tags found
No related merge requests found
......@@ -33,9 +33,8 @@ import pickle
import pykat
import warnings
import re
import collections
from collections import namedtuple
from collections import namedtuple, OrderedDict
from pykat.node_network import NodeNetwork
from pykat.detectors import Detector
......@@ -245,7 +244,7 @@ class kat(object):
self.scene = None # scene object for GUI
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.__detectors = {} # dictionary of detectors
self.__commands = {} # dictionary of commands
......@@ -394,7 +393,7 @@ class kat(object):
if values[1] == "FTblock":
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))
if newTag in self.__blocks:
......@@ -806,20 +805,11 @@ class kat(object):
print " ** removing line '{0}'".format(obj)
objs.remove(obj)
def generateKatScript(self) :
""" Generates the kat file which can then be run """
out = []
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")
def writeBlock():
for obj in objs:
if isinstance(obj, str):
out.append(obj + '\n')
......@@ -834,9 +824,33 @@ class kat(object):
else:
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 np.size(objs)>0:
out.append("\n")
out.append("%%% FTblock " + key + "\n")
writeBlock()
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
for key in self.nodes.getNodes():
txt = self.nodes.getNodes()[key].getFinesseText()
......@@ -857,7 +871,6 @@ class kat(object):
else:
out.append(txt + "\n")
if self.vacuum != None:
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