Index: /trunk/src/calc_field.m
===================================================================
--- /trunk/src/calc_field.m	(revision 379)
+++ /trunk/src/calc_field.m	(revision 380)
@@ -64,5 +64,6 @@
     RoleList={};
     units_cell={};
-    % new civ data
+    
+    %% interpolation with new civ data 
     if isfield(DataIn,'X_SubRange')
         XMax=max(max(DataIn.X_SubRange));
@@ -88,4 +89,5 @@
         DataOut.V=zeros(size(XI));
         DataOut.vort=zeros(size(XI));
+        
         DataOut.div=zeros(size(XI));
         nbval=zeros(size(XI));
@@ -126,20 +128,8 @@
                         ListFields={'vort'};
                         VarAttributes{1}.Role='scalar';
-%                         EMX = [DMXY(:,:,1) PM];
-%                         EMY = [DMXY(:,:,2) PM];
-%                         DataIn.U_tps(nbvec_sub+1,isub)=0;%constant value suppressed by spatial derivatives
-%                         DataIn.V_tps(nbvec_sub+1,isub)=0;%constant value suppressed by spatial derivatives
-%                         DataIn.V_tps(nbvec_sub+2,isub)=0;% X coefficient suppressed for x wise derivatives
-%                         DataIn.U_tps(nbvec_sub+3,isub)=0;% Y coefficient suppressed for x wise derivatives
                         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);
                     case 'div'
                         ListFields={'div'};
                         VarAttributes{1}.Role='scalar';
-%                         EMX = [DMXY(:,:,1) PM];
-%                         EMY = [DMXY(:,:,2) PM];
-%                         DataIn.U_tps(nbvec_sub+1,isub)=0;%constant value suppressed by spatial derivatives
-%                         DataIn.V_tps(nbvec_sub+1,isub)=0;%constant value suppressed by spatial derivatives
-%                         DataIn.V_tps(nbvec_sub+2,isub)=0;% X coefficient suppressed for x wise derivatives
-%                         DataIn.U_tps(nbvec_sub+3,isub)=0;% Y coefficient suppressed for x wise derivatives
                         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);
                 end
@@ -161,6 +151,8 @@
         DataOut.VarAttribute={[],[]};
         DataOut.VarAttribute{3}.Role='errorflag';
-        DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];      
+        DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];   
     else   
+        
+    %% civx data    
         DataOut=DataIn;
         for ilist=1:length(FieldName)
Index: /trunk/src/check_files.m
===================================================================
--- /trunk/src/check_files.m	(revision 379)
+++ /trunk/src/check_files.m	(revision 380)
@@ -52,4 +52,5 @@
     'editxml.fig';...%interface for editxml
     'fileparts_uvmat';...% extracts the root name,field indexes and nomenclature type from an input filename
+    'fill_GUI';...% fill a GUI with handles 'handles' from input data Param 
     'find_field_indices';...% group the variables of a nc-formated Matlab structure into 'fields' with common dimensions
     'find_file_series';...%check the content of an input file and find the corresponding file series
@@ -59,4 +60,6 @@
     'get_field';...% choose and plot a field from a Netcdf file
     'get_field.fig';...%interface for get_field
+    'get_file_series';...% determine the list of file names and file indices for functions called by 'series'.
+    'get_file_type';...% determine info about a file (image, multimage, civdata,...) .
     'griddata_uvmat';...%make 2D linear interpolation using griddata, with input appropriate for both Matlab 6.5 and 7
     'hist_update';...%  update of a current global histogram by inclusion of a new field
@@ -83,5 +86,4 @@
     'read_GUI';... %read all parameters set by a GUI as a Matlab structure
     'read_imatext';...%read .civ files (obsolete, but can be adapted to other text documentation files) 
-    'read_set_object';...%read the data on the set_object interface, TODO: use instead the general function read_GUI
     'read_xls';...%read excel files containing the list of the experiments
     'reinit';...% suppress the personal parameter file 'uvmat_perso.mat'
Index: /trunk/src/fill_GUI.m
===================================================================
--- /trunk/src/fill_GUI.m	(revision 379)
+++ /trunk/src/fill_GUI.m	(revision 380)
@@ -1,4 +1,4 @@
+%'fill_GUI': fill a GUI with handles 'handles' from input data Param 
 % -----------------------------------------------------------------------
-% --- read a GUI with handle 'handle' producing a structure 'struct'
 function errormsg=fill_GUI(Param,handles)
 %------------------------------------------------------------------------
Index: /trunk/src/get_file_type.m
===================================================================
--- /trunk/src/get_file_type.m	(revision 379)
+++ /trunk/src/get_file_type.m	(revision 380)
@@ -1,5 +1,5 @@
-  %'get_file_series': determine the list of file names and file indices for functions called by 'series'. 
+%'get_file_type': determine info about a file (image, multimage, civdata,...) . 
 %------------------------------------------------------------------------
-% [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param)
+% [FileType,FileInfo,Object]=get_file_type(fileinput)
 %
 % OUTPUT:
Index: /trunk/src/read_civdata.m
===================================================================
--- /trunk/src/read_civdata.m	(revision 379)
+++ /trunk/src/read_civdata.m	(revision 380)
@@ -47,5 +47,5 @@
 % 'nc2struct': reads a netcdf file 
 
-function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,XI,YI)
+function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,CivStage)
 errormsg='';
 VelTypeOut=VelType;%default
@@ -65,6 +65,6 @@
 
 %% reading data
-[varlist,role,units,vel_type_out_cell]=varcivx_generator(FieldNames,VelType);
-[Field,vardetect,ichoice]=nc2struct(filename,varlist);%read the variables in the netcdf file
+[varlist,role,units,VelTypeOut]=varcivx_generator(FieldNames,VelType,CivStage);
+[Field,vardetect]=nc2struct(filename,varlist);%read the variables in the netcdf file
 if isfield(Field,'Txt')
     errormsg=Field.Txt;
@@ -75,11 +75,11 @@
      return
 end
-switch vel_type_out_cell{ichoice}
-    case{'civ1','fix1','patch1'}
-        Field.dt=Field.Civ1_Dt;
-    case{'civ2','fix2','patch2'}
-        Field.dt=Field.Civ2_Dt;
+switch VelTypeOut
+    case{'civ1','civ-filter1','filter1'}
+        Field.Dt=Field.Civ1_Dt;
+    case{'civ2','civ-filter2','filter2'}
+        Field.Dt=Field.Civ2_Dt;
 end
-Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'dt'}];
+Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt'}];
 var_ind=find(vardetect);
 for ivar=1:min(numel(var_ind),numel(Field.VarAttribute))
@@ -88,65 +88,7 @@
     Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
 end
-if ~isempty(ichoice)
-    VelTypeOut=vel_type_out_cell{ichoice};
-end
 
-
-%% renaming for standard conventions
-%Field.NbCoord=Field.nb_coord;
-%Field.NbDim=2;%Field.nb_dim;
-
-%% CivStage
-% if isfield(Field,'patch2')&& isequal(Field.patch2,1)
-%     Field.CivStage=6;
-% elseif isfield(Field,'fix2')&& isequal(Field.fix2,1)
-%     Field.CivStage=5;
-% elseif isfield(Field,'civ2')&& isequal(Field.civ2,1)
-%     Field.CivStage=4; 
-% elseif isfield(Field,'patch')&& isequal(Field.patch,1)
-%     Field.CivStage=3; 
-% elseif isfield(Field,'fix')&& isequal(Field.fix,1)
-%     Field.CivStage=2;
-% else
-%     Field.CivStage=1;
-% end 
 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'NbCoord','NbDim','TimeUnit','CoordUnit'}];
-% %determine the appropriate constant for time and dt for the PIV pair
-% test_civ1=isequal(VelTypeOut,'civ1')||isequal(VelTypeOut,'interp1')||isequal(VelTypeOut,'filter1');
-% test_civ2=isequal(VelTypeOut,'civ2')||isequal(VelTypeOut,'interp2')||isequal(VelTypeOut,'filter2');
-% Field.Time=0; %default
-% Field.TimeUnit='s'; 
-% if test_civ1
-%     if isfield(Field,'absolut_time_T0')
-%         Field.Time=double(Field.absolut_time_T0);
-%         Field.dt=double(Field.dt);
-%     else
-%        Field.Txt='the input file is not civx'; 
-%        Field.CivStage=0;
-%        Field.dt=0;
-%     end
-% elseif test_civ2
-%     Field.Time=double(Field.absolut_time_T0_2);
-%     Field.dt=double(Field.dt2);
-% else
-%     Field.Txt='the input file is not civx';
-%     Field.CivStage=0;
-%     Field.dt=0;
-% end
-% 
-% 
-% 
 % %% update list of global attributes
-% List=Field.ListGlobalAttribute;
-% ind_remove=[];
-% for ilist=1:length(List)
-%     switch(List{ilist})
-%         case {'patch2','fix2','civ2','patch','fix','dt2','absolut_time_T0','absolut_time_T0_2','nb_coord','nb_dim','pixcmx','pixcmy'}
-%             ind_remove=[ind_remove ilist];
-%             Field=rmfield(Field,List{ilist});
-%     end
-% end
-% List(ind_remove)=[];
-% Field.ListGlobalAttribute=[{'NbCoord'},{'NbDim'} List {'Time','TimeUnit','CivStage','CoordUnit'}];
 Field.NbCoord=2;
 Field.NbDim=2;
@@ -157,5 +99,4 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% TAKEN FROM read_civxdata NOT USED
 % [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type) 
 %INPUT:
@@ -166,8 +107,7 @@
 %             
 % vel_type: character string indicating the types of velocity fields to read ('civ1','civ2'...)
-%            if vel_type=[] or'*', a  priority choice, given by vel_type_out{1,2}, is done depending 
-%            if vel_type='filter'; a structured field is sought (filter2 in priority, then filter1)
+%            if vel_type=[] or'*', a  priority choice is done, civ2 considered better than civ1 )
 
-function [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type) 
+function [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type,CivStage) 
 
 %% default input values
@@ -187,14 +127,37 @@
         case {'vort','div','strain'}
             testder=1;
+            
     end
     end
 end    
+
+if isempty(vel_type)
+    switch CivStage
+        case {6} %filter2 available
+            vel_type='civ2';
+        case {4,5}% civ2 available but not filter2
+            if testder% derivatives needed
+                vel_type='civ1';
+            else
+                vel_type='civ2';
+            end
+        case {1,2,3}% civ1 available but not civ2
+            vel_type='civ1';
+    end
+end
+if strcmp(vel_type,'civ2') && testder
+    vel_type='filter2';
+elseif stcmp(vel_type,'civ1') && testder
+    vel_type='filter1';
+end
+
 switch vel_type
-    case 'civ1'
-        var={'X','Y','Z','U','V','W','C','F','FF';...
-            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF'};
-        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
-        units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
-    case 'interp1'
+    case {'civ1'}
+        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';...
+            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF',...
+            'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites'};
+        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','',''};
+        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
+    case 'civ-filter1'
         var={'X','Y','Z','U','V','W','FF';...
             'Civ1_X','Civ1_Y','','Civ1_U_Diff','Civ1_V_Diff','','Civ1_FF'};
@@ -207,9 +170,14 @@
         units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
     case 'civ2'
-        var={'X','Y','Z','U','V','W','C','F','FF';...
-            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF'};
-        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
-        units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
-    case 'interp2'
+        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';...
+            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF',...
+            'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites'};
+        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','',''};
+        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
+%         var={'X','Y','Z','U','V','W','C','F','FF';...
+%             'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF'};
+%         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
+%         units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
+    case 'civ-filter2'
         var={'X','Y','Z','U','V','W','FF';...
             'Civ2_X','Civ2_Y','','Civ2_U_Diff','Civ2_V_Diff','','Civ2_FF'};
@@ -221,44 +189,6 @@
         role={'','','','','','','','',''};
         units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
-    otherwise % if VelType=[], choose the best field, civ in priority, or patch2 for derivatives
-        if testpatch
-            var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';...
-                'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites';...
-                'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites'};
-            role={'','','','','','','',''};
-            units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel'};
-        else
-            var={'X','Y','Z','U','V','W','C','F','FF';...
-                'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF';...
-                'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF'};
-            role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
-            units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
-        end
 end
-if isempty(vel_type) || isequal(vel_type,'*') %undefined velocity type (civ1,civ2...)
-    if testder
-         vel_type_out{1}='filter2'; %priority to filter2 for scalar reading, filter1 as second
-        vel_type_out{2}='filter1';
-    else
-        vel_type_out{1}='civ2'; %priority to civ2 for vector reading, civ1 as second priority      
-        vel_type_out{2}='civ1';
-    end
-elseif isequal(vel_type,'filter')
-        vel_type_out{1}='filter2'; %priority to filter2 for scalar reading, filter1 as second
-        vel_type_out{2}='filter1';
-        if ~testder
-            vel_type_out{3}='civ1';%civ1 as third priority if derivatives are not needed
-        end
-elseif testder
-    test_civ1=isequal(vel_type,'civ1')||isequal(vel_type,'interp1')||isequal(vel_type,'filter1');
-    if test_civ1
-        vel_type_out{1}='filter1'; %switch to filter for reading spatial derivatives
-    else
-        vel_type_out{1}='filter2';
-    end
-else   
-    vel_type_out{1}=vel_type;%imposed velocity field 
-end
-vel_type_out=vel_type_out';
+vel_type_out=vel_type;
 
 
@@ -266,3 +196,2 @@
 
 
-
Index: /trunk/src/read_civxdata.m
===================================================================
--- /trunk/src/read_civxdata.m	(revision 379)
+++ /trunk/src/read_civxdata.m	(revision 380)
@@ -49,9 +49,13 @@
 function [Field,VelTypeOut,errormsg]=read_civxdata(filename,FieldNames,VelType)
 errormsg='';
-DataTest=nc2struct(filename,'ListGlobalAttribute','Conventions');
+DataTest=nc2struct(filename,'ListGlobalAttribute','Conventions','CivStage');
 if isfield(DataTest,'Txt')
-    errormsg=DataTest.Txt;    
+    errormsg=DataTest.Txt; 
+    return
 elseif isequal(DataTest.Conventions,'uvmat/civdata')%test for new civ format
-     [Field,VelTypeOut]=read_civdata(filename,FieldNames,VelType);
+     [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,DataTest.CivStage);
+%      if ~isempty(errormsg)
+%          msgbox_uvmat('ERROR',errormsg)
+%      end
      return
 end
Index: /trunk/src/read_field.m
===================================================================
--- /trunk/src/read_field.m	(revision 379)
+++ /trunk/src/read_field.m	(revision 380)
@@ -56,5 +56,5 @@
             field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
             if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
-                Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
+                Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage');
                 % case of new civdata conventions
                 if isequal(Data.Conventions,'uvmat/civdata')
@@ -62,5 +62,5 @@
                     ParamOut.ColorVar='ima_cor';
                     InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
-                    [Field,ParamOut.VelType,errormsg]=read_civdata(ObjectName,InputField,ParamIn.VelType);
+                    [Field,ParamOut.VelType,errormsg]=read_civdata(ObjectName,InputField,ParamIn.VelType,Data.CivStage);
                     test_civx=Field.CivStage;
                     %case of old civx conventions
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 379)
+++ /trunk/src/uvmat.m	(revision 380)
@@ -2103,5 +2103,5 @@
     set(handles.VelType_1,'Visible','on')
     set(handles.FixVelType,'Visible','on')
-    menu=set_veltype_display(ParamOut.CivStage);
+    menu=set_veltype_display(ParamOut.CivStage,FileType);
     index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in  the menu
     index_val=find(index_menu,1);
@@ -2193,6 +2193,4 @@
     end
 end
-
-% menu_transform=get(handles.transform_fct,'String');
 choice_value=get(handles.transform_fct,'Value');
 transform_list=get(handles.transform_fct,'UserData');
@@ -2807,6 +2805,4 @@
         set(handles.VelType_1,'Visible','off')
     end
-%     set_veltype_display([handles.VelType_1 handles.interp1_1 handles.filter1_1 ...
-%             handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
     if isfield(UvData,'XmlData_1')
         UvData=rmfield(UvData,'XmlData_1');
@@ -3056,5 +3052,5 @@
 %------------------------------------------------------------------------
 % --- set the visibility of relevant velocity type menus: 
-function menu=set_veltype_display(Civ)
+function menu=set_veltype_display(Civ,FileType)
 %------------------------------------------------------------------------
 if isequal(Civ,0)
@@ -3069,5 +3065,13 @@
     imax=6;
 end
+if ~exist('FileType','var')
+    FileType='civx';
+end
+switch FileType
+    case 'civx'
 menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
+    case 'civdata'
+    menu={'civ1';'civ-filter1';'filter1';'civ2';'civ-filter2';'filter2'};   
+end
 menu=menu(1:imax);
 
