<p><b>mpetersen@lanl.gov</b> 2012-05-14 15:26:59 -0600 (Mon, 14 May 2012)</p><p>plot sections tool: Add ability to use subdirectories within the dir variable.  Add optional latex command.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/tools/plot_mpas_cross_sections/find_cell_sections.m
===================================================================
--- branches/tools/plot_mpas_cross_sections/find_cell_sections.m        2012-05-14 19:42:02 UTC (rev 1908)
+++ branches/tools/plot_mpas_cross_sections/find_cell_sections.m        2012-05-14 21:26:59 UTC (rev 1909)
@@ -59,17 +59,6 @@
   depth(i) = depth(i-1) + 0.5*(hZLevel(i) + hZLevel(i-1));
 end
 
-if (min(lonCell)&gt;-1e-8)
-  for iSection=1:nSections
-    if (coord(iSection,2)&lt;0)
-      coord(iSection,2) = coord(iSection,2) + 360;
-    end
-    if (coord(iSection,4)&lt;0)
-      coord(iSection,4) = coord(iSection,4) + 360;
-    end
-  end
-end
-
 % The native grid variables use:
 % lat varies from -pi/2:pi/2
 % lon varies from -pi:pi
@@ -101,23 +90,23 @@
         + (latCoord(i) - latCell(iCell))^2);
        if (dist&lt;minDist(i))
          minDist(i) = dist;
-         seedCellIndex(i,iSection) = iCell;
+         seedCellIndex(i) = iCell;
        end
      end
    end
 
    % Rename first cell on route:
-   lonBeginCell = lonCell(seedCellIndex(1,iSection));
-   latBeginCell = latCell(seedCellIndex(1,iSection));
-   beginCellIndex = seedCellIndex(1,iSection);
+   lonBeginCell = lonCell(seedCellIndex(1));
+   latBeginCell = latCell(seedCellIndex(1));
+   beginCellIndex = seedCellIndex(1);
 
    % Assign first cell on route to cell index array:
    sectionCellIndex(1,iSection) = beginCellIndex;
 
    % Rename last cell on route:
-   lonEndCell = lonCell(seedCellIndex(2,iSection));
-   latEndCell = latCell(seedCellIndex(2,iSection));
-   endCellIndex = seedCellIndex(2,iSection);
+   lonEndCell = lonCell(seedCellIndex(2));
+   latEndCell = latCell(seedCellIndex(2));
+   endCellIndex = seedCellIndex(2);
    
    % Assign distance from beginCell to endCell.  This is the
    % distance to 'beat' by candidate neighbor cells.
@@ -172,7 +161,7 @@
      sectionCellIndex(i+1,iSection) = minDistCellIndex;
      nCellsInSection(iSection) = i+1;
 
-     if (minDistCellIndex==seedCellIndex(2,iSection))
+     if (minDistCellIndex==endCellIndex)
         break
      end
 
@@ -180,7 +169,7 @@
 
    temptext = char(sectionText(iSection));
    fprintf(['Section %3i, ' temptext ' '],iSection)
-   if (minDistCellIndex==seedCellIndex(2,iSection))
+   if (minDistCellIndex==endCellIndex)
      fprintf(' complete with %g cells.</font>
<font color="gray">',nCellsInSection(iSection))
    else
      fprintf(['WARNING: Did not complete path to end' ...

Modified: branches/tools/plot_mpas_cross_sections/plot_mpas_cross_sections.m
===================================================================
--- branches/tools/plot_mpas_cross_sections/plot_mpas_cross_sections.m        2012-05-14 19:42:02 UTC (rev 1908)
+++ branches/tools/plot_mpas_cross_sections/plot_mpas_cross_sections.m        2012-05-14 21:26:59 UTC (rev 1909)
@@ -30,7 +30,7 @@
 sim(1).dir = 'x5.NA.75km_15km';
 sim(1).netcdf_file = ['o.x5.NA.75km_15km.0027-01-01_00.00.00_acc_uReconstruct.nc'];
 
-sim(2).dir = 'x5.NA.75km_15km.leith';
+sim(2).dir = 'x5.NA.75km_15km/leith';
 sim(2).netcdf_file = ['o.x5.NA.75km_15km.leith.0027-01-01_00.00.00_acc_uReconstruct.nc'];
 
 sim(3).dir = 'x1.15km';
@@ -130,18 +130,31 @@
 
 var_lims = [-10 10 2.5; -10 10 2.5; 0 20 2.5];
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  Specify latex command
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+% This matlab script will invoke a latex compiler in order to
+% produce a pdf file.  Specify the unix command-line latex
+% executable, or 'none' to not compile the latex document.
+
+latex_command = 'latex';
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  Begin main code.  Normally this does not need to change.
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%close all
 
+% change the coordinate range to be 0 to 360.
+coord(:,2) = mod(coord(:,2),360);
+coord(:,4) = mod(coord(:,4),360);
+
 for iSim = 1:length(sim)
 
   fprintf(['**** simulation: ' sim(iSim).dir '</font>
<font color="red">'])
-  unix(['mkdir -p docs/' sim(iSim).netcdf_file '_dir/f']);
   fid_latex = fopen('temp.tex','w');
   fprintf(fid_latex,['%% file created by plot_mpas_cross_sections, ' date '</font>
<font color="black"></font>
<font color="gray">']);
 
@@ -193,13 +206,22 @@
   end % iPage
   fprintf(fid_latex,['</font>
<font color="black">\\end{document}</font>
<font color="black"></font>
<font color="red">']);
   fclose(fid_latex);
-  dir = ['docs/' sim(iSim).netcdf_file '_dir/'];
-  filename = [sim(iSim).netcdf_file '.tex'];
-  unix(['cat mpas_sections.head.tex temp.tex &gt; ' dir filename ]);
-  unix(['mv f/*jpg ' dir 'f']);
-  cd(dir);
-  unix(['latex ' filename]);
-  cd('../..');
+
+  doc_dir = ['docs/' regexprep(sim(iSim).dir,'/','_') '_' ...
+             sim(iSim).netcdf_file '_dir' ];
+  unix(['mkdir -p ' doc_dir '/f']);
+  unix(['mv f/*jpg ' doc_dir '/f']);
+
+  filename = [ regexprep(sim(iSim).dir,'/','_') '_' sim(iSim).netcdf_file '.tex'];
+  unix(['cat mpas_sections.head.tex temp.tex &gt; ' doc_dir '/' filename ]);
+
+  if not(strcmp(latex_command,'none'))
+    fprintf('*** Compiling latex document </font>
<font color="gray">')
+    cd(doc_dir);
+    unix([latex_command ' ' filename]);
+    cd('../..');
+  end
+  
 end % iSim
 
 

Modified: branches/tools/plot_mpas_cross_sections/sub_plot_cell_sections.m
===================================================================
--- branches/tools/plot_mpas_cross_sections/sub_plot_cell_sections.m        2012-05-14 19:42:02 UTC (rev 1908)
+++ branches/tools/plot_mpas_cross_sections/sub_plot_cell_sections.m        2012-05-14 21:26:59 UTC (rev 1909)
@@ -101,7 +101,9 @@
    subplot('position',[0 .95 1 .05]); axis off
    text(.005,.7,[ date ]);
 
-   filename=['f/' regexprep(dir,'\.','_') '_cell_map' ];
+   dir_name1 =  regexprep(dir,'\.','_');
+   dir_name2 =  regexprep(dir_name1,'/','_');
+   filename=['f/' dir_name2 '_cell_map' ];
    print('-djpeg',[filename '.jpg'])
    
    % put printing text in a latex file

Modified: branches/tools/plot_mpas_cross_sections/sub_plot_cross_sections.m
===================================================================
--- branches/tools/plot_mpas_cross_sections/sub_plot_cross_sections.m        2012-05-14 19:42:02 UTC (rev 1908)
+++ branches/tools/plot_mpas_cross_sections/sub_plot_cross_sections.m        2012-05-14 21:26:59 UTC (rev 1909)
@@ -99,10 +99,13 @@
    set(h,'HorizontalAlignment','center','FontWeight','bold','FontSize',14)
       text(.005,.7,[ date ]);
 
-      filename=['f/' regexprep(dir,'\.','_') '_' pageName '_var' num2str(iVar)];
-      print('-djpeg',[filename '.jpg'])
-      fprintf(fid_latex,['\\begin{figure}[btp]  \\center </font>
<font color="red"> \\includegraphics[width=7.5in]{'...
-              filename '.jpg} </font>
<font color="black">\\end{figure} </font>
<font color="blue">']);
+   dir_name1 =  regexprep(dir,'\.','_');
+   dir_name2 =  regexprep(dir_name1,'/','_');
+   filename=['f/' dir_name2 '_' pageName '_var' num2str(iVar)];
+   print('-djpeg',[filename '.jpg'])
+   fprintf(fid_latex,['\\begin{figure}[btp]  \\center </font>
<font color="blue"> \\includegraphics[width=7.5in]{'...
+      filename '.jpg} </font>
<font color="black">\\end{figure} </font>
<font color="blue">']);
+
    %   print('-depsc2',[filename '.eps'])
 
 end

</font>
</pre>