Ignore:
Timestamp:
May 21, 2018, 7:06:45 PM (6 years ago)
Author:
sommeria
Message:

find field cells improved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r1027 r1045  
    554554    return
    555555end
    556 CellInfo=CellInfo(NbDim>=2); %keep only the 2D cells
    557 %%%%%% TODO: treat 1D fields: project as identity so that P o P=P for projection operation
     556CellInfo=CellInfo(NbDim>=2); %keep only the 2D or 3D cells
    558557cell_select=true(size(CellInfo));
    559558
    560559for icell=1:length(CellInfo)
    561560    if isfield(CellInfo{icell},'ProjModeRequest')
    562         if ~strcmp(CellInfo{icell}.ProjModeRequest, ProjMode)
    563             cell_select(icell)=0;
    564         end
     561%         if ~strcmp(CellInfo{icell}.ProjModeRequest, ProjMode)
     562%             cell_select(icell)=0;
     563%         end
    565564        if strcmp(ProjMode,'interp_tps')&& ~strcmp(CellInfo{icell}.CoordType,'tps')
    566565            cell_select(icell)=0;
     
    851850                end
    852851               
    853                
    854                
    855                
    856                
    857852            else
    858853                AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
     
    929924                ProjData.ListVarName=[ProjData.ListVarName {AXName}];
    930925                ProjData.VarDimName=[ProjData.VarDimName {AXName}];
     926                nbvar=numel(ProjData.VarDimName);
     927                ProjData.VarAttribute{nbvar}.Role='coord_x';
    931928                for ivar=VarIndex
    932929                    %VarName{ivar}=FieldData.ListVarName{ivar};
     
    950947                    ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName{ivar}];
    951948                    ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate
    952                     ProjData.VarAttribute{ivar}.Role='continuous';% for plot with continuous line
     949                    nbvar=nbvar+1;
     950                    ProjData.VarAttribute{nbvar}.Role='coord_y';% for plot with continuous line
    953951                end
    954952                if nbcolor==3
     
    11221120
    11231121check_grid=zeros(size(CellInfo));% =1 if a grid is needed , =0 otherwise, for each field cell
    1124 ProjMode=cell(size(CellInfo));
    1125 for icell=1:numel(CellInfo)
    1126     ProjMode{icell}=ObjectData.ProjMode;% projection mode of the plane object
    1127 end
     1122ProjMode=num2cell(blanks(numel(CellInfo)));
     1123ProjMode=regexprep(ProjMode,' ',ObjectData.ProjMode);
     1124%ProjMode=cell(size(CellInfo));
     1125% for icell=1:numel(CellInfo)
     1126%     ProjMode{icell}=ObjectData.ProjMode;% projection mode of the plane object
     1127% end
    11281128icell_grid=[];% field cell index which defines the grid
    11291129if ~strcmp(ObjectData.ProjMode,'projection')&& ~strcmp(ObjectData.Type,'plane_z')% TODO:rationalize
     
    12021202    ProjData.ListVarName={AYName,AXName};
    12031203   
    1204     ProjData.VarAttribute={[],[]};
     1204    ProjData.VarAttribute{1}.Role='coord_y';
     1205    ProjData.VarAttribute{2}.Role='coord_x';
    12051206end
    12061207   
     
    12191220        continue % only cells represnting 2D or 3D fields are involved
    12201221    end
    1221     VarIndex=CellInfo{icell}.VarIndex;%  indices of the selected variables in the list FieldData.ListVarName
     1222    VarIndex= CellInfo{icell}.VarIndex;%  indices of the selected variables in the list FieldData.ListVarName
    12221223    %dimensions
    12231224    DimCell=FieldData.VarDimName{VarIndex(1)};
     
    12371238                continue %skip for next cell (needs tps field cell)
    12381239            end
    1239             coord_x=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)});% initial x coordinates
    1240             coord_y=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)});% initial y coordinates
     1240            coord_x=FieldData.(CellInfo{icell}.XName);% initial x coordinates
     1241            coord_y=FieldData.(CellInfo{icell}.YName);% initial y coordinates
    12411242            check3D=(numel(CellInfo{icell}.CoordIndex)==3);
    12421243            if check3D
    1243                 coord_z=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});
     1244                coord_z=FieldData.(CellInfo{icell}.ZName);
    12441245            end
    12451246           
     
    12561257                fieldZ=norm_plane(1)*coord_x + norm_plane(2)*coord_y+ norm_plane(3)*coord_z;% distance to the plane
    12571258                indcut=find(abs(fieldZ) <= width);
    1258                 for ivar=VarIndex
     1259                for ivar=[CellInfo{icell}.CoordIndex CellInfo{icell}.VarIndex]
    12591260                    VarName=FieldData.ListVarName{ivar};
    12601261                    FieldData.(VarName)=FieldData.(VarName)(indcut);
     
    13051306                    return
    13061307                end
    1307                 for ivar=VarIndex
     1308                for ivar=[CellInfo{icell}.CoordIndex CellInfo{icell}.VarIndex]
    13081309                    VarName=FieldData.ListVarName{ivar};
    13091310                    FieldData.(VarName)=FieldData.(VarName)(indcut);
     
    13211322                    nbvar=0;
    13221323                    %nbvar=numel(ProjData.ListVarName);
    1323                     for ivar=VarIndex %transfer variables to the projection plane
     1324                    for ivar=[CellInfo{icell}.CoordIndex CellInfo{icell}.VarIndex] %transfer variables to the projection plane
    13241325                        VarName=FieldData.ListVarName{ivar};
    13251326                        if ivar==CellInfo{icell}.CoordIndex(end)
     
    14011402                SubRange=FieldData.(FieldData.ListVarName{CellInfo{icell}.SubRange_tps});
    14021403                checkUV=0;
    1403                 if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')
    1404                     FieldVar=cat(3,FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x_tps}),FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y_tps}));
     1404                if strcmp(CellInfo{icell}.VarType,'vector')
     1405                    FieldVar=cat(3,FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}),FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}));
    14051406                    checkUV=1;
    14061407                end
Note: See TracChangeset for help on using the changeset viewer.