[Dart-dev] DART/branches Revision: 11143
dart at ucar.edu
dart at ucar.edu
Wed Feb 22 17:48:35 MST 2017
thoar at ucar.edu
2017-02-22 17:48:35 -0700 (Wed, 22 Feb 2017)
51
These work with the native Matlab netCDF support.
Modified: DART/branches/rma_trunk/diagnostics/matlab/nc_var_dims.m
===================================================================
--- DART/branches/rma_trunk/diagnostics/matlab/nc_var_dims.m 2017-02-22 23:36:36 UTC (rev 11142)
+++ DART/branches/rma_trunk/diagnostics/matlab/nc_var_dims.m 2017-02-23 00:48:35 UTC (rev 11143)
@@ -32,7 +32,7 @@
varinfo = ncinfo(ncfname,varname);
dimsizes = varinfo.Size;
rank = length(dimsizes);
- dimnames = cell(rank,1);
+ dimnames = cell(1,rank);
for idim = 1:rank
dimnames{idim} = varinfo.Dimensions(idim).Name;
end
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 23:36:36 UTC (rev 11142)
+++ DART/branches/rma_trunk/diagnostics/matlab/plot_bias_xxx_profile.m 2017-02-23 00:48:35 UTC (rev 11143)
@@ -63,7 +63,12 @@
addRequired(p,'fname', at ischar);
addRequired(p,'copy', at ischar);
-addParamValue(p,'obsname',default_obsname, at ischar);
+if (exist('inputParser/addParameter','file') == 2)
+ addParameter(p,'obsname',default_obsname, at ischar);
+else
+ addParamValue(p,'obsname',default_obsname, at ischar);
+end
+
parse(p, fname, copy, varargin{:});
% if you want to echo the input
@@ -87,34 +92,27 @@
plotdat.fname = fname;
plotdat.copystring = copy;
-plotdat.binseparation = nc_read_att(fname, nc_global, 'bin_separation');
-plotdat.binwidth = nc_read_att(fname, nc_global, 'bin_width');
-time_to_skip = nc_read_att(fname, nc_global, 'time_to_skip');
-plotdat.lonlim1 = nc_read_att(fname, nc_global, 'lonlim1');
-plotdat.lonlim2 = nc_read_att(fname, nc_global, 'lonlim2');
-plotdat.latlim1 = nc_read_att(fname, nc_global, 'latlim1');
-plotdat.latlim2 = nc_read_att(fname, nc_global, 'latlim2');
-plotdat.biasconv = nc_read_att(fname, nc_global, 'bias_convention');
+plotdat.binseparation = nc_read_att(fname, '/', 'bin_separation');
+plotdat.binwidth = nc_read_att(fname, '/', 'bin_width');
+time_to_skip = nc_read_att(fname, '/', 'time_to_skip');
+plotdat.lonlim1 = nc_read_att(fname, '/', 'lonlim1');
+plotdat.lonlim2 = nc_read_att(fname, '/', 'lonlim2');
+plotdat.latlim1 = nc_read_att(fname, '/', 'latlim1');
+plotdat.latlim2 = nc_read_att(fname, '/', 'latlim2');
+plotdat.biasconv = nc_read_att(fname, '/', 'bias_convention');
-plotdat.mlevel = local_nc_varget(fname, 'mlevel');
-plotdat.plevel = local_nc_varget(fname, 'plevel');
-plotdat.plevel_edges = local_nc_varget(fname, 'plevel_edges');
-plotdat.hlevel = local_nc_varget(fname, 'hlevel');
-plotdat.hlevel_edges = local_nc_varget(fname, 'hlevel_edges');
-plotdat.bincenters = nc_varget(fname, 'time');
-plotdat.binedges = nc_varget(fname, 'time_bounds');
-plotdat.region_names = nc_varget(fname, 'region_names');
-plotdat.nregions = nc_dim_exists(fname,'region');
+plotdat.mlevel = local_ncread(fname, 'mlevel');
+plotdat.plevel = local_ncread(fname, 'plevel');
+plotdat.plevel_edges = local_ncread(fname, 'plevel_edges');
+plotdat.hlevel = local_ncread(fname, 'hlevel');
+plotdat.hlevel_edges = local_ncread(fname, 'hlevel_edges');
+plotdat.bincenters = ncread(fname, 'time');
+plotdat.binedges = ncread(fname, 'time_bounds');
+plotdat.region_names = ncread(fname, 'region_names')';
+[plotdat.nregions,~] = nc_dim_info(fname,'region');
-% Matlab wants character matrices to be Nx1 instead of 1xN.
-
-if (plotdat.nregions == 1 && (size(plotdat.region_names,2) == 1) )
- plotdat.region_names = deblank(plotdat.region_names');
-end
-
% Coordinate between time types and dates
-calendar = nc_read_att(fname,'time','calendar');
timeunits = nc_read_att(fname,'time','units');
timebase = sscanf(timeunits,'%*s%*s%d%*c%d%*c%d'); % YYYY MM DD
timeorigin = datenum(timebase(1),timebase(2),timebase(3));
@@ -174,8 +172,7 @@
% get appropriate vertical coordinate variable
- [dimnames, ~] = nc_var_dims( fname, plotdat.guessvar);
- varinfo = nc_getvarinfo(fname, plotdat.analyvar);
+ [dimnames,~] = nc_var_dims(fname, plotdat.guessvar);
% this is a superfluous check ... FindVerticalVars already weeds out
% variables only present on surface or undef because obs_diag
@@ -220,27 +217,20 @@
level_edges = sort(plotdat.level_edges);
plotdat.level_edges = level_edges;
- guess = nc_varget(fname, plotdat.guessvar);
- analy = nc_varget(fname, plotdat.analyvar);
- n = size(analy);
More information about the Dart-dev
mailing list