Changeset 206 for trunk/src/read_get_field.m
- Timestamp:
- Feb 27, 2011, 10:40:29 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/read_get_field.m
r179 r206 388 388 389 389 if test3D % (a revoir) 390 390 %scalar w variable 391 391 inputlist=get(handles.vector_z,'String'); 392 392 val=get(handles.vector_z,'Value');%selected indices in the ordinate listbox 393 393 VarNameW=inputlist{val}; %name of the variable in the list 394 VarIndex=name2index(VarNameW,Field.ListVarName);%index of the variable in ListVarName 395 %check consistency of dimensions with u 396 dimname_w=Field.VarDimName{VarIndex}; 397 if ~isequal(dimname_w,dimname_u) 398 errormsg='inconsistent dimensions for u and v'; 399 return 400 end 401 nbvar=nbvar+1; 402 % w_index=nbvar; 403 ListVarName{nbvar}=Field.ListVarName{VarIndex}; 404 VarDimName{nbvar}=dimname_u; 405 if numel(VarAttribute)>=VarIndex 406 SubVarAttribute{nbvar}=VarAttribute{VarIndex}; 407 end 408 SubVarAttribute{nbvar}.Role='vector_z'; 394 VarIndex=name2index(VarNameW,Field.ListVarName);%index of the variable in ListVarName 395 %check consistency of dimensions with u 396 if ~isempty( VarIndex) 397 dimname_w=Field.VarDimName{VarIndex}; 398 if ~isequal(dimname_w,dimname_u) 399 errormsg='inconsistent dimensions for u and w'; 400 return 401 end 402 nbvar=nbvar+1; 403 % w_index=nbvar; 404 ListVarName{nbvar}=Field.ListVarName{VarIndex}; 405 VarDimName{nbvar}=dimname_u; 406 if numel(VarAttribute)>=VarIndex 407 SubVarAttribute{nbvar}=VarAttribute{VarIndex}; 408 end 409 SubVarAttribute{nbvar}.Role='vector_z'; 410 end 409 411 end 410 412 … … 446 448 447 449 %permute indices if coord_y is not the first matrix index: scalar case 450 NbDim=2; %default 448 451 if test_scalar 449 452 VarNameA=Field.ListVarName{VarIndexA};%name of the scalar variable … … 455 458 DimCellA=DimCellA(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 456 459 end 457 %ind_single=find(npxy==1);458 460 ind_select=find(npxy~=1);%look for non singleton dimensions 459 461 DimCellA=DimCellA(ind_select);%dimension names for the scalar variable, after removing singletons … … 461 463 dimA=[]; 462 464 if test_zdimvar%dim_x && dim_y && ~isempty(VarSubIndexA) 465 NbDim=3;% field considered as 3D if a z coordinate is defined (to distinguish for instance from 2D color images with 3 components) 463 466 ind_singleton=find(strcmp(dimname_z,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions 464 467 if ~isempty(ind_singleton) … … 468 471 icoord=find(strcmp(dimname_z,DimCellA),1);% a dimension variable 469 472 dimA=[dimA icoord]; 470 % for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar471 % if strcmp(dimname_z,DimCellA{icoord})% a dimension variable472 % dimA=[dimA icoord];473 % break474 % end475 % end476 473 end 477 474 if test_ydimvar%dim_x && dim_y && ~isempty(VarSubIndexA) … … 507 504 end 508 505 ind_select=find(npxy~=1) ;%look for non singleton dimensions 509 DimCell=DimCell(ind_select); 506 DimCell=DimCell(ind_select);%list of dimension names for the scalar, after singleton removal 510 507 npxy=npxy(ind_select); 511 508 testold=0; … … 519 516 end 520 517 if empty_coord_x 521 coord_x_name=DimCell{ 2};518 coord_x_name=DimCell{NbDim}; 522 519 SubField.ListVarName=[{coord_x_name} SubField.ListVarName]; 523 520 SubField.VarDimName=[{coord_x_name} SubField.VarDimName]; … … 525 522 eval(['SubField.' coord_x_name '=linspace(Coord_2(1),Coord_2(end),npxy(2));']) 526 523 else 527 eval(['SubField.' coord_x_name '=[0.5 npxy( 2)-0.5];'])524 eval(['SubField.' coord_x_name '=[0.5 npxy(NbDim)-0.5];']) 528 525 end 529 526 … … 536 533 end 537 534 if empty_coord_y 538 coord_y_name=DimCell{ 1};535 coord_y_name=DimCell{NbDim-1}; 539 536 SubField.ListVarName=[{coord_y_name} SubField.ListVarName]; 540 537 SubField.VarDimName=[{coord_y_name} SubField.VarDimName]; … … 542 539 eval(['SubField.' coord_y_name '=linspace(Coord_1(1),Coord_1(end),npxy(1));']) 543 540 else 544 eval(['SubField.' coord_y_name '=[npxy( 1)-0.5 0.5];'])541 eval(['SubField.' coord_y_name '=[npxy(NbDim-1)-0.5 0.5];']) 545 542 end 546 543 if ~testold
Note: See TracChangeset
for help on using the changeset viewer.