<p><b>dwj07@fsu.edu</b> 2012-03-15 11:12:52 -0600 (Thu, 15 Mar 2012)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Updating python visualization script to support different coordinate types (cells, edges, and vertices).<br>
        Adding interpolation of mesh from an unstructured hexagonal mesh to a structured rectangular mesh for smoothing of data.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/ocean_projects/ocean_test_cases_staging/ocean/baroclinic_channel/visualize_channel.py
===================================================================
--- branches/ocean_projects/ocean_test_cases_staging/ocean/baroclinic_channel/visualize_channel.py        2012-03-15 16:58:59 UTC (rev 1646)
+++ branches/ocean_projects/ocean_test_cases_staging/ocean/baroclinic_channel/visualize_channel.py        2012-03-15 17:12:52 UTC (rev 1647)
@@ -1,6 +1,10 @@
 #!/usr/bin/python
 import sys, os, glob, shutil, numpy
-from netCDF import *
+
+sys.path.append('/home/douglasj/softwares/python/lib/python2.7/site-packages')
+
+from netCDF4 import *
+from netCDF4 import Dataset as NetCDFFile
 from pylab import *
 
 from optparse import OptionParser
@@ -8,7 +12,7 @@
 import time
 import matplotlib
 import matplotlib.pyplot as plt
-from matplotlib.contour import QuadContourSet
+from scipy.interpolate import griddata
 
 parser = OptionParser()
 parser.add_option(&quot;-f&quot;, &quot;--file&quot;, dest=&quot;filename&quot;, help=&quot;file to visualize&quot;, metavar=&quot;FILE&quot;)
@@ -34,16 +38,24 @@
 else:
         color_min = float(options.minimum)
 
-x_length = 160000
-y_length = 500000
+f = NetCDFFile(options.filename,'r')
 
-steps = 40
+times = f.variables['xtime']
+field = f.variables[options.variable]
 
-f = NetCDFFile(options.filename,'r')
+dim = field.dimensions[1]
+if dim == &quot;nCells&quot;:
+        x = f.variables['xCell'][:]
+        y = f.variables['yCell'][:]
+elif dim == &quot;nEdges&quot;:
+        x = f.variables['xEdge'][:]
+        y = f.variables['yEdge'][:]
+elif dim == &quot;nVertices&quot;:
+        x = f.variables['xVertex'][:]
+        y = f.variables['yVertex'][:]
 
-times = f.variables['xtime']
-temperature = f.variables[options.variable]
 dcedge = f.variables['dcEdge']
+vert_levs = len(f.dimensions['nVertLevels'])
 
 junk = dcedge[:]
 resolution = junk.max()
@@ -51,9 +63,8 @@
 del dcedge
 del junk
 
-nx = x_length/resolution
-ny = y_length/resolution
-vert_levs = 20
+nx = int((x.max() - x.min())/resolution - 1)
+ny = int((y.max() - y.min())/resolution)
 
 time_length = times.shape[0]
 
@@ -63,13 +74,13 @@
 print &quot;vert_levs = &quot;, vert_levs, &quot; time_length = &quot;, time_length
 
 print &quot;Computing global max and min&quot;
-junk = temperature[:,:,0]
+junk = field[:,:,0]
 maxval = junk.max()
 minval = junk.min()
 
 del junk
 
-junk = temperature[:,:,:]
+junk = field[:,:,:]
 global_max = junk.max()
 global_min = junk.min()
 
@@ -79,27 +90,31 @@
 print &quot;Surface max = &quot;, maxval, &quot; Surface min = &quot;, minval
 
 if color_max == color_min:
-        color_max = maxval
-        color_min = minval
+        color_max = global_max
+        color_min = global_min
 
+steps = 30
 step = (color_max - color_min) / steps
 color_bar_levels = arange(color_min-step, color_max+step, step)
 
-temp_slice = temperature[:, :, 0]
-temp_slice = temp_slice.reshape(time_length, ny, nx)
+xi = linspace(x.min(), x.max(), nx*2)
+yi = linspace(y.min(), y.max(), ny*2)
 
+zi = griddata((x, y), field[0,:,0], (xi[None,:], yi[:,None]), method='linear')
+
 plt.ion()
 fig = plt.figure(1)
 ax = fig.add_subplot(111)
 
-C = plt.contourf(temp_slice[0, :,:], levels=color_bar_levels)
+plt.contourf(xi, yi, zi, levels=color_bar_levels)
 plt.colorbar()
 plt.draw()
 
-for t in range( 1, time_length):
+for t in range(1, time_length):
          ax.cla()
+        zi = griddata((x, y), field[t,:,0], (xi[None,:], yi[:,None]), method='linear')
  
-        C = plt.contourf(temp_slice[t, :,:], levels=color_bar_levels)
+        plt.contourf(xi, yi, zi, levels=color_bar_levels)
         plt.draw()
          time.sleep(0.05)
 

</font>
</pre>