[Dart-dev] [3239] DART/trunk/diagnostics/matlab: Updated to ask a couple more questions for additional

nancy at subversion.ucar.edu nancy at subversion.ucar.edu
Fri Feb 15 09:05:33 MST 2008


An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/dart-dev/attachments/20080215/3ad78edf/attachment.html
-------------- next part --------------
Modified: DART/trunk/diagnostics/matlab/PlotObsLocs.m
===================================================================
--- DART/trunk/diagnostics/matlab/PlotObsLocs.m	2008-02-15 00:21:19 UTC (rev 3238)
+++ DART/trunk/diagnostics/matlab/PlotObsLocs.m	2008-02-15 16:05:33 UTC (rev 3239)
@@ -1,6 +1,7 @@
 function phandle = PlotObsLocs(in_dartqc, in_box, in_typelist, in_epochlist, ...
                     in_subset, in_plotd, in_world, in_invertz, in_writeplot, ...
-                    in_legend2dloc, in_legend3dloc, in_viewlist)
+                    in_legend2dloc, in_legend3dloc, in_viewlist, ...
+                    in_ncfname, in_orientation, in_plotname)
 % PLOTOBSLOCS - Plot an observation_locations.NNN.dat file as output from the latest obs_diag program in DART.
 % (You must enable an obs_diag_nml namelist entry to get the output files; 
 % they are not created by default.)
@@ -12,7 +13,8 @@
 % usage:
 % PlotObsLocs(in_dartqc, in_box, in_typelist, in_epochlist, in_subset, 
 %             in_plotd, in_world, in_invertz, in_writeplot, 
-%             in_legend2dloc, in_legend3dloc, in_viewlist)
+%             in_legend2dloc, in_legend3dloc, in_viewlist,
+%             in_ncfname, in_orientation, in_plotname)
 %
 % where:
 %
@@ -79,6 +81,20 @@
 %               printed in the lower left corner during the rotation; these
 %               views can be used to create .ps files if you are saving the 
 %               plots to a file or if you want the same viewpoints reused.
+%
+% in_ncfname = 'obs_diag_output.nc' by default - the netcdf file created by
+%              the obs_diag program.  It contains the mapping between the
+%              observation type numbers and the string labels identifying them.
+%
+% in_orientation = 'landscape' but can be 'portrait' or 'tall'.  The best
+%                   use of page space depends sharply on the aspect ratio of
+%                   the area you are plotting.  'landscape' works well for
+%                   a whole-earth 2d plot; 'portrait' is good for CONUS.
+%
+% in_plotname = name of output postscript file if writeplot is 1.  The default
+%               filename is generated as 'Nd_locations_epochNNN.ps', but
+%               subsequent plots will overwrite earlier ones, so this input
+%               can be used to customize the name.
 
 % Data Assimilation Research Testbed -- DART
 % Copyright 2004-2007, Data Assimilation Research Section
@@ -92,7 +108,7 @@
 % $Date$
 
 % data subset selections:
-%  used vs unused (or both) obs
+%  dart QC values - whether assimilated or not
 %  subregions - lon, lat, height min/max
 %  obs type list
 %  random subset to thin data
@@ -116,7 +132,8 @@
 %  user_specified (prompt user for 4 or 6 corners)
 %
 
-arg_used = 0;         % dart QC values to use ... see in_dartqc table above
+arg_ncfname = 'obs_diag_output.nc';  % default file to use for obs info
+arg_dartqc = 0;         % dart QC values to use ... see in_dartqc table above
 arg_box = [];         % [[lon_min, lon_max, lat_min, lat_max], v_min, v_max]
 arg_typelist = [];    % numeric observation type list; if ~[], integer list
 arg_epochlist = [];   % list of epochs to process; if ~[], integer list
@@ -127,16 +144,17 @@
 arg_writeplot = 0;    % write out postscript plot files (1=yes)
 arg_legend2dloc = 'SouthWest';  % where on the plot to plop the 2d legend box
 arg_legend3dloc = 'NorthWest';  % where on the plot to plop the 3d legend box
-                              % see matlab doc for alternatives
+                                % see matlab doc for alternatives
+arg_orientation = 'landscape';  % could be portrait, tall
 arg_viewlist = [10  10;  10  80; ];
                       % default viewpoints for 3D plots.
                       % [90 0], [0 90] and [0 0] are also good.
+arg_plotname = 'default';  % default is Nd_locations_epoch00N.ps
 
- ncfname = 'obs_diag_output.nc';
 
 % get the values from the arguments and fill them in:
 if (~isa(in_dartqc,'char'))
-  arg_used = in_dartqc;
+  arg_dartqc = in_dartqc;
 end
 if (~isa(in_box,'char'))
   arg_box = in_box;
@@ -171,6 +189,15 @@
 if (~isa(in_viewlist,'char'))
   arg_viewlist = in_viewlist;
 end
+if (~strcmp(in_ncfname,'default'))
+  arg_ncfname = in_ncfname;
+end
+if (~strcmp(in_orientation,'default'))
+  arg_orientation = in_orientation;
+end
+if (~strcmp(in_plotname,'default'))
+  arg_plotname = in_plotname;
+end
 
 
 %-----------
@@ -181,8 +208,8 @@
 if (~isequal(arg_epochlist,[]))
   epochlist = arg_epochlist;
 else
-  epochtime = getnc(ncfname,'time');
-  epochbnds = getnc(ncfname,'time_bounds');
+  epochtime = getnc(arg_ncfname,'time');
+  epochbnds = getnc(arg_ncfname,'time_bounds');
   epochlist = 1:length(epochtime);
 end
 
@@ -209,7 +236,7 @@
  end
  
  % format of the data in these files must be:
- %   lon  lat  ivert  flavor  key  used
+ %   lon  lat  ivert  flavor  key  dartqc
  t = reshape(r, 6, []);
  s = transpose(t);
  
@@ -221,7 +248,7 @@
  % in the 'Observation_Kind()' array.  (this file is produced by
  % running obs_diag -- full name is ObsDiagAtts.m)
  
- Observation_Kind = getnc(ncfname,'ObservationTypes');
+ Observation_Kind = getnc(arg_ncfname,'ObservationTypes');
 
  % Use a different marker and color for each observation type
  % (12*6) = 72 combinations at the moment. Could extend these
@@ -267,8 +294,8 @@
  
    % select the rows we want to plot, optionally with a variety
    % of subsetting.  function form is:
-   %   out = select_subset(rawdata_in, used/unused, boundingbox, subset_count)
-   l = select_subset(thisobs, arg_used, arg_box, arg_subset);
+   %   out = select_subset(rawdata_in, dartqc, boundingbox, subset_count)
+   l = select_subset(thisobs, arg_dartqc, arg_box, arg_subset);
  
    % if there are any of this obs type left, plot them
    if (size(l, 1) ~= 0) 
@@ -369,28 +396,31 @@
  % whole world in (lon, lat) degree coords
  if (arg_world)
  
-    % add a 2D plot of the world continent outlines
-    worldmap(lmax);
+   % add a 2D plot of the world continent outlines
+   worldmap(lmax);
     
-    % these plots are generally longer than high, and add 3d-box.
-  % orient landscape;
-    set(gca, 'Box', 'on');
+   % set the default orientation
+   orient(arg_orientation);
+   set(gca, 'Box', 'on');
 
-    % various attempts to make the x/y axis have the same spacing per degree
-    % but shrink the vertical because it can be much larger.  but all these
-    % did strange things to the viewpoint so i am giving up on them for now.
-    %axis equal;
+   % various attempts to make the x/y axis have the same spacing per degree
+   % but shrink the vertical because it can be much larger.  but all these
+   % did strange things to the viewpoint so i am giving up on them for now.
+   %axis equal;
 
-    %vert = lmax / 100;
-    %set(gca, 'DataAspectRatio', [1 1 vert], 'PlotBoxAspectRatio', [1 1 vert], 'Box', 'on');
-    %set(gca, 'DataAspectRatio', [1 1 10], 'Box', 'on');
+   %vert = lmax / 100;
+   %set(gca, 'DataAspectRatio', [1 1 vert], 'PlotBoxAspectRatio', [1 1 vert], 'Box', 'on');
+   %set(gca, 'DataAspectRatio', [1 1 10], 'Box', 'on');
  
    xlabel('Longitude (degrees)', 'FontSize', 14);
-   ylabel('Latitude (degrees)', 'FontSize', 14);
+   ylabel('Latitude (degrees)',  'FontSize', 14);
    if (arg_plotd == 3)
      zlabel('Height (units = ?)', 'FontSize', 14);
    end
  else
+   % set the default orientation
+   orient(arg_orientation);
+
    xlabel('First coordinate', 'FontSize', 14);
    ylabel('Second coordinate', 'FontSize', 14);
    if (arg_plotd == 3)
@@ -405,12 +435,12 @@
  wysiwyg;
 
 
- if (arg_used < 0)
+ if (arg_dartqc < 0)
    tstring = sprintf('Obs Locs for Epoch %d with DART QC values <= %d', ...
-                       epoch, abs(arg_used));
- elseif (arg_used >= 0)
+                       epoch, abs(arg_dartqc));
+ elseif (arg_dartqc >= 0)
    tstring = sprintf('Obs Locs for Epoch %d with DART QC value == %d', ...
-                       epoch, arg_used);
+                       epoch, arg_dartqc);
  end
 
  if (arg_subset > 0)
@@ -441,18 +471,27 @@
  % view angles -- you can set a list and get multiple plots out.
  if (arg_writeplot) 
     if (arg_plotd == 2)
-      fname = sprintf('2d_locations_epoch%.03d.ps', epoch);
-      print('-dpsc', fname);
+       if (~strcmp(arg_plotname,'default'))
+          fname = sprintf('%s_epoch%.03d.ps', arg_plotname, epoch);
+       else
+          fname = sprintf('2d_locations_epoch%.03d.ps', epoch);
+       end
+       print('-dpsc', fname);
     else
+  
+          % set up viewlist as: arg_viewlist = [ az el; az el; ... ];
+          for v = 1 : size(arg_viewlist, 1)
+             view(arg_viewlist(v, :));
+             if (~strcmp(arg_plotname,'default'))
+                fname = sprintf('%s_view%.02d_epoch%.03d.ps', arg_plotname, v, epoch);
+             else
+                fname = sprintf('3d_locations_view%.02d_epoch%.03d.ps', v, epoch);
+             end
+             print('-dpsc', fname);
+          end
 
-      % set up viewlist as: arg_viewlist = [ az el; az el; ... ];
-      for v = 1 : size(arg_viewlist, 1)
-         view(arg_viewlist(v, :));
-         fname = sprintf('3d_locations%d_epoch%.03d.ps', v, epoch);
-         print('-dpsc', fname);
-      end
-
     end   % 2d vs 3d
+    disp('Plot(s) written to disk.');
  end  % create .ps files?
  
 end  % for epoch  (main loop)
@@ -466,7 +505,7 @@
 % given a raw data array and possible selectors, return
 % the subset of rows which match.
 
-function out = select_subset(raw, used, box, number)
+function out = select_subset(raw, dartqc, box, number)
 
 % default is to assume we found no data.  set it at the
 % end if we get there.
@@ -480,14 +519,14 @@
 
 % select based on dart QC flag
 % -99 implies everything, -3 implies 0,1,2,3 
-if (used < 0)
-  data = raw(raw(:,6) <= abs(used),:);
-elseif (used >= 0)
-  data = raw(raw(:,6) ==     used ,:);
+if (dartqc < 0)
+  data = raw(raw(:,6) <= abs(dartqc),:);
+elseif (dartqc >= 0)
+  data = raw(raw(:,6) ==     dartqc ,:);
 end
 
 if (isequal(data, []))
-  fprintf('all observations removed after used/unused selection\n');
+  fprintf('all observations removed after DART QC selection\n');
   return
 end
 
@@ -526,7 +565,7 @@
 
 out = data;
 
-end % function out = select_subset(raw, used, box, number)
+end % function out = select_subset(raw, dartqc, box, number)
 
 %------------------------------------------------------
 % generate a list of R random numbers between 1 and N

Modified: DART/trunk/diagnostics/matlab/plot_observation_locations.m
===================================================================
--- DART/trunk/diagnostics/matlab/plot_observation_locations.m	2008-02-15 00:21:19 UTC (rev 3238)
+++ DART/trunk/diagnostics/matlab/plot_observation_locations.m	2008-02-15 16:05:33 UTC (rev 3239)
@@ -25,9 +25,9 @@
 % setup all args to be the string 'default', which will be interpreted by 
 % the PlotObsLocs routine to use the default values.   
  
+ncfname     = 'default';
 plotd       = 'default';
-ncfname     = 'default';
-used        = 'default';
+dartqc      = 'default';
 typelist    = 'default';
 box         = 'default';
 epochs      = 'default';
@@ -36,11 +36,15 @@
 writeplot   = 'default';
 loc2dstring = 'default';
 loc3dstring = 'default';
+orientation = 'default';
 viewlist    = 'default';
 invertz     = 'default';
- 
+plotname    = 'default';
+
 % what the arg list looks like:
-%PlotObsLocs(in_used, in_box, in_typelist, in_epochlist, in_subset, in_plotd, in_world, in_invertz, in_writeplot, in_legend2dloc, in_legend_3dloc, in_viewlist)
+%PlotObsLocs(in_dartqc, in_box, in_typelist, in_epochlist, in_subset, in_plotd, 
+%             in_world, in_invertz, in_writeplot, in_legend2dloc, in_legend_3dloc, 
+%             in_viewlist, in_ncfname, in_orientation, in_plotname)
 
 done = 0;
 disp('Plot observations at their proper locations.  Many subsetting options exist.');
@@ -53,7 +57,7 @@
 disp(' '); 
 
    % What file has the metadata 
-   reply = input('Enter the netCDF file name with the metadata:  ');
+   reply = input('Enter the netCDF file name with the metadata (default: ''obs_diag_output.nc''):  ');
    if (~isempty(reply))
       ncfname = reply;
    end
@@ -62,13 +66,13 @@
 while done == 0
 
    % 2D or 3D plot?
-   reply = input('Input 2 for 2D plot, 3 for 3D plot:  ');
+   reply = input('Input 2 for 2D plot, 3 for 3D plot (default: 2D):  ');
    if (~isempty(reply))
       plotd = reply;
    end
 
     
-   % plot used, unused, or both
+   % plot selecting on dart QC value
    disp('')
    disp('DART QC Values ... 0 == all OK')
    disp('DART QC Values ... 1 == Evaluated only')
@@ -80,9 +84,9 @@
    disp('DART QC Values ... 7 == outlier rejected')
    disp('   a negative value means everything ''up to'' that value, i.e.')
    disp('    -3 == 0, 1, 2, and 3          -99 == everything');
-   reply = input('Input DART QC val:  ');
+   reply = input('Input DART QC val (default: 0):  ');
    if (~isempty(reply))
-      used = reply;
+      dartqc = reply;
    end
    
    % restrict observations to a particular observation type?
@@ -111,18 +115,34 @@
    end
     
    % plot world map beneath?
-   reply = input('Input 0 to remove world map, 1 to restore it:  ');
+   reply = input('Input 0 to remove world map, 1 to restore it (default: 1):  ');
    if (~isempty(reply))
       world = reply;
    end
     
    % write out .ps files?
-   reply = input('Input 1 to write .ps files for each plot, 0 to reset:  ');
+   reply = input('Input 1 to write .ps files for each plot, 0 to reset (default: 0):  ');
    if (~isempty(reply))
       writeplot = reply;
    end
     
+   % output plot filename
+   if (writeplot == 1)
+      reply = input('Set output plot filename, ''default'' to reset:  ');
+      if (~isempty(reply))
+         plotname = reply;
+      end
+   end
+    
    % legendloc
+   disp('Examples of valid legend strings:');
+   disp(' ''North'' : inside plot box near top');
+   disp(' ''South'',''East'',''West'',''NorthEast'', etc');
+   disp(' ''NorthOutside'' : outside plot box near top');
+   disp(' ''SouthOutside'', ''NorthEastOutside'', etc');
+   disp(' ''Best'' : least conflict with data in plot');
+   disp(' ''BestOutside'' : least unused space outside plot');
+   disp(' defaults to: ''SouthWest'' for 2D plots; ''NorthWest'' for 3D plots');
    reply = input('Input Matlab string for legend location, ''default'' to reset:  ');
    if (~isempty(reply))
       if (plotd == 3)
@@ -132,6 +152,13 @@
       end
    end
     
+   % page orientation
+   disp('Possible page orientations: ''landscape'', ''portrait'', ''tall'' ');
+   reply = input('Input Matlab string for page orientation, ''default'' to reset (default: ''landscape''):  ');
+   if (~isempty(reply))
+      orientation = reply;
+   end
+    
    % viewlist and invert z axis
    invertz = 1;
    if (plotd == 3) 
@@ -146,7 +173,8 @@
       end
    end
     
-   PlotObsLocs(used, box, typelist, epochs, subset, plotd, world, invertz, writeplot, loc2dstring, loc3dstring, viewlist)
+   PlotObsLocs(dartqc, box, typelist, epochs, subset, plotd, world, invertz, writeplot, ...
+               loc2dstring, loc3dstring, viewlist, ncfname, orientation, plotname);
    
    reply = input('Quit now or plot again? 1 = quit, <cr> plots again:  ');
    if (~isempty(reply))


More information about the Dart-dev mailing list