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

adding in beam detector

parent f0b5c5f1
No related branches found
No related tags found
No related merge requests found
import pykat
kat = pykat.finesse.kat()
kat.parseCommands("""
l l1 1 0 n0
s s1 1 n0 n1
beam b1 0 n1
gauss g1 l1 n0 1 0
xaxis b1 x lin -3 3 100
x2axis b1 y lin -3 3 100
""")
out = kat.run()
import pylab
pylab.pcolormesh(out.x, out.y, out["b1"])
pylab.show()
......@@ -220,6 +220,53 @@ class Detector2(BaseDetector):
self._set_node(value, 1)
class beam(Detector1):
def __init__(self, name, node_name, frequency=None, alternate_beam=False):
BaseDetector.__init__(self, name, node_name)
self.alternate_beam = alternate_beam
self.__f = Param("f", self, frequency)
@property
def f(self): return self.__f
@f.setter
def f(self, value):
self.__f.value = value
@staticmethod
def parseFinesseText(text):
values = text.split()
node=values[-1]
alt_beam = node[-1] == '*'
if len(values) == 3:
return beam(values[1], node, alternate_beam=alt_beam)
elif len(values) == 4:
return beam(values[1], node, alternate_beam=alt_beam, frequency=pykat.SIfloat.SIfloat(values[2]))
else:
raise pkex.BasePyKatException('Beam detector code "{0}" is not a valid FINESSE command'.format(text))
def getFinesseText(self) :
rtn = []
if self.alternate_beam:
alt = '*'
else:
alt = ''
if self.f.value is None:
rtn.append("beam {name} {node}{alt}".format(name=self.name, node=self.node.name, alt=alt))
else:
rtn.append("beam {name} {f} {node}{alt}".format(name=self.name, f=str(self.f.value), node=self.node.name, alt=alt))
for p in self._params:
rtn.extend(p.getFinesseText())
return rtn
......
......@@ -835,6 +835,8 @@ class kat(object):
obj = pykat.detectors.bp.parseFinesseText(line)
elif(first[0:4] == "gouy"):
obj = pykat.detectors.gouy.parseFinesseText(line)
elif(first[0:4] == "beam"):
obj = pykat.detectors.beam.parseFinesseText(line)
elif(first[0:2] == "pd" and first != "pdtype"):
obj = pykat.detectors.pd.parseFinesseText(line)
elif(first == "qshot" or first == "qshotS" or first == "qshotN"):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment