<p><b>mhoffman@lanl.gov</b> 2013-02-12 15:25:56 -0700 (Tue, 12 Feb 2013)</p><p>BRANCH COMMIT - land ice<br>
Added option to plotting script to print actual cell values. Activate with -p<br>
</p><hr noshade><pre><font color="gray">Modified: branches/land_ice_projects/grid_tools/animate_mpas_field.py
===================================================================
--- branches/land_ice_projects/grid_tools/animate_mpas_field.py        2013-02-12 22:13:00 UTC (rev 2462)
+++ branches/land_ice_projects/grid_tools/animate_mpas_field.py        2013-02-12 22:25:56 UTC (rev 2463)
@@ -30,6 +30,7 @@
parser.add_option("-m", "--min", dest="minimum", help="minimum for color bar", metavar="MIN")
parser.add_option("-g", "--log", action="store_true", dest="log", help="include this flag to plot on log scale", metavar="LOG")
parser.add_option("-k", "--mask", action="store_true", dest="mask", help="include this flag to mask non-ice cells with gray", metavar="MASK")
+parser.add_option("-p", "--printval", action="store_true", dest="printval", help="include this flag to print numeric cell values (slow)", metavar="PRINTVAL")
options, args = parser.parse_args()
@@ -125,33 +126,29 @@
markersize = 70
markershape = 'h'
-t=0
-plt.scatter(xCell[:], yCell[:], markersize, var_slice[0,:], marker=markershape, edgecolors='none', vmin=minval, vmax=maxval)
-plt.colorbar()
-if options.mask:
- maskindices = numpy.nonzero(thickness[0,:] <= 0.0)[:]
- plt.scatter(numpy.take(xCell,maskindices), numpy.take(yCell,maskindices), markersize+2, '0.9', marker=markershape, edgecolors='none')
-plt.title( plottitle + ' at time '+ xtime[0,:].tostring().strip() )
-plt.draw()
-if options.saveimages:
- plotname = varname + '.' + '{0:04d}'.format(t) + '.' + options.filename + '.png'
- plt.savefig(plotname)
- print 'Saved plot as ' + plotname
-
-for t in range(1, time_length):
+for t in range(0, time_length):
ax.cla()
plt.scatter(xCell[:], yCell[:], markersize, var_slice[t,:], marker=markershape, edgecolors='none', vmin=minval, vmax=maxval)
+ if t==0:
+ plt.colorbar()
if options.mask:
maskindices = numpy.nonzero(thickness[t,:] <= 0.0)[:]
plt.scatter(numpy.take(xCell,maskindices), numpy.take(yCell,maskindices), markersize+2, '0.9', marker=markershape, edgecolors='none')
+ if options.printval:
+ for iCell in range(xCell[:].shape[0]):
+ plt.text(xCell[iCell], yCell[iCell], '{0:.1f}'.format(var_slice[t,iCell]), horizontalalignment='center', verticalalignment='center', fontsize=3)
+ dpi=300
+ else:
+ dpi=150
+
plt.title( plottitle + ' at time ' + xtime[t,:].tostring().strip() ) #str(t) )
plt.draw()
time.sleep(0.05)
if options.saveimages:
plotname = varname + '.' + '{0:04d}'.format(t) + '.' + options.filename + '.png'
#plt.ioff()
- plt.savefig(plotname)
+ plt.savefig(plotname,dpi=dpi)
#plt.ion()
print 'Saved plot as ' + plotname
</font>
</pre>