[Dart-dev] DART/branches Revision: 11137

dart at ucar.edu dart at ucar.edu
Wed Feb 22 13:20:38 MST 2017


thoar at ucar.edu
2017-02-22 13:20:38 -0700 (Wed, 22 Feb 2017)
204
Replaced third-party nc_getdiminfo with (our) nc_dim_info.
Removed get_ens_size.m -- no longer needed that the 'member' dimension is available.
Removed get_var_series.m -- deprecated a long time ago ...




Modified: DART/branches/rma_trunk/diagnostics/matlab/nc_var_dims.m
===================================================================
--- DART/branches/rma_trunk/diagnostics/matlab/nc_var_dims.m	2017-02-22 20:20:07 UTC (rev 11136)
+++ DART/branches/rma_trunk/diagnostics/matlab/nc_var_dims.m	2017-02-22 20:20:38 UTC (rev 11137)
@@ -1,20 +1,20 @@
-function vdims = nc_var_dims(ncfname,varname);
+function [dimnames, dimsizes] = nc_var_dims(ncfname,varname)
 %% Get the names of the coordinate variables for each 
 % of the dimensions of the variable.
 %
-% vdims = nc_var_dims(ncfname,varname);
+% dimnames = nc_var_dims(ncfname,varname);
 %
 % ncfname    file name of a netcdf file
 % varname    a variable names
-% vdims      a cell array of the coordinate variables
+% dimnames      a cell array of the coordinate variables
 %
 % EXAMPLE:
 % 
 % ncfname = 'obs_seq.final.nc';
 % varname = 'RADIOSONDE_TEMPERATURE_guess';
-% vdims   = nc_var_dims(ncfname,varname);
-% for i = 1:length(vdims)
-%    disp(sprintf('variable %s dimension %d is %s',varname,i,vdims{i}))
+% dimnames   = nc_var_dims(ncfname,varname);
+% for i = 1:length(dimnames)
+%    disp(sprintf('variable %s dimension %d is %s',varname,i,dimnames{i}))
 % end
 
 %% DART software - Copyright UCAR. This open source software is provided
@@ -23,17 +23,23 @@
 %
 % DART $Id$
 
-if ( nc_isvar(ncfname, varname) )
-   varinfo = nc_getvarinfo(ncfname,varname);
-   vdims   = varinfo.Dimension;
+dimnames = [];
+dimsizes = [];
+
+[present, ~] = nc_var_exists(ncfname,varname);
+
+if ( present )
+    varinfo  = ncinfo(ncfname,varname);
+    dimsizes = varinfo.Size;
+    rank     = length(dimsizes);
+    dimnames = cell(rank,1);
+    for idim = 1:rank
+        dimnames{idim} = varinfo.Dimensions(idim).Name;
+    end
 else
-   fprintf('%s does not have a %s variable.\n',ncfname, varname)
-   fprintf('It does have the following:\n')
-   nc_dump(ncfname)
-   error('%s does not have a %s variable.',ncfname, varname)
+    error('%s does not have a %s variable.',ncfname, varname)
 end
 
-
 % <next few lines under version control, do not edit>
 % $URL$
 % $Revision$

Modified: DART/branches/rma_trunk/diagnostics/matlab/plot_bias_xxx_profile.m
===================================================================
--- DART/branches/rma_trunk/diagnostics/matlab/plot_bias_xxx_profile.m	2017-02-22 20:20:07 UTC (rev 11136)
+++ DART/branches/rma_trunk/diagnostics/matlab/plot_bias_xxx_profile.m	2017-02-22 20:20:38 UTC (rev 11137)
@@ -174,19 +174,18 @@
 
    % get appropriate vertical coordinate variable
 
-   guessdims = nc_var_dims(  fname, plotdat.guessvar);
-   analydims = nc_var_dims(  fname, plotdat.analyvar);
-   varinfo   = nc_getvarinfo(fname, plotdat.analyvar);
+   [dimnames, ~] = nc_var_dims(  fname, plotdat.guessvar);
+   varinfo       = nc_getvarinfo(fname, plotdat.analyvar);
 
    % this is a superfluous check ... FindVerticalVars already weeds out
    % variables only present on surface or undef because obs_diag
    % does not time-average statistics for these.
 
-   if (~ isempty(strfind(guessdims{2},'surface')))
+   if (~ isempty(strfind(dimnames{2},'surface')))
       fprintf('%s is a surface field.\n',plotdat.guessvar)
       fprintf('Cannot display a surface field this way.\n')
       continue
-   elseif (~ isempty(strfind(guessdims{2},'undef')))
+   elseif (~ isempty(strfind(dimnames{2},'undef')))
       fprintf('%s has no vertical definition.\n',plotdat.guessvar)
       fprintf('Cannot display this field this way.\n')
       continue

Modified: DART/branches/rma_trunk/diagnostics/matlab/plot_evolution.m
===================================================================
--- DART/branches/rma_trunk/diagnostics/matlab/plot_evolution.m	2017-02-22 20:20:07 UTC (rev 11136)
+++ DART/branches/rma_trunk/diagnostics/matlab/plot_evolution.m	2017-02-22 20:20:38 UTC (rev 11137)
@@ -122,36 +122,30 @@
 
 plotdat.fname         = fname;
 plotdat.copystring    = copy;


More information about the Dart-dev mailing list