Commit 90e0e1a2 authored by Daniel Brown's avatar Daniel Brown
Browse files

output now correctly returns detector values when using out['name']. If yaxis...

output now correctly returns detector values when using out['name']. If yaxis is used to specify multiple outputs values per detector the result of out[name] is a 2d array
parent 2787dbfa
......@@ -14,16 +14,17 @@ m m1 0.5 0.5 0 n2 n3
s s2 10 1 n3 n4
m m2 0.5 0.5 0 n4 n5
s s3 10 1 n5 n6
yaxis abs:deg
"""
#kat = finesse.kat(katexe='/Users/adf/work/bin/kat')
kat = finesse.kat()
kat.parseCommands(code)
kat.add(cavity('cav1', 'm1', 'n3', 'm2', 'n4'))
kat.add(photodiode('pd_cav','n4'))
kat.add(photodiode('pd_cav','n4',num_demods=1, demods=[1]))
kat.add(photodiode('pd_ref','n2'))
kat.add(photodiode('pd_trs','n5'))
......@@ -40,6 +41,7 @@ out = kat.run(printout=0,printerr=0)
pl.figure()
pl.plot(out.x, out["pd_cav"])
pl.plot(out.x, out["pd_ref"])
pl.xlabel(out.xlabel)
pl.ylabel("Intensity [W]")
pl.legend(out.ylabels)
......
......@@ -21,6 +21,7 @@ class Detector(object) :
self.tag = None
self.__node = None
self._params = []
self._mask = {}
if node.find('*'):
self._alternate_beam = True
......@@ -59,6 +60,16 @@ class Detector(object) :
def __str__(self): return self.name
def mask(self, n, m, factor):
id = str(n)+"_"+str(m)
# if the mask is 1 then remove this so it doesn't get
# printed as by default the value is 1.0
if id in self._mask and factor == 1.0:
del self._mask[id]
self._mask[id] = factor
class pd(Detector):
def __init__(self, name, num_demods, node_name, senstype=None, alternate_beam=False, **kwargs):
......
......@@ -70,14 +70,16 @@ class katRun(object):
def get(self, value): return self[value]
def __getitem__(self, value):
if value in self.ylabels:
idx = self.ylabels.index(value)
if len(self.y.shape) == 1:
return self.y
idx = [i for i in range(len(self.ylabels)) if self.ylabels[i].split(" ")[0] == str(value)]
if len(idx) == 1 and len(self.y.shape) == 1:
return self.y.squeeze()
elif len(idx) > 0:
return self.y[:,idx].squeeze()
elif len(idx) == 1:
return self.y[idx].squeeze()
else:
return self.y[:, idx]
else:
raise pkex.BasePyKatException("No output by the name {0} found".format(value))
raise pkex.BasePyKatException("No output by the name {0} found".format(str(value)))
class katRun2D(object):
def __init__(self):
......
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