Changeset 675 for trunk/src/proj_field.m
- Timestamp:
- Aug 27, 2013, 11:25:21 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/proj_field.m
r672 r675 562 562 NbPoint=ceil(LineLength/DX); 563 563 DX=LineLength/NbPoint;%adjust DX to get an integer nbre of intervals in a closed line 564 DX_e nd=DX/2;564 DX_edge=DX/2; 565 565 else 566 DX_e nd=(LineLength-DX*floor(LineLength/DX))/2;%margin from the first point and first interpolationpoint566 DX_edge=(LineLength-DX*floor(LineLength/DX))/2;%margin from the first point and first interpolation point, the same for the end point 567 567 end 568 568 XI=[]; … … 571 571 dlengthI=[]; 572 572 if strcmp(ObjectData.Type,'ellipse') 573 phi=(DX_e nd:DX:LineLength)*2*pi/LineLength;573 phi=(DX_edge:DX:LineLength)*2*pi/LineLength; 574 574 XI=ObjectData.RangeX*cos(phi); 575 575 YI=ObjectData.RangeY*sin(phi); … … 580 580 costheta=cos(theta(isegment)); 581 581 sintheta=sin(theta(isegment)); 582 XIsegment=(LineCoord(isegment,1)+DX_end*costheta:DX*costheta:LineCoord(isegment+1,1)); 583 YIsegment=(LineCoord(isegment,2)+DX_end*sintheta:DX*sintheta:LineCoord(isegment+1,2)); 582 % XIsegment=LineCoord(isegment,1)+DX_edge*costheta:DX*costheta:LineCoord(isegment+1,1)); 583 % YIsegment=(LineCoord(isegment,2)+DX_edge*sintheta:DX*sintheta:LineCoord(isegment+1,2)); 584 NbInterval=floor((dlength(isegment)-DX_edge)/DX); 585 LastX=DX_edge+DX*NbInterval; 586 NbPoint=NbInterval+1; 587 XIsegment=linspace(LineCoord(isegment,1)+DX_edge*costheta,LineCoord(isegment,1)+LastX*costheta,NbPoint); 588 YIsegment=linspace(LineCoord(isegment,2)+DX_edge*sintheta,LineCoord(isegment,2)+LastX*sintheta,NbPoint); 584 589 XI=[XI XIsegment]; 585 590 YI=[YI YIsegment]; 586 591 ThetaI=[ThetaI theta(isegment)*ones(1,numel(XIsegment))]; 587 592 dlengthI=[dlengthI DX*ones(1,numel(XIsegment))]; 588 DX_e nd=DX_end+DX-(dlength(isegment)-DX*(numel(XIsegment)-1));593 DX_edge=DX-(dlength(isegment)-LastX);%edge for the next segment set to keep DX=DX_end+DX_edge between two segments 589 594 end 590 595 end 591 596 Xproj=cumsum(dlengthI); 592 597 else 593 errormsg=' meshDX needed for interpolation';598 errormsg='abscissa mesh along line DX needed for interpolation'; 594 599 return 595 600 end … … 713 718 [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI)); 714 719 ProjData.X=Xproj; 715 % ProjData.ListVarName=[ProjData.ListVarName {XName}];716 % ProjData.VarDimName=[ProjData.VarDimName {XName}];717 720 nbvar=numel(ProjData.ListVarName); 718 721 ProjData.VarAttribute{nbvar}.long_name='abscissa along line'; … … 923 926 testXMin=XMax>XMin; 924 927 testXMax=1;% range restriction along X 925 % else926 % XMin=FieldData.XMin;%default927 % XMax=FieldData.XMax;%default928 928 end 929 929 if isfield(ObjectData,'RangeY') … … 932 932 testYMin=YMax>YMin; 933 933 testYMax=1; 934 % else935 % YMin=FieldData.YMin;%default936 % YMax=FieldData.YMax;%default937 934 end 938 935 width=0;%default width of the projection band … … 1036 1033 if ~isfield(FieldData,'XMax') 1037 1034 FieldData=find_field_bounds(FieldData); 1038 % CellIndex=find(check_grid);1039 % for igrid=1:numel(CellIndex)1040 % icell=CellIndex(igrid);% TODO: recalculate coordinates here to get the bounds in the rotated coordinates1041 % NbDim=NbDimArray(icell);1042 % for idim=1:NbDim %loop on space dimensions1043 % ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension1044 % Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field1045 % if ~isequal(ivar,0)% a variable corresponds to the dimension #idim1046 %1047 %1048 %1049 % else1050 % Coord_i_str=['Coord_' num2str(idim)];1051 % DCoord_min(idim)=1;%default1052 % Coord{idim}=[0.5 DimValue(idim)-0.5];1053 % test_direct(idim)=1;1054 % end1055 % % default bounds, case of gridded data1056 % if strcmp(CellInfo{icell}.CoordType,'grid')1057 % % find default mesh1058 % for idim=1:NbDim %loop on space dimensions1059 % test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default1060 % ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension1061 % DimValue=size(FieldData.(FieldData.ListVarName{ivar}));1062 % if ~isequal(ivar,0)% a variable corresponds to the dimension #idim1063 % Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field1064 % if numel(Coord{idim})==2 %input array defined on a regular grid1065 % DCoord_min(idim)=(Coord{idim}(2)-Coord{idim}(1))/DimValue(idim);1066 % Coord{idim}=linspace(Coord{idim}(1),Coord{idim}(2),DimValue(idim));1067 % else1068 % DCoord=diff(Coord{idim});%array of coordinate derivatives for the input field1069 % DCoord_min(idim)=min(DCoord);1070 % DCoord_max=max(DCoord);1071 % if abs(DCoord_max-DCoord_min(idim))>abs(DCoord_max/1000)1072 % msgbox_uvmat('ERROR',['non monotonic dimension variable # ' num2str(idim) ' in proj_field.m'])1073 % return1074 % end1075 % test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity1076 % end1077 % test_direct(idim)=(DCoord_min(idim)>0);1078 % else % no variable associated with the dimension #idim, the coordinate value is set equal to the matrix index by default1079 % % Coord_i_str=['Coord_' num2str(idim)];1080 % % DCoord_min(idim)=1;%default1081 % % Coord{idim}=[0.5 DimValue(idim)-0.5];1082 % % test_direct(idim)=1;1083 % end1084 % end1085 % if isempty(DY)1086 % DY=abs(DCoord_min(NbDim-1));1087 % end1088 % npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol1089 % if isempty(DX)1090 % DX=abs(DCoord_min(NbDim));1091 % end1092 % npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol1093 % for idim=1:NbDim1094 % if test_interp(idim)1095 % DimValue(idim)=1+round(abs(Coord{idim}(end)-Coord{idim}(1))/abs(DCoord_min(idim)));%nbre of points after possible interpolation on a regular gri1096 % end1097 % end1098 % Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY);1099 % test_direct_y=test_direct(NbDim-1);1100 % Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX);1101 % test_direct_x=test_direct(NbDim);1102 % DAX=DCoord_min(NbDim);1103 % DAY=DCoord_min(NbDim-1);1104 % minAX=min(Coord_x);1105 % maxAX=max(Coord_x);1106 % minAY=min(Coord_y);1107 % maxAY=max(Coord_y);1108 % xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes1109 % ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);1110 % xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame1111 % ycor_new=-xcorner*sin_om+ycorner*cos_om;1112 % if ~testXMax1113 % XMax(igrid)=max(xcor_new);1114 % end1115 % if ~testXMin1116 % XMin(igrid)=min(xcor_new);1117 % end1118 % if ~testYMax1119 % YMax(igrid)=max(ycor_new);1120 % end1121 % if ~testYMin1122 % YMin(igrid)=min(ycor_new);1123 % end1124 % DX(igrid)=(maxAX-minAX)/(DimValue(NbDim)-1);1125 % DY(igrid)=(maxAY-minAY)/(DimValue(NbDim-1)-1);1126 % if NbDim==31127 % DZ(igrid)=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);1128 % if ~test_direct(1)1129 % DZ=-DZ;1130 % end1131 % Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));1132 % test_direct_z=test_direct(1);1133 % end1134 % else1135 %1136 % end1137 % YMax=max(YMax);1138 % YMin=min(YMin);1139 % XMax=max(XMax);1140 % XMin=min(XMin);1141 1035 end 1142 1036 end … … 1188 1082 end 1189 1083 VarIndex=CellInfo{icell}.VarIndex;% indices of the selected variables in the list FieldData.ListVarName 1190 % ivar_U=[];ivar_V=[];ivar_W=[];1191 % if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')1192 % ivar_U=CellInfo{icell}.VarIndex_vector_x_tps;1193 % ivar_V=CellInfo{icell}.VarIndex_vector_y_tps;1194 % elseif isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y')1195 % ivar_U=CellInfo{icell}.VarIndex_vector_x;1196 % ivar_V=CellInfo{icell}.VarIndex_vector_y;1197 % end1198 % if isfield(CellInfo{icell},'VarIndex_vector_z')1199 % ivar_W=CellInfo{icell}.VarIndex_vector_z;1200 % end1201 1084 %dimensions 1202 1085 DimCell=FieldData.VarDimName{VarIndex(1)}; … … 1390 1273 Coord_x=[]; 1391 1274 1392 1393 1394 % % default bounds1395 % minAX=min(Coord_x);1396 % maxAX=max(Coord_x);1397 % minAY=min(Coord_y);1398 % maxAY=max(Coord_y);1399 % xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes1400 % ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);1401 % xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame1402 % ycor_new=-xcorner*sin_om+ycorner*cos_om;1403 % if ~testXMax1404 % XMax=max(xcor_new);1405 % end1406 % if ~testXMin1407 % XMin=min(xcor_new);1408 % end1409 % if ~testYMax1410 % YMax=max(ycor_new);1411 % end1412 % if ~testYMin1413 % YMin=min(ycor_new);1414 % end1415 % DXinit=(maxAX-minAX)/(DimValue(NbDim)-1);1416 % DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1);1417 % if DX==01418 % DX=DXinit;1419 % end1420 % if DY==01421 % DY=DYinit;1422 % end1423 % if NbDim==31424 % DZ=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);1425 % if ~test_direct(1)1426 % DZ=-DZ;1427 % end1428 % Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));1429 % test_direct_z=test_direct(1);1430 % end1431 %define new coordiantes if not already done by the definition of a projection grid1432 if ~check_grid1433 1434 1435 end1436 1437 1275 if testangle 1438 1276 ProjMode{icell}='interp_lin'; %request linear interpolation for projection on a tilted plane 1439 1277 end 1440 1441 % npX=floor((XMax-XMin)/DX+1); 1442 % npY=floor((YMax-YMin)/DY+1); 1443 % if test_direct_y 1444 % coord_y_proj=linspace(YMin,YMax,npY);%abscissa of the new pixels along the line 1445 % else 1446 % coord_y_proj=linspace(YMax,YMin,npY);%abscissa of the new pixels along the line 1447 % end 1448 % if test_direct_x 1449 % coord_x_proj=linspace(XMin,XMax,npX);%abscissa of the new pixels along the line 1450 % else 1451 % coord_x_proj=linspace(XMax,XMin,npX);%abscissa of the new pixels along the line 1452 % end 1278 1453 1279 if isequal(ProjMode{icell},'projection')% && (~testangle || test90y || test90x) 1454 1280 if NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax% no range restriction
Note: See TracChangeset
for help on using the changeset viewer.