Commit 7d635b06 authored by Daniel Brown's avatar Daniel Brown
Browse files

Fixing x2axis variables, adding new isolator

parent 36b80188
Pipeline #1585 passed with stage
in 18 seconds
...@@ -466,12 +466,8 @@ class xaxis(Command): ...@@ -466,12 +466,8 @@ class xaxis(Command):
Command.__init__(self, axis_type, True) Command.__init__(self, axis_type, True)
self._axis_type = axis_type self._axis_type = axis_type
self.x = putter("x1", self) self._set_variables()
self.mx = putter("mx1", self)
self._putters.append(self.x)
self._putters.append(self.mx)
if scale == "lin": if scale == "lin":
scale = Scale.linear scale = Scale.linear
...@@ -508,6 +504,13 @@ class xaxis(Command): ...@@ -508,6 +504,13 @@ class xaxis(Command):
self.__param = param self.__param = param
self.__comp = param._owner() self.__comp = param._owner()
def _set_variables(self):
self.x = putter("x1", self)
self.mx = putter("mx1", self)
self._putters.append(self.x)
self._putters.append(self.mx)
@property @property
def param(self): return self.__param def param(self): return self.__param
@param.setter @param.setter
...@@ -549,12 +552,14 @@ class xaxis(Command): ...@@ -549,12 +552,14 @@ class xaxis(Command):
class x2axis(xaxis): class x2axis(xaxis):
def __init__(self, scale, limits, param, steps, comp=None, axis_type="x2axis"): def __init__(self, scale, limits, param, steps, comp=None, axis_type="x2axis"):
xaxis.__init__(self, scale, limits, param, steps, comp=comp, axis_type=axis_type) xaxis.__init__(self, scale, limits, param, steps, comp=comp, axis_type=axis_type)
def _set_variables(self):
self.x = putter("x2", self) self.x = putter("x2", self)
self.mx = putter("mx2", self) self.mx = putter("mx2", self)
self._putters.append(self.x) self._putters.append(self.x)
self._putters.append(self.mx) self._putters.append(self.mx)
@staticmethod @staticmethod
def parseFinesseText(text): def parseFinesseText(text):
values = text.split() values = text.split()
......
...@@ -1022,6 +1022,49 @@ class isolator(Component): ...@@ -1022,6 +1022,49 @@ class isolator(Component):
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/isolator.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1]), (14,24,self.nodes[2])]) self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/isolator.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1]), (14,24,self.nodes[2])])
return self._svgItem return self._svgItem
class isolator1(Component):
def __init__(self, name, node1, node2, node3, node4):
"""
Creates a 4-port isolator component.
"""
Component.__init__(self, name)
self._requested_node_names.append(node1)
self._requested_node_names.append(node2)
self._requested_node_names.append(node3)
self._requested_node_names.append(node4)
self._svgItem = None
@staticmethod
def parseFinesseText(text):
values = text.split()
if values[0] != "isol1":
raise pkex.BasePyKatException("'{0}' not a valid Finesse isolator command".format(text))
values.pop(0) # remove initial value
if len(values) == 5:
return isolator1(values[0], values[1], values[2], values[3], values[4])
else:
raise pkex.BasePyKatException("Isolator1 Finesse code format incorrect '{0}'".format(text))
def getFinesseText(self):
rtn = ['isol1 {0} {1} {2} {3} {4}'.format(self.name, self.nodes[0].name,
self.nodes[1].name, self.nodes[2].name,
self.nodes[3].name)]
for p in self._params:
rtn.extend(p.getFinesseText())
return rtn
class lens(Component): class lens(Component):
def __init__(self, name, node1, node2, f=1, p=None): def __init__(self, name, node1, node2, f=1, p=None):
......
...@@ -471,6 +471,7 @@ class katRun(object): ...@@ -471,6 +471,7 @@ class katRun(object):
if ylim is not None: if ylim is not None:
pyplot.ylim(ylim[0],ylim[1]) pyplot.ylim(ylim[0],ylim[1])
pyplot.margins(0, 0.05)
pyplot.tight_layout() pyplot.tight_layout()
if legend: if legend:
...@@ -1112,6 +1113,8 @@ class kat(object): ...@@ -1112,6 +1113,8 @@ class kat(object):
obj = pykat.components.beamSplitter.parseFinesseText(line) obj = pykat.components.beamSplitter.parseFinesseText(line)
elif(first[0:2] == "gr"): elif(first[0:2] == "gr"):
obj = pykat.components.grating.parseFinesseText(line) obj = pykat.components.grating.parseFinesseText(line)
elif(first[0:5] == "isol1"):
obj = pykat.components.isolator1.parseFinesseText(line)
elif(first[0:4] == "isol"): elif(first[0:4] == "isol"):
obj = pykat.components.isolator.parseFinesseText(line) obj = pykat.components.isolator.parseFinesseText(line)
elif(first[0:4] == "lens"): elif(first[0:4] == "lens"):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment