Changeset 389


Ignore:
Timestamp:
Apr 8, 2012, 11:11:38 PM (12 years ago)
Author:
sommeria
Message:

several bugs corrected: object managing, tps filter...

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r383 r389  
    6565    units_cell={};
    6666   
    67     %% interpolation with new civ data
    68     %if isfield(DataIn,'X_SubRange')
     67    %% interpolation with new civ data
    6968    if isfield(DataIn,'SubRange') &&(strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))
    70         XMax=max(max(DataIn.SubRange(1,:,:)));
     69        XMax=max(max(DataIn.SubRange(1,:,:)));% extrema of the coordinates
    7170        YMax=max(max(DataIn.SubRange(2,:,:)));
    7271        XMin=min(min(DataIn.SubRange(1,:,:)));
     
    7675            xI=XMin:Mesh:XMax;
    7776            yI=YMin:Mesh:YMax;
    78             [XI,YI]=meshgrid(xI,yI);
     77            [XI,YI]=meshgrid(xI,yI);% interpolation grid
    7978            XI=reshape(XI,[],1);
    8079            YI=reshape(YI,[],1);
     
    8281        DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; %reproduce global attribute
    8382        for ilist=1:numel(DataOut.ListGlobalAttribute)
    84             eval(['DataOut.' DataOut.ListGlobalAttribute{ilist} '=DataIn.' DataIn.ListGlobalAttribute{ilist} ';'])
     83            DataOut.(DataOut.ListGlobalAttribute{ilist})=DataIn.(DataIn.ListGlobalAttribute{ilist});
    8584        end
    8685        DataOut.ListVarName={'coord_y','coord_x','FF'};
     
    8988        DataOut.coord_y=[yI(1) yI(end)];
    9089        DataOut.coord_x=[xI(1) xI(end)];
    91         DataOut.U=zeros(size(XI));
    92         DataOut.V=zeros(size(XI));
    93         DataOut.vort=zeros(size(XI));       
    94         DataOut.div=zeros(size(XI));
     90        switch FieldName{1}
     91            case {'velocity','u','v'}
     92                DataOut.U=zeros(size(XI));
     93                DataOut.V=zeros(size(XI));
     94            case 'vort'
     95                DataOut.vort=zeros(size(XI));
     96            case 'div'
     97                DataOut.div=zeros(size(XI));
     98            case 'strain'
     99                DataOut.strain=zeros(size(XI));
     100        end
    95101        nbval=zeros(size(XI));
    96102        NbSubDomain=size(DataIn.SubRange,3);
    97103        for isub=1:NbSubDomain
    98104            if isfield(DataIn,'NbSites')
    99                 nbvec_sub=DataIn.NbSites(isub); 
     105                nbvec_sub=DataIn.NbSites(isub);
    100106            else
    101                 nbvec_sub=numel(find(DataIn.Indices_tps(:,isub))); 
     107                nbvec_sub=numel(find(DataIn.Indices_tps(:,isub)));
    102108            end
    103                 ind_sel=find(XI>=DataIn.SubRange(1,1,isub) & XI<=DataIn.SubRange(1,2,isub) & YI>=DataIn.SubRange(2,1,isub) & YI<=DataIn.SubRange(2,2,isub));
    104                 %rho smoothing parameter
    105                 epoints = [XI(ind_sel) YI(ind_sel)];% coordinates of interpolation sites
    106                 ctrs=DataIn.Coord_tps(1:nbvec_sub,:,isub);%(=initial points) ctrs
    107                 nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap)
    108 %                 PM = [ones(size(epoints,1),1) epoints];
    109                 switch FieldName{1}
    110                     case {'velocity','u','v'}
    111                        % DM_eval = DistanceMatrix(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs
    112                        % EM = tps(1,DM_eval);%values of thin plate
    113                         EM = tps_eval(epoints,ctrs);
    114                     case{'vort','div'}
    115                         [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs
    116      
    117                 end
    118                 switch FieldName{1}
    119                     case 'velocity'
    120                         ListFields={'U', 'V'};
    121                         VarAttributes{1}.Role='vector_x';
    122                         VarAttributes{2}.Role='vector_y';
    123                         DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    124                         DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    125                     case 'u'
    126                         ListFields={'U'};
    127                         VarAttributes{1}.Role='scalar';
    128                         DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    129                     case 'v'
    130                         ListFields={'V'};
    131                         VarAttributes{1}.Role='scalar';
    132                         DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    133                     case 'vort'
    134                         ListFields={'vort'};
    135                         VarAttributes{1}.Role='scalar';
    136                         DataOut.vort(ind_sel)=DataOut.vort(ind_sel)+EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)-EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
    137                     case 'div'
    138                         ListFields={'div'};
    139                         VarAttributes{1}.Role='scalar';
    140                         DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDY *DataIn.V_tps(1:nbvec_sub+3,isub);
    141                 end
    142         end
    143         DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang 
    144        
     109            ind_sel=find(XI>=DataIn.SubRange(1,1,isub) & XI<=DataIn.SubRange(1,2,isub) & YI>=DataIn.SubRange(2,1,isub) & YI<=DataIn.SubRange(2,2,isub));
     110            %rho smoothing parameter
     111            epoints = [XI(ind_sel) YI(ind_sel)];% coordinates of interpolation sites
     112            ctrs=DataIn.Coord_tps(1:nbvec_sub,:,isub);%(=initial points) ctrs
     113            nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap)
     114            switch FieldName{1}
     115                case {'velocity','u','v'}
     116                    EM = tps_eval(epoints,ctrs);%kernels for calculating the velocity from tps 'sources'
     117                case{'vort','div','strain'}
     118                    [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%kernels for calculating the spatial derivatives from tps 'sources'
     119            end
     120            switch FieldName{1}
     121                case 'velocity'
     122                    ListFields={'U', 'V'};
     123                    VarAttributes{1}.Role='vector_x';
     124                    VarAttributes{2}.Role='vector_y';
     125                    DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
     126                    DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
     127                case 'u'
     128                    ListFields={'U'};
     129                    VarAttributes{1}.Role='scalar';
     130                    DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
     131                case 'v'
     132                    ListFields={'V'};
     133                    VarAttributes{1}.Role='scalar';
     134                    DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
     135                case 'vort'
     136                    ListFields={'vort'};
     137                    VarAttributes{1}.Role='scalar';
     138                    DataOut.vort(ind_sel)=DataOut.vort(ind_sel)+EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)-EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
     139                case 'div'
     140                    ListFields={'div'};
     141                    VarAttributes{1}.Role='scalar';
     142                    DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDY *DataIn.V_tps(1:nbvec_sub+3,isub);
     143                case 'strain'
     144                    ListFields={'strain'};
     145                    VarAttributes{1}.Role='scalar';
     146                    DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
     147            end
     148        end
     149        DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang     
    145150        DataOut.FF=reshape(DataOut.FF,numel(yI),numel(xI));
    146151        nbval(nbval==0)=1;
    147         DataOut.U=DataOut.U ./nbval;
    148         DataOut.V=DataOut.V ./nbval;
    149         DataOut.U=reshape(DataOut.U,numel(yI),numel(xI));
    150         DataOut.V=reshape(DataOut.V,numel(yI),numel(xI));
     152        switch FieldName{1}
     153              case {'velocity','u','v'}
     154        DataOut.U=reshape(DataOut.U./nbval,numel(yI),numel(xI));
     155        DataOut.V=reshape(DataOut.V./nbval,numel(yI),numel(xI));
     156            case 'vort'
    151157        DataOut.vort=reshape(DataOut.vort,numel(yI),numel(xI));
     158            case 'div'
    152159        DataOut.div=reshape(DataOut.div,numel(yI),numel(xI));
     160            case 'strain'
     161           DataOut.strain=reshape(DataOut.strain,numel(yI),numel(xI));
     162        end
    153163        DataOut.ListVarName=[DataOut.ListVarName ListFields];
    154164        for ilist=3:numel(DataOut.ListVarName)
     
    157167        DataOut.VarAttribute={[],[]};
    158168        DataOut.VarAttribute{3}.Role='errorflag';
    159         DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];   
    160     else   
     169        DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];
     170    else
    161171       
    162     %% civx data   
     172        %% civx data
    163173        DataOut=DataIn;
    164174        for ilist=1:length(FieldName)
  • trunk/src/civ.m

    r388 r389  
    11691169nbslice=numel(j1_civ1);
    11701170if ~strcmp(CivMode,'CivX')
     1171    if Param.CheckCiv1
    11711172    [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});
    11721173    [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});
     1174    end
     1175    if Param.CheckCiv2
     1176    [Param.Civ2.FileTypeA,FileInfo,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1});
     1177    [Param.Civ2.FileTypeB,FileInfo,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1});
     1178    end
    11731179end
    11741180
     
    29412947% determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of
    29422948% the field series set by first_i, incr, last_i
     2949% index=1: look for pairs for civ1
     2950% index=2: look for pairs for civ2
    29432951function errormsg=find_netcpair_civ(handles,index)
    29442952%------------------------------------------------------------------------
     
    29472955%% initialisation
    29482956errormsg='';
    2949 % filebase=get(handles.RootPath,'String');
    2950 % [filepath,Nme,ext_dir]=fileparts(filebase);
    29512957browse=get(handles.RootPath,'UserData');
    29522958compare_list=get(handles.ListCompareMode,'String');
     
    29662972
    29672973%% determine nom_type_nc, nomenclature type of the .nc files:
    2968 % nom_type_nc='';%default
    2969 % if isfield(browse,'nom_type_nc')
    2970 %     nom_type_nc=browse.nom_type_nc;
    2971 % end
    2972 % if isempty(nom_type_nc)
    2973     [nom_type_nc]=nomtype2pair(nom_type_ima,mode);
    2974 % end
    2975 % browse.nom_type_nc=nom_type_nc;
    2976 % set(handles.RootPath,'UserData',browse)
     2974[nom_type_nc]=nomtype2pair(nom_type_ima,mode);
    29772975
    29782976%% reads .nc subdirectoy and image numbers from the interface
     
    30043002
    30053003%% case with no Civ1 operation, netcdf files need to exist for reading
    3006 % be performed, while the result is needed for next steps.
    30073004displ_pair={''};
    30083005select=ones(size(1:nbpair));%flag for displayed pairs =1 for display
     
    30363033                    errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1];
    30373034                else
    3038                     errormsg=['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1];
     3035                    errormsg=['no civ1 file available for the selected reference indices (i,j)= ' num2str(ref_i) ', ' num2str(ref_j) ' and subdirectory ' subdir_civ1];
    30393036                end
    30403037                set(handles.ListPairCiv1,'String',{''});
     
    30943091            if select(ipair)
    30953092                displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
    3096                 if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair)&&displ_num(2,ipair)>=1 &&displ_num(1,ipair)>=1
    3097                     dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt
     3093                %if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair)&&displ_num(2,ipair)>=1 &&displ_num(1,ipair)>=1
     3094                 %   dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt
     3095               if ~checkframe && size(time,1)>=ref_i+1+ceil(ipair/2) && size(time,2)>=ref_j+1&& ref_i-floor(ipair/2)>=0 && ref_j>=0
     3096                 dt=time(ref_i+1+ceil(ipair/2),ref_j+1)-time(ref_i+1-floor(ipair/2),ref_j+1);%time interval dtref_j+1
    30983097                else
    30993098                    dt=1;
  • trunk/src/civ_matlab.m

    r388 r389  
    172172        return
    173173    end
    174     check_patch1=1;
     174   
    175175    Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}];
    176176    Data.Patch1_Rho=Param.Patch1.SmoothingParam;
    177177    Data.Patch1_Threshold=Param.Patch1.MaxDiff;
    178178    Data.Patch1_SubDomain=Param.Patch1.SubdomainSize;
    179     Data.ListVarName=[Data.ListVarName {'Civ1_U_Diff','Civ1_V_Diff','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
     179    Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
    180180    Data.VarDimName=[Data.VarDimName {'NbVec1','NbVec1',{'NbCoord','Two','NbSubDomain1'},{'NbSubDomain1'},...
    181181             {'NbVec1Sub','NbCoord','NbSubDomain1'},{'Nbtps1','NbSubDomain1'},{'Nbtps1','NbSubDomain1'}}];
     
    183183    Data.VarAttribute{nbvar-1}.Role='vector_x';
    184184    Data.VarAttribute{nbvar}.Role='vector_y';
    185     Data.Civ1_U_Diff=zeros(size(Data.Civ1_X));
    186     Data.Civ1_V_Diff=zeros(size(Data.Civ1_X));
     185    Data.Civ1_U_smooth=zeros(size(Data.Civ1_X));
     186    Data.Civ1_V_smooth=zeros(size(Data.Civ1_X));
    187187    if isfield(Data,'Civ1_FF')
    188188        ind_good=find(Data.Civ1_FF==0);
     
    192192    [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
    193193            filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold);
    194       Data.Civ1_U_Diff(ind_good)=Data.Civ1_U(ind_good)-Ures;
    195       Data.Civ1_V_Diff(ind_good)=Data.Civ1_V(ind_good)-Vres;
     194%       Data.Civ1_U_Diff(ind_good)=Data.Civ1_U(ind_good)-Ures;
     195%       Data.Civ1_V_Diff(ind_good)=Data.Civ1_V(ind_good)-Vres;
     196      Data.Civ1_U_smooth(ind_good)=Ures;
     197      Data.Civ1_V_smooth(ind_good)=Vres;
    196198      Data.Civ1_FF(ind_good)=FFres;
    197199      Data.CivStage=3;                             
     
    213215    ibx2=ceil(par_civ2.Bx/2);
    214216    iby2=ceil(par_civ2.By/2);
    215     isx2=ibx2+5;% search ara +-5 pixels around the guess
    216     isy2=iby2+5;
     217    isx2=ibx2+4;% search ara +-4 pixels around the guess
     218    isy2=iby2+4;
    217219    % shift from par_civ2.filename_nc1
    218220    % shiftx=velocity interpolated at position
  • trunk/src/filter_tps.m

    r387 r389  
    2828W_smooth=[];
    2929NbCoord=size(Coord,2);
    30 NbSubDomain=ceil(nbvec/SubDomain);
     30NbSubDomain=nbvec/SubDomain;
    3131MinCoord=min(Coord,[],1);
    32 % MinY=min(Y,);
    3332MaxCoord=max(Coord,[],1);
    34 % MaxY=max(Y);
    3533Range=MaxCoord-MinCoord;
    36 % RangY=MaxY-MinY;
    3734AspectRatio=Range(2)/Range(1);
    3835NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);
     
    7572            SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4;
    7673            SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4;
    77 %             SubRangy(isub,1)=SubRangy(isub,1)-Siz(2)/4;
    78 %             SubRangy(isub,2)=SubRangy(isub,2)+Siz(2)/4;
    79         else
    80            
     74        else         
    8175            [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),rho);
    8276            [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel,:),V(ind_sel),rho);
     
    109103                [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),V(ind_sel(ind_ind_sel)),rho);
    110104                U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+U_smooth_sub;
    111                 V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;
     105                V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;   
    112106                NbSites(isub)=numel(ind_ind_sel);
    113                 %Indices_tps(1:NbSites(isub),isub)=ind_sel(ind_ind_sel);
    114107                Coord_tps(1:NbSites(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:);
    115 %                 Y_tps(1:NbSites(isub),:,isub)=Coord(ind_sel(ind_ind_sel),2);
    116108                U_tps(1:NbSites(isub)+3,isub)=U_tps_sub;
    117109                V_tps(1:NbSites(isub)+3,isub)=V_tps_sub;
     
    127119if ~isempty(ind_empty)
    128120    SubRange(:,:,ind_empty)=[];
    129 %     SubRangy(ind_empty,:)=[];
    130 %     Indices_tps(:,ind_empty)=[];
    131121    Coord_tps(:,:,ind_empty)=[];
    132 %     Y_tps(:,ind_empty)=[];
    133122    U_tps(:,ind_empty)=[];
    134123    V_tps(:,ind_empty)=[];
  • trunk/src/plot_field.m

    r388 r389  
    156156        set(htext,'String',{''})
    157157    else
    158         [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext);
     158        [errormsg]=plot_text(Data,CellVarIndex(index_0D),VarType(index_0D),htext);
    159159    end
    160160    haxes=[];
     
    244244            set(htext,'String',{''})
    245245        else
    246             [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext);
     246            [errormsg]=plot_text(Data,CellVarIndex(index_0D),VarType(index_0D),htext);
    247247        end
    248248    end
     
    276276
    277277%-------------------------------------------------------------------
    278 function errormsg=plot_text(FieldData,CellVarIndex,htext)
     278function errormsg=plot_text(FieldData,CellVarIndex,VarTypeCell,htext)
    279279%-------------------------------------------------------------------
    280280errormsg=[];
     
    283283    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list data.ListVarName
    284284    for ivar=1:length(VarIndex)
    285          VarName=FieldData.ListVarName{VarIndex(ivar)};
    286          VarValue=FieldData.(VarName);
    287          if size(VarValue,1)~=1
    288              VarValue=VarValue';
    289          end
    290          txt=[VarName '=' num2str(VarValue)];
    291          txt_cell=[txt_cell;{txt}];
     285        checkancillary=0;
     286        if length(FieldData.VarAttribute)>=VarIndex(ivar)
     287            VarAttribute=FieldData.VarAttribute{VarIndex(ivar)};
     288            if isfield(VarAttribute,'Role')&&strcmp(VarAttribute.Role,'ancillary')
     289                checkancillary=1;
     290            end
     291        end
     292        if ~checkancillary% does not display variables with attribute '.Role=ancillary'
     293            VarName=FieldData.ListVarName{VarIndex(ivar)};
     294            VarValue=FieldData.(VarName);
     295            if size(VarValue,1)~=1
     296                VarValue=VarValue';
     297            end
     298            txt=[VarName '=' num2str(VarValue)];
     299            txt_cell=[txt_cell;{txt}];
     300        end
    292301    end
    293302end
     
    11781187siz2=1;
    11791188while siz2<2
    1180 %     values=[-9:div:9];
    11811189    values=-10:div:10;
    11821190    ind=find((ord*values-MaxA)<0 & (ord*values-MinA)>0);%indices of 'values' such that MinA<ord*values<MaxA
     
    11871195    end
    11881196    siz2=size(ind,2);
    1189 %     siz2=siz(2)
    11901197    div=div/10;
    11911198end
     
    11931200end
    11941201
    1195 %'proj_grid': project  fields with unstructured coordinantes on a regular grid
    11961202% -------------------------------------------------------------------------
    1197 % function [A,rangx,rangy]=proj_grid(vec_X,vec_Y,vec_A,rgx_in,rgy_in,npxy_in)
    1198 
    1199 
     1203% --- 'proj_grid': project  fields with unstructured coordinantes on a regular grid
    12001204function [A,rangx,rangy]=proj_grid(vec_X,vec_Y,vec_A,rgx_in,rgy_in,npxy_in)
     1205% -------------------------------------------------------------------------
    12011206if length(vec_Y)<2
    12021207    msgbox_uvmat('ERROR','less than 2 points in proj_grid.m');
     
    12121217        rangx=rgx_in; % first and last positions
    12131218        rangy=rgy_in;
    1214 %             npxy=npxy_in;
    12151219        dxy(1)=1/(npxy_in(1)-1);%grid mesh in y
    12161220        dxy(2)=1/(npxy_in(2)-1);%grid mesh in x
     
    12271231    xi=[rangx(1):dxy(2):rangx(2)];
    12281232    yi=[rangy(1):dxy(1):rangy(2)];
    1229     [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
    12301233    A=griddata_uvmat(vec_X,vec_Y,vec_A,xi,yi');
    12311234    A=reshape(A,length(yi),length(xi));
     
    12351238    ymax=vec_Y(indexend+1);% y coordinate AFTER line change
    12361239    ymin=vec_Y(index(1));
    1237     %y=[vec_Y(index) ymax]; % the set of y ordinates including the last one
    12381240    y=vec_Y(index);
    12391241    y(length(y)+1)=ymax;
     
    12521254    else       
    12531255        rangx=[vec_X(1) vec_X(nx)];% first and last position found for x
    1254 %             rangy=[ymin ymax];
    12551256          rangy=[max(ymax,ymin) min(ymax,ymin)];
    12561257        if max(nx,ny) <= 64 & isequal(npxy_in,'np>256')
     
    12721273    else %no interpolation for a resolution higher than 256
    12731274        A=B;
    1274         XI=X;
    1275         YI=Y;
    1276     end
    1277 end
     1275    end
     1276end
  • trunk/src/read_civdata.m

    r382 r389  
    8383Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt'}];
    8484var_ind=find(vardetect);
    85 for ivar=1:min(numel(var_ind),numel(Field.VarAttribute))
     85for ivar=1:numel(var_ind)
    8686    Field.VarAttribute{ivar}.Role=role{var_ind(ivar)};
    8787    Field.VarAttribute{ivar}.Unit=units{var_ind(ivar)};
     
    9595Field.TimeUnit='s';
    9696Field.CoordUnit='pixel';
    97 
    98 
    9997
    10098%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    122120for ilist=1:length(FieldNames)
    123121    if ~isempty(FieldNames{ilist})
    124     switch FieldNames{ilist}
    125         case{'u','v'}
    126             testpatch=1;
    127         case {'vort','div','strain'}
    128             testder=1;
    129            
     122        switch FieldNames{ilist}
     123            case{'u','v'}
     124                testpatch=1;
     125            case {'vort','div','strain'}
     126                testder=1;
     127        end
    130128    end
    131     end
    132 end   
    133 
     129end
    134130if isempty(vel_type)
    135131    switch CivStage
     
    153149
    154150switch vel_type
    155     case {'civ1','filter1'}
    156         var={'X','Y','Z','U','V','W','C','F','FF','X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites','Indices_tps';...
     151    case 'civ1'
     152        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
    157153            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF',...
    158             'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites','Civ1_Indices_tps'};
    159         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','','',''};
    160         units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel','',''};
    161     case 'civ-filter1'
    162         var={'X','Y','Z','U','V','W','FF';...
    163             'Civ1_X','Civ1_Y','','Civ1_U_Diff','Civ1_V_Diff','','Civ1_FF'};
    164         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','errorflag'};
    165         units={'pixel','pixel','pixel','pixel','pixel','pixel',[]};
    166 %     case 'filter1'
    167 %         var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites','Indices_tps';...
    168 %             'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites','Civ1_Indices_tps'};
    169 %         role={'','','','','','','','','',''};
    170 %         units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel','',''};
    171     case {'civ2','filter2'}
    172         var={'X','Y','Z','U','V','W','C','F','FF','X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites','Indices_tps';...
     154            'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbSites'};
     155        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','ancillary','ancillary',...
     156            'ancillary','ancillary','ancillary','ancillary'};
     157        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
     158    case 'filter1'
     159        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
     160            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U_smooth','Civ1_V_smooth','Civ1_W','Civ1_C','Civ1_F','Civ1_FF',...
     161            'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbSites'};
     162        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','ancillary','ancillary',...
     163            'ancillary','ancillary','ancillary','ancillary'};
     164        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
     165    case 'civ2'
     166        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
    173167            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF',...
    174             'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites','Civ2_Indices_tps'};
    175         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','','',''};
    176         units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel','',''};
    177 %         var={'X','Y','Z','U','V','W','C','F','FF';...
    178 %             'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF'};
    179 %         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
    180 %         units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
    181     case 'civ-filter2'
    182         var={'X','Y','Z','U','V','W','FF';...
    183             'Civ2_X','Civ2_Y','','Civ2_U_Diff','Civ2_V_Diff','','Civ2_FF'};
    184         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','errorflag'};
    185         units={'pixel','pixel','pixel','pixel','pixel','pixel',[]};
    186 %     case 'filter2'
    187 %         var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites','Indices_tps';...
    188 %             'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites','Civ2_Indices_tps'};
    189 %         role={'','','','','','','','','',''};
    190 %         units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel','',''};
     168            'Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps','','Civ2_SubRange','Civ2_NbSites'};
     169        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','',''};
     170        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
     171    case 'filter2'
     172        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
     173            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U_smooth','Civ2_V_smooth','Civ2_W','Civ2_C','Civ2_F','Civ2_FF',...
     174            'Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps','','Civ2_SubRange','Civ2_NbSites'};
     175        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','',''};
     176        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
    191177end
    192178vel_type_out=vel_type;
  • trunk/src/uvmat.m

    r388 r389  
    4242%           .NewSeries: =1 when the first view of a new field series is displayed, else 0
    4343%           .filename:(char string)
    44 %           .VelType:(char string) type of velocity field selected
    45 %           .VelType_1:(char string)  REMPLACER LE CELL ACTUEL
    4644%           .FieldName: (char string) main field selected('image', 'velocity'...)
    47 %           .FieldName_1:(char string) second field selected('image', 'velocity'...)
    4845%           .CName: (char string)name of the scalar used for vector colors
    4946%          .MovieObject{1}: movie object representing an input movie
    5047%          .MovieObject{2}: idem for a second input series (_1)
    5148%          .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
    52 %          .VelType_1: last velocity type (VelType, civ2...) for the second input series
    53 %          .FieldName_1: last field name(velocity, vorticity...) for the second input series
    5449%          .ZMin, .ZMax: range of the z coordinate
    5550%..... to complement
     
    18921887set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
    18931888drawnow
    1894 %filename=read_file_boxes(handles);
    18951889[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    18961890filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     
    18991893    [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    19001894    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
    1901    % filename_1=read_file_boxes_1(handles);
    19021895end
    19031896num_i1=stra2num(get(handles.i1,'String'));
     
    19831976            FieldName= list_fields{index_fields}; % selected field
    19841977            if ~strcmp(FieldName,'get_field...')
    1985                 TestVelType=get(handles.FixVelType,'Value');
    1986                 if TestVelType
    1987                     VelType=setfield(handles);% read the velocity type.
     1978                if get(handles.FixVelType,'Value')
     1979                    VelTypeList=get(handles.VelType,'String');
     1980                    VelType=VelTypeList{get(handles.VelType,'Value')};
     1981%                     VelType=setfield(handles);% read the velocity type.
    19881982                end
    19891983            end
     
    20432037        case {'civx','civdata','netcdf'};
    20442038            list_fields=get(handles.Fields_1,'String');% list menu fields
    2045             index_fields=get(handles.Fields_1,'Value');% selected string index
    2046             FieldName_1= list_fields{index_fields}; % selected field
     2039            FieldName_1= list_fields{get(handles.Fields_1,'Value')}; % selected field
    20472040            if ~strcmp(FieldName,'get_field...')
    2048                 TestVelType=get(handles.FixVelType,'Value');
    2049                 if TestVelType
    2050                     VelType_1=setfield(handles);% read the velocity type.
     2041                if get(handles.FixVelType,'Value')
     2042                    VelTypeList=get(handles.VelType_1,'String');
     2043                    VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type.
     2044%                     VelType_1=setfield(handles);% read the velocity type.
    20512045                end
    20522046            end
     
    20742068    test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
    20752069    if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
    2076         if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
    2077             test_keepdata_1= strcmp(filename_1,UvData.filename_1) && strcmp(VelType_1,UvData.VelType_1) && strcmp(FieldName_1,UvData.FieldName_1);
     2070        if isfield(UvData,'filename_1')%&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
     2071            test_keepdata_1= strcmp(filename_1,UvData.filename_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1);
    20782072        end
    20792073    end
    20802074    if test_keepdata_1
    2081         Field{2}=UvData.Field_1;
     2075        Field{2}=UvData.Field_1;% keep the stored field
    20822076    else
    20832077        ParamIn.FieldName=FieldName_1;
     
    21362130    set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
    21372131else
    2138     if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')
     2132    if (~strcmp(FileType_1,'netcdf')&&~strcmp(FileType_1,'civdata')&&~strcmp(FileType_1,'civx'))|| isequal(FieldName_1,'get_field...')
    21392133        set(handles.VelType_1,'Visible','off')
    21402134    else
     
    21622156if  UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3);
    21632157        set(handles.SubField,'Value',1);
    2164         %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
    21652158        set(handles.RootPath_1,'String','"')
    21662159        set(handles.RootFile_1,'String','"')
    21672160        set(handles.SubDir_1,'String','"');
    21682161         indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2);
    2169         %[indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
    21702162        set(handles.FileIndex_1,'String',indices)
    21712163        set(handles.FileExt_1,'String','"');
     
    21832175%% store the current open names, fields and vel types in uvmat interface
    21842176UvData.filename_1=filename_1;
    2185 UvData.VelType_1=[];%default
    2186 UvData.FieldName_1=[];
    2187 if isfield(ParamOut_1,VelType)
    2188     UvData.VelType_1=ParamOut_1.VelType;
    2189 end
    2190 if isfield(ParamOut_1,FieldName)
    2191     UvData.FieldName_1=ParamOut_1.FieldName;
    2192 end
    21932177
    21942178%% apply coordinate transform or other user fct
     
    22092193end
    22102194%px to phys or other transform on field
    2211 if ~isempty(transform) 
     2195if ~isempty(transform)
    22122196    if length(Field)>=2
    22132197        Field{2}.ZIndex=z_index;
     
    22192203        Field{1}=transform(Field{1},XmlData);
    22202204    end
    2221 end
    2222 
    2223 
    2224 %% update tps in phys coordinates if needed
    2225 if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(FileType,'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V')
    2226     [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],1500,0);
     2205    %% update tps in phys coordinates if needed
     2206    if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(FileType,'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V')
     2207        Field{1}.X=Field{1}.X(Field{1}.FF==0);
     2208        Field{1}.Y=Field{1}.Y(Field{1}.FF==0);
     2209        Field{1}.U=Field{1}.U(Field{1}.FF==0);
     2210        Field{1}.V=Field{1}.V(Field{1}.FF==0);
     2211        [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],Field{1}.Patch1_SubDomain,0);
     2212    end
     2213    if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
     2214        %update tps in phys coordinates if needed
     2215        if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(FileType_1,'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V')
     2216            Field{2}.X=Field{2}.X(Field{2}.FF==0);
     2217            Field{2}.Y=Field{1}.Y(Field{2}.FF==0);
     2218            Field{2}.U=Field{1}.U(Field{2}.FF==0);
     2219            Field{2}.V=Field{1}.V(Field{2}.FF==0);
     2220            [Field{2}.SubRange,Field{2}.NbSites,Field{2}.Coord_tps,Field{2}.U_tps,Field{2}.V_tps]=filter_tps([Field{2}.X Field{2}.Y],Field{2}.U,Field{2}.V,[],1500,0);
     2221        end
     2222    end
    22272223end
    22282224
    22292225%% calculate scalar
    2230 if strcmp(FileType(1:3),'civ') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
    2231     Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1},VelType);
    2232 end
    2233 if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
    2234     %update tps in phys coordinates if needed
    2235     if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(FileType_1,'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V')
    2236         [Field{2}.SubRange,Field{2}.NbSites,Field{2}.Coord_tps,Field{2}.U_tps,Field{2}.V_tps]=filter_tps([Field{2}.X Field{2}.Y],Field{2}.U,Field{2}.V,[],1500,0);
    2237     end
    2238     Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2},VelType_1);
     2226if (strcmp(FileType,'civdata')||strcmp(FileType,'civx'))&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
     2227    Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1},ParamOut.VelType);
     2228end
     2229if numel(Field)==2 && ~test_keepdata_1 && (strcmp(FileType,'civdata')||strcmp(FileType,'civx'))  &&~strcmp(ParamOut.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...')
     2230     Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2},ParamOut_1.VelType);
    22392231end
    22402232
     
    23872379    end
    23882380else
    2389     % create a default projection
    2390     UvData.Object{1}.ProjMode='projection';%main plotting plane
    2391     UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
    2392     set(handles.ListObject,'Value',1);
    2393     list_object=get(handles.ListObject,'String');
    2394     if isempty(list_object)
    2395         list_object={''};
    2396     elseif ~isempty(list_object{1})
    2397         list_object=[{''};list_object];
    2398     end
    2399     set(handles.ListObject,'String',list_object);
    2400 %     set(handles.list_object_2,'String',list_object);
     2381%     % create a default projection
     2382%     UvData.Object{1}.ProjMode='projection';%main plotting plane
     2383%     UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
     2384%     set(handles.ListObject,'Value',1);
     2385%     list_object=get(handles.ListObject,'String');
     2386%     if isempty(list_object)
     2387%         list_object={''};
     2388%     elseif ~isempty(list_object{1})
     2389%         list_object=[{''};list_object];
     2390%     end
     2391%     set(handles.ListObject,'String',list_object);
     2392% %     set(handles.list_object_2,'String',list_object);
    24012393end
    24022394testnewseries=UvData.NewSeries;
     
    27832775var_FixFlag(1:nb_vectors)=AxeData.FF;%
    27842776fin=close(nc);
    2785 
    2786 %-------------------------------------------------------------------
    2787 %determines the fields to read from the interface
    2788 %------------------------------------------------------------------
    2789 function VelType=setfield(handles)
    2790 VelTypeList=get(handles.VelType,'String');
    2791 index=get(handles.VelType,'Value');
    2792 VelType=VelTypeList{index};
    2793 
    2794 %-------------------------------------------------------------------
    2795 %determines the veltype of the second field to read from the iinterface
    2796 %------------------------------------------------------------------
    2797 function VelType=setfield_1(handles)
    2798 VelTypeList=get(handles.VelType_1,'String');
    2799 index=get(handles.VelType_1,'Value');
    2800 VelType=VelTypeList{index};
    28012777
    28022778%---------------------------------------------------
     
    29662942    set(handles.num_Npy,'Visible','off')
    29672943end
    2968 setfield(handles);% update the field structure ('civ1'....)
    29692944if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
    29702945    run0_Callback(hObject, eventdata, handles)
     
    29802955if check_new && isfield(UvData,'XmlData')
    29812956    UvData.XmlData{2}=UvData.XmlData{1};
     2957end
     2958if isfield(UvData,'Field_1')
     2959    UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read)
    29822960end
    29832961list_fields=get(handles.Fields,'String');% list menu fields
     
    30623040        end
    30633041        set(handles.uvmat,'UserData',UvData)
    3064         setfield(handles);% update the field structure ('civ1'....)
     3042%         setfield(handles);% update the field structure ('civ1'....)
    30653043        if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
    30663044            run0_Callback(hObject, eventdata, handles)
     
    30723050function menu=set_veltype_display(Civ,FileType)
    30733051%------------------------------------------------------------------------
    3074 if isequal(Civ,0)
    3075     imax=0;
    3076 elseif isequal(Civ,1) || isequal(Civ,2)
    3077    imax=1;
    3078 elseif isequal(Civ,3)
    3079     imax=3;
    3080 elseif isequal(Civ,4) || isequal(Civ,5)
    3081     imax=4;
    3082 elseif isequal(Civ,6) %patch2
    3083     imax=6;
    3084 end
    30853052if ~exist('FileType','var')
    30863053    FileType='civx';
     
    30883055switch FileType
    30893056    case 'civx'
    3090 menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
     3057        menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
     3058        if isequal(Civ,0)
     3059            imax=0;
     3060        elseif isequal(Civ,1) || isequal(Civ,2)
     3061            imax=1;
     3062        elseif isequal(Civ,3)
     3063            imax=3;
     3064        elseif isequal(Civ,4) || isequal(Civ,5)
     3065            imax=4;
     3066        elseif isequal(Civ,6) %patch2
     3067            imax=6;
     3068        end
    30913069    case 'civdata'
    3092     menu={'civ1';'civ-filter1';'filter1';'civ2';'civ-filter2';'filter2'};   
    3093 end
     3070        menu={'civ1';'filter1';'civ2';'filter2'};
     3071        if isequal(Civ,0)
     3072            imax=0;
     3073        elseif isequal(Civ,1) || isequal(Civ,2)
     3074            imax=1;
     3075        elseif isequal(Civ,3)
     3076            imax=2;
     3077        elseif isequal(Civ,4) || isequal(Civ,5)
     3078            imax=3;
     3079        elseif isequal(Civ,6) %patch2
     3080            imax=4;
     3081        end
     3082end
     3083
     3084
     3085
    30943086menu=menu(1:imax);
    30953087
     
    31073099 
    31083100set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic)
     3101UvData=get(handles.uvmat,'UserData');
    31093102%refresh field with a second filename=first fiel name
    31103103set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
     
    31133106[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    31143107filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    3115 %filename=read_file_boxes(handles);
    3116 
    3117 index=get(handles.VelType_1,'Value');
    3118 if index==1
     3108% VelTypeList=get(handles.VelType_1,'String');
     3109% VelType_1=VelTypeList{get(handles.VelType_1,'Value')};
     3110if isempty(InputFile.VelType_1)
    31193111        filename_1='';% we plot the current field without the second field
    31203112        set(handles.SubField,'Value',0)
     
    31233115      [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    31243116     filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
    3125     %filename_1=read_file_boxes_1(handles); %read the current second field
     3117%       UvData.VelType{2}=InputFile.VelType_1;
    31263118else
    31273119     filename_1=filename;% we compare two fields in the same file
     3120     UvData.FileType{2}=UvData.FileType{1};
     3121%      UvData.VelType{2}=InputFile.VelType_1;
    31283122     set(handles.SubField,'Value',1)
    31293123end
    3130 
     3124if isfield(UvData,'Field_1')
     3125    UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists
     3126end
     3127set(handles.uvmat,'UserData',UvData)
    31313128num_i1=stra2num(get(handles.i1,'String'));
    31323129num_i2=stra2num(get(handles.i2,'String'));
     
    44564453
    44574454%read the file
    4458 % t=xmltree(fileinput);
    4459 % data=convert(t);
    44604455data=xml2struct(fileinput);
    44614456data.enable_plot=1;
    4462 [pp,data.Name]=fileparts(FileName);
    4463 %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
     4457[tild,data.Name]=fileparts(FileName);
    44644458hset_object=findobj(allchild(0),'tag','set_object');
    44654459if ~isempty(hset_object)
     
    44904484set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
    44914485data.enable_plot=1;
    4492 transform_list=get(handles.transform_fct,'String');
    4493 val=get(handles.transform_fct,'Value');
    4494 %data.CoordType=transform_list{val};
    44954486data.Coord=[0 0]; %default
    44964487if isfield(UvData,'Field')
    44974488    Field=UvData.Field;
    44984489    if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
    4499         data.RangeX=Field.Mesh;
    4500         data.RangeY=Field.Mesh;
    4501         data.DX=Field.Mesh;
    4502         data.DY=Field.Mesh;
     4490        ord=10^(floor(log10(Field.Mesh)));%order of magnitude
     4491        if Field.Mesh/ord>=5
     4492            mesh=5*ord;
     4493        elseif Field.Mesh/ord>=2
     4494            mesh=2*ord;
     4495        else
     4496            mesh=ord;
     4497        end
     4498        data.RangeX=mesh;
     4499        data.RangeY=mesh;
     4500        data.DX=mesh;
     4501        data.DY=mesh;
    45034502    elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
    45044503        np=size(Field.A);
     
    45164515    end
    45174516end
    4518 % if isfield(data,'Type') && isequal(data.Type,'line')
    4519 %     if isfield(data,'DX')
    4520 %         data.Coord=[[0 0 0];[data.DX 0 0]]; %default
    4521 %     else
    4522 %         data.Coord=[[0 0 0];[1 0 0]]; %default
    4523 %     end
    4524 % end
    45254517if ishandle(handles.UVMAT_title)
    45264518    delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
    45274519end
    4528 %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    45294520set_object(data,handles);% call the set_object interface
    45304521set(handles.MenuObject,'checked','on')
     
    45334524CheckZoom_Callback(handles.uvmat, [], handles)
    45344525set(handles.delete_object,'Visible','on')
    4535 % set(handles._title,'Visible','on')
    4536 % set(handles.view_field_title,'Visible','on')
    45374526
    45384527%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.