Index: /trunk/src/browse_data.m
===================================================================
--- /trunk/src/browse_data.m	(revision 580)
+++ /trunk/src/browse_data.m	(revision 581)
@@ -22,5 +22,5 @@
 function varargout = browse_data(varargin)
 
-% Last Modified by GUIDE v2.5 15-Feb-2013 19:41:48
+% Last Modified by GUIDE v2.5 07-Mar-2013 18:55:00
 
 % Begin initialization code - DO NOT EDIT
@@ -47,11 +47,13 @@
 function browse_data_OpeningFcn(hObject, eventdata, handles, Campaign)
 %------------------------------------------------------------------------
-% Choose default command line output for browse_data
+
+%% Choose default command line output for browse_data
 handles.output = 'Cancel';
 
-% Update handles structure
+%% Update handles structure
 guidata(hObject, handles);
-
-% Determine the position of the dialog - centered on the screen
+set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
+
+%% Determine the position of the dialog - centered on the screen
 FigPos=get(0,'DefaultFigurePosition');
 OldUnits = get(hObject, 'Units');
@@ -95,9 +97,9 @@
    set(handles.OK,'Visible','on')
    set(handles.Cancel,'Visible','on')
-   set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal 
+   set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal 
    set(hObject,'Visible','on')
    drawnow
    % UIWAIT makes GUI wait for user response (see UIRESUME)
-   uiwait(handles.figure);
+   uiwait(handles.browse_data);
 end
 
@@ -108,5 +110,5 @@
 % Get default command line output from handles structure
 varargout{1} = handles.output;
-delete(handles.figure)
+delete(handles.browse_data)
 
 %------------------------------------------------------------------------
@@ -312,5 +314,5 @@
 set(handles.ListExperiments,'Value',1)
 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
-DataviewData=get(handles.figure,'UserData');
+DataviewData=get(handles.browse_data,'UserData');
 List=DataviewData.List;
 Currentpath=get(handles.SourceDir,'String');
@@ -580,5 +582,5 @@
 set(handles.ListExperiments,'Value',1)
 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
-DataviewData=get(handles.figure,'UserData')
+DataviewData=get(handles.browse_data,'UserData')
 List=DataviewData.List;
 Currentpath=get(handles.SourceDir,'String');
@@ -654,5 +656,5 @@
 handles.output.Device=Device;
 guidata(hObject, handles);% Update handles structure
-uiresume(handles.figure);
+uiresume(handles.browse_data);
 drawnow
 return
@@ -676,5 +678,5 @@
 
 %update all the selected xml files
-DataviewData=get(handles.figure,'UserData');
+DataviewData=get(handles.browse_data,'UserData');
 % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ...
 %     DataviewData.GeometryCalib.CalibrationType ' calibration data'])
@@ -771,5 +773,5 @@
 % handles.output ='OK, Calibration replicated';
 % guidata(hObject, handles);% Update handles structure
-% uiresume(handles.figure);
+% uiresume(handles.browse_data);
 
 % --- Executes on button press in Cancel.
@@ -778,18 +780,18 @@
 guidata(hObject, handles); % Update handles structure
 % Use UIRESUME instead of delete because the OutputFcn needs
-uiresume(handles.figure);
-
-% --- Executes when user attempts to close figure.
-function figure_CloseRequestFcn(hObject, eventdata, handles)
-if isequal(get(handles.figure, 'waitstatus'), 'waiting')
+uiresume(handles.browse_data);
+
+% --- Executes when user attempts to close browse_data.
+function browse_data_CloseRequestFcn(hObject, eventdata, handles)
+if isequal(get(handles.browse_data, 'waitstatus'), 'waiting')
     % The GUI is still in UIWAIT, us UIRESUME
-    uiresume(handles.figure);
+    uiresume(handles.browse_data);
 else
     % The GUI is no longer waiting, just close it
-    delete(handles.figure);
+    delete(handles.browse_data);
 end
 
 % --- Executes on key press over figure1 with no controls selected.
-function figure_KeyPressFcn(hObject, eventdata, handles)
+function browse_data_KeyPressFcn(hObject, eventdata, handles)
 % Check for "enter" or "escape"
 if isequal(get(hObject,'CurrentKey'),'escape')
@@ -800,7 +802,7 @@
     guidata(hObject, handles);
     
-    uiresume(handles.figure);
+    uiresume(handles.browse_data);
 end
 if isequal(get(hObject,'CurrentKey'),'return')
-    uiresume(handles.figure);
+    uiresume(handles.browse_data);
 end 
Index: /trunk/src/calc_field_tps.m
===================================================================
--- /trunk/src/calc_field_tps.m	(revision 580)
+++ /trunk/src/calc_field_tps.m	(revision 581)
@@ -2,5 +2,5 @@
 %'calc_field_tps': defines fields (velocity, vort, div...) from civ data and calculate them with tps interpolation
 %---------------------------------------------------------------------
-% [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,Operation,Coord_interp)
+% [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,FieldName,Coord_interp)
 %
 % OUTPUT:
@@ -12,8 +12,8 @@
 % SubRange
 % FieldVar
-% Operation: cell array representing the list of operations (eg div, rot..)
+% FieldName: cell array representing the list of operations (eg div, rot..)
 % Coord_interp: coordiantes of sites on which the fields need to be calculated
 
-function [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,Operation,Coord_interp)
+function [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,FieldName,Coord_interp)
 
 %list of defined scalars to display in menus (in addition to 'ima_cor').
@@ -44,7 +44,7 @@
 check_grid=0;
 check_der=0;
-for ilist=1:length(Operation)
-    OperationType=regexprep(Operation{ilist},'(.+','');
-    switch OperationType
+for ilist=1:length(FieldName)
+    FieldNameType=regexprep(FieldName{ilist},'(.+','');
+    switch FieldNameType
         case 'vec'
             check_grid=1;
@@ -55,9 +55,9 @@
         case {'U','V','norm'}
             check_grid=1;
-            DataOut.(OperationType)=zeros(nb_sites,1);
+            DataOut.(FieldNameType)=zeros(nb_sites,1);
             VarAttribute{1}.Role='scalar';
         case {'curl','div','strain'}
             check_der=1;
-            DataOut.(OperationType)=zeros(nb_sites,1);
+            DataOut.(FieldNameType)=zeros(nb_sites,1);
             VarAttribute{1}.Role='scalar';
     end
@@ -79,7 +79,7 @@
     end
     ListVar={};
-    for ilist=1:length(Operation)
+    for ilist=1:length(FieldName)
         var_count=numel(ListVar);
-        switch Operation{ilist}
+        switch FieldName{ilist}
             case 'vec(U,V)'
                 ListVar=[ListVar {'U', 'V'}];
Index: /trunk/src/check_files.m
===================================================================
--- /trunk/src/check_files.m	(revision 580)
+++ /trunk/src/check_files.m	(revision 581)
@@ -32,4 +32,5 @@
 svn_info.status=[];
 list_fct={...
+    'xmltree';...%function for editing xml files (toolbox outside uvmat)
     'browse_data';...% function for scanning directories in a project/campaign
     'browse_data.fig';...% GUI corresponding to dataview
@@ -101,4 +102,5 @@
     'set_object.m';...%  edit a projection object
     'set_object.fig';...% interface for set_object
+    'set_subdomains';...% sort a set of points defined by scattered coordinates in subdomains, as needed for tps interpolation
     'stra2num';...% transform letters (a, b, A, B,) or numerical strings ('1','2'..) to the corresponding numbers
     'sub_field';...% combine the two input fields,
@@ -106,4 +108,5 @@
     'struct2xml';... transform a matlab structure to a xml tree.
     'tps_coeff';...% calculate the thin plate spline (tps) coefficients
+    'tps_coeff_field';...% calculate the thin plate spline (tps) coefficients with subdomains for a field structure
     'tps_eval';... %calculate the thin plate spline (tps) interpolation at a set of points
     'tps_eval_dxy';...% calculate the derivatives of thin plate spline (tps) interpolation at a set of points (limited to the 2D case)
Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 580)
+++ /trunk/src/civ.m	(revision 581)
@@ -24,5 +24,5 @@
 %TODO: search range
 
-% Last Modified by GUIDE v2.5 24-Jul-2012 13:14:00
+% Last Modified by GUIDE v2.5 09-Mar-2013 22:50:23
 % Begin initialization code - DO NOT EDIT
 gui_Singleton = 1;
@@ -3705,8 +3705,8 @@
 handle_txtbox=findobj(hchildren,'tag','txt_Mask');
 if isequal(get(hObject,'Value'),0)
-    set(handles.num_SubdomainSize,'Visible','on')
+    set(handles.num_SubDomainSize,'Visible','on')
     set(handles.num_FieldSmooth,'Visible','on')
 else
-    set(handles.num_SubdomainSize,'Visible','off')
+    set(handles.num_SubDomainSize,'Visible','off')
     set(handles.num_FieldSmooth,'Visible','off')
 end
@@ -3717,8 +3717,8 @@
 % %------------------------------------------------------------------------
 % if isequal(get(handles.CheckStereo,'Value'),0)
-%     set(handles.num_SubdomainSize,'Visible','on')
+%     set(handles.num_subdomainsize,'Visible','on')
 %     set(handles.num_FieldSmooth,'Visible','on')
 % else
-%     set(handles.num_SubdomainSize,'Visible','off')
+%     set(handles.num_subdomainsize,'Visible','off')
 %     set(handles.num_FieldSmooth,'Visible','off')
 % end
Index: /trunk/src/civ_matlab.m
===================================================================
--- /trunk/src/civ_matlab.m	(revision 580)
+++ /trunk/src/civ_matlab.m	(revision 581)
@@ -165,7 +165,7 @@
     
     Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}];
-    Data.Patch1_Rho=Param.Patch1.FieldSmooth;
-    Data.Patch1_Threshold=Param.Patch1.MaxDiff;
-    Data.Patch1_SubDomain=Param.Patch1.SubdomainSize;
+    Data.Patch1_FieldSmooth=Param.Patch1.FieldSmooth;
+    Data.Patch1_MaxDiff=Param.Patch1.MaxDiff;
+    Data.Patch1_SubDomainSize=Param.Patch1.SubDomainSize;
     nbvar=length(Data.ListVarName);
     Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
@@ -185,5 +185,5 @@
     end
     [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
-        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);
+        filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff);
     Data.Civ1_U_smooth(ind_good)=Ures;
     Data.Civ1_V_smooth(ind_good)=Vres;
@@ -373,7 +373,7 @@
 if isfield (Param,'Patch2')
     Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch2_Rho','Patch2_Threshold','Patch2_SubDomain'}];
-    Data.Patch2_Rho=Param.Patch2.FieldSmooth;
-    Data.Patch2_Threshold=Param.Patch2.MaxDiff;
-    Data.Patch2_SubDomain=Param.Patch2.SubdomainSize;
+    Data.Patch2_FieldSmooth=Param.Patch2.FieldSmooth;
+    Data.Patch2_MaxDiff=Param.Patch2.MaxDiff;
+    Data.Patch2_SubDomainSize=Param.Patch2.SubdomainSize;
     nbvar=length(Data.ListVarName);
     Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbSites','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
@@ -394,5 +394,5 @@
     end
     [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
-        filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold);
+        filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomainSize,Data.Patch2_FieldSmooth,Data.Patch2_MaxDiff);
     Data.Civ2_U_smooth(ind_good)=Ures;
     Data.Civ2_V_smooth(ind_good)=Vres;
Index: /trunk/src/filter_tps.m
===================================================================
--- /trunk/src/filter_tps.m	(revision 580)
+++ /trunk/src/filter_tps.m	(revision 581)
@@ -1,12 +1,12 @@
 %'filter_tps': find the thin plate spline coefficients for interpolation-smoothing
 %------------------------------------------------------------------------
-% [SubRange,NbSites,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
+% [SubRange,NbCentres,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
 %
 % OUTPUT:
 % SubRange(NbCoord,NbSubdomain,2): range (min, max) of the coordiantes x and y respectively, for each subdomain
-% NbSites(NbSubdomain): number of source points for each subdomain
+% NbCentres(NbSubdomain): number of source points for each subdomain
 % FF: false flags
 % U_smooth, V_smooth: filtered velocity components at the positions of the initial data
-% Coord_tps(NbSites,NbCoord,NbSubdomain): positions of the tps centres
+% Coord_tps(NbCentres,NbCoord,NbSubdomain): positions of the tps centres
 % U_tps,V_tps: weight of the tps for each subdomain
 % to get the interpolated field values, use the function calc_field.m
@@ -19,16 +19,15 @@
 % Subdomain: estimated number of data points in each subdomain
 
-function [SubRange,NbSites,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
-%subdomain decomposition
+function [SubRange,NbCentres,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
+
+%% adjust subdomain decomposition
 warning off
-nbvec=size(Coord,1);
-W_tps=[];%default
-W_smooth=[];
+NbVec=size(Coord,1);
 NbCoord=size(Coord,2);
-NbSubDomain=nbvec/SubDomain;
-MinCoord=min(Coord,[],1);
-MaxCoord=max(Coord,[],1);
+MinCoord=min(Coord,[],1);%lower coordinate bounds
+MaxCoord=max(Coord,[],1);%upper coordinate bounds
 Range=MaxCoord-MinCoord;
 AspectRatio=Range(2)/Range(1);
+NbSubDomain=NbVec/SubDomain;
 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);
 NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);
@@ -41,15 +40,23 @@
 CentreY=reshape(CentreY,1,[]);% Y positions of subdomain centres
 CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres
-rho=Siz(1)*Siz(2)*Rho/1000;%optimum rho increase as the area of the subdomain (division by 10^6 to reach good values with the default GUI input)
-U_tps_sub=zeros(nbvec,NbSubDomain);%default spline
-V_tps_sub=zeros(nbvec,NbSubDomain);%default spline
-Indices_tps=zeros(nbvec,NbSubDomain);%default indices
-U_smooth=zeros(nbvec,1);
-V_smooth=zeros(nbvec,1);
-nb_select=zeros(nbvec,1);
-FF=zeros(nbvec,1);
+
+%% smoothing parameter
+rho=Siz(1)*Siz(2)*Rho/1000;%optimum rho increase as the area of the subdomain (division by 1000 to reach good values with the default GUI input)
+
+%% default output
+SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains
+NbCentres=zeros(NbSubDomain);%number of interpolated values per subdomain, =0 by default
+Coord_tps=zeros(NbVec,NbCoord,NbSubDomain);% default positions of the tps source= initial positions of the good vectors sorted by subdomain
+U_tps=zeros(NbVec,NbSubDomain);%default spline
+V_tps=zeros(NbVec,NbSubDomain);%default spline
+W_tps=[];%default (2 component case)
+U_smooth=zeros(NbVec,1); % smoothed velocity U at the initial positions
+V_smooth=zeros(NbVec,1);% smoothed velocity V at the initial positions
+W_smooth=[];%default (2 component case)
+FF=zeros(NbVec,1);
+nb_select=zeros(NbVec,1);
 check_empty=zeros(1,NbSubDomain);
-SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains
-% SubRangy=zeros(NbSubDomain,2);
+
+%% calculate tps coeff in each subdomain
 for isub=1:NbSubDomain
     SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)];
@@ -57,10 +64,11 @@
     ind_sel_previous=[];
     ind_sel=0;
-    while numel(ind_sel)>numel(ind_sel_previous) %increase the subdomain during four iterations at most
+    %increase iteratively the subdomain if it contains less than SubDomainNbVec/4 source vectors
+    while numel(ind_sel)>numel(ind_sel_previous)
         ind_sel_previous=ind_sel;
         ind_sel=find(Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub));
         % if no vector in the subdomain, skip the subdomain
         if isempty(ind_sel)
-            check_empty(isub)=1;    
+            check_empty(isub)=1;
             U_tps(1,isub)=0;%define U_tps and V_tps by default
             V_tps(1,isub)=0;
@@ -70,5 +78,5 @@
             SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4;
             SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4;
-        else          
+        else
             [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),rho);
             [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel,:),V(ind_sel),rho);
@@ -78,6 +86,6 @@
             ind_ind_sel=1:numel(ind_sel);%default
             if exist('Threshold','var')
-            FF(ind_sel)=20*(NormDiff>Threshold);%put FF value to 20 to identify the criterium of elimmination
-            ind_ind_sel=find(FF(ind_sel)==0); % select the indices of ind_sel corresponding to the remaining vectors
+                FF(ind_sel)=20*(NormDiff>Threshold);%put FF value to 20 to identify the criterium of elimmination
+                ind_ind_sel=find(FF(ind_sel)==0); % select the indices of ind_sel corresponding to the remaining vectors
             end
             % if no value exceeds threshold, the result is recorded
@@ -85,25 +93,25 @@
                 U_smooth(ind_sel)=U_smooth(ind_sel)+U_smooth_sub;
                 V_smooth(ind_sel)=V_smooth(ind_sel)+V_smooth_sub;
-                NbSites(isub)=numel(ind_sel);
-                Coord_tps(1:NbSites(isub),:,isub)=Coord(ind_sel,:);
-                U_tps(1:NbSites(isub)+3,isub)=U_tps_sub;
-                V_tps(1:NbSites(isub)+3,isub)=V_tps_sub;         
+                NbCentres(isub)=numel(ind_sel);
+                Coord_tps(1:NbCentres(isub),:,isub)=Coord(ind_sel,:);
+                U_tps(1:NbCentres(isub)+3,isub)=U_tps_sub;
+                V_tps(1:NbCentres(isub)+3,isub)=V_tps_sub;
                 nb_select(ind_sel)=nb_select(ind_sel)+1;
                 display('good')
                 break
-            % if too few selected vectors, increase the subrange for next iteration
+                % if too few selected vectors, increase the subrange for next iteration
             elseif numel(ind_ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous);
                 SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4;
                 SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4;
-            % else interpolation-smoothing is done again with the selected vectors
+                % else interpolation-smoothing is done again with the selected vectors
             else
                 [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),U(ind_sel(ind_ind_sel)),rho);
                 [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),V(ind_sel(ind_ind_sel)),rho);
                 U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+U_smooth_sub;
-                V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;   
-                NbSites(isub)=numel(ind_ind_sel);
-                Coord_tps(1:NbSites(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:);
-                U_tps(1:NbSites(isub)+3,isub)=U_tps_sub;
-                V_tps(1:NbSites(isub)+3,isub)=V_tps_sub;
+                V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;
+                NbCentres(isub)=numel(ind_ind_sel);
+                Coord_tps(1:NbCentres(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:);
+                U_tps(1:NbCentres(isub)+3,isub)=U_tps_sub;
+                V_tps(1:NbCentres(isub)+3,isub)=V_tps_sub;
                 nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+1;
                 display('good2')
@@ -113,6 +121,7 @@
     end
 end
+
+%% remove empty subdomains
 ind_empty=find(check_empty);
-%remove empty subdomains
 if ~isempty(ind_empty)
     SubRange(:,:,ind_empty)=[];
@@ -121,6 +130,8 @@
     V_tps(:,ind_empty)=[];
 end
-nb_select(nb_select==0)=1;%ones(size(find(nb_select==0)));
-U_smooth=U_smooth./nb_select;
+
+%% final adjustments
+nb_select(nb_select==0)=1;
+U_smooth=U_smooth./nb_select;% take the average at the intersection of several subdomains
 V_smooth=V_smooth./nb_select;
 fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
Index: /trunk/src/find_field_cells.m
===================================================================
--- /trunk/src/find_field_cells.m	(revision 580)
+++ /trunk/src/find_field_cells.m	(revision 581)
@@ -1,4 +1,3 @@
-%'find_field_cells': test field structure for input in proj_field and plot_field
-%    group the variables  into 'fields' with common dimensions
+%'find_field_cells': analyse the field structure for input in uvmat functions, grouping the variables  into 'fields' with common coordinates
 %------------------------------------------------------------------------
 % function  [CellInfo,NbDim,errormsg]=find_field_cells(Data)
@@ -9,5 +8,5 @@
 %     .CoordIndex: array of the indices of the variables representing the coordinates (in the order z,y,x)
 %     .CoordSize: array of the nbre of values for each  coordinate in a grid, nbre of points in the unstructured case
-%     .NbSite_tps:
+%     .NbCentres_tps:
 %     .SubRange_tps
 %     .VarIndex: arrays of the variable indices in the field cell
@@ -19,5 +18,5 @@
 %              _vector_x,_y,_z: indices of variables giving the vector components x, y, z
 %              _warnflag: index of warnflag    
-%      .FieldRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation  or derivatives (tps) is needed to calculate the requested field
+%      .ProjModeRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation  or derivatives (tps) is needed to calculate the requested field
 %      .FieldName = operation to be performed to finalise the field cell after projection
 %      .SubCheck=0 /1 indicate that the field must be substracted (second  entry in uvmat)
@@ -61,10 +60,10 @@
 
 function [CellInfo,NbDim,errormsg]=find_field_cells(Data)
-
+CellInfo={};
 NbDim=0;
 errormsg='';
 if ~isfield(Data,'ListVarName'), errormsg='the list of variables .ListVarName is missing';return;end
 if ~isfield(Data,'VarDimName'), errormsg='the list of dimensions .VarDimName is missing';return;end
-nbvar=numel(Data.ListVarName);%number of field variables
+nbvar=numel(Data.ListVarName);%number of variables in the field structure
 if ~isequal(numel(Data.VarDimName),nbvar), errormsg='.ListVarName and .VarDimName have unequal length';return;end
 % check the existence of variable data
@@ -86,5 +85,5 @@
 %   'ancillary','image','color','discrete','scalar','coord_tps'};% rmq vector_x_tps and vector_y_tps to be replaced by vector_x and vector_y
 Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks
-FieldRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default
+ProjModeRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default
 FieldName=cell(size(Role)); % fieldRequest set to {} by default
 CheckSub=zeros(size(Role));% =1 for fields to substract
@@ -95,6 +94,6 @@
             Role{ivar}=Data.VarAttribute{ivar}.Role;
         end
-        if isfield(Data.VarAttribute{ivar},'FieldRequest')
-            FieldRequest{ivar}=Data.VarAttribute{ivar}.FieldRequest;
+        if isfield(Data.VarAttribute{ivar},'ProjModeRequest')
+            ProjModeRequest{ivar}=Data.VarAttribute{ivar}.ProjModeRequest;
         end
         if isfield(Data.VarAttribute{ivar},'FieldName')
@@ -162,21 +161,23 @@
 check_coord_tps= strcmp('coord_tps',Role(~check_select));
 ivar_tps=ivar_remain(check_coord_tps);% variable indices corresponding to tps coordinates
+
+% loop on the tps coordinate sets
 for icell_tps=1:numel(ivar_tps)
+    check_cell=zeros(1,nbvar);% =1 for the variables selected in the current cell
+    check_cell(ivar_tps(icell_tps))=1;% mark the coordiante variable as selected
     DimCell=Data.VarDimName{ivar_tps(icell_tps)};% dimension names for the current tps coordinate variable
     icell=numel(CellInfo)+icell_tps; % new field cell index
     CellInfo{icell}.CoordIndex=ivar_tps(icell_tps);% index of the  tps coordinate variable
-    %CellInfo{icell}.VarIndex_subrange_tps=[];
-    %CellInfo{icell}.VarIndex_nbsites_tps=[];
     if numel(DimCell)==3
         VarDimName=Data.VarDimName(~check_select);
         for ivardim=1:numel(VarDimName)
             if strcmp(VarDimName{ivardim},DimCell{3})
-                CellInfo{icell}.NbSite_tps= ivar_remain(ivardim);
-                check_cell(ivar_remain(ivardim))=1;% nbre of sites for each tps subdomain
+                CellInfo{icell}.NbCentres_tps= ivar_remain(ivardim);% nbre of sites for each tps subdomain
+                check_cell(ivar_remain(ivardim))=1;% mark the variable as selected
             elseif strcmp(VarDimName{ivardim}{1},DimCell{2}) && strcmp(VarDimName{ivardim}{3},DimCell{3})
-                CellInfo{icell}.SubRange_tps=ivar_remain(ivardim);
-                check_cell(ivar_remain(ivardim))=1;% subrange definiton for tps
-            elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3})
-                check_cell(ivar_remain(ivardim))=1;% variable
+                CellInfo{icell}.SubRange_tps=ivar_remain(ivardim);% subrange definiton for tps
+                check_cell(ivar_remain(ivardim))=1;% mark the variable as selected
+            elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3})% variable
+                check_cell(ivar_remain(ivardim))=1;% mark the variable as selected
             end
         end
@@ -222,5 +223,5 @@
     end
 end
-ListCoordIndex=ListCoordIndex(check_coord_select);% list of coordinate variable indices
+ListCoordIndex=ListCoordIndex(check_keep);% list of coordinate variable indices
 ListCoordName=ListCoordName(check_keep);% list of coordinate variable names
 ListDimName=ListDimName(check_keep);% list of coordinate dimension names
@@ -315,6 +316,6 @@
             CellInfo{icell}.(['VarIndex_' Role{ivar}])= ivar;
         end
-        if ~isempty(FieldRequest{ivar})
-            CellInfo{icell}.FieldRequest=FieldRequest{ivar};
+        if ~isempty(ProjModeRequest{ivar})
+            CellInfo{icell}.ProjModeRequest=ProjModeRequest{ivar};
         end
         if ~isempty(FieldName{ivar})
Index: /trunk/src/get_field.m
===================================================================
--- /trunk/src/get_field.m	(revision 580)
+++ /trunk/src/get_field.m	(revision 581)
@@ -1,3 +1,3 @@
-%'get_field': display variables and attributes from a Netcdf file, and RUN selected fields
+%'get_field': display variables and attributes from a Netcdf file, and OK selected fields
 %------------------------------------------------------------------------
 %function varargout = get_field(varargin)
@@ -22,8 +22,8 @@
 function varargout = get_field(varargin)
 
-% Last Modified by GUIDE v2.5 26-Jul-2012 09:11:23
+% Last Modified by GUIDE v2.5 10-Mar-2013 21:19:52
 
 % Begin initialization code - DO NOT EDIT
-gui_Singleton = 0;
+gui_Singleton = 1;
 gui_State = struct('gui_Name',       mfilename, ...
                    'gui_Singleton',  gui_Singleton, ...
@@ -45,12 +45,10 @@
 %------------------------------------------------------------------------
 % --- Executes just before get_field is made visible.
-function get_field_OpeningFcn(hObject, eventdata, handles,filename,multiple)
+function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn)
 %------------------------------------------------------------------------
 global nb_builtin % nbre of functions to include by default in the menu of  functions called by RUN
 
-
-
 %% Choose default command line output for get_field
-handles.output = hObject;
+handles.output = 'Cancel';
 
 %% Update handles structure
@@ -58,62 +56,16 @@
 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
 
-%% prepare the list of RUN fcts and set their paths
-% functions included by default in 'get_field.m
-% menu_str={'PLOT';'FFT';'filter_band'}; 
-% nb_builtin=numel(menu_str);
-% path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat'
-% addpath(fullfile(path_uvmat,'get_field'))
-% testexist=zeros(size(menu_str'));%default
-% for ilist=1:length(menu_str)
-%     if exist(menu_str{ilist},'file')
-%         fct_handle{ilist,1}=str2func(menu_str{ilist});
-%         testexist(ilist)=1;
-%     else
-%         fct_handle{ilist,1}=[];
-%         testexist(ilist)=0;
-%     end
-% end
-% rmpath(fullfile(path_uvmat,'get_field'))
-% dir_perso=prefdir;
-
-% look for functions previously used (names and paths saved in the personal file uvmat_perso.mat):
-% profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
-% if exist(profil_perso,'file')
-%       h=load (profil_perso);
-%      if isfield(h,'get_field_fct') && iscell(h.get_field_fct)
-%          for ilist=1:length(h.get_field_fct)
-%             [path,file]=fileparts(h.get_field_fct{ilist});
-%             addpath(path)        
-%             if exist(file,'file')
-%                 h_func=str2func(file);
-%                 testexist=[testexist 1]; 
-%              else
-%                 h_func=[];
-%                 testexist=[testexist 0]; 
-%              end
-%              fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
-%              rmpath(path)
-%              menu_str=[menu_str; {file}]; 
-%          end
-%      end
-% end
-
-% menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
-% fct_handle=fct_handle(testexist==1);
-% menu_str=[menu_str;{'more...'}];
-% set(handles.ACTION,'String',menu_str)
-% set(handles.ACTION,'UserData',fct_handle)% store the list of path in UserData of ACTION
-% set(handles.path_action,'String',fullfile(path_uvmat,'get_field'))
-% set(handles.ACTION,'Value',1)% PLOT option selected
-
-%% settings for 'slave' mode, called by uvamt, or 'master' mode
+%% settings for 'slave' mode, called by uvmat, or 'master' mode
 if exist('filename','var') && ischar(filename) %transfer input file name in slave mode
     set(handles.inputfile,'String',filename)% prefill the input file name
-    Field=nc2struct(filename,[]);% reads the  field structure, without variables
+    Field=nc2struct(filename,[]);% reads the  field structure, without the variables
     if isfield(Field,'Txt')
-        msgbox_uvmat('ERROR',Field.Txt)
+        msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])
     else
         set(handles.get_field,'UserData',Field);
-        Field_input(handles,Field);
+        if ~exist('ParamIn','var')
+            ParamIn=[];
+        end
+        Field_input(handles,Field,ParamIn);
     end
 else  %master mode
@@ -121,27 +73,6 @@
 end
 
-%% load the list of previously browsed files for the upper bar menu Open
-% dir_perso=prefdir;
-% profil_perso=fullfile(dir_perso,'uvmat_perso.mat');%
-% if exist(profil_perso,'file')
-%     h=load (profil_perso);
-%     if isfield(h,'MenuFile_1')
-%         set(handles.MenuFile_1,'Label',h.MenuFile_1);
-%     end
-%     if isfield(h,'MenuFile_1')
-%         set(handles.MenuFile_2,'Label',h.MenuFile_2);
-%     end
-%     if isfield(h,'MenuFile_1')
-%         set(handles.MenuFile_3,'Label',h.MenuFile_3);
-%     end
-%     if isfield(h,'MenuFile_1')
-%         set(handles.MenuFile_4,'Label',h.MenuFile_4);
-%     end
-%     if isfield(h,'MenuFile_1')
-%         set(handles.MenuFile_5,'Label',h.MenuFile_5);
-%     end
-% end
-
 %% put the GUI on the lower right of the sceen
+set(hObject,'Unit','pixel')
 pos_view_field=get(hObject,'Position');
 ScreenSize=get(0,'ScreenSize');
@@ -150,14 +81,15 @@
 set(hObject,'Position',pos_view_field)
 
-%% remove already opened get_field GUI with name get_field
-if ~(exist('multiple','var') && isequal(multiple,1)) %set single occurrence
-    hget_field=findobj(allchild(0),'Name','get_field'); %hget_field(1)= new GUI
-    if length(hget_field)>1
-        delete(hget_field(2))
-    end
-else
-    set(hObject,'name','get_field_1')
-end
-
+% if ~(exist('multiple','var') && isequal(multiple,1)) %set single occurrence
+%     hget_field=findobj(allchild(0),'Name','get_field'); %hget_field(1)= new GUI
+%     if length(hget_field)>1
+%         delete(hget_field(2))
+%     end
+% else
+%     set(hObject,'name','get_field_1')
+% end
+set(handles.get_field,'WindowStyle','modal')% Make the GUI modal 
+drawnow
+ uiwait(handles.get_field);
 
 %------------------------------------------------------------------------
@@ -166,4 +98,5 @@
 %------------------------------------------------------------------------
 varargout{1} = handles.output;
+delete(handles.get_field)
 
 %------------------------------------------------------------------------
@@ -186,5 +119,5 @@
 %------------------------------------------------------------------------
 % --- update the display when a new field is introduced.
-function Field_input(handles,Field)
+function Field_input(handles,Field,ParamInput)
 %------------------------------------------------------------------------
 if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName)
@@ -203,4 +136,9 @@
 set(handles.variables,'String',[{'*'} Txt])
 variables_Callback(handles.variables,[], handles)
+
+if exist('ParamInput','var')
+    fill_GUI(ParamInput,handles);
+    return
+else
 set(handles.abscissa,'String',[{''} Txt ])
 set(handles.ordinate,'String',Txt)
@@ -209,35 +147,51 @@
 set(handles.vector_z,'String',[{''} Txt ])
 set(handles.vec_color,'String',[{''} Txt ])
-set(handles.coord_x_scalar,'String',[{''} Txt ])
-set(handles.coord_y_scalar,'String',[{''} Txt ])
-set(handles.coord_x_vectors,'String',[{''} Txt ])
-set(handles.coord_y_vectors,'String',[{''} Txt ])
-set(handles.coord_z_scalar,'String',[{''} Txt ])
-set(handles.coord_z_vectors,'String',[{''} Txt ])
+% set(handles.XVarName,'String',[{''} Txt ])
+% set(handles.ZVarName,'String',[{''} Txt ])
+% set(handles.coord_x_vectors,'String',[{''} Txt ])
+% set(handles.coord_y_vectors,'String',[{''} Txt ])
+% set(handles.YVarName,'String',[{''} Txt ])
+% set(handles.TimeVarName,'String',[{''} Txt ])
 set(handles.scalar,'Value',1)
 
 set(handles.scalar,'String', Txt )
 [CellInfo,NbDim,errormsg]=find_field_cells(Field);
-% [CellVarIndex,NbDim,CoordType,VarRole,errormsg]=find_field_cells(Field);
 if ~isempty(errormsg)  
     msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg])
     return
 end  
-% for icell=1:numel(CellInfo)
-%     NbDim(icell)=max(NbDim(icell),numel(CellInfo{icell}.VarIndex));
-% end
 [maxdim,imax]=max(NbDim);
-   
+
+%% set time mode
+if maxdim>=4
+    set(handles.SwitchVarIndexTime,'Value',4)
+else
+    time_index=[];
+    if isfield(Field,'ListGlobalAttribute')
+    time_index=find(~cellfun('isempty',regexp(Field.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time'
+    end
+    if isempty(time_index)
+        set(handles.SwitchVarIndexTime,'Value',1)
+    else
+        set(handles.SwitchVarIndexTime,'Value',2)
+    end
+end
+SwitchVarIndexTime_Callback([],[], handles)
+
 if maxdim>=3
     set(handles.vector_z,'Visible','on')
     set(handles.vector_z,'String',[{''} Txt ])
-    set(handles.coord_z_vectors,'Visible','on')
-    set(handles.coord_z_vectors,'String',[{''} Txt ])
-    set(handles.coord_z_scalar,'Visible','on')
-    set(handles.coord_z_scalar,'String',[{''} Txt ])
+        set(handles.ZVarName,'Visible','on')
+    set(handles.SwitchVarIndexZ,'Visible','on')
+    set(handles.Z_title,'Visible','on')
+%     set(handles.TimeVarName,'Visible','on')
+%     set(handles.TimeVarName,'String',[{''} Txt ])
+%     set(handles.YVarName,'Visible','on')
+%     set(handles.YVarName,'String',[{''} Txt ])
 else
     set(handles.vector_z,'Visible','off')
-    set(handles.coord_z_vectors,'Visible','off')
-    set(handles.coord_z_scalar,'Visible','off')
+    set(handles.ZVarName,'Visible','off')
+    set(handles.SwitchVarIndexZ,'Visible','off')
+    set(handles.Z_title,'Visible','off')
 end
 if maxdim>=2 
@@ -248,27 +202,32 @@
         set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1))
         set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1))
-        if strcmp(CellInfo{imax}.CoordType,'scattered')
-            set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end))
-            set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1))
-        elseif strcmp(CellInfo{imax}.CoordType,'grid')
-            set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)+1)
-            set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
-        end
+%         if strcmp(CellInfo{imax}.CoordType,'scattered')
+%             set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end))
+%             set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1))
+%         elseif strcmp(CellInfo{imax}.CoordType,'grid')
+%             set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)+1)
+%             set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
+%         end
     else
         set(handles.CheckScalar,'Value',1)
         set(handles.CheckVector,'Value',0)
-        if isfield(CellInfo{imax},'VarIndex_scalar') 
-            set(handles.scalar,'Value',CellInfo{imax}.VarIndex_scalar(1))
-                set(handles.coord_x_scalar,'Value',CellInfo{imax}.CoordIndex(end)+1)
-                set(handles.coord_y_scalar,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
-            if numel(CellInfo{imax}.CoordIndex)==3
-                set(handles.coord_z_scalar,'Value',CellInfo{imax}.CoordIndex(1)+1)
-            end
-        end
-    end
-    CheckPlot1D_Callback(handles.CheckPlot1D, [], handles)
-    CheckScalar_Callback(handles.CheckScalar, [], handles)
-    CheckVector_Callback(handles.CheckVector, [], handles)
-end
+%         if isfield(CellInfo{imax},'VarIndex_scalar') 
+%             set(handles.scalar,'Value',CellInfo{imax}.VarIndex_scalar(1))
+%                 set(handles.XVarName,'Value',CellInfo{imax}.CoordIndex(end)+1)
+%                 set(handles.ZVarName,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
+%             if numel(CellInfo{imax}.CoordIndex)==3
+%                 set(handles.YVarName,'Value',CellInfo{imax}.CoordIndex(1)+1)
+%             end
+%         end
+    end
+else
+    set(handles.CheckPlot1D,'Value',1)
+    set(handles.CheckScalar,'Value',0)
+    set(handles.CheckVector,'Value',0)
+end
+end
+CheckPlot1D_Callback(handles.CheckPlot1D, [], handles)
+CheckScalar_Callback(handles.CheckScalar, [], handles)
+CheckVector_Callback(handles.CheckVector, [], handles)
 
 %------------------------------------------------------------------------
@@ -324,5 +283,5 @@
 %     set(handles.variables,'Value',xindex+1)%outline  in the list of variables 
 %     variables_Callback(hObject, eventdata, handles)  %display properties of the TimeVariable (dim, attributes)
-%     if  ~test_2D &  ~test_scalar% look for possible varaibles to RUN in ordinate    
+%     if  ~test_2D &  ~test_scalar% look for possible varaibles to OK in ordinate    
 %         index=Field.VarDimIndex{xindex};%dimension indices of the TimeVariable selected for abscissa
 %         VarIndex=[];
@@ -330,5 +289,5 @@
 %             index_i=Field.VarDimIndex{ilist};
 %             if ~isempty(index_i)
-%                 if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, RUN is possible
+%                 if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, OK is possible
 %                     VarIndex=[VarIndex ilist];
 %                 end
@@ -378,45 +337,45 @@
 
 string_coord=[{''};string(test_coord==1)];
-val=get(handles.coord_x_scalar,'Value');
+val=get(handles.XVarName,'Value');
 if val>numel(string_coord)
-    set(handles.coord_x_scalar,'Value',1)
-end
-set(handles.coord_x_scalar,'String',string_coord);
-val=get(handles.coord_y_scalar,'Value');
+    set(handles.XVarName,'Value',1)
+end
+set(handles.XVarName,'String',string_coord);
+val=get(handles.ZVarName,'Value');
 if val>numel(string_coord)
-    set(handles.coord_y_scalar,'Value',1)
-end
-set(handles.coord_y_scalar,'String',string_coord);
-val=get(handles.coord_y_scalar,'Value');
+    set(handles.ZVarName,'Value',1)
+end
+set(handles.ZVarName,'String',string_coord);
+val=get(handles.ZVarName,'Value');
 if val>numel(string_coord)
-    set(handles.coord_y_scalar,'Value',1)
-end
-set(handles.coord_z_scalar,'String',string_coord);
-
-
-%------------------------------------------------------------------------
-% --- Executes on selection change in coord_x_scalar.
-function coord_x_scalar_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-index=get(handles.coord_x_scalar,'Value');
-string=get(handles.coord_x_scalar,'String');
+    set(handles.ZVarName,'Value',1)
+end
+set(handles.YVarName,'String',string_coord);
+
+
+%------------------------------------------------------------------------
+% --- Executes on selection change in XVarName.
+function XVarName_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+index=get(handles.XVarName,'Value');
+string=get(handles.XVarName,'String');
 VarName=string{index};
 update_field(hObject, eventdata, handles,VarName)
 
 %------------------------------------------------------------------------
-% --- Executes on selection change in coord_y_scalar.
-function coord_y_scalar_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-index=get(handles.coord_y_scalar,'Value');
-string=get(handles.coord_y_scalar,'String');
+% --- Executes on selection change in ZVarName.
+function ZVarName_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+index=get(handles.ZVarName,'Value');
+string=get(handles.ZVarName,'String');
 VarName=string{index};
 update_field(hObject, eventdata, handles,VarName)
 
 %------------------------------------------------------------------------
-% --- Executes on selection change in coord_z_scalar.
-function coord_z_scalar_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-index=get(handles.coord_z_scalar,'Value');
-string=get(handles.coord_z_scalar,'String');
+% --- Executes on selection change in YVarName.
+function YVarName_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+index=get(handles.YVarName,'Value');
+string=get(handles.YVarName,'String');
 VarName=string{index};
 update_field(hObject, eventdata, handles,VarName)
@@ -480,9 +439,9 @@
 end
 set(handles.coord_y_vectors,'String',string_coord);
-val=get(handles.coord_z_vectors,'Value');
+val=get(handles.TimeVarName,'Value');
 if val>numel(string_coord)
-    set(handles.coord_z_vectors,'Value',1)
-end
-set(handles.coord_z_vectors,'String',string_coord);
+    set(handles.TimeVarName,'Value',1)
+end
+set(handles.TimeVarName,'String',string_coord);
 
 update_field(hObject, eventdata, handles,VarName)
@@ -525,9 +484,9 @@
 
 %------------------------------------------------------------------------
-% --- Executes on selection change in coord_z_scalar.
-function coord_z_vectors_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-index=get(handles.coord_z_vectors,'Value');
-string=get(handles.coord_z_vectors,'String');
+% --- Executes on selection change in YVarName.
+function TimeVarName_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+index=get(handles.TimeVarName,'Value');
+string=get(handles.TimeVarName,'String');
 VarName=string{index};
 update_field(hObject, eventdata, handles,VarName)
@@ -689,5 +648,5 @@
 VarIndex.y=name2index(list_var,Field.ListVarName);
 if isequal(VarIndex.A,VarIndex.y)
-    set(handles.coord_y_scalar,'Value',1)
+    set(handles.ZVarName,'Value',1)
 elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y)
    set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components
@@ -811,8 +770,16 @@
 
 %---------------------------------------------------------
-% --- Executes on button press in RUN.
-
-function RUN_Callback(hObject, eventdata, handles)
+% --- Executes on button press in OK.
+
+function OK_Callback(hObject, eventdata, handles)
 %---------------------------------------------------------
+
+handles.output=read_GUI(handles.get_field);
+guidata(hObject, handles);% Update handles structure
+uiresume(handles.get_field);
+drawnow
+return
+
+%%%% SKIPPED %%%%
 hfield=[];
 huvmat=findobj(allchild(0),'tag','uvmat');
@@ -911,5 +878,5 @@
 if strcmp(list_fig{val},'uvmat')
     set(handles.inputfile,'Enable','off')% desactivate the input file edit box   
-    set(handles.RUN,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt)
+    set(handles.OK,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt)
     set(handles.MenuOpen,'Visible','off')
     set(handles.MenuExport,'Visible','off')
@@ -933,8 +900,8 @@
 % %------------------------------------------------
 % % --- Executes on button press in Plot_histo.
-% %RUN global histograms
+% %OK global histograms
 % %-------------------------------------------------
 % function RUN_histo_Callback(hObject, eventdata, handles)
-% % hObject    handle to RUN (see GCBO)
+% % hObject    handle to OK (see GCBO)
 % % eventdata  reserved - to be defined in a future version of MATLAB
 % % handles    structure with handles and user data (see GUIDATA)
@@ -1672,135 +1639,197 @@
     set(handles.TimeIndexValue,'Visible','off')
 end
-
-%------------------------------------------------------------------------
-% --- Executes on selection change in TimeDimensionMenu.
-function TimeDimensionMenu_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-index=get(handles.TimeDimensionMenu,'Value');
-DimList=get(handles.TimeDimensionMenu,'String');
-DimName=DimList{index};
-Field=get(handles.get_field,'UserData');
-DimIndex=find(strcmp(DimName,Field.ListDimName),1);
-ref_index=round(Field.DimValue(DimIndex)/2);   
-set(handles.TimeIndexValue,'String',num2str(ref_index))
-scalar_Callback(hObject, eventdata, handles)
-vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time)
- % look for a corresponding time variable and value
- time_test=zeros(size(Field.VarDimName));
- for ilist=1:numel(Field.VarDimName)
-     if isequal(Field.VarDimName{ilist},{DimName})
-         time_test(ilist)=1;
-     end
- end
- ListVariable=Field.ListVarName(time_test==1);
- set(handles.TimeVariableMenu,'Value',1)
- if isempty(ListVariable)     
-     set(handles.TimeVariableMenu,'String',{''})
-     set(handles.TimeVarValue,'String','')
- else
-    set(handles.TimeVariableMenu,'String',ListVariable)
-    TimeVarName=ListVariable{1};
-    VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables
-    inputfile=get(handles.inputfile,'String');% read the input file
-    SubField=nc2struct(inputfile,{TimeVarName});
-    eval(['TimeValue=SubField.' TimeVarName '(ref_index);'])
-    set(handles.TimeVarValue,'Visible','on')
-    set(handles.TimeVariableMenu,'Visible','on')
-    set(handles.TimeVarValue,'String',num2str(TimeValue))
- end
-
-
+% 
+% %------------------------------------------------------------------------
+% % --- Executes on selection change in TimeDimensionMenu.
+% function TimeDimensionMenu_Callback(hObject, eventdata, handles)
+% %------------------------------------------------------------------------
+% index=get(handles.TimeDimensionMenu,'Value');
+% DimList=get(handles.TimeDimensionMenu,'String');
+% DimName=DimList{index};
+% Field=get(handles.get_field,'UserData');
+% DimIndex=find(strcmp(DimName,Field.ListDimName),1);
+% ref_index=round(Field.DimValue(DimIndex)/2);   
+% set(handles.TimeIndexValue,'String',num2str(ref_index))
+% scalar_Callback(hObject, eventdata, handles)
+% vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time)
+%  % look for a corresponding time variable and value
+%  time_test=zeros(size(Field.VarDimName));
+%  for ilist=1:numel(Field.VarDimName)
+%      if isequal(Field.VarDimName{ilist},{DimName})
+%          time_test(ilist)=1;
+%      end
+%  end
+%  ListVariable=Field.ListVarName(time_test==1);
+%  set(handles.TimeVariableMenu,'Value',1)
+%  if isempty(ListVariable)     
+%      set(handles.TimeVariableMenu,'String',{''})
+%      set(handles.TimeVarValue,'String','')
+%  else
+%     set(handles.TimeVariableMenu,'String',ListVariable)
+%     TimeVarName=ListVariable{1};
+%     VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables
+%     inputfile=get(handles.inputfile,'String');% read the input file
+%     SubField=nc2struct(inputfile,{TimeVarName});
+%     eval(['TimeValue=SubField.' TimeVarName '(ref_index);'])
+%     set(handles.TimeVarValue,'Visible','on')
+%     set(handles.TimeVariableMenu,'Visible','on')
+%     set(handles.TimeVarValue,'String',num2str(TimeValue))
+%  end
+% 
+% 
+% % % -----------------------------------------------------------------------
+% % % --- Executes on button press in TimeVariable.
+% % function TimeVariable_Callback(hObject, eventdata, handles)
+% % % -----------------------------------------------------------------------
+% % val=get(handles.TimeVariable,'Value');
+% % if val
+% %     Field=get(handles.get_field,'UserData');
+% %     time_test=zeros(size(Field.VarDimName));
+% %     for ilist=1:numel(Field.VarDimName)
+% %         if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension
+% %             time_test(ilist)=1;
+% %         end
+% %     end
+% %     ind_test=find(time_test);
+% %     if isempty(time_test)
+% %         set(handles.TimeVariable,'Value',0)
+% %         set(handles.TimeVariableMenu,'Visible','off')
+% %         set(handles.TimeVarValue,'Visible','off')
+% %     else
+% %         set(handles.TimeVariableMenu,'Visible','on')
+% %         set(handles.TimeVarValue,'Visible','on')
+% %         if get(handles.TimeVariableMenu,'Value')>numel(ind_test)
+% %             set(handles.TimeVariableMenu,'Value',1)
+% %         end
+% %         set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test))
+% %         TimeVariableMenu_Callback(hObject, eventdata, handles)
+% %         set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time
+% %         set(handles.TimeAttribute,'Value',0)
+% %         TimeAttribute_Callback(hObject, eventdata, handles)
+% %     end
+% % else
+% %     set(handles.TimeVariableMenu,'Visible','off')
+% %     set(handles.TimeVarValue,'Visible','off')
+% % end
+% 
 % % -----------------------------------------------------------------------
-% % --- Executes on button press in TimeVariable.
-% function TimeVariable_Callback(hObject, eventdata, handles)
+% % --- Executes on selection change in TimeVariableMenu.
+% function TimeVariableMenu_Callback(hObject, eventdata, handles)
 % % -----------------------------------------------------------------------
-% val=get(handles.TimeVariable,'Value');
-% if val
-%     Field=get(handles.get_field,'UserData');
-%     time_test=zeros(size(Field.VarDimName));
-%     for ilist=1:numel(Field.VarDimName)
-%         if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension
-%             time_test(ilist)=1;
-%         end
-%     end
-%     ind_test=find(time_test);
-%     if isempty(time_test)
-%         set(handles.TimeVariable,'Value',0)
-%         set(handles.TimeVariableMenu,'Visible','off')
-%         set(handles.TimeVarValue,'Visible','off')
-%     else
-%         set(handles.TimeVariableMenu,'Visible','on')
-%         set(handles.TimeVarValue,'Visible','on')
-%         if get(handles.TimeVariableMenu,'Value')>numel(ind_test)
-%             set(handles.TimeVariableMenu,'Value',1)
-%         end
-%         set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test))
-%         TimeVariableMenu_Callback(hObject, eventdata, handles)
-%         set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time
-%         set(handles.TimeAttribute,'Value',0)
-%         TimeAttribute_Callback(hObject, eventdata, handles)
-%     end
-% else
-%     set(handles.TimeVariableMenu,'Visible','off')
-%     set(handles.TimeVarValue,'Visible','off')
+% ListVar=get(handles.TimeVariableMenu,'String');
+% index=get(handles.TimeVariableMenu,'Value');
+% TimeVariable=ListVar{index};% name of the selected variable
+% if isempty(TimeVariable)% case of blank selection
+%     return
 % end
-
-% -----------------------------------------------------------------------
-% --- Executes on selection change in TimeVariableMenu.
-function TimeVariableMenu_Callback(hObject, eventdata, handles)
-% -----------------------------------------------------------------------
-ListVar=get(handles.TimeVariableMenu,'String');
-index=get(handles.TimeVariableMenu,'Value');
-TimeVariable=ListVar{index};% name of the selected variable
-if isempty(TimeVariable)% case of blank selection
-    return
-end
-Field=get(handles.get_field,'UserData'); %index of 
-VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables
-DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable
-set(handles.TimeDimensionMenu,'Value',1)
-set(handles.TimeDimensionMenu,'String',DimName)
-inputfile=get(handles.inputfile,'String');% read the input file
-SubField=nc2struct(inputfile,{TimeVariable});
-eval(['TimeDimension=numel(SubField.' TimeVariable ');'])
-ref_index=round(TimeDimension/2);
-eval(['TimeValue=SubField.' TimeVariable '(ref_index);'])
-set(handles.TimeIndexValue,'String',num2str(ref_index))
-set(handles.TimeVarValue,'String',num2str(TimeValue))
-
-
-function TimeValue_Callback(hObject, eventdata, handles)
-%TO suppress 
-
-% -----------------------------------------------------------------------
-function TimeIndexValue_Callback(hObject, eventdata, handles)
-% -----------------------------------------------------------------------
-TimeIndex=str2double(get(handles.TimeIndexValue,'String'));
-TimeVarName=Field.ListVarName{time_index};
-set(handles.TimeVariable,'Value',1)
-set(handles.TimeName,'String',TimeVarName)
-fileinput=get(handles.inputfile,'String');
-SubField=nc2struct(fileinput,{TimeVarName});
-eval(['TimeValue=SubField.' TimeVarName '(ref_index);']);
-set(handles.TimeValue,'Visible','on')
-set(handles.TimeValue,'String',num2str(TimeValue))
-
-% -----------------------------------------------------------------------
-function SelectFigure_Callback(hObject, eventdata, handles)
-% -----------------------------------------------------------------------
-val=get(handles.SelectFigure,'Value');
-if val
-    set(handles.list_fig,'Visible','on')
-    %% look at the existing figures in the work space
-    browse_fig(handles.list_fig)
-else
-   set(handles.list_fig,'Visible','off') 
-end
-
-
-function TimeVarValue_Callback(hObject, eventdata, handles)
-
+% Field=get(handles.get_field,'UserData'); %index of 
+% VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables
+% DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable
+% set(handles.TimeDimensionMenu,'Value',1)
+% set(handles.TimeDimensionMenu,'String',DimName)
+% inputfile=get(handles.inputfile,'String');% read the input file
+% SubField=nc2struct(inputfile,{TimeVariable});
+% eval(['TimeDimension=numel(SubField.' TimeVariable ');'])
+% ref_index=round(TimeDimension/2);
+% eval(['TimeValue=SubField.' TimeVariable '(ref_index);'])
+% set(handles.TimeIndexValue,'String',num2str(ref_index))
+% set(handles.TimeVarValue,'String',num2str(TimeValue))
 
 
 % --- Executes on button press in check_rgb.
 function check_rgb_Callback(hObject, eventdata, handles)
+
+
+% --- Executes when user attempts to close get_field.
+function get_field_CloseRequestFcn(hObject, eventdata, handles)
+if isequal(get(handles.get_field, 'waitstatus'), 'waiting')
+    % The GUI is still in UIWAIT, us UIRESUME
+    uiresume(handles.get_field);
+else
+    % The GUI is no longer waiting, just close it
+    delete(handles.get_field);
+end
+
+
+
+
+
+% --- Executes on selection change in listbox30.
+function listbox30_Callback(hObject, eventdata, handles)
+% hObject    handle to listbox30 (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: contents = cellstr(get(hObject,'String')) returns listbox30 contents as cell array
+%        contents{get(hObject,'Value')} returns selected item from listbox30
+
+
+% --- Executes on selection change in SwitchVarIndexX.
+function SwitchVarIndexX_Callback(hObject, eventdata, handles)
+% hObject    handle to SwitchVarIndexX (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: contents = cellstr(get(hObject,'String')) returns SwitchVarIndexX contents as cell array
+%        contents{get(hObject,'Value')} returns selected item from SwitchVarIndexX
+
+
+% --- Executes on selection change in SwitchVarIndexTime.
+function SwitchVarIndexTime_Callback(hObject, eventdata, handles)
+menu=get(handles.SwitchVarIndexTime,'String');
+option=menu{get(handles.SwitchVarIndexTime,'Value')};
+switch option
+    case 'file index'
+        set(handles.TimeVarName, 'Visible','off')
+    case 'attribute'
+        set(handles.TimeVarName, 'Visible','on')
+        time_index=[];
+        ListAttributes=get(handles.attributes,'String');
+        if ~isempty(ListAttributes)
+            time_index=find(~cellfun('isempty',regexp(ListAttributes,'Time')));% index of the attributes containing the string 'Time'
+        end
+        if ~isempty(time_index)
+            set(handles.TimeVarName,'Value',time_index(1))
+        else
+            set(handles.TimeVarName,'Value',1)
+        end
+        set(handles.TimeVarName, 'String',ListAttributes)
+    case 'variable'
+        ListDim=get(handles.dimensions,'String');
+        Field=get(handles.get_field,'UserData');
+        for idim=1:numel(ListDim)
+            var_count=[];
+            for ilist=1:numel(Field.VarDimName)
+                DimName=Field.VarDimName{ilist};
+                if strcmp(DimName,ListDim{idim})||strcmp(DimName,{ListDim{idim}}) %if the variable has a single dim ( 1D array)
+                    var_count=[var_count ilist];
+                end
+            end
+            if numel(var_count)==1
+                TimeVarName=[TimeVarName;Field.ListVarName{var_count}];
+            end
+        end
+        set(handles.TimeVarName, 'Visible','on')
+        List=get(handles.TimeVarName,'String');
+        option=List{get(handles.TimeVarName,'Value')};
+        ind=find(strcmp(option,get(handles.dimensions,'String')));
+        if isempty(ind)
+            set(handles.TimeVarName, 'Value',1);
+        else
+            set(handles.TimeVarName, 'Value',ind);
+        end
+        set(handles.TimeVarName, 'String',TimeVarName)
+    case 'dim index'
+        set(handles.TimeVarName, 'Visible','on')
+        List=get(handles.TimeVarName,'String');
+        option=List{get(handles.TimeVarName,'Value')};
+        ind=find(strcmp(option,get(handles.dimensions,'String')));
+        if isempty(ind)
+            set(handles.TimeVarName, 'Value',1);
+        else
+            set(handles.TimeVarName, 'Value',ind);
+        end
+        set(handles.TimeVarName, 'String',get(handles.dimensions,'String'))
+end
+
+    
Index: /trunk/src/msgbox_uvmat.m
===================================================================
--- /trunk/src/msgbox_uvmat.m	(revision 580)
+++ /trunk/src/msgbox_uvmat.m	(revision 581)
@@ -7,5 +7,5 @@
 %INPUT:
 % title: string indicating the type of message box:
-%          title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N', default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig). 
+%          title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N','INPUT_MENU' default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig). 
 %          if title='INPUT_TXT', input data is asked in an edit box
 %          if title='CONFIMATION'', 'ERROR', 'WARNING', the figure remains  opened until a button 'OK' is pressed
@@ -37,6 +37,8 @@
 % End initialization code - DO NOT EDIT
 
+%------------------------------------------------------------------------
 % --- Executes just before msgbox_uvmat is made visible.
 function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display_str,default_answer,Position)
+%------------------------------------------------------------------------
 % This function has no output args, see OutputFcn.
 
@@ -89,4 +91,7 @@
             testinputstring=1;
             testCancel=1; %no cancel button
+        case 'INPUT_MENU'
+            testinputstring=2;
+            testCancel=1; %no cancel button
         otherwise
           %  testinputstring=1;
@@ -98,11 +103,6 @@
     set(handles.text1, 'String', display_str);
 end
-% if testinputstring
-%     set(handles.edit_box, 'Visible', 'on');
-% else
-%     set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]);
-% end
-if testinputstring
-    % set(handles.figure1,'Position',[40,80,20*length(default_answer),50])
+
+if testinputstring==1
     set(handles.edit_box, 'Visible', 'on');
     if ~exist('default_answer','var');
@@ -111,24 +111,27 @@
     set(handles.edit_box, 'String', default_answer);
     if exist('Position','var')
-    if iscell(default_answer)
-        widthstring=max(max(cellfun('length',default_answer)),length(display_str));
-        heightstring=size(default_answer,1);%nbre of expected lines
-        set(handles.edit_box,'Max',2);
-    else
-        widthstring=max(length(default_answer),length(display_str));
-        heightstring=1;
-    end
-    widthstring=max(widthstring,length(title)+20);
-    boxsize=[10*widthstring 20*heightstring];%size of the display edit box 
-    set(handles.edit_box,'Units','pixels')
-    set(handles.edit_box,'FontUnits','pixels')
-    set(handles.edit_box,'FontSize',12)  
-   set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)])
-   FigPos(3)=10+boxsize(1);
-   FigPos(4)=56+boxsize(2);
-   FigPos(2)=Position(2)-FigPos(4)-25;
-   set(handles.figure1,'Position',FigPos)
-    end
-%     set(handles.figure1,'Position',[40,40,20*length(default_answer),50])
+        if iscell(default_answer)
+            widthstring=max(max(cellfun('length',default_answer)),length(display_str));
+            heightstring=size(default_answer,1);%nbre of expected lines
+            set(handles.edit_box,'Max',2);
+        else
+            widthstring=max(length(default_answer),length(display_str));
+            heightstring=1;
+        end
+        widthstring=max(widthstring,length(title)+20);
+        boxsize=[10*widthstring 20*heightstring];%size of the display edit box
+        set(handles.edit_box,'Units','pixels')
+        set(handles.edit_box,'FontUnits','pixels')
+        set(handles.edit_box,'FontSize',12)
+        set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)])
+        FigPos(3)=10+boxsize(1);
+        FigPos(4)=56+boxsize(2);
+        FigPos(2)=Position(2)-FigPos(4)-25;
+        set(handles.figure1,'Position',FigPos)
+    end
+elseif testinputstring==2
+    set(handles.edit_box,'style','listbox')
+    set(handles.edit_box, 'Visible', 'on');
+    set(handles.edit_box,'String', default_answer)
 else
     set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]);
@@ -189,7 +192,8 @@
 uiwait(handles.figure1);
 
-
+%------------------------------------------------------------------------
 % --- Outputs from this function are returned to the command line.
 function varargout = msgbox_uvmat_OutputFcn(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 
 % Get default command line output from handles structure
@@ -200,6 +204,10 @@
         varargout{1}='No';
     else
+        if strcmp(get(handles.edit_box,'Style'),'listbox')
+             varargout{1}=get(handles.edit_box,'Value');
+        else
         varargout{1}=get(handles.edit_box,'String');
-        if isempty(varargout{1}) || isequal(varargout{1},'')
+        end
+        if isempty(varargout{1}) 
             varargout{1}='Yes';
         end
@@ -208,19 +216,25 @@
 end
  delete(handles.figure1);
- 
+
+%------------------------------------------------------------------------ 
 % --- Executes on button press in OK.
 function OK_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 handles.output = get(hObject,'String');
 guidata(hObject, handles);% Update handles structure
 uiresume(handles.figure1);
 
+%------------------------------------------------------------------------
 % --- Executes on button press in No.
 function No_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 handles.output='No';
 guidata(hObject, handles);
 uiresume(handles.figure1);
 
+%------------------------------------------------------------------------
 % --- Executes on button press in Cancel.
 function Cancel_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 handles.output = get(hObject,'String');
 %handles.output = 'Cancel'
@@ -230,7 +244,8 @@
 uiresume(handles.figure1);
 
-
+%------------------------------------------------------------------------
 % --- Executes when user attempts to close figure1.
 function figure1_CloseRequestFcn(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
     % The GUI is still in UIWAIT, us UIRESUME
@@ -241,6 +256,8 @@
 end
 
+%------------------------------------------------------------------------
 % --- Executes on key press over figure1 with no controls selected.
 function figure1_KeyPressFcn(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 % Check for "enter" or "escape"
 if isequal(get(hObject,'CurrentKey'),'escape')
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 580)
+++ /trunk/src/plot_field.m	(revision 581)
@@ -249,5 +249,5 @@
 function errormsg=plot_text(FieldData,CellInfo,htext)
 %-------------------------------------------------------------------
-errormsg=[];
+errormsg='';
 txt_cell={};
 Data={};
@@ -1045,5 +1045,7 @@
     
     %decimate by a factor 2 in vector mesh(4 in nbre of vectors)
+    check_decimate=0;
     if isfield(PlotParam.Vectors,'CheckDecimate4') && PlotParam.Vectors.CheckDecimate4
+        check_decimate=1;
         diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
         dy_thresh=max(abs(diffy))/2; 
@@ -1055,4 +1057,17 @@
         nb_sel=length(ind_sel);
         ind_sel=ind_sel(1:2:nb_sel);% take half the points on a line
+    elseif isfield(PlotParam.Vectors,'CheckDecimate16') && PlotParam.Vectors.CheckDecimate16
+        check_decimate=1;
+        diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
+        dy_thresh=max(abs(diffy))/2; 
+        ind_jump=find(abs(diffy) > dy_thresh); %indices with diff(vec_Y)> max/2, detect change of line
+        ind_sel=1:ind_jump(1);%select the first line
+        for i=2:4:length(ind_jump)-1
+            ind_sel=[ind_sel (ind_jump(i)+1:ind_jump(i+1))];% select the odd lines
+        end
+        nb_sel=length(ind_sel);
+        ind_sel=ind_sel(1:4:nb_sel);% take half the points on a line
+    end
+    if check_decimate
         vec_X=vec_X(ind_sel);
         vec_Y=vec_Y(ind_sel);
Index: /trunk/src/proj_field.m
===================================================================
--- /trunk/src/proj_field.m	(revision 580)
+++ /trunk/src/proj_field.m	(revision 581)
@@ -142,5 +142,5 @@
         return
     end
-elseif  ~isequal(ObjectData.ProjMode,'interp')
+elseif  ~isequal(ObjectData.ProjMode,'interp_lin')
     errormsg=(['ProjMode option ' ObjectData.ProjMode ' not available in proj_field']);
         return
@@ -223,5 +223,5 @@
                     Var=FieldData.(VarName)(indsel);
                     ProjData.(VarName)(ipoint,1)=mean(Var);
-                    if isequal(ObjectData.ProjMode,'interp')
+                    if isequal(ObjectData.ProjMode,'interp_lin')
                          ProjData.(VarName)(ipoint,1)=griddata_uvmat(coord_x(indsel),coord_y(indsel),Var,Xpoint(1),Xpoint(2));
                     end
@@ -524,7 +524,7 @@
 theta=angle(dlinx+1i*dliny);%angle of each segment
 theta(siz_line(1))=theta(siz_line(1)-1);
-% determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'filter')
+% determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'interp_tps')
 xsup=zeros(1,siz_line(1)); xinf=zeros(1,siz_line(1)); ysup=zeros(1,siz_line(1)); yinf=zeros(1,siz_line(1));
-if isequal(ProjMode,'projection') || isequal(ProjMode,'filter')
+if isequal(ProjMode,'projection') || isequal(ProjMode,'interp_tps')
     xsup(1)=ObjectData.Coord(1,1)-width*sin(theta(1));
     xinf(1)=ObjectData.Coord(1,1)+width*sin(theta(1));
@@ -580,10 +580,10 @@
     % check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y
     if strcmp(CellInfo{icell}.CoordType,'scattered')
-        if  ~isequal(ProjMode,'interp')
+        if  ~isequal(ProjMode,'interp_lin')
             if width==0
                 errormsg='range of the projection object is missing';
                 return      
             else
-                lambda=2/(width*width); %smoothing factor used for filter: weight exp(-2) at distance width from the line
+                lambda=2/(width*width); %smoothing factor used for interp_tps: weight exp(-2) at distance width from the line
             end
         end
@@ -621,5 +621,5 @@
                 flagsel=ones(size(coord_x));
             end
-            if isequal(ProjMode,'projection') | isequal(ProjMode,'filter')
+            if isequal(ProjMode,'projection') || isequal(ProjMode,'interp_tps')
                 flagsel=flagsel & ((coord_y -yinf(ip))*(xinf(ip+1)-xinf(ip))>(coord_x-xinf(ip))*(yinf(ip+1)-yinf(ip))) ...
                 & ((coord_y -ysup(ip))*(xsup(ip+1)-xsup(ip))<(coord_x-xsup(ip))*(ysup(ip+1)-ysup(ip))) ...
@@ -649,5 +649,5 @@
                      end
                 end
-            elseif isequal(ProjMode,'interp') %linear interpolation:
+            elseif isequal(ProjMode,'interp_lin') %linear interpolation:
                 npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX)
                 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint);
@@ -659,5 +659,5 @@
                      end
                 end
-            elseif isequal(ProjMode,'filter') %filtering
+            elseif isequal(ProjMode,'interp_tps') %filtering
                 npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX)
                 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint);
@@ -983,13 +983,13 @@
 for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
     ProjMode{icell}=ObjectData.ProjMode;
-    if isfield(CellInfo{icell},'FieldRequest')
-        switch CellInfo{icell}.FieldRequest
+    if isfield(CellInfo{icell},'ProjModeRequest')
+        switch CellInfo{icell}.ProjModeRequest
             case 'interp_lin'
-                ProjMode{icell}='interp';
+                ProjMode{icell}='interp_lin';
             case 'interp_tps'
-                ProjMode{icell}='filter';
-        end
-    end
-    if strcmp(ProjMode{icell},'interp')||strcmp(ProjMode{icell},'filter')
+                ProjMode{icell}='interp_tps';
+        end
+    end
+    if strcmp(ProjMode{icell},'interp_lin')||strcmp(ProjMode{icell},'interp_tps')
         check_grid=1;
     end
@@ -1043,6 +1043,6 @@
         %% case of input fields with unstructured coordinates
         case 'scattered'
-            if strcmp(ProjMode{icell},'filter')
-                continue %skip for filter (needs tps field cell)
+            if strcmp(ProjMode{icell},'interp_tps')
+                continue %skip for interp_tps (needs tps field cell)
             end
             coord_x=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)});% initial x coordinates 
@@ -1148,5 +1148,5 @@
                         end
                     end
-                case 'interp'%interpolate data on a regular grid
+                case 'interp_lin'%interpolate data on a regular grid
                     coord_x_proj=XMin:DX:XMax;
                     coord_y_proj=YMin:DY:YMax;
@@ -1205,9 +1205,9 @@
             end
 
-            %% case of tps interpolation (applies only in filter mode and for spatial derivatives)
+            %% case of tps interpolation (applies only in interp_tps mode and for spatial derivatives)
         case 'tps'
-            if strcmp(ProjMode{icell},'filter')
+            if strcmp(ProjMode{icell},'interp_tps')
                 Coord=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex});
-                NbSites=FieldData.(FieldData.ListVarName{CellInfo{icell}.NbSite_tps});
+                NbCentres=FieldData.(FieldData.ListVarName{CellInfo{icell}.NbCentres_tps});
                 SubRange=FieldData.(FieldData.ListVarName{CellInfo{icell}.SubRange_tps});
                 if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')
@@ -1221,5 +1221,5 @@
                 XI=XI+ObjectData.Coord(1,1);
                 YI=YI+ObjectData.Coord(1,2);
-                [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbSites,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI));   
+                [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI));   
                 ListFieldProj=(fieldnames(DataOut))';
                 VarDimName=cell(size(ListFieldProj));
@@ -1461,11 +1461,11 @@
                     YIMA=reshape(round(YIMA),1,npX*npY);
                     flagin=XIMA>=1 & XIMA<=DimValue(2) & YIMA >=1 & YIMA<=DimValue(1);%flagin=1 inside the original image
-                    if isequal(ProjMode{icell},'filter')
-                        npx_filter=ceil(abs(DX/DAX));
-                        npy_filter=ceil(abs(DY/DAY));
-                        Mfilter=ones(npy_filter,npx_filter)/(npx_filter*npy_filter);
-                        test_filter=1;
+                    if isequal(ProjMode{icell},'interp_tps')
+                        npx_interp_tps=ceil(abs(DX/DAX));
+                        npy_interp_tps=ceil(abs(DY/DAY));
+                        Minterp_tps=ones(npy_interp_tps,npx_interp_tps)/(npx_interp_tps*npy_interp_tps);
+                        test_interp_tps=1;
                     else
-                        test_filter=0;
+                        test_interp_tps=0;
                     end
                     eval(['ProjData.' AYName '=[coord_y_proj(1) coord_y_proj(end)];']) %record the new (projected ) y coordinates
@@ -1476,12 +1476,4 @@
                             eval(['ProjData.' VarName '=interp2(Coord{2},Coord{1},FieldData.' VarName ',Coord_x,Coord_y'');']) %TO TEST
                         end
-                        %filter the field (image) if option 'filter' is used
-%                         if test_filter
-%                             Aclass=class(FieldData.A);
-%                             eval(['ProjData.' VarName '=filter2(Mfilter,FieldData.' VarName ',''valid'');'])
-%                             if ~isequal(Aclass,'double')
-%                                 eval(['ProjData.' VarName '=' Aclass '(FieldData.' VarName ');'])%revert to integer values
-%                             end
-%                         end
                         eval(['vec_A=reshape(FieldData.' VarName ',[],nbcolor);'])%put the original image in line
                         %ind_in=find(flagin);
@@ -1525,5 +1517,5 @@
                 else
                     errormsg='projection of structured coordinates on oblique plane not yet implemented';
-                    %TODO: use interp3
+                    %TODO: use interp_lin3
                     return
                 end
@@ -1801,5 +1793,5 @@
                 end
             end  
-        elseif isequal(ObjectData.ProjMode,'interp')||isequal(ObjectData.ProjMode,'filter')%interpolate data on a regular grid
+        elseif isequal(ObjectData.ProjMode,'interp_lin')||isequal(ObjectData.ProjMode,'interp_tps')%interpolate data on a regular grid
             coord_x_proj=XMin:DX:XMax;
             coord_y_proj=YMin:DY:YMax;
@@ -2074,11 +2066,11 @@
                 YIMA=reshape(round(YIMA),1,npX*npY);
                 flagin=XIMA>=1 & XIMA<=DimValue(2) & YIMA >=1 & YIMA<=DimValue(1);%flagin=1 inside the original image 
-                if isequal(ObjectData.ProjMode,'filter')
-                    npx_filter=ceil(abs(DX/DAX));
-                    npy_filter=ceil(abs(DY/DAY));
-                    Mfilter=ones(npy_filter,npx_filter)/(npx_filter*npy_filter);
-                    test_filter=1;
+                if isequal(ObjectData.ProjMode,'interp_tps')
+                    npx_interp_tps=ceil(abs(DX/DAX));
+                    npy_interp_tps=ceil(abs(DY/DAY));
+                    Minterp_tps=ones(npy_interp_tps,npx_interp_tps)/(npx_interp_tps*npy_interp_tps);
+                    test_interp_tps=1;
                 else
-                    test_filter=0;
+                    test_interp_tps=0;
                 end
                 eval(['ProjData.' AYName '=[coord_y_proj(1) coord_y_proj(end)];']) %record the new (projected ) y coordinates
@@ -2089,8 +2081,8 @@
                           eval(['ProjData.' VarName '=interp2(Coord{2},Coord{1},FieldData.' VarName ',Coord_x,Coord_y'');']) %TO TEST
                     end
-                    %filter the field (image) if option 'filter' is used
-                    if test_filter  
+                    %filter the field (image) if option 'interp_tps' is used
+                    if test_interp_tps  
                          Aclass=class(FieldData.A);
-                         ProjData.(VarName)=filter2(Mfilter,FieldData.(VarName),'valid');
+                         ProjData.(VarName)=interp_tps2(Minterp_tps,FieldData.(VarName),'valid');
                          if ~isequal(Aclass,'double')
                              ProjData.(VarName)=Aclass(FieldData.(VarName));%revert to integer values
Index: /trunk/src/read_civdata.m
===================================================================
--- /trunk/src/read_civdata.m	(revision 580)
+++ /trunk/src/read_civdata.m	(revision 581)
@@ -62,12 +62,12 @@
 errormsg='';
 if ischar(FieldNames), FieldNames={FieldNames}; end;
-FieldRequest='';
+ProjModeRequest='';
 for ilist=1:length(FieldNames)
     if ~isempty(FieldNames{ilist})
         switch FieldNames{ilist}
             case{'U','V','norm(U,V)'}
-                FieldRequest='interp_lin';
+                ProjModeRequest='interp_lin';
             case {'curl(U,V)','div(U,V)','strain(U,V)'}
-                FieldRequest='interp_tps';
+                ProjModeRequest='interp_tps';
         end
     end
@@ -76,5 +76,5 @@
 %% reading data
 Data=nc2struct(filename,'ListGlobalAttribute','CivStage');
-[varlist,role,VelTypeOut]=varcivx_generator(FieldRequest,VelType,Data.CivStage);
+[varlist,role,VelTypeOut]=varcivx_generator(ProjModeRequest,VelType,Data.CivStage);
 if isempty(varlist)
     erromsg=['error in read_civdata: unknow velocity type ' VelType];
@@ -109,17 +109,28 @@
 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt','Time'}];
 ivar_U_tps=[];
+ivar_V_tps=[];
 var_ind=find(vardetect);
 for ivar=1:numel(var_ind)
     Field.VarAttribute{ivar}.Role=role{var_ind(ivar)};
-    Field.VarAttribute{ivar}.FieldRequest=FieldRequest;
     if strcmp(role{var_ind(ivar)},'vector_x')
         Field.VarAttribute{ivar}.FieldName=FieldNames;
+        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
         ivar_U=ivar;
     end
     if strcmp(role{var_ind(ivar)},'vector_x_tps')
         Field.VarAttribute{ivar}.FieldName=FieldNames;
+        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
         ivar_U_tps=ivar;
     end
-%     Field.VarAttribute{ivar}.Unit=units{var_ind(ivar)};
+    if strcmp(role{var_ind(ivar)},'vector_y')
+        Field.VarAttribute{ivar}.FieldName=FieldNames;
+        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
+        ivar_V=ivar;
+    end
+    if strcmp(role{var_ind(ivar)},'vector_y_tps')
+        Field.VarAttribute{ivar}.FieldName=FieldNames;
+        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
+        ivar_V_tps=ivar;
+    end
     Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
 end
@@ -127,7 +138,10 @@
     Field.VarAttribute{ivar_U}.VarIndex_tps=ivar_U_tps;
 end
-
+if ~isempty(ivar_V_tps)
+    Field.VarAttribute{ivar_V}.VarIndex_tps=ivar_V_tps;
+end
+
+%% update list of global attributes
 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'NbCoord','NbDim','TimeUnit','CoordUnit'}];
-% %% update list of global attributes
 Field.NbCoord=2;
 Field.NbDim=2;
@@ -146,5 +160,5 @@
 %            if vel_type=[] or'*', a  priority choice is done, civ2 considered better than civ1 )
 
-function [var,role,vel_type_out,errormsg]=varcivx_generator(FieldRequest,vel_type,CivStage) 
+function [var,role,vel_type_out,errormsg]=varcivx_generator(ProjModeRequest,vel_type,CivStage) 
 
 %% default input values
@@ -154,7 +168,7 @@
 
 %% select the priority order for automatic vel_type selection
-if strcmp(vel_type,'civ2') && strcmp(FieldRequest,'derivatives')
+if strcmp(vel_type,'civ2') && strcmp(ProjModeRequest,'derivatives')
     vel_type='filter2';
-elseif strcmp(vel_type,'civ1') && strcmp(FieldRequest,'derivatives')
+elseif strcmp(vel_type,'civ1') && strcmp(ProjModeRequest,'derivatives')
     vel_type='filter1';
 end
@@ -164,5 +178,5 @@
             vel_type='filter2';
         case {4,5}% civ2 available but not filter2
-            if strcmp(FieldRequest,'derivatives')% derivatives needed
+            if strcmp(ProjModeRequest,'derivatives')% derivatives needed
                 vel_type='filter1';
             else
@@ -203,5 +217,5 @@
        % units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
 end
-if ~strcmp(FieldRequest,'interp_tps')
+if ~strcmp(ProjModeRequest,'interp_tps')
     var=var(:,1:9);%suppress tps if not needed
 end
Index: /trunk/src/read_civxdata.m
===================================================================
--- /trunk/src/read_civxdata.m	(revision 580)
+++ /trunk/src/read_civxdata.m	(revision 581)
@@ -95,5 +95,5 @@
         Field.VarAttribute{ivar}.FieldName=FieldNames;
         if testinterp
-            Field.VarAttribute{ivar}.FieldRequest='interp_lin';
+            Field.VarAttribute{ivar}.ProjModeRequest='interp_lin';
         end
     end
Index: /trunk/src/set_object.m
===================================================================
--- /trunk/src/set_object.m	(revision 580)
+++ /trunk/src/set_object.m	(revision 581)
@@ -249,11 +249,11 @@
     switch Type
         case {'points','line','polyline','plane'}
-            menu_proj={'projection';'interp';'filter';'none'};
+            menu_proj={'projection';'interp_lin';'interp_tps';'none'};
         case {'polygon','rectangle','ellipse'}
             menu_proj={'inside';'outside';'mask_inside';'mask_outside'};
         case 'volume'
-            menu_proj={'interp';'none'};
+            menu_proj={'interp_lin';'none'};
         otherwise
-            menu_proj={'projection';'interp';'filter';'none'};%default
+            menu_proj={'projection';'interp_lin';'interp_tps';'none'};%default
     end
 else
@@ -288,5 +288,5 @@
 set(handles.num_RangeX_2,'Visible','off')
 set(handles.num_RangeY_1,'Visible','off')
-if isequal(ProjMode,'interp')
+if isequal(ProjMode,'interp_lin')
     set(handles.num_RangeY_2,'Visible','off')
 else
@@ -315,5 +315,5 @@
 %         set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line')
 %         set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line')
-        if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
+        if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps')
             set(handles.num_DX,'Visible','on')
             set(handles.num_DX,'TooltipString','num_DX: mesh for the interpolated field along the line')
@@ -338,5 +338,5 @@
             set(handles.num_RangeZ_2,'Visible','on')
         end
-        if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
+        if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps')
             set(handles.num_DX,'Visible','on')
             set(handles.num_DY,'Visible','on')
@@ -345,5 +345,5 @@
             set(handles.num_DY,'Visible','off')
         end
-        if  isequal(ProjMode,'interp')
+        if  isequal(ProjMode,'interp_lin')
             set(handles.num_DZ,'Visible','on')  
         end
@@ -360,5 +360,5 @@
         set(handles.num_RangeZ_1,'Visible','on')
         set(handles.num_RangeZ_2,'Visible','on')
-        if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
+        if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps')
             set(handles.num_DX,'Visible','on')
             set(handles.num_DY,'Visible','on')
@@ -485,6 +485,6 @@
     PlotType='text';
 else
-    % create tps coeff if needed for ProjMode 'filter'
-    if strcmp(ObjectData.ProjMode,'filter')&&~isfield(UvData.Field,'Coord_tps')     
+    % create tps coeff if needed for ProjMode 'interp_tps'
+    if strcmp(ObjectData.ProjMode,'interp_tps')&&~isfield(UvData.Field,'Coord_tps')     
         UvData.Field=calc_tps(UvData.Field,1);
     end
Index: /trunk/src/sub_field.m
===================================================================
--- /trunk/src/sub_field.m	(revision 580)
+++ /trunk/src/sub_field.m	(revision 581)
@@ -75,14 +75,14 @@
 
 %% field request
-FieldRequest=cell(size(Field.ListVarName));
+ProjModeRequest=cell(size(Field.ListVarName));
 for ilist=1:numel(Field.VarAttribute)
-    if isfield(Field.VarAttribute{ilist},'FieldRequest')
-        FieldRequest{ilist}=Field.VarAttribute{ilist}.FieldRequest;
+    if isfield(Field.VarAttribute{ilist},'ProjModeRequest')
+        ProjModeRequest{ilist}=Field.VarAttribute{ilist}.ProjModeRequest;
     end
 end
-FieldRequest_1=cell(size(Field_1.ListVarName));
+ProjModeRequest_1=cell(size(Field_1.ListVarName));
 for ilist=1:numel(Field_1.VarAttribute)
-    if isfield(Field_1.VarAttribute{ilist},'FieldRequest')
-        FieldRequest_1{ilist}=Field_1.VarAttribute{ilist}.FieldRequest;
+    if isfield(Field_1.VarAttribute{ilist},'ProjModeRequest')
+        ProjModeRequest_1{ilist}=Field_1.VarAttribute{ilist}.ProjModeRequest;
     end
 end
@@ -115,5 +115,5 @@
         VarVal=Field_1.(Field_1.ListVarName{ilist});
         for i1=1:numel(Field.ListVarName)
-            if (isempty(FieldRequest{i1})&&isempty(FieldRequest_1{ilist})||strcmp(FieldRequest{i1},FieldRequest_1{ilist})) && isequal(Field.(Field.ListVarName{i1}),VarVal)
+            if (isempty(ProjModeRequest{i1})&&isempty(ProjModeRequest_1{ilist})||strcmp(ProjModeRequest{i1},ProjModeRequest_1{ilist})) && isequal(Field.(Field.ListVarName{i1}),VarVal)
                ind_remove(ilist)=1;
                NewDim=Field.VarDimName{i1};
Index: /trunk/src/tps_coeff.m
===================================================================
--- /trunk/src/tps_coeff.m	(revision 580)
+++ /trunk/src/tps_coeff.m	(revision 581)
@@ -8,4 +8,7 @@
 % The spatial derivatives are obtained as EMDX*U_tps and EMDY*U_tps, where
 % EMDX and EMDY are obtained from the function tps_eval_dxy.
+% for big data sets, a splitting in subdomains is needed, see functions
+% set_subdomains and tps_coeff_field.
+%
 %------------------------------------------------------------------------
 % [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing)
@@ -13,26 +16,26 @@
 % OUPUT:
 % U_smooth: values of the quantity U at the N centres after smoothing
-% U_tps: tps weights of the centres
+% U_tps: tps weights of the centres and columns of the linear
 
 %INPUT:
-% ctrs: Nxs matrix  representing the postions of the N centers, sources of the tps (s=space dimension)
+% ctrs: NxNbDim matrix  representing the positions of the N centers, sources of the tps (NbDim=space dimension)
 % U: Nx1 column vector representing the values of the considered scalar measured at the centres ctrs
 % Smoothing: smoothing parameter: the result is smoother for larger Smoothing.
-
+%
+%related functions:
+% tps_eval, tps_eval_dxy
+% tps_coeff_field, set_subdomains, filter_tps, calc_field
 
 function [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing)
 %------------------------------------------------------------------------
-%Smoothing smoothing parameter
-% X=reshape(X,[],1);
-% Y=reshape(Y,[],1);
-N=size(ctrs,1);
-% rhs = reshape(U,[],1);
-U = [U; zeros(3,1)];
-% ctrs = [X Y];% coordinates of measurement sites, radial base functions are located at the measurement sites
+
+N=size(ctrs,1);% nbre of source centres
+NbDim=size(ctrs,2);% space dimension (2 or 3)
+U = [U; zeros(NbDim+1,1)];
 EM = tps_eval(ctrs,ctrs);
 SmoothingMat=Smoothing*eye(N,N);%  Smoothing=1/(2*omega) , omega given by fasshauer;
-SmoothingMat=[SmoothingMat zeros(N,3)];
+SmoothingMat=[SmoothingMat zeros(N,NbDim+1)];
 PM=[ones(N,1) ctrs];
-IM=[EM+SmoothingMat; [PM' zeros(3,3)]];
+IM=[EM+SmoothingMat; [PM' zeros(NbDim+1,NbDim+1)]];
 U_tps=(IM\U);
 U_smooth=EM *U_tps;
Index: /trunk/src/tps_eval.m
===================================================================
--- /trunk/src/tps_eval.m	(revision 580)
+++ /trunk/src/tps_eval.m	(revision 581)
@@ -16,4 +16,5 @@
 % related functions:
 % tps_coeff, tps_eval_dxy
+% tps_coeff_field, set_subdomains, filter_tps, calc_field
 
 function EM = tps_eval(dsites,ctrs)
Index: /trunk/src/tps_eval_dxy.m
===================================================================
--- /trunk/src/tps_eval_dxy.m	(revision 580)
+++ /trunk/src/tps_eval_dxy.m	(revision 581)
@@ -15,4 +15,5 @@
 % related functions:
 % tps_coeff, tps_eval
+% tps_coeff_field, set_subdomains, filter_tps, calc_field
 
   function [DMX,DMY] = tps_eval_dxy(dsites,ctrs)
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 580)
+++ /trunk/src/uvmat.m	(revision 581)
@@ -68,5 +68,5 @@
 %                    --->transform fct<---             transform (e.g. phys.m) and combine input fieldname  
 %                            |                                    
-%                        (calc_tps.m)               calculate tps coefficients (for filter projection or spatial derivatives).
+%                        (tps_coeff_field.m)               calculate tps coefficients (for filter projection or spatial derivatives).
 %                            |
 %                       UvData.Field-------------->histogram
@@ -1022,5 +1022,6 @@
 switch FileType
     case {'civx','civdata'}
-        [FieldList,ColorList]=calc_field;
+%         [FieldList,ColorList]=calc_field;
+        [FieldList,ColorList]=set_field_list('U','V','C');
         set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
         set(handles_Fields,'Value',2) % set menu to 'velocity
@@ -2046,5 +2047,5 @@
 if  (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))
     for iobj=1:numel(UvData.Object)
-        if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter')
+        if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'interp_tps')
             check_proj_tps=1;
             break
@@ -2438,5 +2439,5 @@
 
 %% calculate tps coefficients if needed
-UvData.Field=calc_tps(UvData.Field,check_proj_tps);
+UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps);
 
 %% analyse input field
@@ -3042,22 +3043,91 @@
 function FieldName_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
+UvData=get(handles.uvmat,'UserData');
 list_fields=get(handles.FieldName,'String');% list menu fields
 index_fields=get(handles.FieldName,'Value');% selected string index
 field= list_fields{index_fields(1)}; % selected string
+
+%% fill the coordinates and variables from selections in get_field
 if isequal(field,'get_field...')
+    if strcmp(get(handles.VelType,'Visible'),'on')
+        % we use the civ choice as default input
+        ParamIn.SwitchVarIndexTime='attribute';
+        ListVelType=get(handles.VelType,'String');
+        VelType=ListVelType{get(handles.VelType,'Value')};
+        switch VelType
+            case 'civ1'
+                 ParamIn.TimeVarName='Civ1_Time';
+                 ParamIn.vector_x='Civ1_U';
+                 ParamIn.vector_y='Civ1_V';
+            case 'filter1'
+                 ParamIn.TimeVarName='Civ1_Time';
+                 ParamIn.vector_x='Civ1_U_smooth';
+                 ParamIn.vector_y='Civ1_V_smooth';
+            case 'civ2'
+                 ParamIn.TimeVarName='Civ2_Time';
+                 ParamIn.vector_x='Civ2_U';
+                 ParamIn.vector_y='Civ2_V';
+            case 'filter2'
+                 ParamIn.TimeVarName='Civ2_Time';
+                 ParamIn.vector_x='Civ2_U_smooth';
+                 ParamIn.vector_y='Civ2_V_smooth';
+        end
+    end
     set(handles.FixVelType,'visible','off')
-    set(handles.VelType,'visible','off')
-    set(handles.VelType_1,'visible','off')
+    set(handles.VelType,'Visible','off')
+    set(handles.VelType_1,'Visible','off')
     [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
-    hget_field=findobj(allchild(0),'name','get_field');
-    if ~isempty(hget_field)
-        delete(hget_field)
-    end
-    get_field(FileName);
+%     hget_field=findobj(allchild(0),'name','get_field');
+%     if ~isempty(hget_field)
+%         delete(hget_field)
+%     end
+    GetFieldData=get_field(FileName,ParamIn);
+    FieldList={};
+    VecColorList={};
+    XName='';
+    YName='';
+    if GetFieldData.CheckVector
+        UName=GetFieldData.PanelVectors.vector_x;
+        VName=GetFieldData.PanelVectors.vector_y;
+        XName=GetFieldData.PanelVectors.coord_x_vectors;
+        YName=GetFieldData.PanelVectors.coord_y_vectors;
+        CName=GetFieldData.PanelVectors.vec_color;
+        [FieldList,VecColorList]=set_field_list(UName,VName,CName);
+%         FieldList={['vec(' UName ',' VName ')'];...
+%             ['norm(' UName ',' VName ')'];...
+%             ['curl(' UName ',' VName ')'];...
+%             ['div(' UName ',' VName ')'];...
+%             ['strain(' UName ',' VName ')']};
+%         VecColorList={['norm(' UName ',' VName ')'];...
+%             UName;...
+%             VName};...
+%             if ~isempty(CName)
+%             VecColorList=[{CName};VecColorList];
+%             end
+    end
+    if GetFieldData.CheckScalar
+        AName=GetFieldData.PanelScalar.scalar;
+        XName=GetFieldData.PanelScalar.coord_x_scalar;
+        YName=GetFieldData.PanelScalar.coord_y_scalar;
+        FieldList={AName};
+    end
+    if GetFieldData.CheckPlot1D
+        XName=GetFieldData.CheckPlot1D.abscissa;
+        YName=GetFieldData.CheckPlot1D.ordinate;
+    end
+    set(handles.Coord_x,'String',{XName})
+    set(handles.Coord_y,'String',{YName})
+    set(handles.FieldName,'Value',1)
+    set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
+    set(handles.ColorScalar,'Value',1)
+    set(handles.ColorScalar,'String',VecColorList);
+    UvData.FileType{1}='netcdf';
+    set(handles.uvmat,'UserData',UvData)
+    run0_Callback(hObject, eventdata, handles)
     return %no further action
 end
 
-UvData=get(handles.uvmat,'UserData');
+
 
 %read the rootfile input display
@@ -3107,5 +3177,4 @@
 indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
 set(handles.FileIndex,'String',indices)
-% set(handles.NomType,'String',NomType)
 
 %common to Fields_1_Callback
@@ -3413,7 +3482,7 @@
 % 
 if isequal(get(handles.edit_vect,'Value'),1)
-    test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
-    test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
-    if ~test_civ2 && ~test_civ1
+    VelTypeMenu=get(handles.VelType,'String');
+    VelType=VelTypeMenu{get(handles.VelType,'Value')};
+    if ~strcmp(VelType,'civ2') && ~strcmp(VelType,'civ1')
         msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
     end 
@@ -3814,4 +3883,16 @@
 function CheckDecimate4_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
+if isequal(get(handles.CheckDecimate4,'Value'),1)
+    set(handles.CheckDecimate16,'Value',0)
+end
+update_plot(handles);
+
+%------------------------------------------------------------------------
+% --- Executes on selection change in CheckDecimate16 (nb_vec/16).
+function CheckDecimate16_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+if isequal(get(handles.CheckDecimate16,'Value'),1)
+    set(handles.CheckDecimate4,'Value',0)
+end
 update_plot(handles);
 
@@ -4341,9 +4422,56 @@
 % --------------------------------------------------------------------
 function MenuExportAxis_Callback(hObject, eventdata, handles)
-answer=msgbox_uvmat('CONFIRMATION','select a figure/axis on which the current uvmat plot will be exported')
-if strcmp(answer,'Yes')
-hchild=get(handles.PlotAxes,'children');
-copyobj(hchild,gca);
-end
+ListFig=findobj(allchild(0),'Type','figure');
+nb_option=0;
+menu={};
+for ilist=1:numel(ListFig)
+    FigName=get(ListFig(ilist),'name');
+    if isempty(FigName)
+        FigName=['figure ' num2str(ListFig(ilist))];
+    end
+    if ~strcmp(FigName,'uvmat')
+        ListAxes=findobj(ListFig(ilist),'Type','axes');
+        ListTags=get(ListAxes,'Tag');
+        if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1))
+            ListAxes=ListAxes(~strcmp('Colorbar',ListTags));
+            if numel(ListAxes)==1
+                nb_option=nb_option+1;
+                menu{nb_option}=FigName ;
+                AxesHandle(nb_option)=ListAxes;
+            else
+                nb_axis=0;
+                for iaxes=1:numel(ListAxes)
+                    nb_axis=nb_axis+1;
+                    nb_option=nb_option+1;
+                    menu{nb_option}=[FigName '_' num2str(nb_axis)];
+                    AxesHandle(nb_option)=ListAxes(nb_axis);
+                end
+            end
+        end
+    end
+end
+if isempty(menu)
+    answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?');
+    if strcmp(answer,'Yes')
+        hfig=figure;
+        copyobj(handles.PlotAxes,hfig);
+    else
+        return
+    end
+    map=colormap(handles.PlotAxes);
+    colormap(map);%transmit the current colormap to the zoom fig
+    colorbar
+else
+    answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu);
+    if isempty(answer)
+        return
+    else
+        axes(AxesHandle(answer))
+        hold on
+        hchild=get(handles.PlotAxes,'children');
+        copyobj(hchild,gca);
+    end
+end
+
 
 %------------------------------------------------------------------------
@@ -4505,5 +4633,5 @@
 %------------------------------------------------------------------------
 data.Type='volume';
-data.ProjMode='interp';%default
+data.ProjMode='interp_lin';%default
 data.ProjModeMenu={};
 % set(handles.create,'Visible','on')
@@ -5019,2 +5147,3 @@
 % --- Executes on button press in CheckColorBar.
 function CheckColorBar_Callback(hObject, eventdata, handles)
+
