Warning, /utils/matlab/gmt/find_all_iters_per_var.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
6802a9bca5 Ed H*0001 function [vit] = find_all_iters_per_var(fall,vnames,vit)
0002
0003 % Function [vit] = find_all_iters_per_var(fall)
0004 %
0005 % INPUTS
0006 % fall cell array of file names
0007 % vanmes cell array list of variable names
0008 % vit variable iteration/time information
0009 % struct with fields: 'tdname', 'tvname', 'vars'
0010 %
0011 % OUTPUTS
0012 % vit ...see above...
0013 %
0014 %
0015 % Ed Hill
0016 if isempty(vit) || not(isfield(vit,'tdname')) || isempty(vit.tdname)
0017 vit.tdname = 'T';
0018 end
0019 if isempty(vit) || not(isfield(vit,'tvname')) || isempty(vit.tvname)
0020 vit.tvname = 'iter';
0021 end
0022
0023 for ii = 1:length(fall)
b3b2b7d964 Ed H*0024 % ii
6802a9bca5 Ed H*0025 nc = netcdf(fall{ii},'read');
0026
0027 if isempty(vnames)
0028 allv = ncnames(var(nc));
0029 else
0030 allv = vnames;
0031 end
0032 if isempty(intersect( ncnames(dim(nc)), vit.tdname ))
0033 % The "time" dimension does not exist in this file so no variable can
0034 % use it
0035 for jj = 1:length(allv)
0036 vit.vars.(allv{jj}) = [];
0037 end
0038 else
0039 if isempty(intersect( ncnames(var(nc)), vit.tvname ))
0040 % Here, the time dimension does exist but the coordinate varible
0041 % doesn't so theres no clear way to determine how the variable
0042 % should be stitched together based solely on this coordinate
0043 % variable.
0044 disp(['WARNING: the "time" dimension ''' vit.tdname ...
0045 ''' exists in file ''' fall{ii} ...
0046 ''' but the coordinate variable ''' vit.tvname ...
0047 ''' doesn''t so theres no way to determine ordering ' ...
0048 'across files!']);
0049 for jj = 1:length(allv)
0050 vit.vars.(allv{jj}) = [];
0051 end
0052 else
b3b2b7d964 Ed H*0053 % allv
6802a9bca5 Ed H*0054 for jj = 1:length(allv)
b3b2b7d964 Ed H*0055 % allv{jj}
0056 % nc{allv{jj}}
0057 if isempty(nc{allv{jj}})
0058 vit.vars.(allv{jj}) = [];
0059 continue;
0060 end
6802a9bca5 Ed H*0061 if isempty(intersect( ncnames(dim(nc{allv{jj}})), vit.tdname ))
0062 vit.vars.(allv{jj}) = [];
0063 else
0064 if not(isfield(vit,'vars')) ...
0065 || not(isfield(vit.vars,allv{jj}))
0066 vit.vars.(allv{jj}) = nc{vit.tvname}(:);
0067 else
0068 vit.vars.(allv{jj}) = ...
0069 union( vit.vars.(allv{jj}), nc{vit.tvname}(:) );
0070 end
0071 end
0072 end
0073 end
0074 end
0075
0076 nc = close(nc);
0077 end