Changeset 399 for trunk/src/find_field_indices.m
- Timestamp:
- Apr 27, 2012, 12:28:47 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_field_indices.m
r397 r399 58 58 VarDimIndex=[]; 59 59 VarDimName={}; 60 61 60 if ~isfield(Data,'VarDimName') 62 61 errormsg='missing .VarDimName'; … … 64 63 end 65 64 66 % loop on the list of variables65 %% loop on the list of variables, group them by common dimensions 67 66 for ivar=1:nbvar 68 67 DimCell=Data.VarDimName{ivar}; %dimensions associated with the variable #ivar … … 85 84 CellVarIndex{icell}=ivar;%put the current variabl index in the new cell 86 85 end 87 86 88 87 %look for dimension variables 89 88 if numel(DimCell)==1% if the variable has a single dimension … … 100 99 end 101 100 102 % find the spatial dimensions and vector components101 %% find the spatial dimensions and vector components 103 102 ListRole={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','warnflag','errorflag',... 104 103 'ancillary','image','color','discrete','scalar','coord_tps'}; 104 NbDim=zeros(size(CellVarIndex));%default 105 105 for icell=1:length(CellVarIndex) 106 106 for ilist=1:numel(ListRole) … … 142 142 return 143 143 end 144 % if ivar_vector_x>1145 % ivar_vector_x=ivar_vector_x(1);146 % end147 % if ivar_vector_y>1148 % ivar_vector_y=ivar_vector_y(1);149 % end150 % if ivar_vector_z>1151 % ivar_vector_z=ivar_vector_z(1);152 % end153 144 if numel(ivar_errorflag)>1 154 145 errormsg='multiply defined error flag in the same cell'; … … 159 150 return 160 151 end 161 %NbDim(icell)=0;% nbre of space dimensions162 % NbDim(icell)=numel(DimCell);163 NbDim(icell)=0;164 152 test_coord=0; 165 153 if numel(VarIndex)>1 … … 193 181 NbDim(icell)=2; 194 182 end 183 %look for tps data 184 if ~isempty(VarType{icell}.coord_tps) 185 VarType{icell}.var_tps=[]; 186 tps_dimnames=Data.VarDimName{VarType{icell}.coord_tps}; 187 if length(tps_dimnames)==3 188 for ilist=1:length(Data.VarDimName) 189 if strcmp(tps_dimnames{1},Data.VarDimName{ilist}{1}) && strcmp(tps_dimnames{3},Data.VarDimName{ilist}{2})% identify the variables corresponding to the tps site coordinates coord_tps 190 VarType{icell}.var_tps=[VarType{icell}.var_tps ilist]; 191 elseif length(Data.VarDimName{ilist})==1 && strcmp(tps_dimnames{3},Data.VarDimName{ilist}{1})% identify the variable corresponding to nbsites 192 VarType{icell}.nbsites_tps= ilist; 193 elseif length(Data.VarDimName{ilist})==3 && strcmp(tps_dimnames{2},Data.VarDimName{ilist}{1})&& strcmp(tps_dimnames{3},Data.VarDimName{ilist}{3})% identify the variable subrange 194 VarType{icell}.subrange_tps= ilist; 195 end 196 end 197 end 198 NbDim(icell)=2; 199 end 195 200 end
Note: See TracChangeset
for help on using the changeset viewer.