<p><b>mhoffman@lanl.gov</b> 2012-03-07 15:24:20 -0700 (Wed, 07 Mar 2012)</p><p>BRANCH COMMIT -- land_ice<br>
Added python script for quick visualization of dome test case output.<br>
</p><hr noshade><pre><font color="gray">Added: branches/land_ice_projects/test_cases/dome/visualize_dome.py
===================================================================
--- branches/land_ice_projects/test_cases/dome/visualize_dome.py         (rev 0)
+++ branches/land_ice_projects/test_cases/dome/visualize_dome.py        2012-03-07 22:24:20 UTC (rev 1602)
@@ -0,0 +1,106 @@
+#!/usr/bin/python
+import sys, os, glob, shutil, numpy
+from netCDF import *
+from pylab import *
+
+from optparse import OptionParser
+
+import time
+import matplotlib
+import matplotlib.pyplot as plt
+from matplotlib.contour import QuadContourSet
+
+
+parser = OptionParser()
+parser.add_option("-f", "--file", dest="filename", help="file to visualize", metavar="FILE")
+parser.add_option("-t", "--time", dest="time", help="time step to visualize (0 based)", metavar="TIME")
+# parser.add_option("-v", "--var", dest="variable", help="variable to visualize", metavar="VAR")
+# parser.add_option("--max", dest="maximum", help="maximum for color bar", metavar="MAX")
+# parser.add_option("--min", dest="minimum", help="minimum for color bar", metavar="MIN")
+
+options, args = parser.parse_args()
+
+if not options.filename:
+        print "No filename provided. Using output.nc."
+ options.filename = "output.nc"
+
+if not options.time:
+        print "No time provided. Using time 0."
+ time_slice = 0
+else:
+ time_slice = int(options.time)
+
+#if not options.variable:
+#        parser.error("Variable is a required input.")
+
+# if not options.maximum:
+#         color_max = 0.0
+# else:
+#         color_max = float(options.maximum)
+
+# if not options.minimum:
+#         color_min = 0.0
+# else:
+#         color_min = float(options.minimum)
+
+nx = 30
+ny = 35
+
+f = NetCDFFile(options.filename,'r')
+
+times = f.variables['xtime']
+thickness = f.variables['thickness']
+dcedge = f.variables['dcEdge']
+bedTopography = f.variables['bedTopography']
+xCell = f.variables['xCell']
+yCell = f.variables['yCell']
+temperature = f.variables['temperature']
+
+vert_levs = f.dimensions['nVertLevels']
+
+time_length = times.shape[0]
+
+# print "nx = ", nx, " ny = ", ny
+print "vert_levs = ", vert_levs, " time_length = ", time_length
+
+
+# print "Computing global max and min"
+# junk = thickness[:,:,0]
+# maxval = junk.max()
+# minval = junk.min()
+#
+# del junk
+#
+# junk = thickness[:,:]
+# global_max = junk.max()
+# global_min = junk.min()
+
+
+var_slice = thickness[time_slice,:]
+# var_slice = var_slice.reshape(time_length, ny, nx)
+
+
+# print "Global max = ", global_max, " Global min = ", global_min
+# print "Surface max = ", maxval, " Surface min = ", minval
+
+fig = plt.figure(1)
+ax = fig.add_subplot(111, aspect='equal')
+# C = plt.contourf(xCell, yCell, var_slice )
+plt.scatter(xCell[:], yCell[:], 80, var_slice, marker='h', edgecolors='none')
+plt.colorbar()
+plt.title('thickness at time ' + str(time_slice) )
+plt.draw()
+
+fig = plt.figure(2)
+for templevel in xrange(0,vert_levs+2):
+ ax = fig.add_subplot(3,4,templevel+1, aspect='equal')
+ var_slice = temperature[time_slice,:,templevel]
+ # C = plt.contourf(xCell, yCell, var_slice )
+ plt.scatter(xCell[:], yCell[:], 40, var_slice, marker='h', edgecolors='none')
+ plt.colorbar()
+ plt.title('temperature at level '+ str(templevel) + ' at time ' + str(time_slice) )
+ plt.draw()
+
+
+plt.show()
+f.close()
Property changes on: branches/land_ice_projects/test_cases/dome/visualize_dome.py
___________________________________________________________________
Added: svn:executable
+ *
</font>
</pre>