Commit ad7ef75a authored by Daniel Brown's avatar Daniel Brown
Browse files

fixing loss parsing/inputs and fixing rsub on Param and gaussbeam

parent 553f88ea
...@@ -159,7 +159,7 @@ class AbstractMirrorComponent(Component): ...@@ -159,7 +159,7 @@ class AbstractMirrorComponent(Component):
super(AbstractMirrorComponent, self).__init__(name) super(AbstractMirrorComponent, self).__init__(name)
if (L != None and R != None and T != None) and SIfloat(R)+SIfloat(T)+SIfloat(L) != 1: if (L != None and R != None and T != None) and SIfloat(R)+SIfloat(T)+SIfloat(L) != 1:
raise pkex.BasePyKatException('L+R+T must equal 1 if all are specified') raise pkex.BasePyKatException('L+R+T must equal 1 if all are specified at {0}'.format(self.name))
elif (R != None and L is None and T != None): elif (R != None and L is None and T != None):
L = 1- (SIfloat(R)+SIfloat(T)) L = 1- (SIfloat(R)+SIfloat(T))
elif (R is None and L != None and T != None): elif (R is None and L != None and T != None):
...@@ -320,20 +320,17 @@ class beamSplitter(AbstractMirrorComponent): ...@@ -320,20 +320,17 @@ class beamSplitter(AbstractMirrorComponent):
if len(values[0])==2: if len(values[0])==2:
values.pop(0) # remove initial value values.pop(0) # remove initial value
return beamSplitter(values[0], values[5], values[6], values[7], values[8], values[1], values[2], values[3], values[4]) return beamSplitter(values[0], values[5], values[6], values[7], values[8], values[1], values[2], None, values[3], values[4])
elif values[0][2]=="1":
values.pop(0) # remove initial value
return beamSplitter(values[0], values[5], values[6],
values[7], values[8], None, values[1], values[2], values[3], values[4])
else: else:
if values[0][2]=="1": values.pop(0) # remove initial value
values.pop(0) # remove initial value return beamSplitter(values[0], values[5], values[6],
return beamSplitter(values[0], values[5], values[6], values[7], values[8], values[1], None, values[3],
values[7], values[8], 1.0 - SIfloat(values[1]) - values[4])
SIfloat(values[2]), values[1], values[3], values[4])
else:
values.pop(0) # remove initial value
return beamSplitter(values[0], values[5], values[6],
values[7], values[8], values[1], 1.0 -
SIfloat(values[1]) - SIfloat(values[2]), values[3],
values[4])
def getFinesseText(self): def getFinesseText(self):
if self.R+self.T+self.L > 1: if self.R+self.T+self.L > 1:
raise pkex.BasePyKatException("Beamsplitter {0} has R+T+L > 1".format(self.name)) raise pkex.BasePyKatException("Beamsplitter {0} has R+T+L > 1".format(self.name))
......
...@@ -507,11 +507,11 @@ class kat(object): ...@@ -507,11 +507,11 @@ class kat(object):
if component_name in self.__detectors : if component_name in self.__detectors :
self.__detectors[component_name].scale = SIfloat(v[1]) self.__detectors[component_name].scale = SIfloat(v[1])
else: else:
raise pkex.BasePyKatException("scale command `{0}` refers to non-existing output".format(text)) raise pkex.BasePyKatException("scale command `{0}` refers to non-existing output".format(component_name))
elif len(values) == 2: elif len(values) == 2:
self.scale = SIfloat(v[1]) self.scale = SIfloat(v[1])
else: else:
raise pkex.BasePyKatException("scale command `{0}` is incorrect.".format(text)) raise pkex.BasePyKatException("scale command `{0}` is incorrect.".format(line))
elif (first == "pdtype"): elif (first == "pdtype"):
v = line.split() v = line.split()
if len(v) == 3: if len(v) == 3:
...@@ -519,9 +519,9 @@ class kat(object): ...@@ -519,9 +519,9 @@ class kat(object):
if component_name in self.__detectors : if component_name in self.__detectors :
self.__detectors[component_name].pdtype = v[2] self.__detectors[component_name].pdtype = v[2]
else: else:
raise pkex.BasePyKatException("pdtype command `{0}` refers to non-existing detector".format(text)) raise pkex.BasePyKatException("pdtype command `{0}` refers to non-existing detector".format(component_name))
else: else:
raise pkex.BasePyKatException("pdtype command `{0}` is incorrect.".format(text)) raise pkex.BasePyKatException("pdtype command `{0}` is incorrect.".format(line))
self.__currentTag = NO_BLOCK self.__currentTag = NO_BLOCK
......
...@@ -138,7 +138,8 @@ class Param(putable, putter): ...@@ -138,7 +138,8 @@ class Param(putable, putter):
def __isub__(self, a): def __isub__(self, a):
return self.value - (a) return self.value - (a)
__rsub__ = __sub__ def __rsub__(self, a):
return (a) - self.value
def __div__(self, a): def __div__(self, a):
return self.value / (a) return self.value / (a)
......
...@@ -117,7 +117,8 @@ class gauss_param(object): ...@@ -117,7 +117,8 @@ class gauss_param(object):
self.__q -= complex(a) self.__q -= complex(a)
return self return self
__rsub__ = __sub__ def __rsub__(self, a):
return gauss_param(self.__lambda, self.__nr, complex(a) - self.__q)
def __div__(self, a): def __div__(self, a):
return gauss_param(self.__lambda, self.__nr, self.__q / complex(a)) return gauss_param(self.__lambda, self.__nr, self.__q / complex(a))
......
Markdown is supported
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