Changeset 674 for trunk/src/struct2nc.m
- Timestamp:
- Aug 23, 2013, 2:56:17 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/struct2nc.m
r530 r674 47 47 return 48 48 end 49 % [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure49 %check the validity of the input field structure 50 50 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data); 51 51 if ~isempty(errormsg) … … 139 139 %'check_field_structure': check the validity of the field struture representation consistant with the netcdf format 140 140 %------------------------------------------------------------------------ 141 % function [DataOut,errormsg]=check_field_structure(Data)141 % [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data) 142 142 % 143 143 % OUTPUT: 144 % DataOut: structure reproducing the input structure Data (TODO: suppress this output)145 144 % errormsg: error message which is not empty when the input structure does not have the right form 145 % ListDimName: list of dimension names (cell array of cahr strings) 146 % DimValue: list of dimension values (numerical array with the same dimension as ListDimName) 147 % VarDimIndex: cell array of dimension index (in the list ListDimName) for each element of Data.ListVarName 146 148 % 147 149 % INPUT: … … 179 181 return 180 182 end 181 % if isfield(Data,'DimValue')182 % Data=rmfield(Data,'DimValue');183 % end184 183 nbdim=0; 185 184 ListDimName={}; 186 185 187 186 %% main loop on the list of variables 187 VarDimIndex=cell(1,nbfield); 188 188 for ivar=1:nbfield 189 189 VarName=Data.ListVarName{ivar}; … … 198 198 elseif ~iscell(DimCell) 199 199 errormsg=['wrong format for .VarDimName{' num2str(ivar) ' (must be the cell of dimension names of the variable ' VarName]; 200 return 201 200 return 202 201 end 203 202 nbcoord=numel(sizvar);%nbre of coordinates for variable named VarName … … 209 208 if nbcoord==2 210 209 if sizvar(1)==1 211 nbcoord=1;212 210 sizvar(1)=sizvar(2); 213 211 elseif sizvar(2)==1 214 nbcoord=1;215 212 else 216 213 errormsg=['1 dimension declared in .VarDimName{' num2str(ivar) '} inconsistent with the nbre of dimensions =2 of the variable ' VarName]; … … 227 224 if numel(DimCell)>nbcoord 228 225 sizvar(nbcoord+1:numel(DimCell))=1;% case of singleton dimensions (not seen by the function size) 229 % DimCell=DimCell(end-nbcoord+1:end)%first singleton diemensions omitted,230 226 elseif nbcoord > numel(DimCell) 231 227 errormsg=['nbre of declared dimensions in .VarDimName{' num2str(ivar) '} smaller than the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName]; … … 234 230 end 235 231 DimIndex=[]; 236 %for idim=1:nbcoord237 232 for idim=1:numel(DimCell) %loop on the coordinates of variable #ivar 238 233 DimName=DimCell{idim}; … … 261 256 VarDimIndex{ivar}=DimIndex; 262 257 end 263 DataOut=Data;
Note: See TracChangeset
for help on using the changeset viewer.