Changeset 738 for trunk/src/proj_field.m
- Timestamp:
- Apr 14, 2014, 11:41:21 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/proj_field.m
r735 r738 920 920 921 921 %% extrema along each axis 922 testXMin=0; 923 testXMax=0; 924 testYMin=0; 925 testYMax=0; 926 if isfield(ObjectData,'RangeX') 922 testXMin=0;% test if min of X coordinates defined on the projection object, =0 by default 923 testXMax=0;% test if max of X coordinates defined on the projection object, =0 by default 924 testYMin=0;% test if min of Y coordinates defined on the projection object, =0 by default 925 testYMax=0;% test if max of Y coordinates defined on the projection object, =0 by default 926 if isfield(ObjectData,'RangeX') % rangeX defined by the projection object 927 927 XMin=min(ObjectData.RangeX); 928 928 XMax=max(ObjectData.RangeX); 929 testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has t owdistinct elements)930 testXMax=1;% range restriction along X931 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 931 end 932 if isfield(ObjectData,'RangeY') % rangeY defined by the projection object 933 933 YMin=min(ObjectData.RangeY); 934 934 YMax=max(ObjectData.RangeY); 935 935 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 937 937 end 938 938 width=0;%default width of the projection band … … 1371 1371 end 1372 1372 end 1373 else % case with interpolation 1373 else % case with interpolation on a grid 1374 1374 if NbDim==2 %2D case 1375 1375 if isequal(ProjMode{icell},'interp_tps') … … 1383 1383 Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)}); 1384 1384 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; 1403 1405 ProjData.(AYName)=[coord_y_proj(1) coord_y_proj(end)]; %record the new (projected ) y coordinates 1404 1406 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.