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/proj_field.m

    r1093 r1094  
    11251125ProjMode=num2cell(blanks(numel(CellInfo)));
    11261126ProjMode=regexprep(ProjMode,' ',ObjectData.ProjMode);
    1127 %ProjMode=cell(size(CellInfo));
    1128 % for icell=1:numel(CellInfo)
    1129 %     ProjMode{icell}=ObjectData.ProjMode;% projection mode of the plane object
    1130 % end
    11311127icell_grid=[];% field cell index which defines the grid
    11321128if strcmp(ObjectData.ProjMode,'projection')
     
    11921188        [XI,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
    11931189        ProjData.VarDimName={AYName,AXName};
    1194         %         XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system
    1195         %         YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3));
    11961190    else% we use the existing grid from field cell #icell_grid
    11971191        NbDim=NbDimArray(icell_grid);
     
    12041198        ProjData.(AXName)=FieldData.(AXName); % new (projected ) y coordinates
    12051199    end
    1206     ProjData.ListVarName={AYName,AXName};
    1207    
     1200    ProjData.ListVarName={AYName,AXName};   
    12081201    ProjData.VarAttribute{1}.Role='coord_y';
    12091202    ProjData.VarAttribute{2}.Role='coord_x';
     1203            YAttribute=FieldData.VarAttribute{CellInfo{icell_grid}.CoordIndex(NbDim-1)};
     1204        XAttribute=FieldData.VarAttribute{CellInfo{icell_grid}.CoordIndex(NbDim)};
     1205    if ~testangle
     1206        if isfield(YAttribute,'units')
     1207            ProjData.VarAttribute{1}.units=YAttribute.units;
     1208        end
     1209         if isfield(XAttribute,'units')
     1210            ProjData.VarAttribute{2}.units=XAttribute.units;
     1211         end
     1212    end
    12101213end
    12111214
     
    12441247            coord_x=FieldData.(CellInfo{icell}.XName);% initial x coordinates
    12451248            coord_y=FieldData.(CellInfo{icell}.YName);% initial y coordinates
    1246      
     1249           
    12471250            if check3D
    12481251                coord_z=FieldData.(CellInfo{icell}.ZName);
     
    13481351                        VarName_FF=FieldData.ListVarName{CellInfo{icell}.VarIndex_errorflag};
    13491352                        indsel=find(FieldData.(VarName_FF)==0);
     1353                        if isempty(indsel)
     1354                            errormsg='bad projection plane: no data found in the projection domain';
     1355                            return
     1356                        end
    13501357                        coord_X=coord_X(indsel);
    13511358                        coord_Y=coord_Y(indsel);
     
    16251632                    end
    16261633                    [X,Y]=meshgrid(Coord{2},Coord{1});%initial coordinates
    1627                     %name of error flag variable
    1628 %                     FFName='FF';%default name (if not already used)
    1629 %                     if isfield(ProjData,'FF')
    1630 %                         ind=1;
    1631 %                         while isfield(ProjData,['FF_' num2str(ind)])
    1632 %                             ind=ind+1;
    1633 %                         end
    1634 %                         FFName=['FF_' num2str(ind)];% append an index to the name of error flag, FF_1,FF_2...
    1635 %                     end
     1634
    16361635                    % project all variables in the cell
    16371636                    for ivar=VarIndex
     
    16561655                            VarAttribute{length(ListVarName)+nbcoord}=FieldData.VarAttribute{ivar};
    16571656                        end
    1658 %                         ProjData.(FFName)=isnan(ProjData.(VarName));%detact NaN (points outside the interpolation range)
    1659 %                         ProjData.(VarName)(ProjData.(FFName))=0; %set to 0 the NaN data
    1660                     end
    1661                     %update list of variables with error flag
    1662 %                     ListVarName=[ListVarName FFName];
    1663 %                     VarDimName=[VarDimName {DimCell}];
    1664 %                     VarAttribute{numel(ListVarName)}.Role='errorflag';
     1657                    end
    16651658                elseif ~testangle % 3Dcase without change of angle
    16661659                    % unstructured z coordinate
     
    16911684                    Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)});%initial y coordinates
    16921685                    Coord{3}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(3)});%initial x coordinates
    1693 
    16941686                    coord_x_proj=ObjectData.RangeX(1):InterpMesh:ObjectData.RangeX(2);% set of coordinates in the projection plane
    16951687                    coord_y_proj=ObjectData.RangeY(1):InterpMesh:ObjectData.RangeY(2);
     
    17001692                    YI_proj=M(2,1)*XI+M(2,2)*YI+ObjectData.Coord(1,2);
    17011693                    ZI_proj=M(3,1)*XI+M(3,2)*YI+ObjectData.Coord(1,3);
    1702                    
    1703    
    17041694                    for ivar=VarIndex
    17051695                        VarName=FieldData.ListVarName{ivar};
     
    17631753    end
    17641754end
    1765 % %prepare substraction in case of two input fields
    1766 % SubData.ListVarName={};
    1767 % SubData.VarDimName={};
    1768 % SubData.VarAttribute={};
    1769 % check_remove=zeros(size(ProjData.ListVarName));
    1770 % for iproj=1:numel(ProjData.VarAttribute)
    1771 %     if isfield(ProjData.VarAttribute{iproj},'CheckSub')&&isequal(ProjData.VarAttribute{iproj}.CheckSub,1)
    1772 %         VarName=ProjData.ListVarName{iproj};
    1773 %         SubData.ListVarName=[SubData.ListVarName {VarName}];
    1774 %         SubData.VarDimName=[SubData.VarDimName ProjData.VarDimName{iproj}];
    1775 %         SubData.VarAttribute=[SubData.VarAttribute ProjData.VarAttribute{iproj}];
    1776 %         SubData.(VarName)=ProjData.(VarName);
    1777 %         check_remove(iproj)=1;
    1778 %     end
    1779 % end
    1780 % if ~isempty(find(check_remove))
    1781 %     ind_remove=find(check_remove);
    1782 %     ProjData.ListVarName(ind_remove)=[];
    1783 %     ProjData.VarDimName(ind_remove)=[];
    1784 %     ProjData.VarAttribute(ind_remove)=[];
    1785 %     ProjData=sub_field(ProjData,[],SubData);
    1786 % end
    17871755
    17881756%-----------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.