Changeset 933 for trunk/src/transform_field/phys_polar.m
 Timestamp:
 Mar 25, 2016, 1:10:12 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/transform_field/phys_polar.m
r924 r933 46 46 function DataOut=phys_polar(DataIn,XmlData,DataIn_1,XmlData_1) 47 47 % 48 %% request input parameters 49 if 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 70 end 71 48 72 Calib{1}=[]; 49 73 if nargin==2nargin==4 … … 68 92 %parameters for polar coordinates (taken from the calibration data of the first field) 69 93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94 XmlData.PolarReferenceRadius=450; 95 XmlData.PolarReferenceAngle=450*pi/2; 70 96 origin_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 97 radius_offset=0;%reference radius used to offset the radial coordinate r 77 98 angle_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 = radiusradius_offset; 90 % new y coordinate = theta*angle_scaleangle_offset 99 if 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 116 end 91 117 92 118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 173 199 [theta,DataOut.X] = cart2pol(DataOut.X,DataOut.Y);%theta and X are the polar coordinates angle and radius 174 200 %shift and renormalize the polar coordinates 175 DataOut.X=DataOut.Xradius_offset;% 176 DataOut.Y= theta*angle_scaleangle_offset;% normalized angle: distance along reference radius201 DataOut.X=DataOut.Xradius_offset;%shift the origin of radius, taken as the new X coordinate 202 DataOut.Y=(thetaangle_offset)*angle_scale;% normalized angle: distance along reference radius,taken as the new Y coordinate 177 203 %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.XData.U/2,Data.YData.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_2XOut_1)/Data. dt;183 VY=(YOut_2YOut_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.XData.U/2,Data.YData.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_2XOut_1)/Data.Dt;% phys velocity u component 209 VY=(YOut_2YOut_1)/Data.Dt; % phys velocity v component 184 210 %transform u,v into polar coordiantes 185 211 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 calculated212 DataOut.V=(UX.*sin(theta)+VY.*cos(theta));%./(DataOut.X)%+radius_ref);% azimuthal velocity component 187 213 %shift and renormalize the angular velocity 188 214 end … … 190 216 %transform of spatial derivatives 191 217 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) 194 220 % estimate the Jacobian matrix DXpx/DXphys 195 221 for ip=1:length(Data.X) … … 207 233 DataOut.DjUi(ip,:,:)=DjUi'; 208 234 end 209 DataOut.DjUi = DataOut.DjUi/Data. dt; % min(Data.DjUi(:,1,1))=DUDX235 DataOut.DjUi = DataOut.DjUi/Data.Dt; % min(Data.DjUi(:,1,1))=DUDX 210 236 end 211 237 end
Note: See TracChangeset
for help on using the changeset viewer.