Changeset 866 for trunk


Ignore:
Timestamp:
Feb 8, 2015, 7:26:02 AM (9 years ago)
Author:
sommeria
Message:

stereo_civ_updated

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field_tps.m

    r809 r866  
    121121        [EMDX,EMDY] = tps_eval_dxy(Coord_interp(ind_sel,:),Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the spatial derivatives from tps 'sources'
    122122    end
    123 %     ListVar={};
    124123    for ilist=1:length(FieldName)
    125 %         var_count=numel(ListVar);
     124        %Operator{ilist}='';%default empty operator (vec, norm,...)
     125        %r=regexp(FieldName{ilist},'(?<Operator>(^vec|^norm|^curl|^div|^strain))\((?<UName>.+),(?<VName>.+)\)$','names');% TODO, replace U, V
    126126        switch FieldName{ilist}
    127127            case 'vec(U,V)'
  • trunk/src/plot_field.m

    r864 r866  
    1515%
    1616% OUPUT:
    17 % PlotType: type of plot: 'text','line'(curve plot),'plane':2D view,'volume'
     17% PlotType: type of plot: 'text','line'(curve plot),'plane':2D view,'volume', or errormsg
    1818% PlotParamOut: structure, representing the updated  plotting parameters, in case of automatic scaling
    1919% haxes: handle of the plotting axis, when a new figure is created.
     
    251251%% display error message
    252252if ~isempty(errormsg)
     253    PlotType=errormsg;
    253254    msgbox_uvmat('ERROR', errormsg)
    254255end
     
    637638    if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') % vector components detected
    638639        if test_vec% a vector field has been already detected
    639             errormsg='error in plot_field: attempt to plot two vector fields: to get the difference project on a plane with mode interp';
     640            errormsg='error in plot_field: attempt to plot two vector fields: to get the difference project on a plane with ProjMode= interp_lin or interp_tps';
    640641            return
    641642        else
  • trunk/src/proj_field.m

    r864 r866  
    120120end
    121121
     122% %% take the difference of projected input fields if relevant
     123% [CellInfo,NbDim,errormsg]=find_field_cells(ProjData);
     124% ind_remove=zeros(size(ProjData.ListVarName));
     125% ivar=[];
     126% ivar_1=[];
     127% for icell=1:numel(CellInfo)
     128%     if ~isempty(CellInfo{icell})
     129%         % if two scalar are in the same cell
     130%         if isfield(CellInfo{icell},'VarIndex_scalar') && numel(CellInfo{icell}.VarIndex_scalar)==2 && ProjData.VarAttribute{CellInfo{icell}.VarIndex_scalar(2)}.CheckSub;
     131%             ivar=[ivar CellInfo{icell}.VarIndex_scalar(1)];
     132%             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_scalar(2)];
     133%         end
     134%         % if two vector u components are in the same cell
     135%         if isfield(CellInfo{icell},'VarIndex_vector_x') && numel(CellInfo{icell}.VarIndex_vector_x)==2 && ProjData.VarAttribute{CellInfo{icell}.VarIndex_vector_x(2)}.CheckSub;
     136%             ivar=[ivar CellInfo{icell}.VarIndex_vector_x(1)];
     137%             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_x(2)];
     138%         end
     139%          % if two vector v components are in the same cell
     140%         if isfield(CellInfo{icell},'VarIndex_vector_y') && numel(CellInfo{icell}.VarIndex_vector_y)==2 && ProjData.VarAttribute{CellInfo{icell}.VarIndex_vector_y(2)}.CheckSub;
     141%             ivar=[ivar CellInfo{icell}.VarIndex_vector_y(1)];
     142%             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_y(2)];
     143%         end
     144%     end
     145% end
     146% % subtract fields if relevant
     147% for imod=1:numel(ivar)
     148%         VarName=ProjData.ListVarName{ivar(imod)};
     149%         VarName_1=ProjData.ListVarName{ivar_1(imod)};
     150%         ProjData.(VarName)=double(ProjData.(VarName))-double(ProjData.(VarName_1));
     151%         ind_remove(ivar_1(imod))=1;
     152% end
     153% ProjData.ListVarName(find(ind_remove))=[];
     154% ProjData.VarDimName(find(ind_remove))=[];
     155% ProjData.VarAttribute(find(ind_remove))=[];
     156
    122157%-----------------------------------------------------------------
    123158%project on a set of points
     
    387422            XName=FieldData.ListVarName{ivar_X};
    388423            YName=FieldData.ListVarName{ivar_Y};
    389             coord_x=FieldData.(XName);
    390             coord_y=FieldData.(YName);
     424            coord_x=FieldData.(FieldData.ListVarName{ivar_X});
     425            coord_y=FieldData.(FieldData.ListVarName{ivar_Y});
    391426            % image or 2D matrix
    392427        case 'grid' %case of structured coordinates
     
    584619                costheta=cos(theta(isegment));
    585620                sintheta=sin(theta(isegment));
    586 %                 XIsegment=LineCoord(isegment,1)+DX_edge*costheta:DX*costheta:LineCoord(isegment+1,1));
    587 %                 YIsegment=(LineCoord(isegment,2)+DX_edge*sintheta:DX*sintheta:LineCoord(isegment+1,2));
     621                %                 XIsegment=LineCoord(isegment,1)+DX_edge*costheta:DX*costheta:LineCoord(isegment+1,1));
     622                %                 YIsegment=(LineCoord(isegment,2)+DX_edge*sintheta:DX*sintheta:LineCoord(isegment+1,2));
    588623                NbInterval=floor((dlength(isegment)-DX_edge)/DX);
    589624                LastX=DX_edge+DX*NbInterval;
     
    618653ProjData.ListVarName={};
    619654ProjData.VarDimName={};
     655check_abscissa=0;
    620656for icell=1:length(CellInfo)
    621657    % list of variable types to be projected
     
    631667    %% identify vector components
    632668    testU=isfield(CellInfo{icell},'VarIndex_vector_x') &&isfield(CellInfo{icell},'VarIndex_vector_y') ;% test for vectors
    633 %     if testU
    634 %         UName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x};
    635 %         VName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y};
    636 %         vector_x=FieldData.(UName);
    637 %         vector_y=FieldData.(VName);
    638 %     end
     669    %     if testU
     670    %         UName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x};
     671    %         VName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y};
     672    %         vector_x=FieldData.(UName);
     673    %         vector_y=FieldData.(VName);
     674    %     end
    639675    %identify error flag
    640676    errorflag=0; %default, no error flag
     
    654690        %case of unstructured coordinates
    655691        case 'scattered'
    656             XName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
    657             YName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
    658             coord_x=FieldData.(XName);
    659             coord_y=FieldData.(YName);
    660             ProjData.ListVarName=[ProjData.ListVarName {XName}];
    661             ProjData.VarDimName=[ProjData.VarDimName {XName}];
    662             nbvar=numel(ProjData.ListVarName);
    663             ProjData.VarAttribute{nbvar}.long_name='abscissa along line';
     692%             XName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
     693%             YName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
     694            coord_x=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)});
     695            coord_y=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
     696           
    664697            if isequal(ProjMode,'projection')
    665698                if width==0
     
    667700                    return
    668701                end
     702                ProjData.ListVarName=[ProjData.ListVarName {FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}}];
     703                ProjData.VarDimName=[ProjData.VarDimName {FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}}];
     704                nbvar=numel(ProjData.ListVarName);
     705                ProjData.VarAttribute{nbvar}.long_name='abscissa along line';
    669706                % select the (non false) input data located in the band of projection
    670707                flagsel=(errorflag==0) & ((coord_y -yinf(1))*(xinf(2)-xinf(1))>(coord_x-xinf(1))*(yinf(2)-yinf(1))) ...
     
    678715                Xproj=(coord_x-ObjectData.Coord(1,1))*costheta + (coord_y-ObjectData.Coord(1,2))*sintheta; %projection on the line
    679716                [Xproj,indsort]=sort(Xproj);% sort points by increasing absissa along the projection line
    680                 ProjData.(XName)=Xproj;
     717                ProjData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)})=Xproj;
    681718                for ivar=1:numel(VarIndex)
    682719                    ProjData.(VarName{ivar})=FieldData.(VarName{ivar})(flagsel);% restrict vrtibles to the projection band
    683720                    ProjData.(VarName{ivar})=ProjData.(VarName{ivar})(indsort);% sort by absissa
    684721                    ProjData.ListVarName=[ProjData.ListVarName VarName{ivar}];
    685                     ProjData.VarDimName=[ProjData.VarDimName {XName}];
     722                    ProjData.VarDimName=[ProjData.VarDimName {FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}}];
    686723                    ProjData.VarAttribute{nbvar+ivar}=FieldData.VarAttribute{VarIndex(ivar)};%reproduce var attribute
    687724                    if isfield(ProjData.VarAttribute{nbvar+ivar},'Role')
     
    695732                end
    696733            elseif isequal(ProjMode,'interp_lin')  %filtering %linear interpolation:
     734                if ~check_abscissa
     735                    XName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
     736                    ProjData.ListVarName=[ProjData.ListVarName {XName}];
     737                    ProjData.VarDimName=[ProjData.VarDimName {XName}];
     738                    nbvar=numel(ProjData.ListVarName);
     739                    ProjData.VarAttribute{nbvar}.long_name='abscissa along line';
     740                    check_abscissa=1; % define abcissa only once
     741                end
    697742                if ~isequal(errorflag,0)
    698743                    VarName_FF=FieldData.ListVarName{CellInfo{icell}.VarIndex_errorflag};
     
    704749                        FieldData.(VarName)=FieldData.(VarName)(indsel);
    705750                    end
    706                 end                   
     751                end
    707752                [ProjVar,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([coord_x coord_y],FieldData,CellInfo{icell}.FieldName,XI,YI);
    708753                ProjData.X=Xproj;
     754                nbvar=numel(ProjData.ListVarName);
    709755                ProjData.ListVarName=[ProjData.ListVarName ListFieldProj];
    710756                ProjData.VarAttribute=[ProjData.VarAttribute VarAttribute];
     
    713759                    if isfield(VarAttribute{ivar},'Role')
    714760                        if  strcmp(VarAttribute{ivar}.Role,'vector_x');
    715                             ivar_U=ivar;
     761                            ivar_U=ivar+nbvar;
    716762                        elseif strcmp(VarAttribute{ivar}.Role,'vector_y');
    717                             ivar_V=ivar;
     763                            ivar_V=ivar+nbvar;
    718764                        end
    719765                    end
     
    741787                    if isfield(VarAttribute{ivar},'Role')
    742788                        if  strcmp(VarAttribute{ivar}.Role,'vector_x');
    743                             ivar_U=ivar;
     789                            ivar_U=ivar+nbvar;
    744790                        elseif strcmp(VarAttribute{ivar}.Role,'vector_y');
    745                             ivar_V=ivar;
     791                            ivar_V=ivar+nbvar;
    746792                        end
    747793                    end
     
    861907                end
    862908            end
    863     end 
     909    end
    864910    if ~isempty(ivar_U) && ~isempty(ivar_V)
    865         vector_x =ProjData.(ProjData.ListVarName{nbvar+ivar_U});
    866          ProjData.(ProjData.ListVarName{nbvar+ivar_U}) =cos(theta)*vector_x+sin(theta)*ProjData.(ProjData.ListVarName{nbvar+ivar_V});
    867           ProjData.(ProjData.ListVarName{nbvar+ivar_V}) =-sin(theta)*vector_x+cos(theta)*ProjData.(ProjData.ListVarName{nbvar+ivar_V});
    868     end
    869        
     911        vector_x =ProjData.(ProjData.ListVarName{ivar_U});
     912        ProjData.(ProjData.ListVarName{ivar_U}) =cos(theta)*vector_x+sin(theta)*ProjData.(ProjData.ListVarName{ivar_V});
     913        ProjData.(ProjData.ListVarName{ivar_V}) =-sin(theta)*vector_x+cos(theta)*ProjData.(ProjData.ListVarName{ivar_V});
     914    end
    870915end
    871916
     
    12301275                   
    12311276                    if isfield(CellInfo{icell},'CheckSub') && CellInfo{icell}.CheckSub && ~isempty(vector_x_proj)
    1232                         ProjData.(ListVarName{vector_x_proj})=ProjData.(ListVarName{vector_x_proj})-VarVal{1};
    1233                         ProjData.(ListVarName{vector_y_proj})=ProjData.(ListVarName{vector_y_proj})-VarVal{2};
     1277                        ProjData.(FieldData.ListVarName{vector_x_proj})=ProjData.(FieldData.ListVarName{vector_x_proj})-VarVal{1};
     1278                        ProjData.(FieldData.ListVarName{vector_y_proj})=ProjData.(FieldData.ListVarName{vector_y_proj})-VarVal{2};
     1279                        ListVarName={};% no new variable
     1280                        VarAttribute={};
    12341281                    else
    12351282                        VarDimName=cell(size(ListVarName));
     
    12431290                        end
    12441291                    end
     1292                    vector_x_proj=CellInfo{icell}.VarIndex_vector_x; %preserve for next cell
     1293                    vector_y_proj=CellInfo{icell}.VarIndex_vector_y; %preserve for next cell
    12451294            end
    12461295           
     
    14911540                            ListVarName=[ListVarName VarName];
    14921541                            VarAttribute{length(ListVarName)}=FieldData.VarAttribute{ivar}; %reproduce the variable attributes
    1493                             eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz
     1542                            ProjData.(VarName)=squeeze(FieldData.(VarName)(iz,:,:));% select the z index iz
    14941543                            %TODO : do a vertical average for a thick plane
    14951544                            if test_interp(2) || test_interp(3)
    1496                                 eval(['ProjData.' VarName '=interp2(Coord{3},Coord{2},ProjData.' VarName ',Coord_x,Coord_y'');'])
     1545                                ProjData.(VarName)=interp2(Coord{3},Coord{2},ProjData.(VarName),Coord_x,Coord_y);
    14971546                            end
    14981547                        end
     
    15351584                if ~isempty(ivar_W)
    15361585                    WName=FieldData.ListVarName{ivar_W};
    1537                     eval(['ProjData.' VName '=ProjData.' VName '+ ProjData.' WName '*sin(Theta);'])%
    1538                     eval(['ProjData.' WName '=NormVec_X*ProjData.' UName '+ NormVec_Y*ProjData.' VName '+ NormVec_Z* ProjData.' WName ';']);
     1586                    ProjData.(VName)=ProjData.(VName)+ ProjData.(WName)*sin(Theta);%
     1587                    ProjData.(WName)=NormVec_X*ProjData.(UName)+ NormVec_Y*ProjData.(VName)+ NormVec_Z* ProjData.(WName);
    15391588                end
    15401589            end
  • trunk/src/sub_field.m

    r864 r866  
    125125
    126126%% look for coordinates common to Field in Field_1
    127 ind_remove=zeros(size(Field_1.ListVarName));
     127ind_remove=false(size(Field_1.ListVarName));
    128128% loop on the variables of the second field Field_1
    129129for ilist=1:numel(Field_1.ListVarName)
    130130    % case of variable with a single dimension
    131     if ~isempty(regexp(Field_1.VarAttribute{ilist}.Role,'^coord'))
     131    if ~isempty(Field_1.VarAttribute{ilist}) && ~isempty(regexp(Field_1.VarAttribute{ilist}.Role,'^coord'))% if variable with Role coord... is found.
    132132        OldDimName=Field_1.VarDimName{ilist};
    133133        if ischar(OldDimName), OldDimName={OldDimName}; end% transform char string to cell if relevant
     
    147147    end
    148148end
    149 Field_1.ListVarName(find(ind_remove))=[];%removes the redondent coordinate
    150 Field_1.VarDimName(find(ind_remove))=[];
    151 Field_1.VarAttribute(find(ind_remove))=[];
     149if ~isempty(find(ind_remove, 1))
     150Field_1.ListVarName(ind_remove)=[];%removes the redondent coordinate
     151Field_1.VarDimName(ind_remove)=[];
     152Field_1.VarAttribute(ind_remove)=[];
     153end
    152154
    153155%% append the other variables of the second field, modifying their name if needed
    154 ListVarNameNew=Field_1.ListVarName;
    155 check_rename=zeros(size(ListVarNameNew));
    156 check_remove=zeros(size(ListVarNameNew));
    157 for ilist=1:numel(ListVarNameNew)
    158     VarName=Field_1.ListVarName{ilist};
    159     ind_prev=find(strcmp(ListVarNameNew{ilist},Field.ListVarName),1);% look for duplicated variable name
     156ListVarNameSub=Field_1.ListVarName;
     157ListVarNameNew=ListVarNameSub;
     158check_rename=zeros(size(ListVarNameSub));
     159check_remove=zeros(size(ListVarNameSub));
     160for ilist=1:numel(ListVarNameSub)
     161    ind_prev=find(strcmp(ListVarNameSub{ilist},Field.ListVarName),1);% look for duplicated variable name
    160162    if ~isempty(ind_prev)% variable name exists in Field
    161 %         check_rename(ilist)=0;
    162         check_remove(ilist)=1;
    163         if isfield(Field_1.VarAttribute{ilist},'Role')&& ismember(Field_1.VarAttribute{ilist}.Role,{'scalar','vector_x','vector_y'})
    164                             ListVarNameNew{ilist}=[ListVarNameNew{ilist} '_1'];
    165                             check_rename(ilist)=1;
    166         end
    167     end
    168     SubData.ListVarName=[SubData.ListVarName ListVarNameNew{ilist}];
    169     SubData.VarDimName=[SubData.VarDimName Field_1.VarDimName(ilist)];
    170     Field_1.VarAttribute{ilist}.CheckSub=1;
    171     SubData.VarAttribute=[SubData.VarAttribute Field_1.VarAttribute{ilist}];
    172     SubData.(ListVarNameNew{ilist})=Field_1.(VarName);% teke the values of the old variable for the newly named one
    173     %SubData.VarAttribute=[SubData.VarAttribute Field_1.VarDimName(ilist)];
    174 end
    175 
    176 %% replace variable name in field expression FieldName, e.g. 'norm(U,V)'-> 'norm(U_1,V_1)'
    177 for ilist=1:numel(ListVarNameNew)
    178     if check_rename(ilist)&&  isfield(Field_1.VarAttribute{ilist},'FieldName')
    179         for ivar=1:numel(find(check_rename))
    180             Field_1.VarAttribute{ilist}.FieldName=regexprep_r(Field_1.VarAttribute{ilist}.FieldName,...
    181                 Field_1.ListVarName{ivar},ListVarNameNew{ivar});
    182         end
    183     end
    184     SubData.VarAttribute=[SubData.VarAttribute Field_1.VarAttribute(ilist)];
    185     SubData.VarAttribute{end}.CheckSub=1;% mark that the field needs to be substracted as an attribute
    186 end
     163        if isfield(Field_1.VarAttribute{ilist},'Role')&&...
     164            ismember(Field_1.VarAttribute{ilist}.Role,{'coord_x','coord_y','scalar','vector_x','vector_y','errorflag'})
     165            ListVarNameNew{ilist}=[ListVarNameSub{ilist} '_1'];%modify the name of the second variable
     166            check_rename(ilist)=1;
     167        else
     168            check_remove(ilist)=1;% variable will be removed
     169        end
     170    end
     171end
     172ListVarNameSub=ListVarNameSub(~check_remove); %eliminate removed variables from the list of the second field
     173ListVarNameNew=ListVarNameNew(~check_remove); % %list of renaimed varaibles corresponding to ListVarNameSub
     174VarDimNameSub=Field_1.VarDimName(~check_remove);
     175VarAttributeSub=Field_1.VarAttribute(~check_remove);
     176check_rename=check_rename(~check_remove);
     177
     178% apply the variable renaming and mark the second field variables with the attribute .CheckSub
     179for ilist=1:numel(ListVarNameSub)
     180     SubData.(ListVarNameNew{ilist})=Field_1.(ListVarNameSub{ilist});% copy the variable content to the new name
     181    if check_rename(ilist)   
     182          % replace name in field expression FieldName, e.g. 'norm(U,V)'-> 'norm(U_1,V_1)'
     183        if  isfield(VarAttributeSub{ilist},'FieldName')
     184            for ivar=1:numel(find(check_rename))
     185                VarAttributeSub{ilist}.FieldName=regexprep_r(VarAttributeSub{ilist}.FieldName,...
     186                    ListVarNameSub{ivar},ListVarNameNew{ivar});
     187            end
     188        end
     189    end
     190    VarAttributeSub{ilist}.CheckSub=1;% mark that the field needs to be substracted as an attribute
     191end
     192
     193SubData.ListVarName=[SubData.ListVarName ListVarNameNew];
     194SubData.VarDimName=[SubData.VarDimName VarDimNameSub];
     195SubData.VarAttribute=[SubData.VarAttribute VarAttributeSub];
    187196
    188197%% substrat fields when possible
    189198[CellInfo,NbDim,errormsg]=find_field_cells(SubData);
    190 ind_remove=zeros(size(SubData.ListVarName));
     199ind_remove=false(size(SubData.ListVarName));
    191200ivar=[];
    192201ivar_1=[];
    193202for icell=1:numel(CellInfo)
    194203    if ~isempty(CellInfo{icell})
     204        % if two scalar are in the same cell
    195205        if isfield(CellInfo{icell},'VarIndex_scalar') && numel(CellInfo{icell}.VarIndex_scalar)==2 && SubData.VarAttribute{CellInfo{icell}.VarIndex_scalar(2)}.CheckSub;
    196206            ivar=[ivar CellInfo{icell}.VarIndex_scalar(1)];
    197207            ivar_1=[ivar_1 CellInfo{icell}.VarIndex_scalar(2)];
    198208        end
     209        % if two vector u components are in the same cell
    199210        if isfield(CellInfo{icell},'VarIndex_vector_x') && numel(CellInfo{icell}.VarIndex_vector_x)==2 && SubData.VarAttribute{CellInfo{icell}.VarIndex_vector_x(2)}.CheckSub;
    200211            ivar=[ivar CellInfo{icell}.VarIndex_vector_x(1)];
    201212            ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_x(2)];
    202213        end
     214         % if two vector v components are in the same cell
    203215        if isfield(CellInfo{icell},'VarIndex_vector_y') && numel(CellInfo{icell}.VarIndex_vector_y)==2 && SubData.VarAttribute{CellInfo{icell}.VarIndex_vector_y(2)}.CheckSub;
    204216            ivar=[ivar CellInfo{icell}.VarIndex_vector_y(1)];
    205217            ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_y(2)];
    206218        end
    207     end
    208 end
     219        % merge the error flags if needed
     220        if isfield(CellInfo{icell},'VarIndex_errorflag') && numel(CellInfo{icell}.VarIndex_errorflag)==2 && SubData.VarAttribute{CellInfo{icell}.VarIndex_vector_y(2)}.CheckSub;
     221            ivar_flag=CellInfo{icell}.VarIndex_errorflag(1);
     222            ivar_flag_1=CellInfo{icell}.VarIndex_errorflag(2);
     223            VarName=SubData.ListVarName{ivar_flag};
     224            VarName_1=SubData.ListVarName{ivar_flag_1};
     225            SubData.(VarName)=SubData.(VarName)~=0 | SubData.(VarName_1)~=0;% combine the error flags of the two fields
     226            ind_remove(ivar_flag_1)=1;
     227        end
     228    end
     229end
     230% subtract fields if relevant
    209231for imod=1:numel(ivar)
    210232        VarName=SubData.ListVarName{ivar(imod)};
     
    213235        ind_remove(ivar_1(imod))=1;
    214236end
    215 SubData.ListVarName(find(ind_remove))=[];
    216 SubData.VarDimName(find(ind_remove))=[];
    217 SubData.VarAttribute(find(ind_remove))=[];
     237SubData.ListVarName(ind_remove)=[];
     238SubData.VarDimName(ind_remove)=[];
     239SubData.VarAttribute(ind_remove)=[];
    218240
    219241function OutputCell=regexprep_r(InputCell,search_string,new_string)
  • trunk/src/transform_field/phys.m

    r836 r866  
    116116        return %bad calib parameter input
    117117    end
    118     if ~(isfield(DataIn_1,'CoordUnit')&& strcmp(DataIn_1.CoordUnit,'pixel'))
    119         return % transform only fields in pixel coordinates
    120     end
     118    if (isfield(DataIn_1,'CoordUnit')&& strcmp(DataIn_1.CoordUnit,'pixel'))
     119%         return % transform only fields in pixel coordinates
     120%     end
    121121    DataOut_1=phys_1(DataOut_1,Calib{2},ZIndex);
     122    end
    122123    if isfield(Calib{1},'SliceCoord')
    123124        if ~(isfield(Calib{2},'SliceCoord') && isequal(Calib{2}.SliceCoord,Calib{1}.SliceCoord))
  • trunk/src/uvmat.m

    r864 r866  
    32833283            if ischar(list_fields),list_fields={list_fields};end
    32843284            FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field
    3285             if ~strcmp(FieldName,'get_field...')
     3285            if ~strcmp(FieldName_1,'get_field...')
    32863286                if get(handles.FixVelType,'Value')
    32873287                    VelTypeList=get(handles.VelType_1,'String');
     
    32893289                end
    32903290            end
    3291             if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on')
     3291            if isempty(FieldName_1)
     3292                FieldName_1=FieldName;% if blank reproduce the field name of the first field
     3293            end
     3294            if ~isempty(regexp(FieldName_1,'^vel'))&& strcmp(get(handles.ColorCode,'Visible'),'on')
    32923295                list_code=get(handles.ColorCode,'String');% list menu fields
    32933296                index_code=get(handles.ColorCode,'Value');% selected string index
     
    37593762            else
    37603763                [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap});
     3764                if ~isempty(regexp(PlotType,'^error'))
     3765                    if ~isempty(regexp(PlotType,'attempt to plot two vector fields'))
     3766                        set(handles.CheckEditObject,'Value',1)
     3767                        CheckEditObject_Callback([], [], handles)
     3768                        hset_object=findobj(allchild(0),'Tag','set_object');%find the GUI set_object
     3769                        hhset_object=guidata(hset_object);%
     3770                        set(hhset_object.ProjMode,'Value',2);
     3771                        set_object('ProjMode_Callback',hset_object,[],hhset_object);
     3772                    end
     3773%                     errormsg=PlotType;
     3774                    return
     3775                end
    37613776                if imap==1
    37623777                    errormsg=fill_GUI(PlotParamOut,handles.uvmat);
     
    44594474            REFRESH_Callback(hObject, eventdata, handles)
    44604475        end
    4461          
    4462 %         set_veltype_display(0) % no veltype display
    4463 %         hget_field=findobj(allchild(0),'name','get_field_1');
    4464 %         if ~isempty(hget_field)
    4465 %             delete(hget_field)
    4466 %         end
    4467 %         hget_field=get_field(FileName_1);
    4468 %         set(hget_field,'name','get_field_1')
    4469 %         hhget_field=guidata(hget_field);
    4470 %         set(hhget_field.list_fig,'Value',1)
    4471 %         set(hhget_field.list_fig,'String',{'uvmat'})
    4472 %         if check_new
    4473 %             UvData.FileType{2}=UvData.FileType{1};
    4474 %             set(handles.FileIndex_1,'String',get(handles.FileIndex,'String'))
    4475 %               set(handles.uvmat,'UserData',UvData)
    4476 %         end
    44774476    case 'image'
    44784477        %% look for image corresponding to civ data
Note: See TracChangeset for help on using the changeset viewer.