Changeset 933 for trunk/src


Ignore:
Timestamp:
Mar 25, 2016, 1:10:12 PM (8 years ago)
Author:
sommeria
Message:

physpolar corrected

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r924 r933  
    16401640                UName=ListVarName{ivar_U};
    16411641                VName=ListVarName{ivar_V};
    1642                 ProjData.(UName)=cos(PlaneAngle(3))*ProjData.(UName)+ sin(PlaneAngle(3))*ProjData.(VName);
     1642                UValue=cos(PlaneAngle(3))*ProjData.(UName)+ sin(PlaneAngle(3))*ProjData.(VName);
    16431643                ProjData.(VName)=(-sin(PlaneAngle(3))*ProjData.(UName)+ cos(PlaneAngle(3))*ProjData.(VName));
     1644                ProjData.(UName)=UValue;
    16441645                if ~isempty(ivar_W)
    16451646                    WName=FieldData.ListVarName{ivar_W};
    1646                     ProjData.(VName)=ProjData.(VName)+ ProjData.(WName)*sin(Theta);%
     1647                    VValue=ProjData.(VName)+ ProjData.(WName)*sin(Theta);%
    16471648                    ProjData.(WName)=NormVec_X*ProjData.(UName)+ NormVec_Y*ProjData.(VName)+ NormVec_Z* ProjData.(WName);
     1649                    ProjData.(VName)=VValue;
    16481650                end
    16491651            end
  • trunk/src/transform_field/phys_polar.m

    r924 r933  
    4646function DataOut=phys_polar(DataIn,XmlData,DataIn_1,XmlData_1)
    4747%------------------------------------------------------------------------
     48%% request input parameters
     49if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0)
     50    prompt = {'origin [x y] of polar coordinates';'reference radius';'reference angle(degrees)'};
     51    dlg_title = 'set the parameters for the polar coordinates';
     52    num_lines= 2;
     53    def     = { '[0 0]';'0';'0'};
     54    if isfield(XmlData,'TransformInput')
     55        if isfield(XmlData.TransformInput,'PolarCentre')
     56            def{1}=num2str(XmlData.TransformInput.PolarCentre);
     57        end
     58        if isfield(XmlData.TransformInput,'PolarReferenceRadius')
     59            def{2}=num2str(XmlData.TransformInput.PolarReferenceRadius);
     60        end
     61        if isfield(XmlData.TransformInput,'PolarReferenceAngle')
     62            def{3}=num2str(XmlData.TransformInput.PolarReferenceAngle);
     63        end
     64    end
     65    answer = inputdlg(prompt,dlg_title,num_lines,def);
     66    DataOut.TransformInput.PolarCentre=str2num(answer{1});
     67    DataOut.TransformInput.PolarReferenceRadius=str2num(answer{2});
     68    DataOut.TransformInput.PolarReferenceAngle=str2num(answer{3});
     69    return
     70end
     71
    4872Calib{1}=[];
    4973if nargin==2||nargin==4
     
    6892%parameters for polar coordinates (taken from the calibration data of the first field)
    6993%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     94XmlData.PolarReferenceRadius=450;
     95XmlData.PolarReferenceAngle=450*pi/2;
    7096origin_xy=[0 0];%center for the polar coordinates in the original x,y coordinates
    71 if isfield(XmlData,'PolarCentre') && isnumeric(XmlData.PolarCentre)
    72     if isequal(length(XmlData.PolarCentre),2);
    73         origin_xy= XmlData.PolarCentre;
    74     end
    75 end
    76 radius_offset=0;%reference radius used to offset the radial coordinate r
     97radius_offset=0;%reference radius used to offset the radial coordinate r
    7798angle_offset=0; %reference angle used as new origin of the polar angle (= axis Ox by default)
    78 if isfield(XmlData,'PolarReferenceRadius') && isnumeric(XmlData.PolarReferenceRadius)
    79     radius_offset=XmlData.PolarReferenceRadius;
    80 end
    81 if radius_offset > 0
    82     angle_scale=radius_offset; %the azimuth is rescale in terms of the length along the reference radius
    83 else
    84     angle_scale=180/pi; %polar angle in degrees
    85 end
    86 if isfield(XmlData,'PolarReferenceAngle') && isnumeric(XmlData.PolarReferenceAngle)
    87     angle_offset=XmlData.PolarReferenceAngle; %offset angle (in unit of the final angle, degrees or arc length along the reference radius))
    88 end
    89 % new x coordinate = radius-radius_offset;
    90 % new y coordinate = theta*angle_scale-angle_offset
     99if isfield(XmlData,'TransformInput')
     100    if isfield(XmlData.TransformInput,'PolarCentre') && isnumeric(XmlData.TransformInput.PolarCentre)
     101        if isequal(length(XmlData.TransformInput.PolarCentre),2);
     102            origin_xy= XmlData.TransformInput.PolarCentre;
     103        end
     104    end
     105    if isfield(XmlData.TransformInput,'PolarReferenceRadius') && isnumeric(XmlData.TransformInput.PolarReferenceRadius)
     106        radius_offset=XmlData.TransformInput.PolarReferenceRadius;
     107    end
     108    if radius_offset > 0
     109        angle_scale=radius_offset; %the azimuth is rescale in terms of the length along the reference radius
     110    else
     111        angle_scale=180/pi; %polar angle in degrees
     112    end
     113    if isfield(XmlData.TransformInput,'PolarReferenceAngle') && isnumeric(XmlData.TransformInput.PolarReferenceAngle)
     114        angle_offset=(pi/180)*XmlData.TransformInput.PolarReferenceAngle; %offset angle (in unit of the final angle, degrees or arc length along the reference radius))
     115    end
     116end
    91117
    92118%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    173199        [theta,DataOut.X] = cart2pol(DataOut.X,DataOut.Y);%theta  and X are the polar coordinates angle and radius
    174200          %shift and renormalize the polar coordinates
    175         DataOut.X=DataOut.X-radius_offset;%
    176         DataOut.Y=theta*angle_scale-angle_offset;% normalized angle: distance along reference radius
     201        DataOut.X=DataOut.X-radius_offset;%shift the origin of radius, taken as the new X coordinate
     202        DataOut.Y=(theta-angle_offset)*angle_scale;% normalized angle: distance along reference radius,taken as the new Y coordinate
    177203        %transform velocity field if exists
    178         if isfield(Data,'U')&isfield(Data,'V')&~isempty(Data.U) & ~isempty(Data.V)& isfield(Data,'dt')
    179             if ~isempty(Data.dt)
    180             [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z);
    181             [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z);
    182             UX=(XOut_2-XOut_1)/Data.dt;
    183             VY=(YOut_2-YOut_1)/Data.dt;      
     204        if isfield(Data,'U') & isfield(Data,'V') & ~isempty(Data.U) & ~isempty(Data.V)& isfield(Data,'Dt')
     205            if ~isempty(Data.Dt)
     206            [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z);% X,Y positions of the vector origin in phys
     207            [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z);% X,Y positions of the vector end in phys
     208            UX=(XOut_2-XOut_1)/Data.Dt;% phys velocity u component
     209            VY=(YOut_2-YOut_1)/Data.Dt; % phys velocity v component     
    184210            %transform u,v into polar coordiantes
    185211            DataOut.U=UX.*cos(theta)+VY.*sin(theta);%radial velocity
    186             DataOut.V=(-UX.*sin(theta)+VY.*cos(theta));%./(DataOut.X)%+radius_ref);%angular velocity calculated
     212            DataOut.V=(-UX.*sin(theta)+VY.*cos(theta));%./(DataOut.X)%+radius_ref);% azimuthal velocity component
    187213            %shift and renormalize the angular velocity
    188214            end
     
    190216        %transform of spatial derivatives
    191217        if isfield(Data,'X') && ~isempty(Data.X) && isfield(Data,'DjUi') && ~isempty(Data.DjUi)...
    192                 && isfield(Data,'dt')
    193             if ~isempty(Data.dt)
     218                && isfield(Data,'Dt')
     219            if ~isempty(Data.Dt)
    194220                % estimate the Jacobian matrix DXpx/DXphys
    195221                for ip=1:length(Data.X)
     
    207233                    DataOut.DjUi(ip,:,:)=DjUi';
    208234                end
    209                 DataOut.DjUi =  DataOut.DjUi/Data.dt;   %     min(Data.DjUi(:,1,1))=DUDX
     235                DataOut.DjUi =  DataOut.DjUi/Data.Dt;   %     min(Data.DjUi(:,1,1))=DUDX
    210236            end
    211237        end
Note: See TracChangeset for help on using the changeset viewer.