Changeset 672 for trunk/src/proj_field.m


Ignore:
Timestamp:
Aug 6, 2013, 3:47:07 PM (11 years ago)
Author:
sommeria
Message:

various bugs corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r655 r672  
    10121012else
    10131013    %% case of a grid requested by the input field
    1014 
    10151014    for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
    10161015        if isfield(CellInfo{icell},'ProjModeRequest')
     
    15451544                        test_interp_tps=0;
    15461545                    end
    1547                     %                     ProjData.coord_y=[YMin YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined
    1548                     %                     ProjData.coord_x=[XMin XMax];
    15491546                    coord_x_proj=XMin:DX:XMax;
    15501547                    coord_y_proj=YMin:DY:YMax;
     
    15521549                    XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system
    15531550                    YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3));
    1554                     [X,Y]=meshgrid(Coord{2},Coord{1});%initial coordiantes
     1551                    Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});
     1552                    Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)});
     1553                    if numel(Coord{1})==2% x coordiante defiend by its bounds, get the whole set
     1554                        Coord{1}=linspace(Coord{1}(1),Coord{1}(2),CellInfo{icell}.CoordSize(1));
     1555                    end
     1556                    if numel(Coord{2})==2% y coordiante defiend by its bounds, get the whole set
     1557                        Coord{2}=linspace(Coord{2}(1),Coord{2}(2),CellInfo{icell}.CoordSize(2));
     1558                    end
     1559                    [X,Y]=meshgrid(Coord{2},Coord{1});%initial coordinates
     1560                    %name of error flag variable
     1561                    FFName='FF';%default name (if not already used)
     1562                    if isfield(ProjData,'FF')
     1563                        ind=1;
     1564                        while isfield(ProjData,['FF_' num2str(ind)])
     1565                            ind=ind+1;
     1566                        end
     1567                        FFName=['FF_' num2str(ind)];% append an index to the name of error flag, FF_1,FF_2...
     1568                    end
     1569                    % project all variables in the cell
    15551570                    for ivar=VarIndex
    15561571                        VarName=FieldData.ListVarName{ivar};
    1557                         %                         if test_interp(1) || test_interp(2)%interpolate on a regular grid
    15581572                        if size(FieldData.(VarName),3)==1
    15591573                            ProjData.(VarName)=interp2(X,Y,double(FieldData.(VarName)),XI,YI,'*linear');
    15601574                        else
    15611575                            ProjData.(VarName)=interp2(X,Y,double(FieldData.(VarName)(:,:,1)),XI,YI,'*linear');
    1562                             for icolor=2:size(FieldData.(VarName),3)
     1576                            for icolor=2:size(FieldData.(VarName),3)% project 'color' components
    15631577                                ProjData.(VarName)=cat(3,ProjData.(VarName),interp2(X,Y,double(FieldData.(VarName)(:,:,icolor)),XI,YI,'*linear')); %TO TEST
    15641578                            end
     
    15701584                            VarAttribute{length(ListVarName)+nbcoord}=FieldData.VarAttribute{ivar};
    15711585                        end;
    1572                     end
     1586                        ProjData.(FFName)=isnan(ProjData.(VarName));%detact NaN (points outside the interpolation range)
     1587                        ProjData.(VarName)(ProjData.(FFName))=0; %set to 0 the NaN data
     1588                    end
     1589                    %update list of variables with error flag
     1590                    ListVarName=[ListVarName FFName];
     1591                    VarDimName=[VarDimName {DimCell}];
     1592                    VarAttribute{numel(ListVarName)}.Role='errorflag';
    15731593                elseif ~testangle
    15741594                    % unstructured z coordinate
Note: See TracChangeset for help on using the changeset viewer.