Changeset 738 for trunk/src/proj_field.m


Ignore:
Timestamp:
Apr 14, 2014, 11:41:21 AM (10 years ago)
Author:
sommeria
Message:

various bug resolutions and improvements in particular with geometry_calib. Introduction of a tool set_slices in uvmat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r735 r738  
    920920
    921921%% extrema along each axis
    922 testXMin=0;
    923 testXMax=0;
    924 testYMin=0;
    925 testYMax=0;
    926 if isfield(ObjectData,'RangeX')
     922testXMin=0;% test if min of X coordinates defined on the projection object, =0 by default
     923testXMax=0;% test if max of X coordinates defined on the projection object, =0 by default
     924testYMin=0;% test if min of Y coordinates defined on the projection object, =0 by default
     925testYMax=0;% test if max of Y coordinates defined on the projection object, =0 by default
     926if isfield(ObjectData,'RangeX') % rangeX defined by the projection object
    927927    XMin=min(ObjectData.RangeX);
    928928    XMax=max(ObjectData.RangeX);
    929     testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has tow distinct elements)
    930     testXMax=1;% range restriction along X
    931 end
    932 if isfield(ObjectData,'RangeY')
     929    testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has two distinct elements)
     930    testXMax=1;% max of X coordinates defined on the projection object
     931end
     932if isfield(ObjectData,'RangeY') % rangeY defined by the projection object
    933933    YMin=min(ObjectData.RangeY);
    934934    YMax=max(ObjectData.RangeY);
    935935    testYMin=YMax>YMin;%=1 if YMin defined (i.e. RangeY has tow distinct elements)
    936     testYMax=1;
     936    testYMax=1;% max of Y coordinates defined on the projection object
    937937end
    938938width=0;%default width of the projection band
     
    13711371                    end
    13721372                end
    1373             else       % case with interpolation
     1373            else       % case with interpolation on a grid
    13741374                if NbDim==2 %2D case
    13751375                    if isequal(ProjMode{icell},'interp_tps')
     
    13831383                    Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});
    13841384                    Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)});
    1385                     xcorner=[min(Coord{NbDim}) max(Coord{NbDim}) max(Coord{NbDim}) min(Coord{NbDim})]-ObjectData.Coord(1,1);% corner absissa of the original grid with respect to the new origin
    1386                     ycorner=[min(Coord{NbDim-1}) min(Coord{NbDim-1}) max(Coord{NbDim-1}) max(Coord{NbDim-1})]-ObjectData.Coord(1,2);% corner ordinates of the original grid
    1387                     xcor_new=xcorner*cos(PlaneAngle(3))+ycorner*sin(PlaneAngle(3));%coordinates of the corners in new frame
    1388                     ycor_new=-xcorner*sin(PlaneAngle(3))+ycorner*cos(PlaneAngle(3));
    1389                     if testXMin
    1390                         xcor_new=max(xcor_new,XMin);
    1391                     end
    1392                     if testXMax
    1393                         xcor_new=min(xcor_new,XMax);
    1394                     end
    1395                     if testYMin
    1396                         ycor_new=max(ycor_new,YMin);
    1397                     end
    1398                     if testYMax
    1399                         ycor_new=min(ycor_new,YMax);
    1400                     end
    1401                     coord_x_proj=min(xcor_new):DX:max(xcor_new);
    1402                     coord_y_proj=min(ycor_new):DY:max(ycor_new);
     1385                    if ~(testXMin && testYMin)% % if the range of the projected coordinates is not fully defined by the projection object, find the extrema of the projected field
     1386                        xcorner=[min(Coord{NbDim}) max(Coord{NbDim}) max(Coord{NbDim}) min(Coord{NbDim})]-ObjectData.Coord(1,1);% corner absissa of the original grid with respect to the new origin
     1387                        ycorner=[min(Coord{NbDim-1}) min(Coord{NbDim-1}) max(Coord{NbDim-1}) max(Coord{NbDim-1})]-ObjectData.Coord(1,2);% corner ordinates of the original grid
     1388                        xcor_new=xcorner*cos(PlaneAngle(3))+ycorner*sin(PlaneAngle(3));%coordinates of the corners in new frame
     1389                        ycor_new=-xcorner*sin(PlaneAngle(3))+ycorner*cos(PlaneAngle(3));
     1390                        if ~testXMin
     1391                            XMin=min(xcor_new);
     1392                        end
     1393                        if ~testXMax
     1394                            XMax=max(xcor_new);
     1395                        end
     1396                        if ~testYMin
     1397                            YMin=min(ycor_new);
     1398                        end
     1399                        if ~testYMax
     1400                            YMax=max(ycor_new);
     1401                        end
     1402                    end
     1403                    coord_x_proj=XMin:DX:XMax;
     1404                    coord_y_proj=YMin:DY:YMax;
    14031405                    ProjData.(AYName)=[coord_y_proj(1) coord_y_proj(end)]; %record the new (projected ) y coordinates
    14041406                    ProjData.(AXName)=[coord_x_proj(1) coord_x_proj(end)]; %record the new (projected ) x coordinates
Note: See TracChangeset for help on using the changeset viewer.