Index: trunk/src/transform_field/phys_polar.m
===================================================================
--- trunk/src/transform_field/phys_polar.m	(revision 1093)
+++ trunk/src/transform_field/phys_polar.m	(revision 1094)
@@ -52,5 +52,5 @@
     dlg_title = 'set the parameters for the polar coordinates';
     num_lines= 2;
-    def     = { '[0 0]';'0';'0';'+'};
+    def     = { '[0 0]';'';'0';'+'};
     if isfield(XmlData,'TransformInput')
         if isfield(XmlData.TransformInput,'PolarCentre')
@@ -87,5 +87,5 @@
 DataCell{2}=[];%default
 checkpixel(1)=0;
-if isfield(DataCell{1},'CoorUnit')&& strcmp(DataCell{1}.CoorUnit,'px') 
+if isfield(DataCell{1},'CoordUnit')&& strcmp(DataCell{1}.CoordUnit,'pixel') 
     checkpixel(1)=1;
 end
@@ -101,5 +101,5 @@
 if nargin==4% case of two input fields
     checkpixel(2)=0;
-if isfield(DataCell{2},'CoorUnit')&& strcmp(DataCell{2}.CoorUnit,'px') 
+if isfield(DataCell{2},'CoordUnit')&& strcmp(DataCell{2}.CoordUnit,'pixel') 
     checkpixel(2)=1;
 end
@@ -124,10 +124,10 @@
         end
     end
-    if isfield(XmlData.TransformInput,'PolarReferenceRadius') && isnumeric(XmlData.TransformInput.PolarReferenceRadius)
+    if isfield(XmlData.TransformInput,'PolarReferenceRadius') && ~isempty(XmlData.TransformInput.PolarReferenceRadius)
         radius_offset=XmlData.TransformInput.PolarReferenceRadius;
     end
     if radius_offset > 0
         angle_scale=radius_offset; %the azimuth is rescale in terms of the length along the reference radius
-        check_degree=0; %the output has the same unit asthe input
+        check_degree=0; %the output has the same unit as the input
     else
         angle_scale=180/pi; %polar angle in degrees
@@ -144,5 +144,5 @@
 
 nbvar=0;%counter for the number of output variables
-nbcoord=0;%counter for the number of variables for radial coordiantes (case of multiple field inputs)
+nbcoord=0;%counter for the number of variablecheck_degrees for radial coordiantes (case of multiple field inputs)
 nbgrid=0;%counter for the number of gridded fields (all linearly interpolated on the same output polar grid)
 nbscattered=0;%counter of scattered fields
@@ -157,5 +157,4 @@
         return
     end
-    % end
     %transform of X,Y coordinates for vector fields
     if isfield(DataCell{ifield},'ZIndex')&& ~isempty(DataCell{ifield}.ZIndex)
@@ -180,18 +179,33 @@
                 Data.VarAttribute{nbvar-1}.Role='coord_x';
                 check_unit=1;
-                if isfield(DataCell{ifield},'CoordUnit')
-                    Data=rmfield(Data,'CoordUnit');
-                    Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit;
-                elseif isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')
-                    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
+                %unit of output field
+                if isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')
+                    radius_unit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units
+                elseif isfield(DataCell{ifield},'CoordUnit')
+                    radius_unit=DataCell{ifield}.CoordUnit;
                 else
-                    check_unit=0;
-                end
+                    radius_unit='';
+                end
+                Data.VarAttribute{nbvar-1}.units=radius_unit;
+                if check_degree
+                     Data.VarAttribute{nbvar}.units='degree';
+                else %case of a reference radius
+                    Data.VarAttribute{nbvar}.units=radius_unit;
+                    Data.CoordUnit=radius_unit;
+                end
+%                 if isfield(DataCell{ifield},'CoordUnit')
+%                     Data=rmfield(Data,'CoordUnit');
+%                     Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit;
+%                 elseif isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')
+%                     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
+%                 else
+%                     check_unit=0;
+%                 end
                 Data.VarAttribute{nbvar}.Role='coord_y';
-                if check_degree
-                Data.VarAttribute{nbvar}.unit='degree';
-                elseif check_unit
-                    Data.VarAttribute{nbvar}.unit=Data.VarAttribute{nbvar-1}.unit;
-                end
+%                 if check_degree
+%                 Data.VarAttribute{nbvar}.units='degree';
+%                 elseif check_unit
+%                     Data.VarAttribute{nbvar}.units=Data.VarAttribute{nbvar-1}.units;
+%                 end
   
                 %transform u,v into polar coordinates
@@ -250,28 +264,29 @@
                 if nbgrid==0% no gridded data yet, introduce the coordinate variables common to all gridded data
                     nbcoord=nbcoord+1;%add new radial coordinates for the first gridded field
-                    radius_name = rename_indexing(radius_name,Data.ListVarName);
-                    theta_name = rename_indexing(theta_name,Data.ListVarName);
-                    Data.ListVarName = [Data.ListVarName {radius_name} {theta_name}];
+                    radius_name = rename_indexing(radius_name,Data.ListVarName);% add an index to the name, or increment an existing index,
+                    theta_name = rename_indexing(theta_name,Data.ListVarName);% if the proposed Name already exists in the list
+                    Data.ListVarName = [Data.ListVarName {radius_name} {theta_name}];%add polar coordinates to the list of variables
                     Data.VarDimName=[Data.VarDimName {radius_name} {theta_name}];
                     nbvar=nbvar+2;
                     if check_reverse
-                                            Data.VarAttribute{nbvar-1}.Role='coord_y';
-                    Data.VarAttribute{nbvar}.Role='coord_x';
+                        Data.VarAttribute{nbvar-1}.Role='coord_y';
+                        Data.VarAttribute{nbvar}.Role='coord_x';
                     else
-                    Data.VarAttribute{nbvar-1}.Role='coord_x';
-                    Data.VarAttribute{nbvar}.Role='coord_y';
+                        Data.VarAttribute{nbvar-1}.Role='coord_x';
+                        Data.VarAttribute{nbvar}.Role='coord_y';
                     end
                     check_unit=1;
-                    if isfield(DataCell{ifield},'CoordUnit')
-                        Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit;
-                    elseif isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')
-                        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
+
+                    if isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')
+                        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
+                    elseif isfield(DataCell{ifield},'CoordUnit')
+                        Data.VarAttribute{nbvar-1}.units=DataCell{ifield}.CoordUnit;%radius in coord units
                     else
                         check_unit=0;
                     end
                     if check_degree
-                        Data.VarAttribute{nbvar}.unit='degree';
+                        Data.VarAttribute{nbvar}.units='degree';%angle in degree
                     elseif check_unit
-                        Data.VarAttribute{nbvar}.unit=Data.VarAttribute{nbvar-1}.unit;
+                        Data.VarAttribute{nbvar}.units=Data.VarAttribute{nbvar-1}.units;% angle in coord unit (normalised by reference radiuss)
                     end
                 end
@@ -282,6 +297,4 @@
                     FieldName{nbgrid}=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_scalar};
                     A{nbgrid}=DataCell{ifield}.(FieldName{nbgrid});
-%                     Data.ListVarName=[Data.ListVarName {FieldName{nbgrid}}];
-%                     Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}}];
                     nbpoint(nbgrid)=numel(A{nbgrid});
                     check_scalar(nbgrid)=1;
@@ -296,5 +309,5 @@
                     A{nbgrid+1}=DataCell{ifield}.(FieldName{nbgrid+1});
                     A{nbgrid+2}=DataCell{ifield}.(FieldName{nbgrid+2});
-                   % Data.ListVarName=[Data.ListVarName {'U_r','U_theta'}];
+                    % Data.ListVarName=[Data.ListVarName {'U_r','U_theta'}];
                     %Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}} {{theta_name,radius_name}}];
                     Data.VarAttribute{nbvar+1}.Role='vector_x';
