Changeset 492 for trunk/src/proj_field.m
- Timestamp:
- Jul 15, 2012, 10:30:28 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/proj_field.m
r491 r492 536 536 %project on a line 537 537 % AJOUTER flux,circul,error 538 % OUTPUT: 539 % ProjData: projected field 540 % 538 541 function [ProjData,errormsg] = proj_line(FieldData, ObjectData) 539 542 %----------------------------------------------------------------- … … 547 550 if isfield(ObjectData,'ProjMode'),ProjMode=ObjectData.ProjMode; end; 548 551 % ProjAngle=90; %90 degrees projection by default 549 % if isfield(FieldData,'ProjAngle'),ProjAngle=ObjectData.ProjAngle; end; 552 550 553 width=0;%default width of the projection band 551 554 if isfield(ObjectData,'Range')&&size(ObjectData.Range,2)>=2 … … 569 572 ListIndex={}; 570 573 571 % angles of the polyline and boundaries of action574 %% angles of the polyline and boundaries of action 572 575 dlinx=diff(ObjectData.Coord(:,1)); 573 576 dliny=diff(ObjectData.Coord(:,2)); 574 theta=angle(dlinx+ i*dliny);%angle of each segment577 theta=angle(dlinx+1i*dliny);%angle of each segment 575 578 theta(siz_line(1))=theta(siz_line(1)-1); 576 579 % determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'filter') 580 xsup=zeros(1,siz_line(1)); xinf=zeros(1,siz_line(1)); ysup=zeros(1,siz_line(1)); yinf=zeros(1,siz_line(1)); 577 581 if isequal(ProjMode,'projection') || isequal(ProjMode,'filter') 578 582 xsup(1)=ObjectData.Coord(1,1)-width*sin(theta(1)); … … 588 592 end 589 593 590 % group the variables (fields of 'FieldData') in cells of variables with the same dimensions594 %% group the variables (fields of 'FieldData') in cells of variables with the same dimensions 591 595 [CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData); 592 596 if ~isempty(errormsg) … … 595 599 end 596 600 597 % loop on variable cells with the same space dimension601 %% loop on variable cells with the same space dimension 598 602 ProjData.ListVarName={}; 599 603 ProjData.VarDimName={}; 604 testproj=zeros(size(FieldData.ListVarName)); 600 605 for icell=1:length(CellVarIndex) 601 606 VarIndex=CellVarIndex{icell};% indices of the selected variables in the list FieldData.ListVarName … … 605 610 end 606 611 testX=~isempty(VarType.coord_x) && ~isempty(VarType.coord_y);% test for unstructured coordinates 612 test_tps=~isempty(VarType.coord_tps); 607 613 testU=~isempty(VarType.vector_x) && ~isempty(VarType.vector_y);% test for vectors 608 614 testfalse=~isempty(VarType.errorflag);% test for error flag 609 615 testproj(VarIndex)=zeros(size(VarIndex));% test =1 for simply projected variables, default =0 610 616 %=0 for vector components, treated separately 611 testproj(VarType.scalar)=1; 612 testproj(VarType.image)=1; 613 testproj(VarType.color)=1; 617 testproj([VarType.scalar VarType.image VarType.color VarType.vector_x VarType.vector_y])=1; 614 618 VarIndex=VarIndex(find(testproj(VarIndex)));%select only the projected variables 615 if testU 616 VarIndex=[VarIndex VarType.vector_x VarType.vector_y];%append u and v at the end of the list of variables 617 end 619 618 620 %identify vector components 619 621 if testU 620 622 UName=FieldData.ListVarName{VarType.vector_x}; 621 623 VName=FieldData.ListVarName{VarType.vector_y}; 622 eval(['vector_x=FieldData.' UName ';'])623 eval(['vector_y=FieldData.' VName ';'])624 vector_x=FieldData.(UName); 625 vector_y=FieldData.(VName); 624 626 end 625 627 %identify error flag 626 628 if testfalse 627 629 FFName=FieldData.ListVarName{VarType.errorflag}; 628 e val(['errorflag=FieldData.' FFName ';'])630 errorflag=FieldData.(FFName); 629 631 end 630 632 % check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y … … 648 650 XName= FieldData.ListVarName{VarType.coord_x}; 649 651 YName= FieldData.ListVarName{VarType.coord_y}; 650 eval(['coord_x=FieldData.' XName ';'])651 eval(['coord_y=FieldData.' YName ';'])652 coord_x=FieldData.(XName); 653 coord_y=FieldData.(YName); 652 654 end 653 655 %initiate projection … … 737 739 end 738 740 ProjData.X=XLine'; 739 cur_index=1;740 741 ProjData.ListVarName=[ProjData.ListVarName {XName}]; 741 742 ProjData.VarDimName=[ProjData.VarDimName {XName}]; … … 871 872 ProjData.VarDimName{end}={AXName,'rgb'}; 872 873 end 873 end 874 end 875 elseif test_tps 876 if isfield(ObjectData,'DX')&~isempty(ObjectData.DX) 877 DX=abs(ObjectData.DX);%mesh of interpolation points along the line 878 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 879 xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1) 880 yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2) 881 % coord_x_proj=XMin:DX:XMax; 882 % coord_y_proj=YMin:DY:YMax; 883 DataOut=calc_field(FieldData.FieldList,FieldData,cat(3,xreg,yreg)); 884 ProjData.ListVarName=[ProjData.ListVarName DataOut.ListVarName]; 885 ProjData.VarDimName=[ProjData.VarDimName DataOut.VarDimName]; 886 ProjData.VarAttribute=[ProjData.VarAttribute DataOut.VarAttribute]; 887 DataOut.ListVarName(1)=[]; 888 DataOut.VarDimName(1)=[]; 889 DataOut.VarAttribute(1)=[]; 890 for ilist=2:length(DataOut.ListVarName)% reshape data, excluding coordinates (ilist=1-2), TODO: rationalise 891 VarName=DataOut.ListVarName{ilist}; 892 ProjData.(VarName)=DataOut.(VarName); 893 end 894 ProjData.coord_x=Xproj; 895 end 874 896 end 875 897 end
Note: See TracChangeset
for help on using the changeset viewer.