Skip to content
Snippets Groups Projects
Commit 55ba57f3 authored by Daniel Brown's avatar Daniel Brown
Browse files

adding amplitude detector

parent 8d0567f5
Branches
No related tags found
No related merge requests found
......@@ -158,14 +158,14 @@ class AbstractMirrorComponent(Component):
def __init__(self, name, R=None, T=None, L=None, phi=0, Rcx=0, Rcy=0, xbeta=0, ybeta=0, mass=0, r_ap=0):
super(AbstractMirrorComponent, self).__init__(name)
if (L != None and R != None and T != None) and R+T+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')
elif (R != None and L is None and T != None):
L = 1- (R+T)
L = 1- (SIfloat(R)+SIfloat(T))
elif (R is None and L != None and T != None):
R = 1 - (L+T)
R = 1 - (SIfloat(L)+SIfloat(T))
elif (R != None and L != None and T is None):
T = 1 - (L+R)
T = 1 - (SIfloat(L)+SIfloat(R))
else:
raise pkex.BasePyKatException('Must specify at least two of L, R or T')
......@@ -244,8 +244,8 @@ class AbstractMirrorComponent(Component):
self.Rcy.value = SIfloat(value)
class mirror(AbstractMirrorComponent):
def __init__(self,name,node1,node2,R=0,T=0,phi=0,Rcx=0,Rcy=0,xbeta=0,ybeta=0,mass=0, r_ap=0):
super(mirror, self).__init__(name, R, T, phi, Rcx, Rcy, xbeta, ybeta, mass, r_ap)
def __init__(self,name,node1,node2,R=None,T=None,L=None,phi=0,Rcx=0,Rcy=0,xbeta=0,ybeta=0,mass=0, r_ap=0):
super(mirror, self).__init__(name, R, T, L, phi, Rcx, Rcy, xbeta, ybeta, mass, r_ap)
self._requested_node_names.append(node1)
self._requested_node_names.append(node2)
......@@ -262,17 +262,17 @@ class mirror(AbstractMirrorComponent):
if len(values[0])==1:
values.pop(0) # remove initial value
return mirror(values[0], values[4], values[5], R=values[1], T=values[2], phi=values[3])
return mirror(values[0], values[4], values[5], L=None, R=values[1], T=values[2], phi=values[3])
else:
if values[0][1]=="1":
values.pop(0) # remove initial value
return mirror(values[0], values[4], values[5], L=values[2], T=values[1], phi=values[3])
return mirror(values[0], values[4], values[5], R=None, L=values[2], T=values[1], phi=values[3])
else:
values.pop(0) # remove initial value
return mirror(values[0], values[4], values[5], R=values[1], L=values[2], phi=values[3])
return mirror(values[0], values[4], values[5], T=None, R=values[1], L=values[2], phi=values[3])
def getFinesseText(self):
if R+T+L > 1:
if self.R+self.T+self.L > 1:
raise pkex.BasePyKatException("Mirror {0} has R+T+L > 1".format(self.name))
rtn = []
......@@ -335,6 +335,9 @@ class beamSplitter(AbstractMirrorComponent):
values[4])
def getFinesseText(self):
if self.R+self.T+self.L > 1:
raise pkex.BasePyKatException("Beamsplitter {0} has R+T+L > 1".format(self.name))
rtn = []
rtn.append('bs {0} {1} {2} {3} {4} {5} {6} {7} {8}'.format(
......
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 01 09:09:10 2013
Created on Fri Feb 01 0split()9:09:10 2013
@author: Daniel
"""
......@@ -81,6 +81,64 @@ class Detector(object) :
self._mask[id] = factor
class ad(Detector):
def __init__(self, name, frequency, node_name, mode=None, alternate_beam=False):
Detector.__init__(self, name, node_name)
self.mode = mode
self.alternate_beam = alternate_beam
self.__f = Param("f", self, frequency)
@property
def mode(self): return self.__mode
@mode.setter
def mode(self, value):
if value != None and len(value) != 2:
raise pkex.BasePyKatException('Mode must be a container of length 2, first element the x mode and second the y mode')
self.__mode = value
@property
def f(self): return self.__f
@f.setter
def f(self, value):
self.__f.value = value
@staticmethod
def parseFinesseText(text):
values = text.split()
if values[-1].endswith('*'):
altbeam = True
else:
altbeam = False
if len(values) == 6:
return ad(values[1], values[4], values[5], mode = [int(values[2]), int(values[3])], alternate_beam=alt_beam)
elif len(values) == 4:
return ad(values[1], values[2], values[3], alternate_beam=altbeam)
else:
raise pkex.BasePyKatException('Amplitude detector code "{0}" is not a valid FINESSE command'.format(text))
def getFinesseText(self) :
rtn = []
if self.alternate_beam:
alt = '*'
else:
alt = ''
if self.mode == None:
rtn.append("ad {name} {f} {node}{alt}".format(name=self.name, f=str(self.f.value), node=self.node.name, alt=alt))
else:
rtn.append("ad {name} {n} {m} {f} {node}{alt}".fomat(name=self.name, n=str(self.mode[0]), m=str(self.mode[1]), f=str(self.f.value), node=self.node.name, alt=alt))
for p in self._params:
rtn.extend(p.getFinesseText())
return rtn
class pd(Detector):
def __init__(self, name, num_demods, node_name, senstype=None, alternate_beam=False, pdtype=None, **kwargs):
......@@ -88,7 +146,7 @@ class pd(Detector):
self.__num_demods = num_demods
self.__senstype = senstype
self.__alternate_beam = alternate_beam
self.alternate_beam = alternate_beam
self.__pdtype = pdtype
# create the parameters for all 5 demodulations regardless
......@@ -204,7 +262,7 @@ class pd(Detector):
@staticmethod
def parseFinesseText(text):
values = text.split(" ")
values = text.split()
demods = 0
senstype = None
......@@ -253,7 +311,7 @@ class pd(Detector):
alt_str = ""
fphi_str = ""
if self.__alternate_beam:
if self.alternate_beam:
alt_str = "*"
for n in range(1, 1+self.num_demods):
......@@ -337,7 +395,7 @@ class photodiode(Detector):
@staticmethod
def parseFinesseText(text):
values = text.split(" ")
values = text.split()
if values[0][0:2] != "pd":
raise exceptions.FinesseParse("'{0}' not a valid photodiode command".format(text))
......
......@@ -438,6 +438,8 @@ class kat(object):
obj = pykat.components.lens.parseFinesseText(line)
elif(first[0:3] == "mod"):
obj = pykat.components.modulator.parseFinesseText(line)
elif(first[0:2] == "ad"):
obj = pykat.detectors.ad.parseFinesseText(line)
elif(first[0:2] == "pd" and first != "pdtype"):
obj = pykat.detectors.pd.parseFinesseText(line)
elif(first == "xaxis" or first == "xaxis*"):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment