<p><b>ringler@lanl.gov</b> 2012-03-14 11:41:47 -0600 (Wed, 14 Mar 2012)</p><p><br>
extend, generalize and document plotting routine.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/ocean_projects/ocean_test_cases_staging/ocean/baroclinic_channel/plot_baroclinic_channel.m
===================================================================
--- branches/ocean_projects/ocean_test_cases_staging/ocean/baroclinic_channel/plot_baroclinic_channel.m        2012-03-14 16:51:46 UTC (rev 1637)
+++ branches/ocean_projects/ocean_test_cases_staging/ocean/baroclinic_channel/plot_baroclinic_channel.m        2012-03-14 17:41:47 UTC (rev 1638)
@@ -1,47 +1,97 @@
-%clear all
+clear all
 
+% A simple plotting program to visualize the evolution of the baroclinic
+% channel simulation. The field is read in, reshaped to be (nx,ny) and
+% plotted for all times.
+%
+% USERS need to specify the following:
+%   nVertLevels: the number of vertical levels in simulation
+%   nx: the number of cells along the x-direction
+%   ny: the number of cells along the y-direction
+%   iLevel: the vertical level that you wish to visualize
+%   var: the variable that you wish to visualize
+%   file: the path to the output (or other file)
+%
+%   NOTE: nx * ny == nCells
+%
+% the default is to plot all data from 1 to Time from the netCDF file
+% subsectioning is allowed by specifying nTimeMin (i.e. when to start)
+% and nTimeMax (i.e. when to end). The actual start and end times are 
+% determined via min/max comparisons to the netCDF file.
+
+% 10km: nx=16, nx=50, 4km: nx=40, ny=125, 1km: nx=160, ny=500
+%-------------------------------------------------------------------------
+
 nVertLevels = 20
-nx = 16
-ny = 50
+nx = 40
+ny = 125
 iLevel = 1
-var = 'temperature'
+var = 'Vor_cell'
+file = '4000m_20levs/se20_160_4procs/output.0000-01-01_00:00:00.nc'
 
-ncid_hex = netcdf.open('10000m_20levs/output.nc','nc_nowrite');
+%optional
+nTimeMin = -1;
+nTimeMax = 9e10;
+%-------------------------------------------------------------------------
 
+%open file
+ncid_hex = netcdf.open(file,'nc_nowrite');
+
+%get dimensions
 [dimname, dimlen] = netcdf.inqDim(ncid_hex,0);
 
+%get handle to var
 ID_hex = netcdf.inqVarID(ncid_hex,var);
+
+%read var and see how big it is
 work = netcdf.getVar(ncid_hex,ID_hex);
-size(work)
+a=size(work)
 
-workq = work(1,:);
-size(workq)
+iTimeMin = max(1,nTimeMin)
+iTimeMax = min(a(3),nTimeMax)
+nTime = iTimeMax - iTimeMin + 1
 
+%make workspace for reduced arrays
+workq = zeros(a(2),nTime);
+tmp=zeros(nx*ny,1);
+workavg = zeros(nx,ny);
+
+%put all data for iLevel into work array
+workq(:,1:nTime) = work(iLevel,:,iTimeMin:iTimeMax);
+clear work
+
+%find min/max of var to set a single colorbar for entire movie
 r = min(workq);
 zmin = min(r)
 r = max(workq);
 zmax = max(r)
 
+%build increments based on zmax and zmin
 inc = (zmax - zmin) / 20;
 zlevs = zmin:inc:zmax
 
-hex = reshape(workq, nx, ny);
-size(hex)
+%loop over time
+for iTime=1:nTime
+    
+    %copy data for iTime into work array and reshape
+    tmp(:)=workq(:,iTime);
+    workavg=reshape(tmp,nx,ny);
+    hex = workavg;
 
-workavg=hex;
-for j=2:2:ny
-    for i=2:nx-1
-        hex(i,j,:) = (workavg(i+1,j,:)+workavg(i,j,:))/2.0;
+    % average data on every other row so it can be plotted as Cartesian
+    for j=2:2:ny
+     for i=2:nx-1
+         hex(i,j) = (workavg(i+1,j)+workavg(i,j))/2.0;
+     end
     end
-end
-clear workavg
 
-hexp = hex(1:nx,1:ny);
-b=hexp;
-figure(1)
-b = transpose(b);
-contourf(b,zlevs)
-caxis([zmin zmax])
-colormap(jet)
-colorbar
+    % plot the data
+    b=hex;
+    figure(1)
+    b = transpose(b);
+    contourf(b,zlevs)
+    caxis([zmin zmax])
+    colormap(jet)
+    colorbar
 
+end
\ No newline at end of file

</font>
</pre>