diff --git a/bin/test_const.py b/bin/test_const.py old mode 100644 new mode 100755 index 3dc33b373c7845d5bc73adc0c395a7216d93ea26..9722cb38e6aafcf860023bd6068a75a38534df1d --- a/bin/test_const.py +++ b/bin/test_const.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + from pykat import finesse from pykat.detectors import * from pykat.components import * diff --git a/pykat/commands.py b/pykat/commands.py index a47b0dd0a51e6bb3573a579a933af2bf0b39cca7..2b70e256ad4023f51ad1bb787f5d93567a43110b 100644 --- a/pykat/commands.py +++ b/pykat/commands.py @@ -44,11 +44,34 @@ class cavity(Command): class gauss(object): @staticmethod def parseFinesseText(text, kat): - values = text.split(" ") + values = text.split() - if not values[0].startswith("gauss"): + if not values[0].startswith("gauss") or (len(values) != 6 and len(values != 8)): raise exceptions.RuntimeError("'{0}' not a valid Finesse gauss command".format(text)) + name = values[1] + component = values[2] + node = values[3] + + + + if values[0].endswith("**"): + if len(values) == 6: + print "" + elif len(values) == 8: + print "" + elif values[0].endswith("*"): + if len(values) == 6: + print "" + elif len(values) == 8: + print "" + else: + if len(values) == 6: + print "" + elif len(values) == 8: + print "" + + class xaxis(Command): def __init__(self, scale, limits, param, steps, comp=None, axis_type="xaxis"): @@ -94,7 +117,7 @@ class xaxis(Command): @staticmethod def parseFinesseText(text): - values = text.split(" ") + values = text.split() if values[0] != "xaxis" and values[0] != "xaxis*": raise exceptions.RuntimeError("'{0}' not a valid Finesse xaxis command".format(text)) @@ -125,7 +148,7 @@ class x2axis(xaxis): @staticmethod def parseFinesseText(text): - values = text.split(" ") + values = text.split() if values[0] != "x2axis" and values[0] != "x2axis*": raise exceptions.RuntimeError("'{0}' not a valid Finesse xaxis command".format(text)) diff --git a/pykat/components.py b/pykat/components.py index 67618085c6abb83ffc4f0a58f49ddc67ca5aa08b..ee2242d198f27cc1e94cda38b69d96b07f1a1b12 100644 --- a/pykat/components.py +++ b/pykat/components.py @@ -234,7 +234,7 @@ class mirror(AbstractMirrorComponent): @staticmethod def parseFinesseText(text): - values = text.split(" ") + values = text.split() if values[0] != "m" and values[0] != "m1" and values[0] != "m2": raise pkex.BasePyKatException("'{0}' not a valid Finesse mirror command".format(text)) @@ -289,7 +289,7 @@ class beamSplitter(AbstractMirrorComponent): @staticmethod def parseFinesseText(text): - values = text.split(" ") + values = text.split() if values[0] != "bs" and values[0] != "bs1" and values[0] != "bs2": raise pkex.BasePyKatException("'{0}' not a valid Finesse beam splitter command".format(text)) @@ -355,7 +355,7 @@ class space(Component): @staticmethod def parseFinesseText(text): - values = text.split(" ") + values = text.split() if values[0] != "s": raise pkex.BasePyKatException("'{0}' not a valid Finesse space command".format(text)) @@ -465,7 +465,7 @@ class grating(Component): @staticmethod def parseFinesseText(text): - values = text.split(" ") + values = text.split() if values[0][0 : 2] != "gr": raise pkex.BasePyKatException("'{0}' not a valid Finesse grating command".format(text)) @@ -533,7 +533,7 @@ class isolator(Component): @staticmethod def parseFinesseText(text): - values = text.split(" ") + values = text.split() if values[0] != "isol": raise pkex.BasePyKatException("'{0}' not a valid Finesse isolator command".format(text)) @@ -575,7 +575,7 @@ class lens(Component): @staticmethod def parseFinesseText(text): - values = text.split(" ") + values = text.split() if values[0] != "lens": raise pkex.BasePyKatException("'{0}' not a valid Finesse lens command".format(text)) @@ -650,7 +650,7 @@ class modulator(Component): @staticmethod def parseFinesseText(text): - v = text.split(" ") + v = text.split() if v[0] != "mod": raise pkex.BasePyKatException("'{0}' not a valid Finesse modulator command".format(text)) @@ -706,7 +706,7 @@ class laser(Component): @staticmethod def parseFinesseText(text): - values = text.split(" ") + values = text.split() if values[0] != "l": raise pkex.BasePyKatException("'{0}' not a valid Finesse laser command".format(text)) diff --git a/pykat/finesse.py b/pykat/finesse.py index 01dcce32cd9a7272ce8f8d4c56dd4e040408cbfa..8217878351538e33292e05d77c9e4c65feb08e05 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -497,7 +497,7 @@ class kat(object): for line in after_process: first = line.split(" ",1)[0] if first == "gauss" or first == "gauss*" or first == "gauss**": - pykat.commands.gauss.parseFinesseText(line) + pykat.commands.gauss.parseFinesseText(line, self) elif (first == "scale"): v = line.split() if len(v) == 3: diff --git a/pykat/node_network.py b/pykat/node_network.py index d5e006f1ce7c022499efd978c722c57e7e52869b..c882dc26b7a99fadd48acbc4dc1851aae557762f 100644 --- a/pykat/node_network.py +++ b/pykat/node_network.py @@ -86,7 +86,7 @@ class NodeNetwork(object): comps = (None,) * 2 if len(comps) >= 2 and comps[0] != None and comps[1] != None: - raise pkex.BasePyKatException("Node is already connected to 2 components") + raise pkex.BasePyKatException("Node '{0}' is already connected to 2 components ({1}, {2})".format(node.name, comps[0], comps[1])) l = list(comps) @@ -118,6 +118,7 @@ class NodeNetwork(object): return n def removeNode(self, node): + if not isinstance(node,Node): raise exceptions.ValueError("node argument is not of type Node") @@ -326,9 +327,12 @@ class Node(object): @property def name(self): return self.__name - + class DumpNode(Node): + __total_dump_node_id = 0 + def __init__(self): - Node.__init__(self, 'dump', None, -1) + DumpNode.__total_dump_node_id -= 1 + Node.__init__(self, 'dump', None, DumpNode.__total_dump_node_id)