Ignore:
Timestamp:
Mar 25, 2021, 9:37:04 AM (3 years ago)
Author:
sommeria
Message:

phys_polar debugged

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/transform_field/phys_polar.m

    r1093 r1094  
    5252    dlg_title = 'set the parameters for the polar coordinates';
    5353    num_lines= 2;
    54     def     = { '[0 0]';'0';'0';'+'};
     54    def     = { '[0 0]';'';'0';'+'};
    5555    if isfield(XmlData,'TransformInput')
    5656        if isfield(XmlData.TransformInput,'PolarCentre')
     
    8787DataCell{2}=[];%default
    8888checkpixel(1)=0;
    89 if isfield(DataCell{1},'CoorUnit')&& strcmp(DataCell{1}.CoorUnit,'px')
     89if isfield(DataCell{1},'CoordUnit')&& strcmp(DataCell{1}.CoordUnit,'pixel')
    9090    checkpixel(1)=1;
    9191end
     
    101101if nargin==4% case of two input fields
    102102    checkpixel(2)=0;
    103 if isfield(DataCell{2},'CoorUnit')&& strcmp(DataCell{2}.CoorUnit,'px')
     103if isfield(DataCell{2},'CoordUnit')&& strcmp(DataCell{2}.CoordUnit,'pixel')
    104104    checkpixel(2)=1;
    105105end
     
    124124        end
    125125    end
    126     if isfield(XmlData.TransformInput,'PolarReferenceRadius') && isnumeric(XmlData.TransformInput.PolarReferenceRadius)
     126    if isfield(XmlData.TransformInput,'PolarReferenceRadius') && ~isempty(XmlData.TransformInput.PolarReferenceRadius)
    127127        radius_offset=XmlData.TransformInput.PolarReferenceRadius;
    128128    end
    129129    if radius_offset > 0
    130130        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 asthe input
     131        check_degree=0; %the output has the same unit as the input
    132132    else
    133133        angle_scale=180/pi; %polar angle in degrees
     
    144144
    145145nbvar=0;%counter for the number of output variables
    146 nbcoord=0;%counter for the number of variables for radial coordiantes (case of multiple field inputs)
     146nbcoord=0;%counter for the number of variablecheck_degrees for radial coordiantes (case of multiple field inputs)
    147147nbgrid=0;%counter for the number of gridded fields (all linearly interpolated on the same output polar grid)
    148148nbscattered=0;%counter of scattered fields
     
    157157        return
    158158    end
    159     % end
    160159    %transform of X,Y coordinates for vector fields
    161160    if isfield(DataCell{ifield},'ZIndex')&& ~isempty(DataCell{ifield}.ZIndex)
     
    180179                Data.VarAttribute{nbvar-1}.Role='coord_x';
    181180                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 units
     181                %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;
    187186                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
    190204                Data.VarAttribute{nbvar}.Role='coord_y';
    191                 if check_degree
    192                 Data.VarAttribute{nbvar}.unit='degree';
    193                 elseif check_unit
    194                     Data.VarAttribute{nbvar}.unit=Data.VarAttribute{nbvar-1}.unit;
    195                 end
     205%                 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
    196210 
    197211                %transform u,v into polar coordinates
     
    250264                if nbgrid==0% no gridded data yet, introduce the coordinate variables common to all gridded data
    251265                    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
    255269                    Data.VarDimName=[Data.VarDimName {radius_name} {theta_name}];
    256270                    nbvar=nbvar+2;
    257271                    if check_reverse
    258                                             Data.VarAttribute{nbvar-1}.Role='coord_y';
    259                     Data.VarAttribute{nbvar}.Role='coord_x';
     272                        Data.VarAttribute{nbvar-1}.Role='coord_y';
     273                        Data.VarAttribute{nbvar}.Role='coord_x';
    260274                    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';
    263277                    end
    264278                    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
    269284                    else
    270285                        check_unit=0;
    271286                    end
    272287                    if check_degree
    273                         Data.VarAttribute{nbvar}.unit='degree';
     288                        Data.VarAttribute{nbvar}.units='degree';%angle in degree
    274289                    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)
    276291                    end
    277292                end
     
    282297                    FieldName{nbgrid}=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_scalar};
    283298                    A{nbgrid}=DataCell{ifield}.(FieldName{nbgrid});
    284 %                     Data.ListVarName=[Data.ListVarName {FieldName{nbgrid}}];
    285 %                     Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}}];
    286299                    nbpoint(nbgrid)=numel(A{nbgrid});
    287300                    check_scalar(nbgrid)=1;
     
    296309                    A{nbgrid+1}=DataCell{ifield}.(FieldName{nbgrid+1});
    297310                    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'}];
    299312                    %Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}} {{theta_name,radius_name}}];
    300313                    Data.VarAttribute{nbvar+1}.Role='vector_x';
Note: See TracChangeset for help on using the changeset viewer.