Changeset 179 for trunk/src/read_get_field.m
- Timestamp:
- Jan 9, 2011, 12:56:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/read_get_field.m
r105 r179 179 179 else 180 180 dimname_y=Field.VarDimName{VarIndex}; 181 %check consistency of dimensions182 181 nbvar=nbvar+1; 183 182 ListVarName{nbvar}=Field.ListVarName{VarIndex}; … … 201 200 SubVarAttribute{nbvar}.Role='coord_y';%abcissa with unstructured coordinates 202 201 end 203 % if isequal(dimname_y,dimname_x)204 % errormsg='identical x and y coordinates selected in get_field';205 % return206 % end207 202 end 208 203 … … 214 209 VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName 215 210 if isempty(VarIndex)% default abscissa = matrix index 216 % coord_z_name=dimname_A{1};% name of the x coordinate = dimension of the plotted quantity 217 % empty_coord_z=1; 211 empty_coord_z=1; 218 212 else 219 213 dimname_z=Field.VarDimName{VarIndex}; 220 %check consistency of dimensions 221 if ~isequal(dimname_z,dimname_A) 222 for icoord=1:numel(dimname_A) 223 if strcmp(dimname_z,dimname_A{icoord})% a dimension variable 224 dim_z=icoord; 225 break 214 nbvar=nbvar+1; 215 ListVarName{nbvar}=Field.ListVarName{VarIndex}; 216 VarDimName{nbvar}=dimname_y; 217 if numel(VarAttribute)>=VarIndex 218 SubVarAttribute{nbvar}=VarAttribute{VarIndex}; 219 end 220 %check consistency of dimensions 221 if ~isequal(dimname_y,dimname_A)% case of dimension variables 222 if iscell(dimname_y) 223 if numel(dimname_y)==1 224 dimname_y=dimname_y{1};%transform to char chain 225 else 226 errormsg='invalid y coordinate selection in get_field'; 227 return 226 228 end 227 229 end 228 if ~dim_z 229 errormsg='inconsistent dimensions for coordinate z'; 230 return 231 end 232 end 233 nbvar=nbvar+1; 234 ListVarName{nbvar}=Field.ListVarName{VarIndex}; 235 VarDimName{nbvar}=dimname_z; 236 if numel(VarAttribute)>=VarIndex 237 SubVarAttribute{nbvar}=VarAttribute{VarIndex}; 238 end 239 if dim_z 230 test_zdimvar=1; 240 231 SubVarAttribute{nbvar}.Role='dimvar';% dimension variable 241 232 else 242 SubVarAttribute{nbvar}.Role='coord_z';% z coordinatewith unstructured coordinates233 SubVarAttribute{nbvar}.Role='coord_z';%abcissa with unstructured coordinates 243 234 end 244 235 end … … 456 447 %permute indices if coord_y is not the first matrix index: scalar case 457 448 if test_scalar 458 VarNameA=Field.ListVarName{VarIndexA}; 459 DimCellA=Field.VarDimName{VarIndexA}; 460 eval(['npxy=size(SubField.' VarNameA ');']) 449 VarNameA=Field.ListVarName{VarIndexA};%name of the scalar variable 450 DimCellA=Field.VarDimName{VarIndexA}; %dimension names for the scalar variable 451 eval(['npxy=size(SubField.' VarNameA ');'])%zize of the scalar variable 461 452 SingleCellA={}; 462 453 if numel(npxy) < numel(DimCellA) … … 464 455 DimCellA=DimCellA(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 465 456 end 466 ind_single=find(npxy==1); 467 if ~isempty(ind_single) 468 %SingleCellA=[SingleCellA DimCellA(ind_single)];TO CHECK 469 end 457 %ind_single=find(npxy==1); 470 458 ind_select=find(npxy~=1);%look for non singleton dimensions 471 DimCellA=DimCellA(ind_select); 459 DimCellA=DimCellA(ind_select);%dimension names for the scalar variable, after removing singletons 472 460 npxy=npxy(ind_select); 473 461 dimA=[]; 474 462 if test_zdimvar%dim_x && dim_y && ~isempty(VarSubIndexA) 475 for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 476 if strcmp(dimname_z,SingleCellA{icoord})% a singleton dimension 477 errormsg=['the singleton dimension ' dimname_z ' has been selected for z']; 478 return 479 end 480 end 481 for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 482 if strcmp(dimname_z,DimCellA{icoord})% a dimension variable 483 dimA=[dimA icoord]; 484 break 485 end 486 end 463 ind_singleton=find(strcmp(dimname_z,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions 464 if ~isempty(ind_singleton) 465 errormsg=['the singleton dimension ' dimname_z ' has been selected for z']; 466 return 467 end 468 icoord=find(strcmp(dimname_z,DimCellA),1);% a dimension variable 469 dimA=[dimA icoord]; 470 % for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 471 % if strcmp(dimname_z,DimCellA{icoord})% a dimension variable 472 % dimA=[dimA icoord]; 473 % break 474 % end 475 % end 487 476 end 488 477 if test_ydimvar%dim_x && dim_y && ~isempty(VarSubIndexA) 489 for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 490 if strcmp(dimname_y,SingleCellA{icoord})% a singleton dimension 491 errormsg=['the singleton dimension ' dimname_y ' has been selected for ordinate']; 492 return 493 end 494 end 495 for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 496 if strcmp(dimname_y,DimCellA{icoord})% a dimension variable 497 dimA=[dimA icoord]; 498 break 499 end 500 end 501 end 502 if test_xdimvar%dim_x && dim_y && ~isempty(VarSubIndexA) 503 for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 504 if strcmp(dimname_x,SingleCellA{icoord})% a singleton dimension 505 errormsg=['the singleton dimension ' dimname_x ' has been selected for abscissa']; 506 return 507 end 508 end 509 for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 510 if strcmp(dimname_x,DimCellA{icoord})% a dimension variable 511 dimA=[dimA icoord]; 512 break 513 end 514 end 478 ind_singleton=find(strcmp(dimname_y,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions 479 if ~isempty(ind_singleton) 480 errormsg=['the singleton dimension ' dimname_y ' has been selected for ordinate']; 481 return 482 end 483 icoord=find(strcmp(dimname_y,DimCellA),1);% a dimension variable 484 dimA=[dimA icoord]; 485 end 486 if test_xdimvar 487 ind_singleton=find(strcmp(dimname_x,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions 488 if ~isempty(ind_singleton) 489 errormsg=['the singleton dimension ' dimname_x ' has been selected for ordinate']; 490 return 491 end 492 icoord=find(strcmp(dimname_x,DimCellA),1);% a dimension variable 493 dimA=[dimA icoord]; 515 494 end 516 495 dimextra=(1:numel(DimCellA));
Note: See TracChangeset
for help on using the changeset viewer.