Ignore:
Timestamp:
Feb 27, 2011, 10:40:29 PM (13 years ago)
Author:
sommeria
Message:

bug fixes to deal with volumes, storage of ACTION menu in series fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_get_field.m

    r179 r206  
    388388           
    389389    if test3D %  (a revoir) 
    390          %scalar w variable
     390        %scalar w variable
    391391        inputlist=get(handles.vector_z,'String');
    392392        val=get(handles.vector_z,'Value');%selected indices in the ordinate listbox
    393393        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
    409411    end 
    410412   
     
    446448
    447449%permute indices if coord_y is not the first matrix index: scalar case
     450NbDim=2; %default
    448451if test_scalar
    449452    VarNameA=Field.ListVarName{VarIndexA};%name of the scalar variable
     
    455458        DimCellA=DimCellA(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
    456459    end
    457     %ind_single=find(npxy==1);
    458460    ind_select=find(npxy~=1);%look for non singleton dimensions
    459461    DimCellA=DimCellA(ind_select);%dimension names for the scalar variable, after removing singletons
     
    461463    dimA=[];
    462464    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)
    463466        ind_singleton=find(strcmp(dimname_z,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions
    464467        if ~isempty(ind_singleton)
     
    468471        icoord=find(strcmp(dimname_z,DimCellA),1);% a dimension variable
    469472        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
    476473    end
    477474    if test_ydimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
     
    507504        end
    508505        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
    510507        npxy=npxy(ind_select);
    511508        testold=0;
     
    519516        end
    520517        if empty_coord_x       
    521                 coord_x_name=DimCell{2};
     518                coord_x_name=DimCell{NbDim};
    522519                SubField.ListVarName=[{coord_x_name} SubField.ListVarName];
    523520                SubField.VarDimName=[{coord_x_name} SubField.VarDimName]; 
     
    525522                    eval(['SubField.' coord_x_name '=linspace(Coord_2(1),Coord_2(end),npxy(2));'])
    526523                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];'])
    528525                end
    529526           
     
    536533        end
    537534        if empty_coord_y
    538             coord_y_name=DimCell{1};
     535            coord_y_name=DimCell{NbDim-1};
    539536            SubField.ListVarName=[{coord_y_name} SubField.ListVarName];
    540537            SubField.VarDimName=[{coord_y_name} SubField.VarDimName];
     
    542539                eval(['SubField.' coord_y_name '=linspace(Coord_1(1),Coord_1(end),npxy(1));'])
    543540            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];'])
    545542            end
    546543            if ~testold
Note: See TracChangeset for help on using the changeset viewer.