(not very good – super slow) bitmap plotting

Former-commit-id: 468d2574ac81e6928bed7cf4e9b92265e8b7ae70
This commit is contained in:
Marek Nečada 2017-05-16 05:25:27 +03:00
parent 22771ef507
commit ac0a4435b6
1 changed files with 28 additions and 2 deletions

View File

@ -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)