Changeset 231 for trunk/src/proj_field.m


Ignore:
Timestamp:
Apr 5, 2011, 12:46:34 AM (13 years ago)
Author:
sommeria
Message:

interactive test for piv introduced various bug corrections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r227 r231  
    12561256        %% case of input fields defined on a structured  grid
    12571257    else
    1258         'TESTproj'
    1259         VarName=FieldData.ListVarName{VarIndex(1)}%get the first variable of the cell to get the input matrix dimensions
     1258        VarName=FieldData.ListVarName{VarIndex(1)};%get the first variable of the cell to get the input matrix dimensions
    12601259        eval(['DimValue=size(FieldData.' VarName ');'])%input matrix dimensions
    12611260        DimValue(DimValue==1)=[];%remove singleton dimensions
     
    12671266                return
    12681267            else
    1269                 VarType.coord
    12701268                if numel(find(VarType.coord))==2% the third matrix dimension does not correspond to a space coordinate
    12711269                    nbcolor=DimValue(3);
     
    12751273            end
    12761274        end
    1277         testangle
     1275        AYName=FieldData.ListVarName{VarType.coord(NbDim-1)};%name of input x coordinate (name preserved on projection)
     1276        AXName=FieldData.ListVarName{VarType.coord(NbDim)};%name of input y coordinate (name preserved on projection)
    12781277        if testangle% TODO modify name also in case of origin shift in x or y
    1279             AYName='Y';
    1280             AXName='X';
     1278            AYProjName='Y';
     1279            AXProjName='X';
    12811280            count=0;
    12821281            %modify coordinate names if they are already used
    12831282            while ~(isempty(find(strcmp('AXName',ProjData.ListVarName),1)) && isempty(find(strcmp('AYName',ProjData.ListVarName),1)))
    12841283                count=count+1;
    1285                 AYName=[AYName '_' num2str(count)];
    1286                 AXName=[AXName '_' num2str(count)];
     1284                AYProjName=[AYProjName '_' num2str(count)];
     1285                AXProjName=[AXProjName '_' num2str(count)];
    12871286            end
    12881287        else
    1289             AYName=FieldData.ListVarName{VarType.coord(NbDim-1)}%name of input x coordinate (name preserved on projection)
    1290             AXName=FieldData.ListVarName{VarType.coord(NbDim)}%name of input y coordinate (name preserved on projection)
    1291         end
    1292         eval(['AX=FieldData.' AXName ';'])
    1293         eval(['AY=FieldData.' AYName ';'])
     1288            AYProjName=AYName;% (name preserved on projection)
     1289            AXProjName=AXName;%name of input y coordinate (name preserved on projection)
     1290        end
    12941291        ListDimName=FieldData.VarDimName{VarIndex(1)};
    1295             ProjData.ListVarName=[ProjData.ListVarName {AYName} {AXName}]; %TODO: check if it already exists in Projdata (several cells)
    1296             ProjData.VarDimName=[ProjData.VarDimName {AYName} {AXName}];
     1292        ProjData.ListVarName=[ProjData.ListVarName {AYProjName} {AXProjName}]; %TODO: check if it already exists in Projdata (several cells)
     1293        ProjData.VarDimName=[ProjData.VarDimName {AYProjName} {AXProjName}];
    12971294        Coord_z=[];
    12981295        Coord_y=[];
     
    13921389            coord_x_proj=linspace(XMax,XMin,npX);%abscissa of the new pixels along the line
    13931390        end
    1394         % case with no rotation and interpolation
    1395         if isequal(ProjMode,'projection') && ~testangle
    1396             if ~testXMin && ~testXMax && ~testYMin && ~testYMax && NbDim==2
    1397                 ProjData=FieldData;
     1391        % case with no interpolation
     1392        if isequal(ProjMode,'projection') && (~testangle || test90y || test90x)
     1393            if  NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax
     1394                ProjData=FieldData;% no change by projection
    13981395            else
    1399                 indY=NbDim-1;
     1396                test_direct
     1397                indY=NbDim-1
    14001398                if test_direct(indY)
    14011399                    min_indy=ceil((YMin-Coord{indY}(1))/DYinit)+1;
     
    14041402                    Ybound(2)=Coord{indY}(1)+DYinit*(max_indy-1);
    14051403                else
    1406                     min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1;
    1407                     max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1;
    1408                     Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1);
    1409                     Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1);
     1404                    min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1
     1405                    max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1
     1406                    Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1)
     1407                    Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1)
    14101408                end
    14111409                if test_direct(NbDim)==1
     
    14171415                    min_indx=ceil((Coord{NbDim}(1)-XMax)/DXinit)+1;
    14181416                    max_indx=floor((Coord{NbDim}(1)-XMin)/DXinit)+1;
    1419                     Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1);
    1420                    
    1421                    
     1417                    Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1);                         
    14221418                    Xbound(1)=Coord{NbDim}(1)+DXinit*(min_indx-1);
    14231419                end
     
    14261422
    14271423                if test90y
    1428                     'TEST3D'
    14291424                    ind_new=[3 2 1];
    1430                     DimCell=DimCell(ind_new);
    1431                     DimValue=DimValue(ind_new);
    1432                     DimCell(1)=[]; %suppress x variable
    1433                     DimValue(1)=[];
     1425                    DimCell={AYProjName,AXProjName}
     1426%                     DimValue=DimValue(ind_new);
    14341427                    iz=ceil((ObjectData.Coord(1,1)-Coord{3}(1))/DX)+1;
    14351428                    for ivar=VarIndex
     
    14381431                        ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
    14391432                        ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar}; %reproduce the variable attributes
    1440                         eval(['size(FieldData.' VarName ')'])
    1441                         eval(['ProjData.' VarName '=permute(FieldData.' VarName ',ind_new)'])% permute x and z indices for 90 degree rotation
    1442                         eval(['size(ProjData.' VarName ')'])
    1443                         eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz
    1444                     end
    1445                     eval(['ProjData.' AYName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates
    1446                     eval(['ProjData.' AXName '=[Coord{1}(end),Coord{1}(1)];']) %record the new (projected ) x coordinates
     1433                        eval(['ProjData.' VarName '=permute(FieldData.' VarName ',ind_new);'])% permute x and z indices for 90 degree rotation
     1434                        eval(['ProjData.' VarName '=squeeze(ProjData.' VarName '(iz,:,:));'])% select the z index iz
     1435                    end
     1436                    eval(['ProjData.' AYProjName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates
     1437                    eval(['ProjData.' AXProjName '=[Coord{1}(end),Coord{1}(1)];']) %record the new (projected ) x coordinates
    14471438                else
    14481439                    if NbDim==3
     
    14701461                        end
    14711462                    end
    1472                     eval(['ProjData.' AYName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates
    1473                     eval(['ProjData.' AXName '=[Xbound(1) Xbound(2)];']) %record the new (projected ) x coordinates
     1463                    eval(['ProjData.' AYProjName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates
     1464                    eval(['ProjData.' AXProjName '=[Xbound(1) Xbound(2)];']) %record the new (projected ) x coordinates
    14741465                end
    14751466            end
     
    15751566    end
    15761567end
    1577 
     1568ProjData
     1569ProjData.VarDimName{3}
    15781570%-----------------------------------------------------------------
    15791571%projection in a volume
Note: See TracChangeset for help on using the changeset viewer.