Changeset 1195 for trunk/src/nc2struct.m
- Timestamp:
- Feb 26, 2026, 4:16:03 PM (5 days ago)
- File:
-
- 1 edited
-
trunk/src/nc2struct.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/nc2struct.m
r1194 r1195 199 199 end 200 200 ListVarName=ListVarName(:,logical(check_keep)); 201 if size(ListVarName,1)>1 %multiple choice of variable ranked by order of priority 202 for iline=1:size(ListVarName,1) 203 search_index=find(strcmp(ListVarName{iline,1},ListVarNameNetcdf),1);%look for the first variable name in the list of NetCDF variables 204 if ~isempty(search_index) 205 break % go to the next line 206 end 207 end 208 ichoice=iline-1;%selected line number in the list of input names of variables 209 else 210 iline=1; 211 end 201 iline=size(ListVarName,1); 212 202 %ListVarName=ListVarName(iline,:);% select the appropriate option for input variable (lin ein the input name matrix) 213 203 if CheckTimeVar … … 274 264 VarName=Data.ListVarName{ivar}; 275 265 VarName=regexprep(VarName,'-','_'); %suppress '-' if it exists in the NetCDF variable name (leads to errors in matlab) 276 % CheckSub=0;277 266 if input_index==4% if a dimension is selected as time 278 267 ind_vec=zeros(1,numel(var_dim{ivar}));% vector with zeros corresponding to al the dimensions of the variable VarName … … 290 279 end 291 280 end 292 % tstart = tic;293 % disp(VarName)294 281 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size); %read the variable data 295 % telapsed = toc(tstart)296 282 Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension 297 298 283 else 284 disp(VarName) 285 xtype(var_index(ivar)) 299 286 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data 300 end 301 if xtype(var_index(ivar))==5% indicate single precision variable 302 Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision 287 end 288 Data.(VarName)=double(Data.(VarName)); %transform all variables to double pecision 289 if isfield(Data,'VarAttribute') && numel(Data.VarAttribute)>=ivar && isfield(Data.VarAttribute{ivar},'scale_factor') 290 Data.(VarName)=Data.VarAttribute{ivar}.scale_factor *Data.(VarName); 303 291 end 304 292 end
Note: See TracChangeset
for help on using the changeset viewer.
