Changeset 782 for trunk/src/plot_field.m


Ignore:
Timestamp:
Jun 3, 2014, 8:10:03 PM (9 years ago)
Author:
sommeria
Message:

AX and AY changed to Coord_x and Coord_y

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r781 r782  
    694694            XName=Data.ListVarName{ivar_X};
    695695            YName=Data.ListVarName{ivar_Y};
    696             eval(['AX=reshape(Data.' XName ',1,[]);'])
    697             eval(['AY=reshape(Data.' YName ',1,[]);'])
    698             [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256');  % interpolate on a grid
     696            eval(['Coord_x=reshape(Data.' XName ',1,[]);'])
     697            eval(['Coord_y=reshape(Data.' YName ',1,[]);'])
     698            [A,Coord_x,Coord_y]=proj_grid(Coord_x',Coord_y',A',[],[],'np>256');  % interpolate on a grid
    699699            if isfield(Data,'VarAttribute')
    700700                if numel(Data.VarAttribute)>=ivar_X && isfield(Data.VarAttribute{ivar_X},'units')
     
    707707        elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates
    708708            YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
    709             AY=Data.(YName);
    710             AX=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)});
     709            Coord_y=Data.(YName);
     710            Coord_x=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)});
    711711            test_interp_X=0; %default, regularly meshed X coordinate
    712712            test_interp_Y=0; %default, regularly meshed Y coordinate
     
    719719                end
    720720            end
    721             if numel(AY)>2
    722                 DAY=diff(AY);
    723                 DAY_min=min(DAY);
    724                 DAY_max=max(DAY);
    725                 if sign(DAY_min)~=sign(DAY_max);% =1 for increasing values, 0 otherwise
     721            if numel(Coord_y)>2
     722                DCoord_y=diff(Coord_y);
     723                DCoord_y_min=min(DCoord_y);
     724                DCoord_y_max=max(DCoord_y);
     725                if sign(DCoord_y_min)~=sign(DCoord_y_max);% =1 for increasing values, 0 otherwise
    726726                    errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(1)} ];
    727727                    return
    728728                end
    729                 test_interp_Y=(DAY_max-DAY_min)> 0.0001*abs(DAY_max);
    730             end
    731             if numel(AX)>2
    732                 DAX=diff(AX);
    733                 DAX_min=min(DAX);
    734                 DAX_max=max(DAX);
    735                 if sign(DAX_min)~=sign(DAX_max);% =1 for increasing values, 0 otherwise
     729                test_interp_Y=(DCoord_y_max-DCoord_y_min)> 0.0001*abs(DCoord_y_max);
     730            end
     731            if numel(Coord_x)>2
     732                DCoord_x=diff(Coord_x);
     733                DCoord_x_min=min(DCoord_x);
     734                DCoord_x_max=max(DCoord_x);
     735                if sign(DCoord_x_min)~=sign(DCoord_x_max);% =1 for increasing values, 0 otherwise
    736736                    errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(2)} ];
    737737                    return
    738738                end
    739                 test_interp_X=(DAX_max-DAX_min)> 0.0001*abs(DAX_max);
     739                test_interp_X=(DCoord_x_max-DCoord_x_min)> 0.0001*abs(DCoord_x_max);
    740740            end
    741741            if test_interp_Y
    742                 npxy(1)=max([256 floor((AY(end)-AY(1))/DAY_min) floor((AY(end)-AY(1))/DAY_max)]);
    743                 yI=linspace(AY(1),AY(end),npxy(1));
     742                npxy(1)=max([256 floor((Coord_y(end)-Coord_y(1))/DCoord_y_min) floor((Coord_y(end)-Coord_y(1))/DCoord_y_max)]);
     743                yI=linspace(Coord_y(1),Coord_y(end),npxy(1));
    744744                if ~test_interp_X
    745                     xI=linspace(AX(1),AX(end),size(A,2));%default
    746                     AX=xI;
     745                    xI=linspace(Coord_x(1),Coord_x(end),size(A,2));%default
     746                    Coord_x=xI;
    747747                end
    748748            end
    749749            if test_interp_X
    750                 npxy(2)=max([256 floor((AX(end)-AX(1))/DAX_min) floor((AX(end)-AX(1))/DAX_max)]);
    751                 xI=linspace(AX(1),AX(end),npxy(2));
     750                npxy(2)=max([256 floor((Coord_x(end)-Coord_x(1))/DCoord_x_min) floor((Coord_x(end)-Coord_x(1))/DCoord_x_max)]);
     751                xI=linspace(Coord_x(1),Coord_x(end),npxy(2));
    752752                if ~test_interp_Y
    753                     yI=linspace(AY(1),AY(end),size(A,1));
    754                     AY=yI;
     753                    yI=linspace(Coord_y(1),Coord_y(end),size(A,1));
     754                    Coord_y=yI;
    755755                end
    756756            end
    757757            if test_interp_X || test_interp_Y
    758                 [AX2D,AY2D]=meshgrid(AX,AY);
    759                 A=interp2(AX2D,AY2D,double(A),xI,yI');
    760             end
    761             AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation
    762             AY=[AY(1) AY(end)];
     758                [Coord_x2D,Coord_y2D]=meshgrid(Coord_x,Coord_y);
     759                A=interp2(Coord_x2D,Coord_y2D,double(A),xI,yI');
     760            end
     761            Coord_x=[Coord_x(1) Coord_x(end)];% keep only the lower and upper bounds for image represnetation
     762            Coord_y=[Coord_y(1) Coord_y(end)];
    763763        end
    764764    end
     
    874874            cont_pos=[cont_pos_min cont_pos_plus];% set of all contour values
    875875           
    876             sizpx=(AX(end)-AX(1))/(np(2)-1);
    877             sizpy=(AY(1)-AY(end))/(np(1)-1);
    878             x_cont=AX(1):sizpx:AX(end); % pixel x coordinates for image display
    879             y_cont=AY(1):-sizpy:AY(end); % pixel x coordinates for image display
     876            sizpx=(Coord_x(end)-Coord_x(1))/(np(2)-1);
     877            sizpy=(Coord_y(1)-Coord_y(end))/(np(1)-1);
     878            x_cont=Coord_x(1):sizpx:Coord_x(end); % pixel x coordinates for image display
     879            y_cont=Coord_y(1):-sizpy:Coord_y(end); % pixel x coordinates for image display
    880880           
    881881            %axes(haxes)% set the input axes handle as current axis
     
    963963        end
    964964        if test_interp%if we interpolate
    965             x=linspace(AX(1),AX(2),np(2));
    966             y=linspace(AY(1),AY(2),np(1));
     965            x=linspace(Coord_x(1),Coord_x(2),np(2));
     966            y=linspace(Coord_y(1),Coord_y(2),np(1));
    967967            [X,Y]=meshgrid(x,y);
    968             xi=linspace(AX(1),AX(2),npxy(2));
    969             yi=linspace(AY(1),AY(2),npxy(1));
     968            xi=linspace(Coord_x(1),Coord_x(2),npxy(2));
     969            yi=linspace(Coord_y(1),Coord_y(2),npxy(1));
    970970            A = interp2(X,Y,double(A),xi,yi');
    971971        end
     
    974974            tag=get(haxes,'Tag');
    975975            if MinA<MaxA
    976                 hima=imagesc(AX,AY,A,[MinA MaxA]);
     976                hima=imagesc(Coord_x,Coord_y,A,[MinA MaxA]);
    977977            else % to deal with uniform field
    978                 hima=imagesc(AX,AY,A,[MaxA-1 MaxA]);
     978                hima=imagesc(Coord_x,Coord_y,A,[MaxA-1 MaxA]);
    979979            end
    980980            % the function imagesc reset the axes 'DataAspectRatioMode'='auto', change if .CheckFixAspectRatio is
     
    992992                set(haxes,'CLim',[MinA MaxA+1])
    993993            end
    994             set(hima,'XData',AX);
    995             set(hima,'YData',AY);
     994            set(hima,'XData',Coord_x);
     995            set(hima,'YData',Coord_y);
    996996        end
    997997       
     
    11931193    else
    11941194        if test_ima %both background image and vectors coexist, take the wider bound
    1195             MinX=min(AX);
    1196             MaxX=max(AX);
    1197             MinY=min(AY);
    1198             MaxY=max(AY);
     1195            MinX=min(Coord_x);
     1196            MaxX=max(Coord_x);
     1197            MinY=min(Coord_y);
     1198            MaxY=max(Coord_y);
    11991199            if test_vec
    12001200                MinX=min(MinX,min(vec_X));
Note: See TracChangeset for help on using the changeset viewer.