From ac0a4435b652934db704e83e895606dddaab7124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Tue, 16 May 2017 05:25:27 +0300 Subject: [PATCH] =?UTF-8?q?(not=20very=20good=20=E2=80=93=20super=20slow)?= =?UTF-8?q?=20bitmap=20plotting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 468d2574ac81e6928bed7cf4e9b92265e8b7ae70 --- misc/hexdisplot.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/misc/hexdisplot.py b/misc/hexdisplot.py index 186263e..0c08173 100755 --- a/misc/hexdisplot.py +++ b/misc/hexdisplot.py @@ -7,6 +7,7 @@ parser = argparse.ArgumentParser() #TODO? použít type=argparse.FileType('r') ? parser.add_argument('--output', '-o', action='store', help='Path to output PDF') parser.add_argument('--nSV', action='store', metavar='N', type=int, default=1, help='Draw N minimum singular values') +parser.add_argument('--bitmap', action='store_true', help='Create an interpolated bitmap rather than a scatter plot.') #parser.add_argument('--eVfreq', action='store', required=True, type=float, help='Frequency in eV') parser.add_argument('inputfile', nargs='+', help='Npz file(s) generated by dispersion_chunks.py or other script') pargs=parser.parse_args() @@ -140,12 +141,30 @@ colormax = np.amax(np.linalg.norm(centers2,axis=0)) for omega in sorted(omegas): klist = k[omega] + if pargs.bitmap: + minx = np.amin(klist[:,0]) + maxx = np.amax(klist[:,0]) + miny = np.amin(klist[:,1]) + maxy = np.amax(klist[:,1]) + l = klist.shape[0] + meshstep = math.sqrt((maxy - miny) * (maxx - minx) / l) / 9 + x = np.linspace(minx, maxx, (maxx-minx) / meshstep) + y = np.linspace(miny, maxy, (maxy-miny) / meshstep) + fullshape = np.broadcast(x[:,nx],y[nx,:]).shape + flatx = np.broadcast_to(x[:,nx], fullshape).flatten + flaty = np.broadcast_to(y[nx,:], fullshape).flatten minsvTElist = svTE[omega] minsvTMlist = svTM[omega] for minN in reversed(range(svn)): f, axes = plt.subplots(1,3, figsize=(20,4.8)) ax = axes[0] - sc = ax.scatter(klist[:,0], klist[:,1], c = np.clip(np.abs(minsvTElist[:,minN]),0,1), lw=0) + if pargs.bitmap: + interpolator = interpolate.interp2d(klist[:,0], klist[:,1], np.abs(minsvTElist[:,minN])) + z = interpolator(flatx, flaty) + z.reshape(fullshape) + sc = ax.pcolormesh(x[:,nx],y[nx,:],z) + else: + sc = ax.scatter(klist[:,0], klist[:,1], c = np.clip(np.abs(minsvTElist[:,minN]),0,1), lw=0) for center in centers2: circle=plt.Circle((center[0],center[1]),omega/cdn, facecolor='none', edgecolor=cmap(np.linalg.norm(center)/colormax),lw=0.5) ax.add_artist(circle) @@ -161,7 +180,14 @@ for omega in sorted(omegas): ax = axes[1] - sc = ax.scatter(klist[:,0], klist[:,1], c = np.clip(np.abs(minsvTMlist[:,minN]),0,1), lw=0) + if pargs.bitmap: + interpolator = interpolate.interp2d(klist[:,0], klist[:,1], np.abs(minsvTMlist[:,minN])) + meshstep = math.sqrt((maxy - miny) * (maxx - minx) / l) / 9 + z = interpolator(flatx, flaty) + z.reshape(fullshape) + sc = ax.pcolormesh(x[:,nx],y[nx,:],z) + else: + sc = ax.scatter(klist[:,0], klist[:,1], c = np.clip(np.abs(minsvTMlist[:,minN]),0,1), lw=0) for center in centers2: circle=plt.Circle((center[0],center[1]),omega/cdn, facecolor='none', edgecolor=cmap(np.linalg.norm(center)/colormax),lw=0.5) ax.add_artist(circle)