Changeset 1060
- Timestamp:
- Dec 19, 2018, 10:16:08 AM (6 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/proj_field.m
r1058 r1060 969 969 970 970 %----------------------------------------------------------------- 971 %project on a plane 971 %project on a plane 972 972 % AJOUTER flux,circul,error 973 973 function [ProjData,errormsg] = proj_plane(FieldData, ObjectData) … … 988 988 % ObjectData.Angle(1)=90*Delta_x/Delta_mod; 989 989 % ObjectData.0(2)=90*Delta_y/Delta_mod; 990 % end 991 if isfield(ObjectData,'Angle')&& isequal(size(ObjectData.Angle),[1 2])&& ~isequal(ObjectData.Angle,[0 0]) 992 test90y=0;%isequal(ObjectData.Angle,[0 90 0]); 990 % end 991 if isfield(ObjectData,'Angle') 992 checkM2=0; 993 if numel(ObjectData.Angle)==2 && ~isequal(ObjectData.Angle,[0 0]) 994 checkM2=1; 995 test90y=0;%isequal(ObjectData.Angle,[0 90 0]); 996 end 993 997 PlaneAngle=(pi/180)*ObjectData.Angle; 994 998 % om=norm(PlaneAngle);%norm of rotation angle in radians … … 1003 1007 1004 1008 M1=[cos(PlaneAngle(1)) sin(PlaneAngle(1)) 0;-sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1]; 1005 M2=[1 0 0;0 cos(PlaneAngle(2)) sin(PlaneAngle(2));0 -sin(PlaneAngle(2)) cos(PlaneAngle(2))]; 1006 M=M2*M1;% first rotate in the x,y plane with angle PlaneAngle(1), then slant around the new x axis0 with angle PlaneAngle(2) 1009 M=M1; 1010 if checkM2 1011 M2=[1 0 0;0 cos(PlaneAngle(2)) sin(PlaneAngle(2));0 -sin(PlaneAngle(2)) cos(PlaneAngle(2))]; 1012 M=M2*M1;% first rotate in the x,y plane with angle PlaneAngle(1), then slant around the new x axis0 with angle PlaneAngle(2) 1013 end 1007 1014 norm_plane=M*[0 0 1]'; 1008 1015 … … 1029 1036 InterpMesh=min(DX,DY);%mesh used for interpolation in a slanted plane 1030 1037 % if strcmp(ObjectData.Type,'plane_z') 1031 % InterpMesh=10*InterpMesh;%TODO: temporary, to shorten computation 1038 % InterpMesh=10*InterpMesh;%TODO: temporary, to shorten computation 1032 1039 % end 1033 1040 … … 1118 1125 if ~strcmp(ObjectData.ProjMode,'projection')&& ~strcmp(ObjectData.Type,'plane_z')% TODO:rationalize 1119 1126 %% define the new coordinates in case of interpolation on a imposed grid 1120 if ~testYMin 1127 if ~testYMin 1121 1128 errormsg='min Y value not defined for the projection grid';return 1122 1129 end … … 1177 1184 [XI,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates 1178 1185 ProjData.VarDimName={AYName,AXName}; 1179 % XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system1180 % YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3));1186 % XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system 1187 % YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3)); 1181 1188 else% we use the existing grid from field cell #icell_grid 1182 1189 NbDim=NbDimArray(icell_grid); … … 1185 1192 AYDimName=FieldData.VarDimName{CellInfo{icell_grid}.CoordIndex(NbDim-1)};% 1186 1193 AXDimName=FieldData.VarDimName{CellInfo{icell_grid}.CoordIndex(NbDim)};% 1187 1194 ProjData.VarDimName={AYDimName,AXDimName}; 1188 1195 ProjData.(AYName)=FieldData.(AYName); % new (projected ) y coordinates 1189 1196 ProjData.(AXName)=FieldData.(AXName); % new (projected ) y coordinates … … 1194 1201 ProjData.VarAttribute{2}.Role='coord_x'; 1195 1202 end 1196 1203 1197 1204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1198 1205 % LOOP ON FIELD CELLS, PROJECT VARIABLES … … 1256 1263 1257 1264 %rotate coordinates if needed: coord_X,coord_Y= = coordinates in the new plane 1258 P si=PlaneAngle(1);1259 Theta=PlaneAngle(2);1260 % Phi=PlaneAngle(3);1265 Phi=PlaneAngle(1); 1266 % Theta=PlaneAngle(2); 1267 % Phi=PlaneAngle(3); 1261 1268 if testangle && ~test90y && ~test90x;%=1 for slanted plane 1262 coord_X=(coord_x *cos(Phi) + coord_y* sin(Phi)); 1263 coord_Y=(-coord_x *sin(Phi) + coord_y *cos(Phi))*cos(Theta); 1264 coord_Y=coord_Y+coord_z *sin(Theta); 1265 coord_X=(coord_X *cos(Psi) - coord_Y* sin(Psi));%A VERIFIER 1266 coord_Y=(coord_X *sin(Psi) + coord_Y* cos(Psi)); 1269 coord_X=coord_x *cos(Phi) + coord_y* sin(Phi); 1270 coord_Y=-coord_x *sin(Phi) + coord_y *cos(Phi); 1271 if checkM2 1272 coord_Y=coord_Y*cos(PlaneAngle(2)); 1273 coord_Y=coord_Y+coord_z *sin(PlaneAngle(2)); 1274 coord_X=(coord_X *cos(Psi) - coord_Y* sin(Psi));%A VERIFIER 1275 coord_Y=(coord_X *sin(Psi) + coord_Y* cos(Psi)); 1276 end 1267 1277 else 1268 1278 coord_X=coord_x; … … 1377 1387 end 1378 1388 if isfield (CellInfo{icell},'VarIndex_vector_x')&& isfield (CellInfo{icell},'VarIndex_vector_y') 1379 vector_x_proj=CellInfo{icell}.VarIndex_vector_x; %preserve for next cell1380 vector_y_proj=CellInfo{icell}.VarIndex_vector_y; %preserve for next cell1389 vector_x_proj=CellInfo{icell}.VarIndex_vector_x; %preserve for next cell 1390 vector_y_proj=CellInfo{icell}.VarIndex_vector_y; %preserve for next cell 1381 1391 end 1382 1392 end … … 1397 1407 1398 1408 %rotate coordinates if needed: coord_X,coord_Y= = coordinates in the new plane 1399 Psi=PlaneAngle(1); 1400 Theta=PlaneAngle(2); 1401 % Phi=PlaneAngle(3); 1409 Phi=PlaneAngle(1); 1402 1410 if testangle && ~test90y && ~test90x;%=1 for slanted plane 1403 new_XI=XI *cos(Phi) - YI*sin(Phi)+ObjectData.Coord(1);1411 new_XI=XI *cos(Phi) - YI* sin(Phi)+ObjectData.Coord(1); 1404 1412 YI=XI *sin(Phi) + YI *cos(Phi)+ObjectData.Coord(2); 1405 1413 XI=new_XI; 1406 % if checkUV1407 % UValue=cos(Phi)*FieldVar(:,:,1)+ sin(Phi)*FieldVar(:,:,2);1408 % FieldVar(:,:,2)=-sin(Phi)*FieldVar(:,:,1)+ cos(Phi)*FieldVar(:,:,2);1409 % FieldVar(:,:,1)=UValue;1410 % end1411 1414 end 1412 1415 … … 1445 1448 DimValue(DimValue==1)=[];%remove singleton dimensions 1446 1449 NbDim=numel(DimValue);%update number of space dimensions 1447 % nbcolor=1; %default number of 'color' components: third matrix index without corresponding coordinate1450 % nbcolor=1; %default number of 'color' components: third matrix index without corresponding coordinate 1448 1451 if NbDim>=3 1449 1452 if NbDim>3 … … 1492 1495 end 1493 1496 if testYMax 1494 1497 YIndexMax=(YMax-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the max y value for the new field 1495 1498 if testYMin%test_direct(indY) 1496 1499 YIndexMin=(YMin-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the min x value for the new field 1497 1500 else 1498 1501 YIndexMin=1; 1499 end 1502 end 1500 1503 else 1501 1504 YIndexMax=numel(Coord{NbDim-1}); … … 1503 1506 end 1504 1507 if testXMax 1505 1508 XIndexMax=(XMax-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the max y value for the new field 1506 1509 if testYMin%test_direct(indY) 1507 1510 XIndexMin=(XMin-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the min x value for the new field 1508 1511 else 1509 1512 XIndexMin=1; 1510 end 1513 end 1511 1514 else 1512 1515 XIndexMax=numel(Coord{NbDim}); … … 1561 1564 end 1562 1565 if testXMax 1563 ProjData.(AXName)=Coord{NbDim}(1)+DX*(XIndexRange-1); %record the new (projected ) x coordinates1566 ProjData.(AXName)=Coord{NbDim}(1)+DX*(XIndexRange-1); %record the new (projected ) x coordinates 1564 1567 else 1565 ProjData.(AXName)=FieldData.(AXName);1568 ProjData.(AXName)=FieldData.(AXName); 1566 1569 end 1567 1570 if testYMax 1568 1571 ProjData.(AYName)=Coord{NbDim-1}(1)+DY*(YIndexRange-1); %record the new (projected ) x coordinates 1569 1572 else 1570 ProjData.(AYName)=FieldData.(AYName);1571 end 1573 ProjData.(AYName)=FieldData.(AYName); 1574 end 1572 1575 end 1573 1576 end … … 1609 1612 XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(2))-YI*sin(PlaneAngle(1));%corresponding coordinates in the original system 1610 1613 YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(2))+YI*cos(PlaneAngle(1)); 1611 1614 1612 1615 if numel(Coord{1})==2% x coordinate defined by its bounds, get the whole set 1613 1616 Coord{1}=linspace(Coord{1}(1),Coord{1}(2),CellInfo{icell}.CoordSize(1)); … … 1634 1637 ProjData.(VarName)=interp2(X,Y,double(FieldData.(VarName)(:,:,1)),XI,YI,'*linear'); 1635 1638 for icolor=2:size(FieldData.(VarName),3)% project 'color' components 1636 ProjData.(VarName)=cat(3,ProjData.(VarName),interp2(X,Y,double(FieldData.(VarName)(:,:,icolor)),XI,YI,'*linear')); 1639 ProjData.(VarName)=cat(3,ProjData.(VarName),interp2(X,Y,double(FieldData.(VarName)(:,:,icolor)),XI,YI,'*linear')); 1637 1640 end 1638 1641 end … … 1674 1677 end 1675 1678 end 1676 else %projection of structured coordinates on oblique plane 1679 else %projection of structured coordinates on oblique plane 1677 1680 % determine the boundaries of the projected field, 1678 1681 % first find the 8 summits of the initial volume in the … … 1683 1686 Coord{3}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(3)});%initial x coordinates 1684 1687 summit=zeros(3,8);% initialize summit coordinates 1685 summit(1,1:4)=[Coord{3}(1) Coord{3}(end) Coord{3}(1) Coord{3}(end)];%square 1688 summit(1,1:4)=[Coord{3}(1) Coord{3}(end) Coord{3}(1) Coord{3}(end)];%square 1686 1689 summit(2,1:4)=[Coord{2}(1) Coord{2}(1) Coord{2}(end) Coord{2}(end)];% square at z= Coord{1}(1) 1687 1690 summit(1:2,5:8)=summit(1:2,1:4); … … 1691 1694 ObjectData.Coord=ObjectData.Coord';% set ObjectData.Coord as a vertical vector 1692 1695 if size(ObjectData.Coord,1)<3 1693 ObjectData.Coord=[ObjectData.Coord; 0];%add z origin at z=0 by default1694 end 1695 1696 ObjectData.Coord=[ObjectData.Coord; 0];%add z origin at z=0 by default 1697 end 1698 1696 1699 M1=[cos(PlaneAngle(1)) sin(PlaneAngle(1)) 0;-sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1]; 1697 1700 M2=[1 0 0;0 cos(PlaneAngle(2)) sin(PlaneAngle(2));0 -sin(PlaneAngle(2)) cos(PlaneAngle(2))]; … … 1712 1715 1713 1716 %modangle=sqrt(PlaneAngle(1)*PlaneAngle(1)+PlaneAngle(2)*PlaneAngle(2)); 1714 % cosphi=PlaneAngle(1)/modangle;1715 % sinphi=PlaneAngle(2)/modangle;1717 % cosphi=PlaneAngle(1)/modangle; 1718 % sinphi=PlaneAngle(2)/modangle; 1716 1719 iX=[coord_x_proj(end)-coord_x_proj(1);0;0]/(npx-1); 1717 1720 iY=[0;coord_y_proj(end)-coord_y_proj(1);0]/(npy-1); 1718 1721 iZ=[0;0;coord_z_proj(end)-coord_z_proj(1)]/(npz-1); 1719 % iX(1:2)=[cosphi -sinphi;sinphi cosphi]*iX(1:2);1720 % iY(1:2)=[-cosphi -sinphi;sinphi cosphi]*iY(1:2);1722 % iX(1:2)=[cosphi -sinphi;sinphi cosphi]*iX(1:2); 1723 % iY(1:2)=[-cosphi -sinphi;sinphi cosphi]*iY(1:2); 1721 1724 1722 1725 ix=M_inv*iX;% vector along the new x coordinates transformed into old coordinates 1723 1726 iy=M_inv*iY;% vector along y coordinates 1724 1727 iz=M_inv*iZ;% vector along z coordinates 1725 1728 1726 1729 [Grid_x,Grid_y,Grid_z]=meshgrid(0:npx-1,0:npy-1,0:npz-1); 1727 1730 if ismatrix(Grid_x)% add a singleton in case of a single z value … … 1733 1736 YI=Origin(2)+ix(2)*Grid_x+iy(2)*Grid_y+iz(2)*Grid_z; 1734 1737 ZI=Origin(3)+ix(3)*Grid_x+iy(3)*Grid_y+iz(3)*Grid_z; 1735 [X,Y,Z]=meshgrid(Coord{3},Coord{2},Coord{1});% mesh in the initial coordinates1738 [X,Y,Z]=meshgrid(Coord{3},Coord{2},Coord{1});% mesh in the initial coordinates 1736 1739 for ivar=VarIndex 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1740 VarName=FieldData.ListVarName{ivar}; 1741 ListVarName=[ListVarName VarName]; 1742 VarDimName=[VarDimName {{'coord_y','coord_x'}}]; 1743 VarAttribute{length(ListVarName)}=FieldData.VarAttribute{ivar}; %reproduce the variable attributes 1744 FieldData.(VarName)=permute(FieldData.(VarName),[2 3 1]); 1745 ProjData.coord_x=coord_x_proj; 1746 ProjData.coord_y=coord_y_proj; 1747 ProjData.(VarName)=interp3(X,Y,Z,double(FieldData.(VarName)),XI,YI,ZI,'*linear'); 1748 ProjData.(VarName)=nanmean(ProjData.(VarName),3); 1749 ProjData.(VarName)=squeeze(ProjData.(VarName)); 1747 1750 end 1748 1751 end … … 1775 1778 UName=ListVarName{ivar_U}; 1776 1779 VName=ListVarName{ivar_V}; 1777 UValue=cos(PlaneAngle(3))*ProjData.(UName)+ sin(PlaneAngle(3))*ProjData.(VName); 1778 ProjData.(VName)=(-sin(PlaneAngle(3))*ProjData.(UName)+ cos(PlaneAngle(3))*ProjData.(VName)); 1780 if checkM2 1781 UValue=cos(PlaneAngle(1))*ProjData.(UName)+ sin(PlaneAngle(1))*ProjData.(VName); 1782 ProjData.(VName)=(-sin(PlaneAngle(1))*ProjData.(UName)+ cos(PlaneAngle(1))*ProjData.(VName)); 1783 else 1784 UValue=cos(PlaneAngle(1))*ProjData.(UName)+ sin(PlaneAngle(1))*ProjData.(VName); 1785 ProjData.(VName)=(-sin(PlaneAngle(1))*ProjData.(UName)+ cos(PlaneAngle(1))*ProjData.(VName)); 1786 end 1779 1787 ProjData.(UName)=UValue; 1780 1788 if ~isempty(ivar_W) -
trunk/src/series/extract_rdvision.m
r1059 r1060 538 538 end 539 539 Dti_stamp=(timestamp(1+NbDti,1)-timestamp(1,1))/NbDti; 540 Dti_stamp=(timestamp(1+NbDti,1)-timestamp(2,1))/(NbDti-1); 540 541 t=set(t,uid_content_Dti,'value',num2str(Dti_stamp));%corret Dti 541 542 if abs(Dti_stamp-Dti)>Dti/1000 -
trunk/src/set_object.m
r1059 r1060 165 165 % if isfield(data,'Angle') && isequal(numel(data.Angle),3) 166 166 set(handles.num_Angle_1,'String',num2str(data.Angle(1))) 167 set(handles.num_Angle_2,'String',num2str(data.Angle(2)))167 % set(handles.num_Angle_2,'String',num2str(data.Angle(2))) 168 168 % set(handles.num_Angle_3,'String',num2str(data.Angle(3))) 169 169 % end … … 332 332 set(handles.num_RangeY_2,'TooltipString',['num_RangeY_2: half width of the ' ObjectStyle]) 333 333 case {'plane','plane_z'} 334 set(handles.num_Angle_ 3,'Visible','on')334 set(handles.num_Angle_1,'Visible','on') 335 335 set(handles.num_RangeX_1,'Visible','on') 336 336 set(handles.num_RangeX_2,'Visible','on') … … 418 418 PlaneAngle(2)=str2num(get(handles.num_Angle_2,'String'));%second angle in degrees 419 419 %PlaneAngle(3)=str2num(get(handles.num_Angle_3,'String'));%second angle in degrees 420 om=norm(PlaneAngle);%norm of rotation angle in radians 421 OmAxis=PlaneAngle/om; %unit vector marking the rotation axis 422 cos_om=cos(pi*om/180); 423 sin_om=sin(pi*om/180); 424 coeff=OmAxis(3)*(1-cos_om); 420 % om=norm(PlaneAngle);%norm of rotation angle in radians 421 % OmAxis=PlaneAngle/om; %unit vector marking the rotation axis 422 cos_om1=cos(pi*PlaneAngle(1)/180); 423 sin_om1=sin(pi*PlaneAngle(1)/180); 424 cos_om2=cos(pi*PlaneAngle(2)/180); 425 sin_om2=sin(pi*PlaneAngle(2)/180); 425 426 %components of the unity vector norm_plane normal to the projection plane 426 norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;427 norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;428 norm_plane(3)=OmAxis(3)*coeff+cos_om;427 % norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; 428 % norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; 429 % norm_plane(3)=OmAxis(3)*coeff+cos_om; 429 430 huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle 430 431 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface 431 432 if isfield(UvData,'X') && isfield(UvData,'Y') && isfield(UvData,'Z') 432 Z= norm_plane(1)*(UvData.X)+norm_plane(2)*(UvData.Y)+norm_plane(3)*(UvData.Z);433 Z=sin_om2*(cos_om1*(UvData.X)+sin_om1*(UvData.Y))+cos_om2*(UvData.Z); 433 434 set(handles.z_slider,'Min',min(Z)) 434 435 set(handles.z_slider,'Max',max(Z)) -
trunk/src/uvmat.m
r1059 r1060 5854 5854 function CheckEditObject_Callback(hObject, eventdata, handles) 5855 5855 %------------------------------------------------------------------- 5856 get(handles.CheckEditObject,'Value') 5856 5857 hset_object=findobj(allchild(0),'Tag','set_object'); 5857 if get(handles.CheckEditObject,'Value') 5858 if get(handles.CheckEditObject,'Value')% if the edit box has been selected 5858 5859 %suppress the other options 5859 5860 set(handles.MenuObject,'checked','off') … … 5883 5884 check_view=get(handles.CheckViewObject,'Value'); 5884 5885 hset_object=findobj(allchild(0),'tag','set_object'); 5885 if ~isempty(hset_object)5886 delete(hset_object)% delete existing version of set_object5887 end5886 % if ~isempty(hset_object) 5887 % delete(hset_object)% delete existing version of set_object 5888 % end 5888 5889 if check_view %activate set_object 5889 5890 IndexObj=get(handles.ListObject,'Value'); … … 5910 5911 5911 5912 %% initiate the new projection object 5913 if isempty(hset_object) 5912 5914 hset_object=set_object(data,[],ZBounds); 5913 5915 set(hset_object,'name','set_object') 5916 end 5917 5914 5918 hhset_object=guidata(hset_object); 5915 5919 if get(handles.CheckEditObject,'Value')% edit mode
Note: See TracChangeset
for help on using the changeset viewer.