diff --git a/bin/test_2d_plot.py b/bin/test_2d_plot.py index debb606f76c3dc14d9fbab6e0333e28b55f14e57..b178319bdd7dd9de0f0c794110675c9f758741f6 100644 --- a/bin/test_2d_plot.py +++ b/bin/test_2d_plot.py @@ -4,6 +4,7 @@ from pykat.detectors import * from pykat.components import * from pykat.commands import * from pykat.structs import * +import matplotlib.image as mpimg from mpl_toolkits.mplot3d.axes3d import Axes3D import numpy as np @@ -13,11 +14,12 @@ code = """ l l1 1 0 0 n1 s s1 10 1 n1 n2 +ad ad1 0 n2 beam b1 0 n2 maxtem 0 -xaxis b1 x lin -7.0 7.0 50 -x2axis b1 y lin -7.0 7.0 50 +xaxis b1 x lin -10.0 10 100 +x2axis b1 y lin -6 6 100 """ @@ -31,5 +33,17 @@ 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_surface(x, y, out.z[0,:]) +p = ax.plot_wireframe(x, y, out.z[1]) +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.set_interpolation('bicubic') +imgplot.set_interpolation('nearest') +pl.colorbar() +pl.xlabel(out.xlabel) +pl.ylabel(out.ylabel) pl.show() diff --git a/pykat/finesse.py b/pykat/finesse.py index 446965176a9dc91930ebfaad9759fc36c22cc6dd..6e5b336051c395c0e62ccfa8a473d7a146787e90 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -524,8 +524,11 @@ class kat(object): # written in linear form x = data[0::(1+self.x2axis.steps),0] y = data[0:(1+self.x2axis.steps),1] + # get rows and columns lined up so that we can reshape a single column of all x/y data + # into a matrix z = data[:,2:].transpose().reshape(data.shape[1]-2, 1+self.xaxis.steps, 1+self.x2axis.steps) - + # once you do this the data for y and x axes need swapping + z = z.swapaxes(1,2) return [x, y, z, hdr] else: shape_len = len(data.shape)