Index: /trunk/src/proj_field.m
===================================================================
--- /trunk/src/proj_field.m	(revision 911)
+++ /trunk/src/proj_field.m	(revision 912)
@@ -1010,4 +1010,10 @@
 end
 
+%% interpolation range
+thresh2=[];
+if isfield(ObjectData,'RangeInterp')
+    thresh2=ObjectData.RangeInterp*ObjectData.RangeInterp;%square of interpolation range (do not interpolate beyond this range)
+end
+
 %% initiate Matlab  structure for physical field
 [ProjData,errormsg]=proj_heading(FieldData,ObjectData);
@@ -1303,8 +1309,9 @@
                     Disty=G(XI,YI)-YI;% diff of y coordinates with the nearest measurement point
                     Dist=Distx.*Distx+Disty.*Disty;
-                    for ivar=1:numel(VarVal)
-                        VarVal{ivar}(Dist>16*ProjData.CoordMesh)=NaN;% % put to NaN interpolated positions further than 4 meshes from initial data
-                    end  
-                    
+                    if ~isempty(thresh2)
+                        for ivar=1:numel(VarVal)
+                            VarVal{ivar}(Dist>thresh2)=NaN;% % put to NaN interpolated positions further than 4 meshes from initial data
+                        end
+                    end
                     if isfield(CellInfo{icell},'CheckSub') && CellInfo{icell}.CheckSub && ~isempty(vector_x_proj)
                         ProjData.(FieldData.ListVarName{vector_x_proj})=ProjData.(FieldData.ListVarName{vector_x_proj})-VarVal{1};
@@ -1358,7 +1365,9 @@
                 for ilist=1:numel(ListVarName)% reshape data, excluding coordinates (ilist=1-2), TODO: rationalise
                     VarName=ListVarName{ilist};
+                    VarDimName{ilist}={'coord_y','coord_x'};
                     ProjData.(VarName)=DataOut.(VarName);
-                    ProjData.(VarName)(Dist>16*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions further than 4 meshes from initial data
-                    VarDimName{ilist}={'coord_y','coord_x'};
+                    if ~isempty(thresh2)
+                        ProjData.(VarName)(Dist>thresh2)=NaN;% put to NaN interpolated positions further than RangeInterp from initial data
+                    end
                 end
             end
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 911)
+++ /trunk/src/series.m	(revision 912)
@@ -1929,5 +1929,5 @@
             end
         end
-        filename_joblist=fullfile(DirOAR,'0_job_list.txt');%create name of the global executable file
+        filename_joblist=fullfile(DirOAR,'job_list.txt');%create name of the global executable file
         filename_log=fullfile(DirLog,'job_list.stdout');%file for output messages of the master oar process
         filename_errors=fullfile(DirLog,'job_list.stderr');%file for error messages of the master oar process
@@ -1947,8 +1947,8 @@
         % shorter than the wall time: in the time interval 'checkpoint' (WallTimeOneJob) before the end of the allowed duration, 
         %  the oar job restarts when an individual job ends. 
-        JobTime=CPUTime*BlockLength*nbfield_j% estimated time for one individual job (in minutes)
+        JobTime=CPUTime*BlockLength*nbfield_j;% estimated time for one individual job (in minutes)
         % wall time (in hours ) for each oar job, allowing 10 individual jobs, but limited to 23 h:
         WallTimeTotal=min(23,4*JobTime/60);
-        disp(['WallTimeTotal: ' num2str(WallTimeTotal) ' hours'])
+        %disp(['WallTimeTotal: ' num2str(WallTimeTotal) ' hours'])
         % estimated time of an individual job (in min), with a margin of error
         WallTimeOneJob=min(4*JobTime+10,WallTimeTotal*60/2);% estimated max time of an individual job for checkpoint
@@ -3396,5 +3396,5 @@
         elseif isequal(Civ,4) || isequal(Civ,5)
             imax=3;
-        elseif isequal(Civ,6) %patch2
+        else%if isequal(Civ,6) %patch2
             imax=4;
         end
Index: /trunk/src/series/check_data_files.m
===================================================================
--- /trunk/src/series/check_data_files.m	(revision 911)
+++ /trunk/src/series/check_data_files.m	(revision 912)
@@ -154,6 +154,10 @@
                     if strcmp(FileType{iview},'civx')||strcmp(FileType{iview},'civdata')
                         if isfield(FileInfo,'CivStage')
-                            liststage={'civ1','fix1','patch1','civ2','fix2','patch2'};
-                            lastfield=liststage{FileInfo.CivStage};
+                            liststage={'civ','fix','patch'};
+                            stagechoice=1+mod(FileInfo.CivStage-1,3);
+                            iter=1+floor((FileInfo.CivStage-1)/3);
+                            lastfield=[liststage{stagechoice} num2str(iter)];
+                            %liststage={'civ1','fix1','patch1','civ2','fix2','patch2'};                        
+                            %lastfield=liststage{FileInfo.CivStage};                           
                         end
                     end
Index: /trunk/src/series/civ_series.m
===================================================================
--- /trunk/src/series/civ_series.m	(revision 911)
+++ /trunk/src/series/civ_series.m	(revision 912)
@@ -356,6 +356,28 @@
             end
         end
-        if ~CheckOverwrite && exist(ncfile,'file')          
-        continue% skip iteration if the mode overwrite is desactivated and the result file already exists
+        ncfile_out=ncfile;% by default 
+        if isfield (Param.ActionInput,'Civ2')
+            i1_civ2=i1_series_Civ2(ifield);
+            i2_civ2=i1_civ2;
+            if ~isempty(i2_series_Civ2)
+                i2_civ2=i2_series_Civ2(ifield);
+            end
+            j1_civ2=1;
+            if ~isempty(j1_series_Civ2)
+                j1_civ2=j1_series_Civ2(ifield);
+            end
+            j2_civ2=i1_civ2;
+            if ~isempty(j2_series_Civ2)
+                j2_civ2=j2_series_Civ2(ifield);
+            end
+            if strcmp(Param.ActionInput.ListCompareMode,'PIV')
+                ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
+            else % displacement
+                ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);
+            end
+        end
+        if ~CheckOverwrite && exist(ncfile_out,'file')
+            disp(['existing output file ' ncfile_out ' already exists, skip to next field'])
+            continue% skip iteration if the mode overwrite is desactivated and the result file already exists
         end
     end
@@ -582,18 +604,18 @@
             par_civ2.ImageA=[];
             par_civ2.ImageB=[];
-            i1=i1_series_Civ2(ifield);
-            i2=i1;
-            if ~isempty(i2_series_Civ2)
-                i2=i2_series_Civ2(ifield);
-            end
-            j1=1;
-            if ~isempty(j1_series_Civ2)
-                j1=j1_series_Civ2(ifield);
-            end
-            j2=j1;
-            if ~isempty(j2_series_Civ2)
-                j2=j2_series_Civ2(ifield);
-            end
-            ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1,[],j1);
+%             i1_civ2=i1_series_Civ2(ifield);
+%             i2_civ2=i1_civ2;
+%             if ~isempty(i2_series_Civ2)
+%                 i2_civ2=i2_series_Civ2(ifield);
+%             end
+%             j1_civ2=1;
+%             if ~isempty(j1_series_Civ2)
+%                 j1_civ2=j1_series_Civ2(ifield);
+%             end
+%             j2_civ2=i1_civ2;
+%             if ~isempty(j2_series_Civ2)
+%                 j2_civ2=j2_series_Civ2(ifield);
+%             end
+            ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2);
             
             if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield))
@@ -602,5 +624,5 @@
                 [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A_Civ2,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield));
             end
-            ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2,[],j2);
+            ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_civ2,[],j2_civ2);
             if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_Civ1(ifield),FrameIndex_B_Civ2)
                 par_civ2.ImageB=par_civ1.ImageB;
@@ -608,9 +630,9 @@
                 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield));
             end
-            if strcmp(Param.ActionInput.ListCompareMode,'PIV')
-                ncfile=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2);
-            else % displacement
-                ncfile=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2,[],j2);
-            end
+%             if strcmp(Param.ActionInput.ListCompareMode,'PIV')
+%                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2);
+%             else % displacement
+%                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2,[],j2);
+%             end
             par_civ2.ImageWidth=FileInfo_A.Width;
             par_civ2.ImageHeight=FileInfo_A.Height;
@@ -712,5 +734,5 @@
                 Civ2_Dt=1;
             else
-                Civ2_Dt=time(i2+1,j2+1)-time(i1+1,j1+1);
+                Civ2_Dt=time(i2_civ2+1,j2_civ2+1)-time(i1_civ2+1,j1_civ2+1);
             end
         end
@@ -737,8 +759,8 @@
             Data.Civ2_ImageB=ImageName_B;
              if strcmp(Param.ActionInput.ListCompareMode,'displacement')
-                Data.Civ2_Time=time(i2+1,j2+1);% the time is the time of the secodn image
+                Data.Civ2_Time=time(i2_civ2+1,j2_civ2+1);% the time is the time of the secodn image
                 Data.Civ2_Dt=1;% time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading
              else
-            Data.Civ2_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2;
+            Data.Civ2_Time=(time(i2_civ2+1,j2_civ2+1)+time(i1_civ2+1,j1_civ2+1))/2;
             Data.Civ2_Dt=Civ2_Dt;
              end
@@ -863,7 +885,7 @@
     %% write result in a netcdf file if requested
     if CheckOutputFile
-        errormsg=struct2nc(ncfile,Data);
+        errormsg=struct2nc(ncfile_out,Data);
         if isempty(errormsg)
-            disp([ncfile ' written'])
+            disp([ncfile_out ' written'])
         else
             disp(errormsg)
Index: /trunk/src/set_object.m
===================================================================
--- /trunk/src/set_object.m	(revision 911)
+++ /trunk/src/set_object.m	(revision 912)
@@ -38,5 +38,5 @@
 function varargout = set_object(varargin)
 
-% Last Modified by GUIDE v2.5 15-Jun-2015 19:51:15
+% Last Modified by GUIDE v2.5 16-Jun-2015 00:33:59
 
 % Begin initialization code - DO NOT REFRESH
@@ -307,4 +307,5 @@
 set(handles.num_DY,'Visible','off')
 set(handles.num_DZ,'Visible','off')
+set(handles.num_RangeInterp,'Visible','off')
 
 switch ObjectStyle
@@ -322,4 +323,5 @@
             set(handles.num_DX,'Visible','on')
             set(handles.num_DX,'TooltipString','num_DX: mesh for the interpolated field along the line')
+            set(handles.num_RangeInterp,'Visible','on')
         end       
     case {'rectangle','ellipse'}
@@ -341,11 +343,12 @@
             set(handles.num_DX,'Visible','on')
             set(handles.num_DY,'Visible','on')
+            set(handles.num_RangeInterp,'Visible','on')
         else
             set(handles.num_DX,'Visible','off')
             set(handles.num_DY,'Visible','off')
         end
-        if  isequal(ProjMode,'interp_lin')
-            set(handles.num_DZ,'Visible','on')  
-        end
+%         if  isequal(ProjMode,'interp_lin')
+%             set(handles.num_DZ,'Visible','on')  
+%         end
      case {'volume'}  
         set(handles.num_RangeX_1,'Visible','on')
@@ -372,8 +375,8 @@
 % set default values read in the plot of uvmat to initiate the mesh 
 if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps')
+            huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle
+        UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
     if isempty(str2num(get(handles.num_DX,'String')))||isempty(str2num(get(handles.num_DY,'String')));     
-        huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle
-        UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
-        Field=UvData.Field;
+%         Field=UvData.Field;
         if  isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh)
             set(handles.num_DX,'String',num2str(UvData.Field.CoordMesh))
@@ -387,4 +390,7 @@
             set(handles.CoordUnit,'String',Field.CoordUnit)
         end       
+    end
+    if isempty(str2num(get(handles.num_RangeInterp,'String')))
+     set(handles.num_RangeInterp,'String',num2str(3*UvData.Field.CoordMesh))% default interpolationlength= 3 meshes
     end
 end
@@ -416,5 +422,5 @@
 huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle
 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
-if isfield(UvData,'X') & isfield(UvData,'Y') & isfield(UvData,'Z')
+if isfield(UvData,'X') && isfield(UvData,'Y') && isfield(UvData,'Z')
     Z=norm_plane(1)*(UvData.X)+norm_plane(2)*(UvData.Y)+norm_plane(3)*(UvData.Z);
     set(handles.z_slider,'Min',min(Z))
@@ -691,6 +697,10 @@
         t=struct2xml(Object);
         t=set(t,1,'name','ProjObject');
-        save(t,FullName)
-        msgbox_uvmat('CONFIRMATION',[FullName  ' saved'])
+        try
+            save(t,FullName)
+            msgbox_uvmat('CONFIRMATION',[FullName  ' saved'])
+        catch ME
+            msgbox_uvmat('ERROR',ME.message)
+        end
     end
 end
@@ -801,21 +811,2 @@
 
 function num_RangeInterp_Callback(hObject, eventdata, handles)
-% hObject    handle to num_RangeInterp (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of num_RangeInterp as text
-%        str2double(get(hObject,'String')) returns contents of num_RangeInterp as a double
-
-
-% --- Executes during object creation, after setting all properties.
-function num_RangeInterp_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to num_RangeInterp (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    empty - handles not created until after all CreateFcns called
-
-% Hint: edit controls usually have a white background on Windows.
-%       See ISPC and COMPUTER.
-if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
-    set(hObject,'BackgroundColor','white');
-end
