Index: trunk/src/series/aver_stat.m
===================================================================
--- trunk/src/series/aver_stat.m	(revision 524)
+++ trunk/src/series/aver_stat.m	(revision 526)
@@ -182,5 +182,4 @@
 
 %% MAIN LOOP ON SLICES
-%%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
 for i_slice=1:NbSlice
     index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice
@@ -196,5 +195,6 @@
             stopstate='queue';
         end
-        
+        if isequal(stopstate,'queue')% enable STOP command
+            
         %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
         for iview=1:nbview
@@ -209,85 +209,40 @@
             end
         end
-        Field=[]; % initiate the current input field structure
+        else
+            errormsg='stop';
+        end
         %%%%%%%%%%%%%%%% end loop on views (input lines) %%%%%%%%%%%%%%%%
         %%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
         % EDIT FROM HERE
-        
+    
         if isempty(errormsg)
-            % coordinate transform (or other user defined transform)
+            Field=Data{1}; % default input field structure
+            %% coordinate transform (or other user defined transform)
             if ~isempty(transform_fct)
-                if nbview==2
-                    [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
-                    if isempty(Data{2})
-                        Data(2)=[];
-                    end
-                else
-                    Data{1}=transform_fct(Data{1},XmlData{1});
+                switch nargin(transform_fct)
+                    case 4
+                        if length(Data)==2
+                            Field=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
+                        else
+                            Field=transform_fct(Data{1},XmlData{1});
+                        end
+                    case 3
+                        if length(Data)==2
+                            Field=transform_fct(Data{1},XmlData{1},Data{2});
+                        else
+                            Field=transform_fct(Data{1},XmlData{1});
+                        end
+                    case 2
+                        Field=transform_fct(Data{1},XmlData{1});
+                    case 1
+                        Field=transform_fct(Data{1});
                 end
             end
             
-            %% check whether tps is needed, then calculate tps coefficients if needed
-            check_tps=0;
-            if ischar(Param.InputFields.FieldName)
-                Param.InputFields.FieldName={Param.InputFields.FieldName};
-            end
-            for ilist=1:numel(Param.InputFields.FieldName)
-                switch Param.InputFields.FieldName{ilist}
-                    case {'vort','div','strain'}
-                        check_tps=1;
-                end
-            end
-            if strcmp(Param.ProjObject.ProjMode,'filter')
-                check_tps=1;
-            end
-            if check_tps
-                SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps
-                if isfield(Data{iview},'SubDomain')
-                    SubDomain=Data{iview}.SubDomain;%
-                end
-                [Data{iview}.SubRange,Data{iview}.NbSites,Data{iview}.Coord_tps,Data{iview}.U_tps,Data{iview}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =...
-                    filter_tps([Data{iview}.X(Data{iview}.FF==0) Data{iview}.Y(Data{iview}.FF==0)],Data{iview}.U(Data{iview}.FF==0),Data{iview}.V(Data{iview}.FF==0),[],SubDomain,0);
-                nbvar=numel(Data{iview}.ListVarName);
-                Data{iview}.ListVarName=[Data{iview}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}];
-                Data{iview}.VarDimName=[Data{iview}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},...
-                    {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}];
-                Data{iview}.VarAttribute{nbvar+3}.Role='coord_tps';
-                Data{iview}.VarAttribute{nbvar+4}.Role='vector_x';
-                Data{iview}.VarAttribute{nbvar+5}.Role='vector_y';
-                if isfield(Data{iview},'ListDimName')%cleaning
-                    Data{iview}=rmfield(Data{iview},'ListDimName');
-                end
-                if isfield(Data{iview},'DimValue')%cleaning
-                    Data{iview}=rmfield(Data{iview},'DimValue');
-                end
-            end
-                 
-            % field calculation (vort, div...)    
-            if strcmp(FileType{1},'civx')||strcmp(FileType{1},'civdata')
-                if isfield(Data{1},'Coord_tps')
-                    Data{1}.FieldList=Param.InputFields.FieldName;
-                else
-                    Data{1}=calc_field(Param.InputFields.FieldName,Data{1});%calculate field (vort..)
-                end
-            end
-         
-            % field substration (for two input file series)
-            if length(Data)==2
-                if strcmp(FileType{2},'civx')||strcmp(FileType{2},'civdata')
-                    if isfield(Data{2},'Coord_tps')
-                        Data{2}.FieldList=Param.InputFields.FieldName;
-                    else
-                        Data{2}=calc_field(Param.InputFields.FieldName,Data{2});%calculate field (vort..)
-                    end
-                end
-                [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields
-                if ~isempty(errormsg)
-                    msgbox_uvmat('ERROR',['error in aver_stat/sub_field:' errormsg])
-                    return
-                end
-            else
-                Field=Data{1};
-            end
-            
+            %% calculate tps coefficients if needed
+            if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'filter')
+                Field=calc_tps(Field,check_proj_tps);
+            end
+
             %field projection on an object
             if Param.CheckObject
@@ -356,5 +311,5 @@
     end
     
-    %writing the result file
+    %writting the result file
     OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);
     if CheckImage{1} %case of images
@@ -381,6 +336,6 @@
 %% open the result file with uvmat (in RUN mode)
 if checkrun
-    hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
-    delete(hget_field)
+%     hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
+%     delete(hget_field)
     uvmat(OutputFile)% open the last result file with uvmat
 end
Index: trunk/src/series/time_series.m
===================================================================
--- trunk/src/series/time_series.m	(revision 524)
+++ trunk/src/series/time_series.m	(revision 526)
@@ -63,5 +63,5 @@
 end
 
-%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
+%%%%%%%%%%%% STANDARD PART  %%%%%%%%%%%%
 %% select different modes,  RUN, parameter input, BATCH
 % BATCH  case: read the xml file for batch case
@@ -87,16 +87,13 @@
 NomType=Param.InputTable(:,4);
 FileExt=Param.InputTable(:,5);
-
-% get the set of input file names (cell array filecell), and the lists of
-% input file or frame indices i1_series,i2_series,j1_series,j2_series
 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
-% filecell{iview,fileindex}: cell array representing the list of file names
+%%%%%%%%%%%%
+% The cell array filecell is the list of input file names, while
+% filecell{iview,fileindex}:
 %        iview: line in the table corresponding to a given file series
 %        fileindex: file index within  the file series, 
 % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j 
 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
-% set of frame indices used for movie or multimage input 
-% numbers of slices and file indices
-
+%%%%%%%%%%%%
 NbSlice=1;%default
 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
@@ -138,5 +135,5 @@
 
 %% coordinate transform or other user defined transform
-transform_fct='';%default
+transform_fct=[];%default
 if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
     addpath(Param.FieldTransform.TransformPath)
@@ -148,5 +145,5 @@
  % EDIT FROM HERE
 
-%% check the validity of  input file types
+%% check the validity of  ctinput file types
 if CheckImage{1}
     FileExtOut='.png'; % write result as .png images for image inputs
@@ -162,10 +159,4 @@
 end
 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
-% if NbSlice~=nbfield_j
-%     answer=_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]);
-%     if ~strcmp(answer,'Yes')
-%         return
-%     end
-% end
 if checkrun==1
     return % stop here for input checks
@@ -189,26 +180,4 @@
     end
 end
-%%% TO UPDATE
-if isequal(InputFields{1},'get_field...')
-    hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
-    if numel(hget_field)>1
-        delete(hget_field(2:end)) % delete multiple occurerence of the GUI get_fioeld
-    elseif isempty(hget_field)
-        filename=filecell{1,1};
-      % filename=name_generator(filebase{1},i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),num_j2{1}(1),SubDir{1}); 
-       idetect(iview)=exist(filename,'file');
-       hget_field=get_field(filename);
-       return
-    end
-    SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
-    if isempty(SubField)
-        delete(hget_field)
-        filename=filecell{1,1};
-       %filename=name_generator(filebase{1},i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),j2_series{1}(1),SubDir{1});
-        hget_field=get_field(filename);
-        SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
-    end
-end
-%%%%%%%
 
 %% Initiate output fields
@@ -255,14 +224,12 @@
             stopstate='queue';
         end
-        
-        %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
         if isequal(stopstate,'queue')% enable STOP command
             Data=cell(1,nbview);%initiate the set Data
             nbtime=0;
             dt=[];
-            % loop on views (in case of multiple input series)
+            %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
             for iview=1:nbview
                 % reading input file(s)
-                [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
+                [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},InputFields{iview},frame_index{iview}(index));
                 if ~isempty(errormsg)
                     errormsg=['time_series/read_field/' errormsg];
@@ -280,24 +247,39 @@
             end
             
+            Field=Data{1}; % default input field structure
             % coordinate transform (or other user defined transform)
             if ~isempty(transform_fct)
-                if nbview==2
-                    [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
-                    if isempty(Data{2})
-                        Data(2)=[];
-                    end
-                else
-                    Data{1}=transform_fct(Data{1},XmlData{1});
-                end
-            end
-            
-            % field substration (for two input file series)
-            if length(Data)==2
-                [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields
-            else
-                Field=Data{1};
-            end
+                switch nargin(transform_fct)
+                    case 4
+                        if length(Data)==2
+                            Field=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
+                        else
+                            Field=transform_fct(Data{1},XmlData{1});
+                        end
+                    case 3
+                        if length(Data)==2
+                            Field=transform_fct(Data{1},XmlData{1},Data{2});
+                        else
+                            Field=transform_fct(Data{1},XmlData{1});
+                        end
+                    case 2
+                        Field=transform_fct(Data{1},XmlData{1});
+                    case 1
+                        Field=transform_fct(Data{1});
+                end
+            end
+            
+            % calculate tps coefficients if needed
+            if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'filter')
+                Field=calc_tps(Field,check_proj_tps);
+            end
+            
+            %field projection on an object
             if Param.CheckObject
                 [Field,errormsg]=proj_field(Field,Param.ProjObject);
+                if ~isempty(errormsg)
+                    msgbox_uvmat('ERROR',['error in aver_stat/proj_field:' errormsg])
+                    return
+                end
             end
             nbfile=nbfile+1;
