[Dart-dev] DART/branches Revision: 11141

dart at ucar.edu dart at ucar.edu
Wed Feb 22 15:03:21 MST 2017


thoar at ucar.edu
2017-02-22 15:03:20 -0700 (Wed, 22 Feb 2017)
86
These now use the native Matlab netcdf routines rather than the third-party toolbox.




Modified: DART/branches/rma_trunk/diagnostics/matlab/get_varnames.m
===================================================================
--- DART/branches/rma_trunk/diagnostics/matlab/get_varnames.m	2017-02-22 21:57:44 UTC (rev 11140)
+++ DART/branches/rma_trunk/diagnostics/matlab/get_varnames.m	2017-02-22 22:03:20 UTC (rev 11141)
@@ -16,29 +16,38 @@
 %
 % DART $Id$
 
-fileinfo    = nc_info(fname);
-Nvarnames   = length(fileinfo.Dataset);
+fileinfo    = ncinfo(fname);
+Nvarnames   = length(fileinfo.Variables);
 
 inds = [];
 
 for i = 1:Nvarnames
+    
+    varname    = fileinfo.Variables(i).Name;
+    isatmosvar = 1;
+    
+    % Reject the obvious coordinate variables and some that are
+    % specific to DART
+    rank = length(fileinfo.Variables(i).Size);
 
-   varname    = fileinfo.Dataset(i).Name;
-   isatmosvar = 1;
-
-   % Reject the obvious coordinate variables and some that are
-   % specific to DART
-
-   if (         nc_iscoordvar(fname,varname)), isatmosvar = 0; end 
-   if (strcmp( varname ,      'time_bounds')), isatmosvar = 0; end 
-   if (strcmp( varname ,     'region_names')), isatmosvar = 0; end 
-   if (strcmp( varname ,     'CopyMetaData')), isatmosvar = 0; end 
-   if (strcmp( varname , 'ObservationTypes')), isatmosvar = 0; end
-
-   % keep track of the 'good' variables
-   if (isatmosvar > 0)
-      inds = [inds i];
-   end
+    if (rank == 1)
+        dimname = fileinfo.Variables(i).Dimensions(1).Name;
+    else
+        dimname = [];
+    end
+    
+    if (strcmp( varname ,            dimname)), isatmosvar = 0; end
+    if (strcmp( varname ,         'inputnml')), isatmosvar = 0; end
+    if (strcmp( varname ,      'time_bounds')), isatmosvar = 0; end
+    if (strcmp( varname ,     'region_names')), isatmosvar = 0; end
+    if (strcmp( varname ,     'CopyMetaData')), isatmosvar = 0; end
+    if (strcmp( varname ,   'MemberMetadata')), isatmosvar = 0; end
+    if (strcmp( varname , 'ObservationTypes')), isatmosvar = 0; end
+    
+    % keep track of the 'good' variables
+    if (isatmosvar > 0)
+        inds = [inds i];
+    end
 end
 
 if (isempty(inds))
@@ -45,10 +54,11 @@
    error('There are only coordinate variables in %s',fname)
 end
 
-% coerce just the names into a cell array 
-
-for i = 1:length(inds)
-   bob{i} = fileinfo.Dataset(inds(i)).Name;
+% coerce just the names into a cell array
+ngood = length(inds);
+bob = cell(ngood,1);
+for i = 1:ngood
+   bob{i} = fileinfo.Variables(inds(i)).Name;
 end
 
 

Modified: DART/branches/rma_trunk/diagnostics/matlab/get_varsNdims.m
===================================================================
--- DART/branches/rma_trunk/diagnostics/matlab/get_varsNdims.m	2017-02-22 21:57:44 UTC (rev 11140)
+++ DART/branches/rma_trunk/diagnostics/matlab/get_varsNdims.m	2017-02-22 22:03:20 UTC (rev 11141)
@@ -34,11 +34,17 @@
 for i = 1:Nvarnames
 
    varname = ALLvarnames{i};
-   varinfo = nc_getvarinfo(fname,varname);
+   y{i}    = varname;
+   
+   varinfo = ncinfo(fname,varname);
+   ydims{i} = varinfo.Dimensions(1).Name;
+   
+   rank = length(varinfo.Size);
+    
+   for idim = 2:rank
+      ydims{i} = sprintf('%s %s',ydims{i}, varinfo.Dimensions(idim).Name);
+   end
 
-   y{i}     = varname;
-   ydims{i} = sprintf('%s ',varinfo.Dimension{:});
-


More information about the Dart-dev mailing list