[Dart-dev] [4535] DART/trunk/diagnostics/matlab/plot_rank_histogram.m: Added the feature that if you use a negative timestep index,
nancy at ucar.edu
nancy at ucar.edu
Wed Oct 20 14:02:34 MDT 2010
Revision: 4535
Author: thoar
Date: 2010-10-20 14:02:34 -0600 (Wed, 20 Oct 2010)
Log Message:
-----------
Added the feature that if you use a negative timestep index,
all available timesteps will be added together. I wonder how long
it will take for someone to ask if they can specify a range of indices.
let the clock start now ...
Modified Paths:
--------------
DART/trunk/diagnostics/matlab/plot_rank_histogram.m
-------------- next part --------------
Modified: DART/trunk/diagnostics/matlab/plot_rank_histogram.m
===================================================================
--- DART/trunk/diagnostics/matlab/plot_rank_histogram.m 2010-10-18 22:13:37 UTC (rev 4534)
+++ DART/trunk/diagnostics/matlab/plot_rank_histogram.m 2010-10-20 20:02:34 UTC (rev 4535)
@@ -30,13 +30,20 @@
% plotdat = plot_rank_histogram(fname, timeindex);
%
%
-% EXAMPLE 2 - rank histogram for the radiosonde temperature observations.
+% EXAMPLE 2 - rank histogram for a particular timestep of radiosonde temperature observations.
% This requires knowledge that 'RADIOSONDE_TEMPERATURE' is an
% observation type in the netCDF file.
%
% fname = 'obs_diag_output.nc'; % netcdf file produced by 'obs_diag'
% timeindex = 3; % plot the histogram for the third timestep
% plotdat = plot_rank_histogram(fname, timeindex, 'RADIOSONDE_TEMPERATURE');
+%
+%
+% EXAMPLE 3 - single rank histogram for all timesteps of radiosonde temperature observations.
+%
+% fname = 'obs_diag_output.nc'; % netcdf file produced by 'obs_diag'
+% timeindex = -1; % use ALL available timesteps
+% plotdat = plot_rank_histogram(fname, timeindex, 'RADIOSONDE_TEMPERATURE');
%% DART software - Copyright � 2004 - 2010 UCAR. This open source software is
% provided by UCAR, "as is", without charge, subject to all terms of use at
@@ -75,7 +82,6 @@
% Harvest plotting info/metadata from netcdf file.
plotdat.fname = fname;
-plotdat.timeindex = timeindex;
plotdat.timecenters = nc_varget(fname,'time');
plotdat.timeedges = nc_varget(fname,'time_bounds');
plotdat.mlevel = nc_varget(fname,'mlevel');
@@ -128,8 +134,14 @@
plotdat.Ntimes = length(plotdat.timecenters);
plotdat.toff = plotdat.timecenters(1) + iskip;
-plotdat.timespan = sprintf('%s -- %s', datestr(plotdat.timeedges(timeindex,1),21), ...
- datestr(plotdat.timeedges(timeindex,2),21));
+if ( timeindex < 1 )
+ plotdat.timeindex = 1:plotdat.Ntimes;
+ plotdat.timespan = sprintf('%s -- %s', datestr(min(plotdat.timeedges(:,1)),21), ...
+ datestr(max(plotdat.timeedges(:,2)),21));
+else
+ plotdat.timespan = sprintf('%s -- %s', datestr(plotdat.timeedges(timeindex,1),21), ...
+ datestr(plotdat.timeedges(timeindex,2),21));
+end
% set up a structure with all static plotting components
@@ -207,6 +219,13 @@
rhist_raw = nc_varget(fname, plotdat.rhistvar);
rhist = reshape(rhist_raw, plotdat.Ntimes, plotdat.Nrhbins, ...
plotdat.nlevels, plotdat.nregions);
+
+ % Collapse the time dimension if need be.
+ if ( timeindex < 0 )
+ guess = sum(guess,1);
+ rhist = sum(rhist,1);
+ plotdat.timeindex = 1;
+ end
% check to see if there is anything to plot
nposs = sum(guess(plotdat.timeindex,plotdat.Npossindex,:,:));
More information about the Dart-dev
mailing list