Commit 486eb5c5 authored by Daniel Brown's avatar Daniel Brown
Browse files

more fixes for GUI and other bits and pieces

parent c3ec8636
......@@ -17,7 +17,7 @@ xaxis m1 r_ap lin 0.1e-3 2e-3 10
kat = finesse.kat(kat_code = code)
maxtem = np.arange(0, 3, 2)
maxtem = np.arange(0, 1, 2)
for tem in maxtem:
print "Calculating maxtem ",tem,"..."
......
......@@ -14,6 +14,7 @@ ad ad1 0 n2
kat = finesse.kat(kat_code = code)
kat.add(xaxis("lin", [0, 360], kat.m2, kat.m2.phi, 1000))
kat.add(xaxis("lin", [0, 360], kat.m2, kat.m2.phi, 1000))
r = kat.run(printerr=1)
......
......@@ -24,7 +24,7 @@ kat.add(photodiode('pd_cav','n4'))
kat.add(photodiode('pd_ref','n2'))
kat.add(photodiode('pd_trs','n5'))
kat.add(xaxis(Scale.linear, [0, 360], kat.m2, kat.m2.phi, 100))
kat.add(xaxis("lin", [0, 360], kat.m2, kat.m2.phi, 100))
kat.m1.Rcx = -1000.0
kat.m1.Rcy = -1000.0
......
......@@ -15,6 +15,10 @@ class Command(object):
""" Base class for individual finesse optical components """
raise NotImplementedError("This function is not implemented")
@staticmethod
def parseFinesseText(text):
raise NotImplementedError("This function is not implemented")
def _on_kat_add(self, kat):
"""
Called when this component has been added to a kat object
......@@ -53,12 +57,12 @@ class xaxis(Command):
if numpy.size(limits) != 2 :
raise exceptions.ValueError("limits input should be a 2x1 vector of limits for the xaxis")
self.limits = limits
self.limits = numpy.array(limits).astype(float)
if steps <= 0 :
raise exceptions.ValueError("steps value should be > 0")
self.steps = steps
self.steps = int(steps)
# if entered component is a string then just store and use that
if isinstance(comp, str):
......@@ -74,6 +78,20 @@ class xaxis(Command):
raise exceptions.ValueError("param argument is not of type Param")
else:
self.__param = param
@staticmethod
def parseFinesseText(text):
values = text.split(" ")
if values[0] != "xaxis" and values[0] != "xaxis*" and values[0] != "x2axis" and values[0] != "x2axis*":
raise exceptions.RuntimeError("'{0}' not a valid Finesse xaxis command".format(text))
values.pop(0) # remove initial value
if len(values) != 6:
raise exceptions.RuntimeError("xaxis Finesse code format incorrect '{0}'".format(text))
return xaxis(values[2], [values[3], values[4]], values[0], values[1], values[5])
def getFinesseText(self):
# store either the component name of the string provided
......
......@@ -20,11 +20,6 @@ class Component(object) :
self.__nodes = []
self._requested_node_names = []
self._kat = None
#if not isinstance(kat,pykat.finesse.kat):
# raise exceptions.ValueError("kat argument is not a pykat.finesse.kat object")
#kat.add(self)
def _on_kat_add(self, kat):
"""
......@@ -87,48 +82,48 @@ class mirror(Component):
self._requested_node_names.append(node1)
self._requested_node_names.append(node2)
self.__R = R
self.__T = T
self.__phi = phi
self.__Rcx = Rcx
self.__Rcy = Rcy
self.__xbeta = xbeta
self.__ybeta = ybeta
self.__R = float(R)
self.__T = float(T)
self.__phi = float(phi)
self.__Rcx = float(Rcx)
self.__Rcy = float(Rcy)
self.__xbeta = float(xbeta)
self.__ybeta = float(ybeta)
@property
def R(self):
return Param('R',self.__R)
def R(self): return Param('R', self.__R)
@R.setter
def R(self,value):
self.__R = value
def R(self,value): self.__R = float(value)
@property
def T(self): return Param('T', self.__T)
@T.setter
def T(self,value): self.__T = value
def T(self,value): self.__T = float(value)
@property
def phi(self): return Param('phi', self.__phi)
@phi.setter
def phi(self,value): self.__phi = value
def phi(self,value): self.__phi = float(value)
@property
def Rcx(self): return Param('Rcx', self.__Rcx)
@Rcx.setter
def Rcx(self,value): self.__Rcx = value
def Rcx(self,value): self.__Rcx = float(value)
@property
def Rcy(self): return Param('Rcy', self.__Rcy)
@Rcy.setter
def Rcy(self,value): self.__Rcy = value
def Rcy(self,value): self.__Rcy = float(value)
@property
def xbeta(self): return Param('xbeta', self.__xbeta)
@xbeta.setter
def xbeta(self,value): self.__xbeta = value
def xbeta(self,value): self.__xbeta = float(value)
@property
def ybeta(self): return Param('ybeta', self.__ybeta)
@ybeta.setter
def ybeta(self,value): self.__ybeta = value
def ybeta(self,value): self.__ybeta = float(value)
@property
def Rc(self):
......@@ -139,8 +134,8 @@ class mirror(Component):
@Rc.setter
def Rc(self,value):
self.Rcx = value
self.Rcy = value
self.Rcx = float(value)
self.Rcy = float(value)
@staticmethod
def parseFinesseText(text):
......@@ -178,7 +173,7 @@ class mirror(Component):
if self._svgItem == None:
nodes = self.getNodes()
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg",self
,[(-4,15,self.nodes[0]),(14,15,self.nodes[1])])
,[(-4,15,nodes[0]),(14,15,nodes[1])])
return self._svgItem
......@@ -189,18 +184,18 @@ class space(Component):
self._requested_node_names.append(node1)
self._requested_node_names.append(node2)
self.__L = L
self.__n = n
self.__L = float(L)
self.__n = float(n)
self._QItem = None
@property
def L(self): return Param('L', self.__L)
@L.setter
def L(self,value): self.__L = value
def L(self,value): self.__L = float(value)
@property
def n(self): return Param('n', self.__n)
@n.setter
def n(self,value): self.__n = value
def n(self,value): self.__n = float(value)
@staticmethod
def parseFinesseText(text):
......@@ -253,24 +248,24 @@ class laser(Component):
self._requested_node_names.append(node)
self.__power = P
self.__f_offset = f_offset
self.__phase = phase
self.__power = float(P)
self.__f_offset = float(f_offset)
self.__phase = float(phase)
@property
def power(self): return Param('P', self.__power)
@power.setter
def power(self,value): self.__power = value
def power(self,value): self.__power = float(value)
@property
def f_offset(self): return Param('f', self.__f_offset)
@f_offset.setter
def f_offset(self,value): self.__f_offset = value
def f_offset(self,value): self.__f_offset = float(value)
@property
def phase(self): return Param('phase', self.__phase)
@phase.setter
def phase(self,value): self.__phase = value
def phase(self,value): self.__phase = float(value)
@staticmethod
def parseFinesseText(text):
......@@ -295,6 +290,7 @@ class laser(Component):
def getQGraphicsItem(self):
if self._svgItem == None:
nodes = self.getNodes()
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/laser.svg",
self,[(65,25,nodes[0])])
......
......@@ -28,7 +28,6 @@ class Detector(object) :
def _on_kat_add(self, kat):
self._node = kat.nodes.createNode(self.__requested_node)
#self.__node.connect(self)
@staticmethod
def parseFinesseText(text):
......
......@@ -144,6 +144,8 @@ class kat(object):
self.add(pykat.components.space.parseFinesseText(line))
elif(first == "l"):
self.add(pykat.components.laser.parseFinesseText(line))
elif(first == "xaxis" or first == "x2axis" or first == "xaxis*" or first == "x2axis*"):
self.add(pykat.commands.xaxis.parseFinesseText(line))
else:
print "Could not parse `{0}`".format(line)
self.__extra_lines.append(line + "\n")
......
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