Commit 056dd5ed authored by Daniel Brown's avatar Daniel Brown
Browse files

adding string conversion for detectors and components to return its name, you...

adding string conversion for detectors and components to return its name, you can then get outputs like out[kat.pd1] or out['pd1']
parent a020231a
......@@ -33,14 +33,14 @@ out = kat.run(printout=0,printerr=0)
fig = pl.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
x, y = np.meshgrid(out.x, out.y)
p = ax.plot_wireframe(x, y, out.z[1])
p = ax.plot_wireframe(x, y, out["b1"])
pl.xlabel(out.xlabel)
pl.ylabel(out.ylabel)
pl.show()
pl.figure()
extent = [np.min(out.x),np.max(out.x),np.min(out.y),np.max(out.y)]
imgplot = pl.imshow(out.z[1], extent=extent)
imgplot = pl.imshow(out["b1"], extent=extent)
#imgplot.set_interpolation('bicubic')
imgplot.set_interpolation('nearest')
pl.colorbar()
......
......@@ -143,6 +143,8 @@ class Component(object):
@property
def id(self): return self.__id
def __str__(self): return self.name
class Param(float):
def __new__(self,name,value):
return float.__new__(self,SIfloat(value))
......
......@@ -43,12 +43,12 @@ class Detector(object) :
@property
def node(self): return self.__node
def __getname(self):
return self.__name
name = property(__getname)
@property
def name(self): return self.__name
def __str__(self): return self.name
class photodiode(Detector):
class __F(list):
......
......@@ -103,12 +103,12 @@ class katRun2D(object):
def get(self, value): return self[value]
def __getitem__(self, value):
idx = [i for i in range(len(self.zlabels)) if self.zlabels[i].split(" ")[0] == value]
idx = [i for i in range(len(self.zlabels)) if self.zlabels[i].split(" ")[0] == str(value)]
if len(idx) > 0:
return self.z[:, idx].squeeze()
return self.z[idx].squeeze()
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 Block:
def __init__(self, name):
......
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