Changeset 1094 for trunk/src/transform_field/phys_polar.m
- Timestamp:
- Mar 25, 2021, 9:37:04 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/transform_field/phys_polar.m
r1093 r1094 52 52 dlg_title = 'set the parameters for the polar coordinates'; 53 53 num_lines= 2; 54 def = { '[0 0]';' 0';'0';'+'};54 def = { '[0 0]';'';'0';'+'}; 55 55 if isfield(XmlData,'TransformInput') 56 56 if isfield(XmlData.TransformInput,'PolarCentre') … … 87 87 DataCell{2}=[];%default 88 88 checkpixel(1)=0; 89 if isfield(DataCell{1},'Coor Unit')&& strcmp(DataCell{1}.CoorUnit,'px')89 if isfield(DataCell{1},'CoordUnit')&& strcmp(DataCell{1}.CoordUnit,'pixel') 90 90 checkpixel(1)=1; 91 91 end … … 101 101 if nargin==4% case of two input fields 102 102 checkpixel(2)=0; 103 if isfield(DataCell{2},'Coor Unit')&& strcmp(DataCell{2}.CoorUnit,'px')103 if isfield(DataCell{2},'CoordUnit')&& strcmp(DataCell{2}.CoordUnit,'pixel') 104 104 checkpixel(2)=1; 105 105 end … … 124 124 end 125 125 end 126 if isfield(XmlData.TransformInput,'PolarReferenceRadius') && isnumeric(XmlData.TransformInput.PolarReferenceRadius)126 if isfield(XmlData.TransformInput,'PolarReferenceRadius') && ~isempty(XmlData.TransformInput.PolarReferenceRadius) 127 127 radius_offset=XmlData.TransformInput.PolarReferenceRadius; 128 128 end 129 129 if radius_offset > 0 130 130 angle_scale=radius_offset; %the azimuth is rescale in terms of the length along the reference radius 131 check_degree=0; %the output has the same unit as the input131 check_degree=0; %the output has the same unit as the input 132 132 else 133 133 angle_scale=180/pi; %polar angle in degrees … … 144 144 145 145 nbvar=0;%counter for the number of output variables 146 nbcoord=0;%counter for the number of variable s for radial coordiantes (case of multiple field inputs)146 nbcoord=0;%counter for the number of variablecheck_degrees for radial coordiantes (case of multiple field inputs) 147 147 nbgrid=0;%counter for the number of gridded fields (all linearly interpolated on the same output polar grid) 148 148 nbscattered=0;%counter of scattered fields … … 157 157 return 158 158 end 159 % end160 159 %transform of X,Y coordinates for vector fields 161 160 if isfield(DataCell{ifield},'ZIndex')&& ~isempty(DataCell{ifield}.ZIndex) … … 180 179 Data.VarAttribute{nbvar-1}.Role='coord_x'; 181 180 check_unit=1; 182 if isfield(DataCell{ifield},'CoordUnit')183 Data=rmfield(Data,'CoordUnit');184 Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit;185 elseif isfield( XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')186 Data.VarAttribute{nbvar-1}.unit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units181 %unit of output field 182 if isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit') 183 radius_unit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units 184 elseif isfield(DataCell{ifield},'CoordUnit') 185 radius_unit=DataCell{ifield}.CoordUnit; 187 186 else 188 check_unit=0; 189 end 187 radius_unit=''; 188 end 189 Data.VarAttribute{nbvar-1}.units=radius_unit; 190 if check_degree 191 Data.VarAttribute{nbvar}.units='degree'; 192 else %case of a reference radius 193 Data.VarAttribute{nbvar}.units=radius_unit; 194 Data.CoordUnit=radius_unit; 195 end 196 % if isfield(DataCell{ifield},'CoordUnit') 197 % Data=rmfield(Data,'CoordUnit'); 198 % Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit; 199 % elseif isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit') 200 % Data.VarAttribute{nbvar-1}.unit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units 201 % else 202 % check_unit=0; 203 % end 190 204 Data.VarAttribute{nbvar}.Role='coord_y'; 191 if check_degree192 Data.VarAttribute{nbvar}.unit='degree';193 elseif check_unit194 Data.VarAttribute{nbvar}.unit=Data.VarAttribute{nbvar-1}.unit;195 end205 % if check_degree 206 % Data.VarAttribute{nbvar}.units='degree'; 207 % elseif check_unit 208 % Data.VarAttribute{nbvar}.units=Data.VarAttribute{nbvar-1}.units; 209 % end 196 210 197 211 %transform u,v into polar coordinates … … 250 264 if nbgrid==0% no gridded data yet, introduce the coordinate variables common to all gridded data 251 265 nbcoord=nbcoord+1;%add new radial coordinates for the first gridded field 252 radius_name = rename_indexing(radius_name,Data.ListVarName); 253 theta_name = rename_indexing(theta_name,Data.ListVarName); 254 Data.ListVarName = [Data.ListVarName {radius_name} {theta_name}]; 266 radius_name = rename_indexing(radius_name,Data.ListVarName);% add an index to the name, or increment an existing index, 267 theta_name = rename_indexing(theta_name,Data.ListVarName);% if the proposed Name already exists in the list 268 Data.ListVarName = [Data.ListVarName {radius_name} {theta_name}];%add polar coordinates to the list of variables 255 269 Data.VarDimName=[Data.VarDimName {radius_name} {theta_name}]; 256 270 nbvar=nbvar+2; 257 271 if check_reverse 258 259 Data.VarAttribute{nbvar}.Role='coord_x';272 Data.VarAttribute{nbvar-1}.Role='coord_y'; 273 Data.VarAttribute{nbvar}.Role='coord_x'; 260 274 else 261 Data.VarAttribute{nbvar-1}.Role='coord_x';262 Data.VarAttribute{nbvar}.Role='coord_y';275 Data.VarAttribute{nbvar-1}.Role='coord_x'; 276 Data.VarAttribute{nbvar}.Role='coord_y'; 263 277 end 264 278 check_unit=1; 265 if isfield(DataCell{ifield},'CoordUnit') 266 Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit; 267 elseif isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit') 268 Data.VarAttribute{nbvar-1}.unit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units 279 280 if isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit') 281 Data.VarAttribute{nbvar-1}.units=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units 282 elseif isfield(DataCell{ifield},'CoordUnit') 283 Data.VarAttribute{nbvar-1}.units=DataCell{ifield}.CoordUnit;%radius in coord units 269 284 else 270 285 check_unit=0; 271 286 end 272 287 if check_degree 273 Data.VarAttribute{nbvar}.unit ='degree';288 Data.VarAttribute{nbvar}.units='degree';%angle in degree 274 289 elseif check_unit 275 Data.VarAttribute{nbvar}.unit =Data.VarAttribute{nbvar-1}.unit;290 Data.VarAttribute{nbvar}.units=Data.VarAttribute{nbvar-1}.units;% angle in coord unit (normalised by reference radiuss) 276 291 end 277 292 end … … 282 297 FieldName{nbgrid}=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_scalar}; 283 298 A{nbgrid}=DataCell{ifield}.(FieldName{nbgrid}); 284 % Data.ListVarName=[Data.ListVarName {FieldName{nbgrid}}];285 % Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}}];286 299 nbpoint(nbgrid)=numel(A{nbgrid}); 287 300 check_scalar(nbgrid)=1; … … 296 309 A{nbgrid+1}=DataCell{ifield}.(FieldName{nbgrid+1}); 297 310 A{nbgrid+2}=DataCell{ifield}.(FieldName{nbgrid+2}); 298 % Data.ListVarName=[Data.ListVarName {'U_r','U_theta'}];311 % Data.ListVarName=[Data.ListVarName {'U_r','U_theta'}]; 299 312 %Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}} {{theta_name,radius_name}}]; 300 313 Data.VarAttribute{nbvar+1}.Role='vector_x';
Note: See TracChangeset
for help on using the changeset viewer.