Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -33,14 +33,14 @@ out = kat.run(printout=0,printerr=0) ...@@ -33,14 +33,14 @@ out = kat.run(printout=0,printerr=0)
fig = pl.figure() fig = pl.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d') ax = fig.add_subplot(1, 1, 1, projection='3d')
x, y = np.meshgrid(out.x, out.y) 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.xlabel(out.xlabel)
pl.ylabel(out.ylabel) pl.ylabel(out.ylabel)
pl.show() pl.show()
pl.figure() pl.figure()
extent = [np.min(out.x),np.max(out.x),np.min(out.y),np.max(out.y)] 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('bicubic')
imgplot.set_interpolation('nearest') imgplot.set_interpolation('nearest')
pl.colorbar() pl.colorbar()
......
...@@ -143,6 +143,8 @@ class Component(object): ...@@ -143,6 +143,8 @@ class Component(object):
@property @property
def id(self): return self.__id def id(self): return self.__id
def __str__(self): return self.name
class Param(float): class Param(float):
def __new__(self,name,value): def __new__(self,name,value):
return float.__new__(self,SIfloat(value)) return float.__new__(self,SIfloat(value))
......
...@@ -44,10 +44,10 @@ class Detector(object) : ...@@ -44,10 +44,10 @@ class Detector(object) :
@property @property
def node(self): return self.__node def node(self): return self.__node
def __getname(self): @property
return self.__name def name(self): return self.__name
name = property(__getname) def __str__(self): return self.name
class photodiode(Detector): class photodiode(Detector):
......
...@@ -103,12 +103,12 @@ class katRun2D(object): ...@@ -103,12 +103,12 @@ class katRun2D(object):
def get(self, value): return self[value] def get(self, value): return self[value]
def __getitem__(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: if len(idx) > 0:
return self.z[:, idx].squeeze() return self.z[idx].squeeze()
else: 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: class Block:
def __init__(self, name): def __init__(self, name):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment