diff --git a/pykat/__init__.py b/pykat/__init__.py index d426115b597a005721ce4b6254a1a5b754fa7ee4..28195a11aaf2e8dcc35029f10b8d28bc2db1c450 100644 --- a/pykat/__init__.py +++ b/pykat/__init__.py @@ -3,7 +3,7 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -__version__ = "0.8.8" +__version__ = "0.8.9" # This flag is used to switch on the gui features in pkat at import time USE_GUI = False diff --git a/pykat/detectors.py b/pykat/detectors.py index f9d9fa2097f7de4003e22ff2e9e23777cecee7b1..be9a1bc263117f376c84796eb6fdeec79bbaf170 100644 --- a/pykat/detectors.py +++ b/pykat/detectors.py @@ -275,6 +275,61 @@ class beam(Detector1): return rtn +class cp(Detector0): + + def __init__(self, name, cavity, direction, parameter): + BaseDetector.__init__(self, name, None) + + self.cavity = str(cavity) + self.direction = direction + self.parameter = parameter + + @property + def direction(self): return self.__direction + @direction.setter + def direction(self, value): + if value.lower() not in ["x", "y"]: + raise pkex.BasePyKatException('Cavity parameter detector direction must be x or y.') + + self.__direction = value + + + @property + def parameter(self): return self.__param + @parameter.setter + def parameter(self, value): + + params = ["w0","w","zr","z","r","q","finesse","m","stability","loss","length","fsr","fwhm","pole","gouy","fsep","A","B","C","D"] + + if value not in params: + raise pkex.BasePyKatException('Cavity parameter detector direction must be one of: ' + ", ".join(params)) + + self.__param = value + + + @staticmethod + def parseFinesseText(text): + values = text.split() + + if len(values) == 4: + # For FINESSE version < 2.1 + # Old format the name of the detector is a combination of the arguments + return cp(values[1] + "_" + values[2] + "_" + values[3], values[1], values[2], values[3]) + elif len(values) == 5: + return cp(values[1], values[2], values[3], values[4]) + else: + raise pkex.BasePyKatException('Cavity parameter detector code "{0}" is not a valid FINESSE command'.format(text)) + + def getFinesseText(self) : + rtn = [] + + rtn.append("cp {name} {cavity} {direction} {parameter}".format(name=self.name, + cavity=str(self.cavity), + direction=self.direction, + parameter=self.parameter)) + + return rtn + class xd(Detector0): def __init__(self, name, component, motion): diff --git a/pykat/finesse.py b/pykat/finesse.py index 8c2dd3bba0c67bcbc27cb4718b0b351e30056dfa..6deae8b6f8c385fe7e9850d185f7a9c35419387f 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -249,14 +249,28 @@ class katRun(object): detectors = list(set([lbl.split()[0] for lbl in self.ylabels])) detectors.sort() + print("") print("--- Output info ---") + print("") print("Run date and time: %s" % self.StartDateTime) print("Detectors used: %s" % (", ".join(detectors))) - + print("") + if kat.noxaxis: print("No xaxis used") else: print("One xaxis used: %s" % kat.xaxis.getFinesseText()) + + import numpy as np + + maxs = np.max(self.y, 0) + mins = np.min(self.y, 0) + + maxlbl = max([len(lbl) for lbl in self.ylabels]) + + for i, lbl in enumerate(self.ylabels): + a = "{0:" + str(maxlbl) + "} : min = {1:.15e} max = {2:.15e}" + print(a.format(lbl, mins[i], maxs[i])) def plot(self, detectors=None, filename=None, show=True, @@ -1025,6 +1039,8 @@ class kat(object): obj = pykat.detectors.xd.parseFinesseText(line) elif(first[0:2] == "tf"): obj = pykat.commands.tf.parseFinesseText(line) + elif(first[0:2] == "cp"): + obj = pykat.detectors.cp.parseFinesseText(line) elif(first[0:2] == "bp"): obj = pykat.detectors.bp.parseFinesseText(line) elif(first[0:4] == "gouy"):