Commit 362f549d authored by Daniel Brown's avatar Daniel Brown
Browse files

if noxaxis is true no xaxis are printed

parent f98bfe4b
......@@ -189,6 +189,9 @@ class xaxis(Command):
return xaxis(values[2], [values[3], values[4]], values[1], values[5], comp=values[0], axis_type=axis_type)
def getFinesseText(self):
if(self._kat.noxaxis):
return '# noaxis is true, switching xaxis off'
# store either the component name of the string provided
comp_name = self.__comp.name if hasattr(self.__comp, "name") else self.__comp
param_name = self.__param.name if isinstance(self.__param, Param) else self.__param
......@@ -198,8 +201,8 @@ class xaxis(Command):
min(self.limits), max(self.limits), self.steps, axis_type=self._axis_type);
class x2axis(xaxis):
def __init__(self, scale, limits, param, steps, comp=None):
xaxis.__init__(self, scale, limits, param, steps, comp=comp, axis_type="x2axis")
def __init__(self, scale, limits, param, steps, comp=None, axis_type="x2axis"):
xaxis.__init__(self, scale, limits, param, steps, comp=comp, axis_type=axis_type)
self.x = putter("x2")
self.mx = putter("mx2")
......@@ -217,4 +220,4 @@ class x2axis(xaxis):
if len(values) != 6:
raise pkex.BasePyKatException("xaxis Finesse code format incorrect '{0}'".format(text))
return x2axis(values[2], [values[3], values[4]], values[1], values[5], comp=values[0])
return x2axis(values[2], [values[3], values[4]], values[1], values[5], comp=values[0],axis_type=axis_type)
......@@ -156,7 +156,7 @@ class katRun(object):
self.katScript = None
self.katVersion = None
self.yaxis = None
def plot(self):
import pylab
......@@ -218,7 +218,7 @@ class katRun2D(object):
with open(filename,'r') as infile:
return pickle.load(infile)
def get(self, value): return self[value]
def get(self, value): return self[value].squeeze()
def __getitem__(self, value):
idx = [i for i in range(len(self.zlabels)) if self.zlabels[i].split()[0] == str(value)]
......@@ -387,7 +387,7 @@ class kat(object):
self.__trace = None
self.__phase = None
self.__maxtem = None
self.__noxaxis = None
self.__noxaxis = False
self.__time_code = None
self.__yaxis = "abs" # default yaxis
self.__lambda0 = 1064e-9
......@@ -815,7 +815,7 @@ class kat(object):
if self.verbose: print "--------------------------------------------------------------"
if self.verbose: print "Running kat - Started at " + str(start)
if hasattr(self, "x2axis"):
if hasattr(self, "x2axis") and self.noxaxis == False:
r = katRun2D()
else:
r = katRun()
......@@ -922,7 +922,7 @@ class kat(object):
if self.verbose: print "\nOutput data saved to '{0}'".format(newoutfile)
if hasattr(self, "x2axis"):
if hasattr(self, "x2axis") and self.noxaxis == False:
[r.x,r.y,r.z,hdr] = self.readOutFile(outfile)
r.xlabel = hdr[0]
......@@ -1067,7 +1067,7 @@ class kat(object):
if len(data.shape) == 1:
data = np.array([data])
if hasattr(self, "x2axis"):
if hasattr(self, "x2axis") and self.noxaxis == False:
# need to parse 2D outputs slightly different as they are effectively 2D matrices
# written in linear form
x = data[0::(1+self.x2axis.steps),0]
......@@ -1193,7 +1193,7 @@ class kat(object):
if self.noxaxis == True:
out.append("noxaxis\n")
if self.yaxis != None:
out.append("yaxis {0}\n".format(self.yaxis))
......
......@@ -29,7 +29,7 @@ class surfacemap:
mapfile.write("%.15g " % self.data[i,j])
mapfile.write("\n")
def plot(self):
def plot(self, show=True, clabel=None):
import pylab
......@@ -40,11 +40,18 @@ class surfacemap:
axes = pylab.imshow(self.data, extent=[min(xrange),max(xrange),min(yrange),max(yrange)])
pylab.xlabel('x [cm]')
pylab.ylabel('y [cm]')
pylab.title('Surface map {0}, type {1}'.format(self.name, self.type))
cbar = fig.colorbar(axes)
pylab.show()
if clabel != None:
cbar.set_label(clabel)
if show:
pylab.show()
return fig
def read_map(filename):
with open(filename, 'r') as f:
......
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