Index: /trunk/src/find_field_cells.m
===================================================================
--- /trunk/src/find_field_cells.m	(revision 673)
+++ /trunk/src/find_field_cells.m	(revision 674)
@@ -107,13 +107,14 @@
 
 %% find scattered (unstructured) coordinates
-ivar_coord_x=find(strcmp('coord_x',Role));
-% VarDimCell=cell(numel(ivar_coord_x));
+ivar_coord_x=find(strcmp('coord_x',Role));%find variables with Role='coord_x'
 check_select=false(1,nbvar);
 check_coord=false(1,nbvar);
 CellInfo=cell(1,numel(ivar_coord_x));
 NbDim=zeros(1,numel(ivar_coord_x));
+% loop on unstructured coordinate x -> different field cells
 for icell=1:numel(ivar_coord_x)
-    DimCell=Data.VarDimName{ivar_coord_x(icell)};
-    if ischar(DimCell),DimCell={DimCell};end
+    DimCell=Data.VarDimName{ivar_coord_x(icell)};% cell of dimension names for ivar_coord_x(icell)
+    if ischar(DimCell),DimCell={DimCell};end % transform char to cell for a single dimension
+    % look for variables sharing dimension(s) with ivar_coord_x(icell)
     check_cell=zeros(numel(DimCell),nbvar);
     for idim=1:numel(DimCell)
@@ -123,5 +124,5 @@
     end
     check_cell=sum(check_cell,1)==numel(DimCell);%logical array=1 for variables belonging to the current cell
-    VarIndex=find(check_cell);
+    VarIndex=find(check_cell);% list of detected variable indices
     if ~(numel(VarIndex)==1 && numel(DimCell)==1)% exclude case of isolated coord_x variable (treated later)
         if ~(numel(VarIndex)==1 && numel(DimCell)>1)% a variable is associated to coordinate
@@ -132,6 +133,6 @@
             else
                 for idim=1:numel(DimCell)
-                 check_index= strcmp(DimCell{idim},Data.ListDimName);
-                 CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index);
+                    check_index= strcmp(DimCell{idim},Data.ListDimName);
+                    CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index);
                 end
                 CellInfo{icell}.CoordSize=prod(CellInfo{icell}.CoordSize);
@@ -291,9 +292,4 @@
 NbDim=[NbDim NewNbDim];
 CellInfo=[CellInfo NewCellInfo];
-% 
-% %% suppress empty cells
-% check_empty=cellfun(@isempty,CellInfo);
-% CellInfo(check_empty)=[];
-% NbDim(check_empty)=[];
 
 %% suppress empty cells or cells with a single coordinate variable 
@@ -308,6 +304,4 @@
 
 %% document roles of non-coordinate variables
-% ListRole={'vector_x','vector_y','vector_z','vector_x_tps','vector_y_tps','warnflag','errorflag',...
-%    'ancillary','image','color','discrete','scalar'};% except coord,coord_x,_y,_z,Coord_tps already taken, into account
 for icell=1:numel(CellInfo)
     VarIndex=CellInfo{icell}.VarIndex;
Index: /trunk/src/find_imadoc.m
===================================================================
--- /trunk/src/find_imadoc.m	(revision 673)
+++ /trunk/src/find_imadoc.m	(revision 674)
@@ -15,5 +15,5 @@
     dotchar=regexp(SubDir,'\.');
     for idot=1:numel(dotchar)
-        XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)) '.xml']);
+        XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)-1) '.xml']);
         if exist(XmlFileName,'file')
             SubDirBase=fullfile(RootPath,SubDir(1:dotchar(end-idot+1)));
Index: /trunk/src/geometry_calib.m
===================================================================
--- /trunk/src/geometry_calib.m	(revision 673)
+++ /trunk/src/geometry_calib.m	(revision 674)
@@ -97,25 +97,25 @@
 ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
 Left=ScreenSize(3)- 460; %right edge close to the right, with margin=40 (GUI width=420 px)
-if ScreenSize(4)>880
+if ScreenSize(4)>920
     Height=840;%default height of the GUI
     Bottom=ScreenSize(4)-Height-40; %put fig at top right
 else
-    Height=ScreenSize(4)-40;
-    Bottom=0; % GUI lies o the screen bottom
-end
-set(handles.calib_type,'Position',[1 Height-30 194 30])%  rank 1
-set(handles.APPLY,'Position',[197 Height-30 110 30])%  rank 1
-set(handles.REPLICATE,'Position',[309 Height-30 110 30])%  rank 1
-set(handles.Intrinsic,'Position',[1 Height-30-2-92 418 92])%  rank 2
-set(handles.Extrinsic,'Position',[1 Height-30-4-92-75 418 75])%  rank 3
-set(handles.PointLists,'Position',[1 Height-30-6-92-75-117 418 117]) %  rank 4
-set(handles.CheckEnableMouse,'Position',[3 Height-30-8-92-75-117-30 203 30])%  rank 5
-set(handles.PLOT,'Position',[3 Height-384 120 30])%  rank 6
-set(handles.Copy,'Position',[151 Height-384 120 30])%  rank 6
-set(handles.CLEAR_PTS,'Position',[297 Height-384 120 30])%  rank 6
-set(handles.phys_title,'Position',[38 Height-416 125 20])%  rank 7
-set(handles.CoordUnit,'Position',[151 Height-416 120 30])%  rank 7
-set(handles.px_title,'Position',[272 Height-416 125 20])%  rank 7
-set(handles.ListCoord,'Position',[1 20 418 Height-436])% rank 8
+    Height=ScreenSize(4)-80;
+    Bottom=40; % GUI lies o the screen bottom (with margin =40)
+end
+set(handles.calib_type,'Position',[1 Height-40 194 30])%  rank 1
+set(handles.APPLY,'Position',[197 Height-40 110 30])%  rank 1
+set(handles.REPLICATE,'Position',[309 Height-40 110 30])%  rank 1
+set(handles.Intrinsic,'Position',[1 Height-40-2-92 418 92])%  rank 2
+set(handles.Extrinsic,'Position',[1 Height-40-4-92-75 418 75])%  rank 3
+set(handles.PointLists,'Position',[1 Height-40-6-92-75-117 418 117]) %  rank 4
+set(handles.CheckEnableMouse,'Position',[3 Height-40-8-92-75-117-30 203 30])%  rank 5
+set(handles.PLOT,'Position',[3 Height-394 120 30])%  rank 6
+set(handles.Copy,'Position',[151 Height-394 120 30])%  rank 6
+set(handles.CLEAR_PTS,'Position',[297 Height-394 120 30])%  rank 6
+set(handles.phys_title,'Position',[38 Height-426 125 20])%  rank 7
+set(handles.CoordUnit,'Position',[151 Height-426 120 30])%  rank 7
+set(handles.px_title,'Position',[272 Height-426 125 20])%  rank 7
+set(handles.ListCoord,'Position',[1 20 418 Height-446])% rank 8
 set(handles.geometry_calib,'Position',[Left Bottom 420 Height])
 
@@ -1149,27 +1149,4 @@
 set(handles.ListCoordFiles,'string',listfile);
 
-%------------------------------------------------------------------------
-% --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
-function key_press_fcn(hObject,eventdata,handles)
-%------------------------------------------------------------------------
-xx=double(get(handles.geometry_calib,'CurrentCharacter')); %get the keyboard character
-%if ismember(xx,[8 127])%backspace or delete
-if ismember(xx,[30 31 8 127])
-    Coord=get(handles.ListCoord,'Data');
-    ind=find(Coord(:,6));
-    Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark
-    switch xx
-        case 30 % arrow upward
-            Coord(ind-1,6)=1;
-        case 31% arrow downward
-            Coord(ind+1,6)=1;
-        case {8 127}% remove line
-            Coord(ind,:)=[];
-    end
-    set(handles.ListCoord,'Data',Coord);
-    PLOT_Callback(hObject,eventdata,handles)
-end
-
-
 
 %------------------------------------------------------------------------
@@ -1240,7 +1217,9 @@
         set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
     end
+    if isfield(GeometryCalib,'SourceCalib')
     calib=GeometryCalib.SourceCalib.PointCoord;
     Coord=[calib zeros(size(calib,1),1)];
     set(handles.ListCoord,'Data',Coord)
+    end
 %     CoordCell=reshape(CoordCell,[],5);
 %     Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
@@ -1284,10 +1263,6 @@
 % --- Executes when user attempts to close geometry_calib.
 function geometry_calib_CloseRequestFcn(hObject, eventdata, handles)
-% hObject    handle to geometry_calib (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hint: delete(hObject) closes the figure
-delete(hObject);
+
+delete(hObject); % closes the figure
 
 %------------------------------------------------------------------------
@@ -1331,5 +1306,5 @@
 
 %------------------------------------------------------------------------ 
-% --- Executes on button press in Copy.
+% --- Executes on button press in Copy: display Coord on the Matlab work space
 %------------------------------------------------------------------------
 function Copy_Callback(hObject, eventdata, handles)
@@ -1341,17 +1316,21 @@
 commandwindow; %brings the Matlab command window to the front
 
-
+%------------------------------------------------------------------------ 
 % --- Executes when selected cell(s) is changed in ListCoord.
+%------------------------------------------------------------------------ 
 function ListCoord_CellSelectionCallback(hObject, eventdata, handles)
+
 if ~isempty(eventdata.Indices)
-iline=eventdata.Indices(1);% selected line number
-Data=get(handles.ListCoord,'Data');
-Data(:,6)=zeros(size(Data,1),1);
-Data(iline,6)=1;% mark the selected line
-set(handles.ListCoord,'Data',Data)
-update_calib_marker(Data(iline,:))
-end 
-
+    iline=eventdata.Indices(1);% selected line number
+    Data=get(handles.ListCoord,'Data');
+    Data(:,6)=zeros(size(Data,1),1);
+    Data(iline,6)=1;% mark the selected line
+    set(handles.ListCoord,'Data',Data)
+    update_calib_marker(Data(iline,:))
+end
+
+%------------------------------------------------------------------------ 
 % --- Executes when entered data in editable cell(s) in ListCoord.
+%------------------------------------------------------------------------ 
 function ListCoord_CellEditCallback(hObject, eventdata, handles)
 
@@ -1366,4 +1345,32 @@
 PLOT_Callback(hObject, eventdata, handles)
 
+%------------------------------------------------------------------------
+% --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
+%------------------------------------------------------------------------
+function key_press_fcn(hObject,eventdata,handles)
+
+xx=double(get(handles.geometry_calib,'CurrentCharacter')); %get the keyboard character
+%if ismember(xx,[8 127])%backspace or delete
+if ismember(xx,[30 31 8 127])% arrow upward, downward, backspace or delete
+    Coord=get(handles.ListCoord,'Data');
+    ind=find(Coord(:,6));
+    Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark
+    switch xx
+        case 30 % arrow upward
+            Coord(ind-1,6)=1;
+        case 31% arrow downward
+            Coord(ind+1,6)=1;
+        case {8 127}% remove line
+            Coord(ind,:)=[];
+    end
+    set(handles.ListCoord,'Data',Coord);
+    PLOT_Callback(hObject,eventdata,handles)
+end
+
+
+
+%------------------------------------------------------------------------
+% --- update the plot of calibration points
+%------------------------------------------------------------------------ 
 function update_calib_marker(Coord)
 %% update the plot on uvmat
Index: /trunk/src/get_field.m
===================================================================
--- /trunk/src/get_field.m	(revision 673)
+++ /trunk/src/get_field.m	(revision 674)
@@ -1,6 +1,18 @@
 %'get_field': display variables and attributes from a Netcdf file, and OK selected fields
 %------------------------------------------------------------------------
-%function varargout = get_field(varargin)
+% GetFieldData=get_field(FileName,ParamIn)
 % associated with the GUI get_field.fig
+%
+% OUPUT:
+% GetFieldData: structure containing the information on the selected
+%      fields, obtained by applying the fct red_GUI to the GUI get_field
+%   .FieldOption='vectors': variables are used for vector plot
+%                  'scalar': variables are used for scalar plot, 
+%                  '1Dplot': variables are used for usual x-y plot,
+%                  'civdata...': go back to automatic reading of civ data
+%   .PanelVectors: sub-structure variables used as vector components
+%   .PanelScalar:
+% INPUT:
+% FileName: name (including path) of the netcdf file to open
 %
 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@@ -42,5 +54,5 @@
 end
 % End initialization code - DO NOT EDIT
-
+      
 %------------------------------------------------------------------------
 % --- Executes just before get_field is made visible.
@@ -54,15 +66,19 @@
 
 %% enter input data
-set(handles.inputfile,'String',filename)% fill the input file name
-Field=nc2struct(filename,[]);% reads the  field structure, without the variables
+if ischar(filename)% input file name
+    set(handles.inputfile,'String',filename)% fill the input file name
+    Field=nc2struct(filename,[]);% reads the  field structure, without the variables
+else
+    'bad input to get_field'
+end
+if ~exist('ParamIn','var')
+    ParamIn=[];
+end
 if isfield(Field,'Txt')
-    msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input fiel reading
+    msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input file reading
     return
 end
 if ~isfield(Field,'ListVarName')
     return
-end
-if ~exist('ParamIn','var')
-    ParamIn=[];
 end
 
@@ -111,10 +127,8 @@
 ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index
 % look at global attributes with numerical values
-check_numvalue=false;
-check_time=false;
+check_numvalue=false(1,numel(Field.ListGlobalAttribute));
 for ilist=1:numel(Field.ListGlobalAttribute)
     Value=Field.(Field.ListGlobalAttribute{ilist});
     check_numvalue(ilist)=isnumeric(Value);
-    check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1));
 end
 Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value
@@ -122,10 +136,17 @@
     ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute
 end
-nboption=numel(ListSwitchVarIndexTime);
 if Field.MaxDim>=2
     ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index
 end
-if ~isempty(find(check_time, 1))
+
+%% select the Time attribute from input
+if isfield(ParamIn,'TimeAttrName')
+    time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1);
+else
+    time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);
+end
+if ~isempty(time_index)
     set(handles.SwitchVarIndexTime,'Value',2);
+    set(handles.TimeName,'UserData',time_index)
 else
     set(handles.SwitchVarIndexTime,'Value',1);
@@ -150,11 +171,23 @@
 end
 if Field.MaxDim>=2 % case of 2D (or 3D) fields
-    if isfield(CellInfo{imax},'VarIndex_vector_x') &&  isfield(CellInfo{imax},'VarIndex_vector_y')
+    check_vec_input=0;
+    if isfield(ParamIn,'vector_x')&& isfield(ParamIn,'vector_y')
+        ichoice_x=find(strcmp(ParamIn.vector_x,Field.Display.ListVarName),1);
+        ichoice_y=find(strcmp(ParamIn.vector_y,Field.Display.ListVarName),1);
+        if ~isempty(ichoice_x)&&~isempty(ichoice_y)
+            set(handles.vector_x,'UserData',ichoice_x)
+            set(handles.vector_y,'UserData',ichoice_y)
+            check_vec_input=1;
+        end
+    end
+    if ~check_vec_input && isfield(CellInfo{imax},'VarIndex_vector_x') &&  isfield(CellInfo{imax},'VarIndex_vector_y')
+        set(handles.vector_x,'UserData',CellInfo{imax}.VarIndex_vector_x(1))
+        set(handles.vector_y,'UserData',CellInfo{imax}.VarIndex_vector_y(1))
+        check_vec_input=1;
+    end
+    if check_vec_input
         set(handles.FieldOption,'Value',3)% set vector selection option
-        set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1))
-        set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1))
-        set(handles.FieldOption,'Value',3)
     else
-        set(handles.FieldOption,'Value',2)
+        set(handles.FieldOption,'Value',2)% set scalar selection option
     end
 else % case of 1D fields
@@ -177,8 +210,4 @@
 %% fill menus for coordinates and time
 FieldOption_Callback(handles.variables,[], handles)% list the global attributes
-%     if isfield(CellInfo{imax},'VarIndex_coord_x')&&  isfield(CellInfo{imax},'VarIndex_coord_y')
-%         set(handles.Coord_x,'Value',CellInfo{imax}.VarIndex_coord_x(1))
-%         set(handles.Coord_y,'Value',CellInfo{imax}.VarIndex_coord_y(1))
-%     end
 
 %% Make choices of coordinates from input
@@ -214,6 +243,4 @@
 return
 
-SwitchVarIndexTime_Callback([],[], handles)
-
 %% set z coordinate menu if relevant
 if Field.MaxDim>=3
@@ -227,4 +254,9 @@
     set(handles.Coord_z,'Visible','off')
     set(handles.Z_title,'Visible','off')
+end
+
+%% make selections according to ParamIn
+if isfield(ParamIn,'vector_x') && isfield(ParamIn,'vector_y')
+    
 end
 
@@ -300,5 +332,5 @@
             for iline=1:length(attr_list)
                 Tabcell{iline,1}=attr_list{iline};
-                eval(['val=VarAttr.' attr_list{iline} ';'])
+                val=VarAttr.(attr_list{iline}) ;
                 if ischar(val);
                     Tabcell{iline,2}=val;
@@ -406,10 +438,10 @@
         end       
         scalar_Callback(hObject, eventdata, handles)
-        
+             
     case 'vectors'
+        set(handles.PanelVectors,'Visible','on')
         set(handles.Coordinates,'Visible','on')
         set(handles.PanelOrdinate,'Visible','off')
         set(handles.PanelScalar,'Visible','off')
-        set(handles.PanelVectors,'Visible','on')
         pos=get(handles.PanelVectors,'Position');
         pos(1)=2;
@@ -420,25 +452,32 @@
         set(handles.Y_title,'Visible','on')
         %default vector selection
-        test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
-        for ilist=1:numel(Field.Display.VarDimName)
-            if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role')
-                Role=Field.Display.VarAttribute{ilist}.Role;
-                if strcmp(Role,'coord_x')||strcmp(Role,'coord_y')
+        vector_x_value=get(handles.vector_x,'UserData');
+        vector_y_value=get(handles.vector_y,'UserData');
+        if ~isempty(vector_x_value)&&~isempty(vector_y_value)
+            set(handles.vector_x,'Value',vector_x_value)
+            set(handles.vector_y,'Value',vector_y_value)
+        else
+            test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate
+            for ilist=1:numel(Field.Display.VarDimName)
+                if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role')
+                    Role=Field.Display.VarAttribute{ilist}.Role;
+                    if strcmp(Role,'coord_x')||strcmp(Role,'coord_y')
+                        test_coord(ilist)=1;
+                    end
+                end
+                dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
+                if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable
                     test_coord(ilist)=1;
                 end
             end
-            dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
-            if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable
-                test_coord(ilist)=1;
+            vector_index=find(~test_coord,2);%get the two first variables not a coordinate
+            if isempty(vector_index)
+                set(handles.vector_x,'Value',1)
+                set(handles.vector_y,'Value',2)
+            else
+                set(handles.vector_x,'Value',vector_index(1))
+                set(handles.vector_y,'Value',vector_index(2))
             end
         end
-        vector_index=find(~test_coord,2);%get the first variable not a coordiante
-        if isempty(vector_index)
-            set(handles.vector_x,'Value',1)
-            set(handles.vector_y,'Value',2)
-        else
-            set(handles.vector_x,'Value',vector_index(1))
-            set(handles.vector_y,'Value',vector_index(2))
-        end       
         vector_Callback(handles)
         
@@ -525,5 +564,5 @@
 end  
 update_field(handles,YName)
-
+         
 %------------------------------------------------------------------------
 % --- Executes on selection change in scalar menu.
@@ -801,20 +840,22 @@
     case 'attribute'
         set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes
-        time_index=[];
-        PreviousList=get(handles.TimeName, 'String');
-        index=[];
-        if ~isempty(PreviousList)
-            PreviousAttr=PreviousList{get(handles.TimeName, 'Value')};
-            index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes));
-        end
-        if isempty(index)
-            time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time'
-        end
+        time_index=get(handles.TimeName,'UserData');    %select the input data
+        if isempty(time_index)
+            PreviousList=get(handles.TimeName, 'String');
+            if ~isempty(PreviousList)
+                PreviousAttr=PreviousList{get(handles.TimeName, 'Value')};
+                index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes),1);
+            end
+        end
+        if isempty(time_index)
+            time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% index of the attributes containing the string 'Time'
+        end      
         if ~isempty(time_index)
-            set(handles.TimeName,'Value',time_index(1))
+            set(handles.TimeName,'Value',time_index)
         else
             set(handles.TimeName,'Value',1)
         end
         set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute)
+
     case 'variable'% TimeName menu represents the available variables
         set(handles.TimeName, 'Visible','on')
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 673)
+++ /trunk/src/plot_field.m	(revision 674)
@@ -545,12 +545,8 @@
 function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo,haxes,PlotParam,PosColorbar)
 %-------------------------------------------------------------------
-
+PlotType='plane';
 grid(haxes, 'off')% remove grid (possibly remaining from other graphs)
+
 %default plotting parameters
-PlotType='plane';%default
-% if ~exist('PlotParam','var')
-%     PlotParam=[];
-% end
-
 if ~isfield(PlotParam,'Scalar')
     PlotParam.Scalar=[];
@@ -559,10 +555,10 @@
     PlotParam.Vectors=[];
 end
-
 PlotParamOut=PlotParam;%default
-hfig=get(haxes,'parent');
+errormsg='';%default
+
+hfig=get(haxes,'parent');%handle of the figure containing the plot axes
 hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
 hima=findobj(haxes,'Tag','ima');% search existing image in the current axes
-errormsg='';%default
 test_ima=0; %default: test for image or map plot
 test_vec=0; %default: test for vector plots
@@ -574,6 +570,7 @@
 YName='';
 y_units='';
-for icell=1:numel(CellInfo) % length(CellVarIndex) =1 or 2 (from the calling function)
-%     VarRole=CellInfo{icell};
+
+% loop on the input field cells
+for icell=1:numel(CellInfo) 
     if strcmp(CellInfo{icell}.CoordType,'tps') %do not plot directly tps data (used for projection only)
         continue
@@ -600,24 +597,24 @@
     ivar_F=[];
     if isfield(CellInfo{icell},'VarIndex_warnflag')
-    ivar_F=CellInfo{icell}.VarIndex_warnflag; %defines index (unique) for warning flag variable
-    end
-    ivar_FF=[];
-    if isfield(CellInfo{icell},'VarIndex_errorflag')
-    ivar_FF=CellInfo{icell}.VarIndex_errorflag; %defines index (unique) for error flag variable
-    end
+        ivar_F=CellInfo{icell}.VarIndex_warnflag; %defines index (unique) for warning flag variable
+    end
+    ivar_FF_vec=[];
     if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') % vector components detected
-        if test_vec
+        if test_vec% a vector field has been already detected
             errormsg='error in plot_field: attempt to plot two vector fields: to get the difference project on a plane with mode interp';
             return
         else
             test_vec=1;
-            vec_U=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_x}); 
+            if isfield(CellInfo{icell},'VarIndex_errorflag')
+                ivar_FF_vec=CellInfo{icell}.VarIndex_errorflag; %defines index (unique) for error flag variable
+            end
+            vec_U=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_x});
             vec_V=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_y});
-            if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates 
+            if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates
                 XName=Data.ListVarName{CellInfo{icell}.CoordIndex(end)};
                 YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
                 vec_X=reshape(Data.(XName),[],1); %transform vectors in column matlab vectors
                 vec_Y=reshape(Data.(YName),[],1);
-            elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates 
+            elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates
                 y=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
                 x=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)});
@@ -628,5 +625,5 @@
                     x=linspace(x(1),x(2),size(vec_U,2));
                 end
-                [vec_X,vec_Y]=meshgrid(x,y);  
+                [vec_X,vec_Y]=meshgrid(x,y);
             end
             if isfield(PlotParam.Vectors,'ColorScalar') && ~isempty(PlotParam.Vectors.ColorScalar)
@@ -637,32 +634,32 @@
                 end
             end
-            if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1)) 
-                if test_vec 
+            if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1))
+%                 if test_vec
                     vec_F=Data.(Data.ListVarName{ivar_F}); % warning flags for  dubious vectors
-                    if  ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1)) 
+                    if  ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1))
                         test_black=1;
                     end
-                end
-            end
-            if ~isempty(ivar_FF) %&& ~test_false
-                if test_vec% TODO: deal with FF for structured coordinates
-                    vec_FF=Data.(Data.ListVarName{ivar_FF}); % flags for false vectors
-                end
+%                 end
+            end
+            if ~isempty(ivar_FF_vec) %&& ~test_false
+%                 if test_vec% TODO: deal with FF for structured coordinates
+                    vec_FF=Data.(Data.ListVarName{ivar_FF_vec}); % flags for false vectors
+%                 end
             end
         end
     elseif ~isempty(ivar_C) %scalar or image
         if test_ima
-             errormsg='attempt to plot two scalar fields or images';
+            errormsg='attempt to plot two scalar fields or images';
             return
         end
         A=squeeze(Data.(Data.ListVarName{ivar_C}));% scalar represented as color image
         test_ima=1;
-        if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates 
+        if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates
             A=reshape(A,1,[]);
             XName=Data.ListVarName{ivar_X};
             YName=Data.ListVarName{ivar_Y};
-            eval(['AX=reshape(Data.' XName ',1,[]);']) 
+            eval(['AX=reshape(Data.' XName ',1,[]);'])
             eval(['AY=reshape(Data.' YName ',1,[]);'])
-            [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256');  % interpolate on a grid  
+            [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256');  % interpolate on a grid
             if isfield(Data,'VarAttribute')
                 if numel(Data.VarAttribute)>=ivar_X && isfield(Data.VarAttribute{ivar_X},'units')
@@ -672,8 +669,8 @@
                     y_units=[' (' Data.VarAttribute{ivar_Y}.units ')'];
                 end
-            end        
-        elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates 
+            end
+        elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates
             YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
-            AY=Data.(YName); 
+            AY=Data.(YName);
             AX=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)});
             test_interp_X=0; %default, regularly meshed X coordinate
@@ -686,5 +683,5 @@
                     y_units=Data.VarAttribute{CellInfo{icell}.CoordIndex(end-1)}.units;
                 end
-            end  
+            end
             if numel(AY)>2
                 DAY=diff(AY);
@@ -692,7 +689,7 @@
                 DAY_max=max(DAY);
                 if sign(DAY_min)~=sign(DAY_max);% =1 for increasing values, 0 otherwise
-                     errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(1)} ];
-                      return
-                end 
+                    errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(1)} ];
+                    return
+                end
                 test_interp_Y=(DAY_max-DAY_min)> 0.0001*abs(DAY_max);
             end
@@ -702,34 +699,31 @@
                 DAX_max=max(DAX);
                 if sign(DAX_min)~=sign(DAX_max);% =1 for increasing values, 0 otherwise
-                     errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(2)} ];
-                      return
-                end 
+                    errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(2)} ];
+                    return
+                end
                 test_interp_X=(DAX_max-DAX_min)> 0.0001*abs(DAX_max);
-            end  
-            if test_interp_Y          
+            end
+            if test_interp_Y
                 npxy(1)=max([256 floor((AY(end)-AY(1))/DAY_min) floor((AY(end)-AY(1))/DAY_max)]);
                 yI=linspace(AY(1),AY(end),npxy(1));
                 if ~test_interp_X
-                    xI=linspace(AX(1),AX(end),size(A,2));%default 
+                    xI=linspace(AX(1),AX(end),size(A,2));%default
                     AX=xI;
                 end
             end
-            if test_interp_X  
+            if test_interp_X
                 npxy(2)=max([256 floor((AX(end)-AX(1))/DAX_min) floor((AX(end)-AX(1))/DAX_max)]);
-                xI=linspace(AX(1),AX(end),npxy(2));   
+                xI=linspace(AX(1),AX(end),npxy(2));
                 if ~test_interp_Y
-                   yI=linspace(AY(1),AY(end),size(A,1)); 
-                   AY=yI;
-                end
-            end
-            if test_interp_X || test_interp_Y               
+                    yI=linspace(AY(1),AY(end),size(A,1));
+                    AY=yI;
+                end
+            end
+            if test_interp_X || test_interp_Y
                 [AX2D,AY2D]=meshgrid(AX,AY);
                 A=interp2(AX2D,AY2D,double(A),xI,yI');
             end
-            AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation 
+            AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation
             AY=[AY(1) AY(end)];
-%         else
-%             errormsg='error in plot_field: invalid coordinate definition ';
-%             return
         end
     end
@@ -742,7 +736,6 @@
             y_units=Data.CoordUnit;
         end
-    end
-        
-end 
+    end   
+end
 
 %%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1092,5 +1085,5 @@
            vec_F=vec_F(ind_sel);
         end
-        if ~isempty(ivar_FF)
+        if ~isempty(ivar_FF_vec)
            vec_FF=vec_FF(ind_sel);
         end
@@ -1106,6 +1099,5 @@
        nbcolor=nbcolor+1;
        colorlist(nbcolor,:)=[0 0 0]; %add black to the list of colors
-       if ~isempty(ivar_FF)
-          %  ind_flag=find(vec_F~=1 & vec_F~=0 & vec_FF==0);  %flag warning but not false
+       if ~isempty(ivar_FF_vec)
             col_vec(vec_F~=1 & vec_F~=0 & vec_FF==0)=nbcolor;
        else
@@ -1114,5 +1106,5 @@
     end
     nbcolor=nbcolor+1;
-    if ~isempty(ivar_FF)
+    if ~isempty(ivar_FF_vec)
         if isfield(PlotParam.Vectors,'CheckHideFalse') && PlotParam.Vectors.CheckHideFalse==1
             colorlist(nbcolor,:)=[NaN NaN NaN];% no plot of false vectors
Index: /trunk/src/read_civdata.m
===================================================================
--- /trunk/src/read_civdata.m	(revision 673)
+++ /trunk/src/read_civdata.m	(revision 674)
@@ -133,25 +133,26 @@
 for ivar=1:numel(var_ind)
     Field.VarAttribute{ivar}.Role=role{var_ind(ivar)};
+    Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
+    Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
     if strcmp(role{var_ind(ivar)},'vector_x')
         Field.VarAttribute{ivar}.FieldName=FieldNames;
-        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
+%         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;
+%         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
         ivar_U_tps=ivar;
     end
     if strcmp(role{var_ind(ivar)},'vector_y')
         Field.VarAttribute{ivar}.FieldName=FieldNames;
-        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
+%         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;
+%         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
         ivar_V_tps=ivar;
     end
-    Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
 end
 if ~isempty(ivar_U_tps)
Index: /trunk/src/set_object.m
===================================================================
--- /trunk/src/set_object.m	(revision 673)
+++ /trunk/src/set_object.m	(revision 674)
@@ -93,5 +93,5 @@
     ZBounds=0; %default 
 end
-set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front)
+set(handles.Coord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function (allow action on uvmat when set_object is in front)
 set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
 set(hObject,'DeleteFcn',{@closefcn})
@@ -722,17 +722,40 @@
     % add lines if multi line input needed
     case{'points','polyline','polygon'}
+        Input=str2num(eventdata.EditData);%pasted input
         Coord=get(handles.Coord,'Data');
-        if ~isnan(Coord(end,1))
-            if isequal(size(Coord,2),3)
-                %Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case)
-                Coord=[Coord;NaN NaN NaN]; %add a line for edition (3D case)
+        iline=eventdata.Indices(1);% selected line number
+        if size(Coord,1)<iline+numel(Input)
+            Coord=[Coord ; zeros(iline+numel(Input)-size(Coord,1),size(Coord,2))];% append zeros to fit the new column
+        end
+        Coord(iline:iline+numel(Input)-1,eventdata.Indices(2))=Input';
+        set(handles.Coord,'Data',Coord)
+end
+
+% --- Executes when selected cell(s) is changed in ListCoord.
+function Coord_CellSelectionCallback(hObject, eventdata, handles)
+
+if ~isempty(eventdata.Indices)
+    iline=eventdata.Indices(1);% selected line number
+    set(handles.Coord,'UserData',iline)
+end
+
+%------------------------------------------------------------------------
+% --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
+%------------------------------------------------------------------------
+function key_press_fcn(hObject,eventdata,handles)
+
+xx=double(get(handles.set_object,'CurrentCharacter')); %get the keyboard character
+if ismember(xx,[8 127 31])%backspace or delete, or downward
+    Coord=get(handles.Coord,'Data');
+    iline=get(handles.Coord,'UserData');
+            if isequal(xx, 31)
+                if isequal(iline,size(Coord,1))% arrow downward
+                Coord=[Coord;zeros(1,size(Coord,2))];
+                end
             else
-                Coord=[Coord;NaN NaN]; %add a line for edition (2D case)
+    Coord(iline,:)=[];% suppress the current line 
             end
-            set(handles.Coord,'Data',Coord)
-        end
-end
-
-
+    set(handles.Coord,'Data',Coord);
+end
 
 function num_Angle_3_Callback(hObject, eventdata, handles)
Index: /trunk/src/struct2nc.m
===================================================================
--- /trunk/src/struct2nc.m	(revision 673)
+++ /trunk/src/struct2nc.m	(revision 674)
@@ -47,5 +47,5 @@
     return
 end
-%  [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure
+%check the validity of the input field structure
 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data);
 if ~isempty(errormsg)
@@ -139,9 +139,11 @@
 %'check_field_structure': check the validity of the field struture representation consistant with the netcdf format
 %------------------------------------------------------------------------
-% function [DataOut,errormsg]=check_field_structure(Data)
+% [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data)
 %
 % OUTPUT:
-% DataOut: structure reproducing the input structure Data (TODO: suppress this output)
 % errormsg: error message which is not empty when the input structure does not have the right form
+% ListDimName: list of dimension names (cell array of cahr strings)
+% DimValue: list of dimension values (numerical array with the same dimension as ListDimName)
+% VarDimIndex: cell array of dimension index (in the list ListDimName) for each element of Data.ListVarName
 %
 % INPUT:
@@ -179,11 +181,9 @@
     return
 end
-% if isfield(Data,'DimValue')
-%     Data=rmfield(Data,'DimValue');
-% end
 nbdim=0;
 ListDimName={};
 
 %% main loop on the list of variables
+VarDimIndex=cell(1,nbfield);
 for ivar=1:nbfield
     VarName=Data.ListVarName{ivar};
@@ -198,6 +198,5 @@
     elseif ~iscell(DimCell)
         errormsg=['wrong format for .VarDimName{' num2str(ivar) ' (must be the cell of dimension names of the variable ' VarName];
-        return
-        
+        return       
     end
     nbcoord=numel(sizvar);%nbre of coordinates for variable named VarName
@@ -209,8 +208,6 @@
         if nbcoord==2
             if sizvar(1)==1
-                nbcoord=1;
                 sizvar(1)=sizvar(2);
             elseif sizvar(2)==1
-                nbcoord=1;
             else
                 errormsg=['1 dimension declared in .VarDimName{' num2str(ivar) '} inconsistent with the nbre of dimensions =2 of the variable ' VarName];
@@ -227,5 +224,4 @@
         if numel(DimCell)>nbcoord
             sizvar(nbcoord+1:numel(DimCell))=1;% case of singleton dimensions (not seen by the function size)
-           % DimCell=DimCell(end-nbcoord+1:end)%first singleton diemensions omitted,
         elseif nbcoord > numel(DimCell)
             errormsg=['nbre of declared dimensions in .VarDimName{' num2str(ivar) '} smaller than the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName];
@@ -234,5 +230,4 @@
     end
     DimIndex=[];
-    %for idim=1:nbcoord
     for idim=1:numel(DimCell) %loop on the coordinates of variable #ivar
         DimName=DimCell{idim};
@@ -261,3 +256,2 @@
     VarDimIndex{ivar}=DimIndex;
 end
-DataOut=Data;
Index: /trunk/src/sub_field.m
===================================================================
--- /trunk/src/sub_field.m	(revision 673)
+++ /trunk/src/sub_field.m	(revision 674)
@@ -26,4 +26,5 @@
     return
 end
+
 %% global attributes
 SubData.ListGlobalAttribute={};%default
@@ -107,24 +108,24 @@
 %% look for coordinates common to Field in Field_1
 ind_remove=zeros(size(Field_1.ListVarName));
+% loop on the variables of the second field Field_1
 for ilist=1:numel(Field_1.ListVarName)
-    if ischar(Field_1.VarDimName{ilist})||numel(Field_1.VarDimName{ilist})==1
-        OldDim=Field_1.VarDimName{ilist};
-        if ischar(OldDim)
-            OldDim=Field_1.VarDimName(ilist);
-        end
-        VarVal=Field_1.(Field_1.ListVarName{ilist});
+    % case of variable with a single dimension
+    OldDimName=Field_1.VarDimName{ilist};
+    if ischar(OldDimName), OldDimName={OldDimName}; end% transform char string to cell if relevant
+    if numel(OldDimName)==1
+        OldDim=Field_1.(Field_1.ListVarName{ilist});% get variable
+        %look for the existence of the variable OldDim in the first field Field
         for i1=1:numel(Field.ListVarName)
-            if (isempty(ProjModeRequest{i1})&&isempty(ProjModeRequest_1{ilist})||strcmp(ProjModeRequest{i1},ProjModeRequest_1{ilist})) && isequal(Field.(Field.ListVarName{i1}),VarVal)
+            if  isequal(Field.(Field.ListVarName{i1}),OldDim) &&...
+                   ((isempty(ProjModeRequest{i1}) && isempty(ProjModeRequest_1{ilist}))  || strcmp(ProjModeRequest{i1},ProjModeRequest_1{ilist}))                
                ind_remove(ilist)=1;
-               NewDim=Field.VarDimName{i1};
-               if ischar(NewDim)
-                   NewDim={NewDim};
-               end
-               Field_1.VarDimName=regexprep_r(Field_1.VarDimName,['^' OldDim{1} '$'],NewDim{1});
+               NewDimName=Field.VarDimName{i1};
+               if ischar(NewDimName), NewDimName={NewDimName}; end %transform char chain to cell if needed
+               Field_1.VarDimName=regexprep_r(Field_1.VarDimName,['^' OldDimName{1} '$'],NewDimName{1});% change the var name of Field_1 to the corresponding var name of Field
             end
         end
     end
 end
-Field_1.ListVarName(find(ind_remove))=[];%removes these redondent coordinates
+Field_1.ListVarName(find(ind_remove))=[];%removes the redondent coordinate
 Field_1.VarDimName(find(ind_remove))=[];
 Field_1.VarAttribute(find(ind_remove))=[];
@@ -150,5 +151,4 @@
 
 %% substrat fields when possible
-%[CellVarIndex,NbDim,CellVarType,errormsg]=find_field_cells(SubData);
 [CellInfo,NbDim,errormsg]=find_field_cells(SubData);
 ind_remove=zeros(size(SubData.ListVarName));
@@ -180,7 +180,8 @@
 SubData.VarDimName(find(ind_remove))=[];
 SubData.VarAttribute(find(ind_remove))=[];
-%end
+'end'
 
 function OutputCell=regexprep_r(InputCell,search_string,new_string)
+OutputCell=InputCell;%default
 for icell=1:numel(InputCell)
     OutputCell{icell}=regexprep(InputCell{icell},search_string,new_string);
Index: /trunk/src/tps_coeff_field.m
===================================================================
--- /trunk/src/tps_coeff_field.m	(revision 673)
+++ /trunk/src/tps_coeff_field.m	(revision 674)
@@ -40,5 +40,5 @@
         X=DataIn.(DataIn.ListVarName{CellInfo{icell}.CoordIndex(end)});% value of x coordinate
         Y=DataIn.(DataIn.ListVarName{CellInfo{icell}.CoordIndex(end-1)});% value of x coordinate
-        check_interp_tps=false(numel(CellInfo{icell}.VarIndex),1);
+        check_interp_tps=false(numel(DataIn.ListVarName),1);
         %for ivar=1:numel(CellInfo{icell}.VarIndex)
         Index_interp=[];
@@ -52,13 +52,16 @@
             Index_interp=[Index_interp CellInfo{icell}.VarIndex_vector_y];
         end
-        for ivar=Index_interp
-            Attr=DataIn.VarAttribute{CellInfo{icell}.VarIndex(ivar)};
+        for iselect=1:numel(Index_interp)
+            Attr=DataIn.VarAttribute{Index_interp(iselect)};
             if ~isfield(Attr,'VarIndex_tps')&& (checkall || (isfield(Attr,'ProjModeRequest')&&strcmp(Attr.ProjModeRequest,'interp_tps')))
-                check_interp_tps(ivar)=1;
+                check_interp_tps(Index_interp(iselect))=1;
             end
         end
-        VarIndexInterp=CellInfo{icell}.VarIndex(check_interp_tps);% indices of variables to interpolate through tps
-        if ~isempty(VarIndexInterp)
-            ListVarInterp=DataIn.ListVarName(VarIndexInterp);
+        
+        %VarIndexInterp=CellInfo{icell}.VarIndex(check_interp_tps);% indices of variables to interpolate through tps
+        %         if ~isempty(VarIndexInterp)
+        ListVarInterp=DataIn.ListVarName(check_interp_tps);
+        VarIndexInterp=find(check_interp_tps);
+        if ~isempty(ListVarInterp)
             % exclude data points marked 'false' for interpolation
             if isfield(CellInfo{icell},'VarIndex_errorflag')
@@ -66,5 +69,5 @@
                 X=X(FF==0);
                 Y=Y(FF==0);
-                for ilist=1:numel(VarIndexInterp)
+                for ilist=1:numel(ListVarInterp)
                     DataIn.(ListVarInterp{ilist})=DataIn.(ListVarInterp{ilist})(FF==0);
                 end
@@ -74,12 +77,11 @@
                 term=['_' num2str(nbtps-1)];
             end
-            ListNewVar=cell(1,numel(VarIndexInterp)+3);
+            ListNewVar=cell(1,numel(ListVarInterp)+3);
             ListNewVar(1:3)={['SubRange' term],['NbCentre' term],['Coord_tps' term]};
-            for ilist=1:numel(VarIndexInterp)
+            for ilist=1:numel(ListVarInterp)
                 ListNewVar{ilist+3}=[ListVarInterp{ilist} '_tps' term];
             end
             nbvar=numel(DataIn.ListVarName);
             DataOut.ListVarName=[DataIn.ListVarName ListNewVar];
-            %ListNewDim={['nb_tps' term],['nb_subdomain' term]};
             DataOut.VarDimName=[DataIn.VarDimName {{'nb_coord','nb_bounds',['nb_subdomain' term]}} {['nb_subdomain' term]} ...
                 {{['nb_tps' term],'nb_coord',['nb_subdomain' term]}}];
@@ -91,8 +93,8 @@
                 DataOut.(['Coord_tps' term])(NbCentre(isub)+1:NbCentre(isub)+3,1:2,isub)=0;%matrix of zeros to complement the matrix Coord_tps (conveninent for file storage)
                 %fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
-%                 fill=zeros(NbCoord+1,NbCoord+1,NbCoord); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
-%                 Coord_tps=cat(1,Coord_tps,fill);
-            end         
-            for ivar=1:numel(VarIndexInterp)
+                %                 fill=zeros(NbCoord+1,NbCoord+1,NbCoord); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
+                %                 Coord_tps=cat(1,Coord_tps,fill);
+            end
+            for ivar=1:numel(ListVarInterp)
                 DataOut.VarDimName{nbvar+3+ivar}={['nb_tps' term],['nb_subdomain' term]};
                 DataOut.VarAttribute{nbvar+3+ivar}=DataIn.VarAttribute{CellInfo{icell}.VarIndex_vector_x};%reproduce attributes of velocity
@@ -112,7 +114,7 @@
             DataOut.(['SubRange' term])=SubRange;
             DataOut.(['NbCentre' term])=NbCentre;
-%             DataOut.(['Coord_tps' term])=Coord_tps;
+            %             DataOut.(['Coord_tps' term])=Coord_tps;
             for ilist=1:numel(VarIndexInterp)
-%                 Var_tps=zeros(size(IndSelSubDomain)+[NbCoord+1 0]);%default spline
+                %                 Var_tps=zeros(size(IndSelSubDomain)+[NbCoord+1 0]);%default spline
                 for isub=1:size(SubRange,3)
                     ind_sel=IndSelSubDomain(1:NbCentre(isub),isub);% array indices selected for the subdomain
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 673)
+++ /trunk/src/uvmat.m	(revision 674)
@@ -442,4 +442,6 @@
 %% display the selected field and related information
 if ~isempty(fileinput)
+    set(handles.SubField,'Value',0)
+    desable_subfield(handles)
     display_file_name(handles,fileinput)
 end
@@ -450,33 +452,7 @@
 %------------------------------------------------------------------------
 fileinput=get(hObject,'Label');
+    set(handles.SubField,'Value',0)
+    desable_subfield(handles)
 display_file_name( handles,fileinput)
-% 
-% % -----------------------------------------------------------------------
-% % --- Open again the file whose name has been recorded in MenuFile_2
-% function MenuFile_2_Callback(hObject, eventdata, handles)
-% %------------------------------------------------------------------------
-% fileinput=get(handles.MenuFile_2,'Label');
-% display_file_name(handles,fileinput)
-% 
-% % -----------------------------------------------------------------------
-% % --- Open again the file whose name has been recorded in MenuFile_3
-% function MenuFile_3_Callback(hObject, eventdata, handles)
-% %------------------------------------------------------------------------
-% fileinput=get(handles.MenuFile_3,'Label');
-% display_file_name(handles,fileinput)
-% 
-% % -----------------------------------------------------------------------
-% % --- Open again the file whose name has been recorded in MenuFile_4
-% function MenuFile_4_Callback(hObject, eventdata, handles)
-% %------------------------------------------------------------------------
-% fileinput=get(handles.MenuFile_4,'Label');
-% display_file_name(handles,fileinput)
-% 
-% % -----------------------------------------------------------------------
-% % --- Open again the file whose name has been recorded in MenuFile_5
-% function MenuFile_5_Callback(hObject, eventdata, handles)
-% %------------------------------------------------------------------------
-% fileinput=get(handles.MenuFile_5,'Label');
-% display_file_name(handles,fileinput)
 
 
@@ -681,26 +657,4 @@
     return
 end
-
-%% detect root name, nomenclature and indices in the input file name:
-[FilePath,FileName,FileExt]=fileparts(fileinput);
-% detect the file type, get the movie object if relevant, and look for the corresponding file series:
-% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
-[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
-
-if strcmp(FileType,'txt')
-    edit(fileinput)
-    return
-elseif strcmp(FileType,'xml')
-    editxml(fileinput)
-     return
-elseif strcmp(FileType,'figure')
-    open(fileinput)
-     return
-end
-
-%% set the mouse pointer to 'watch'
-set(handles.uvmat,'Pointer','watch')
-set(handles.RootPath,'BackgroundColor',[1 1 0])
-drawnow
 
 %% define the relevant handles for the first field series (index=1) or the second file series (index=2)
@@ -728,4 +682,26 @@
     set(handles.FileExt_1,'Visible','on');
     set(handles.NomType_1,'Visible','on');
+    set(handles.TimeName_1,'Visible','on')
+    set(handles.TimeValue_1,'Visible','on')
+end
+set(handles_RootPath,'BackgroundColor',[1 1 0])% paint edit box to yellow to visualise root file input
+set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch'
+drawnow
+
+%% detect root name, nomenclature and indices in the input file name:
+[FilePath,FileName,FileExt]=fileparts(fileinput);
+% detect the file type, get the movie object if relevant, and look for the corresponding file series:
+% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
+[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
+
+if strcmp(FileType,'txt')
+    edit(fileinput)
+    return
+elseif strcmp(FileType,'xml')
+    editxml(fileinput)
+     return
+elseif strcmp(FileType,'figure')
+    open(fileinput)
+     return
 end
 
@@ -820,9 +796,4 @@
         %enable other menus
         set(handles.MenuOpenCampaign,'Enable','on')
-%         set(handles.MenuCampaign_1,'Enable','on')
-%         set(handles.MenuCampaign_2,'Enable','on')
-%         set(handles.MenuCampaign_3,'Enable','on')
-%         set(handles.MenuCampaign_4,'Enable','on')
-%         set(handles.MenuCampaign_5,'Enable','on')
         set(handles.MenuExport,'Enable','on')
         set(handles.MenuExportFigure,'Enable','on')
@@ -854,6 +825,6 @@
 end
 
-%% set back the mouse pointer to arrow
-set(handles.uvmat,'Pointer','arrow')
+set(handles_RootPath,'BackgroundColor',[1 1 1])% paint back edit box to white to visualise end of root file input
+set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow
 
 
@@ -869,13 +840,9 @@
 end
 if index==1
-    handles_RootPath=handles.RootPath;
     handles_Fields=handles.FieldName;
 elseif index==2
-    handles_RootPath=handles.RootPath_1;
     handles_Fields=handles.FieldName_1;
 end
 
-set(handles_RootPath,'BackgroundColor',[1 1 0])
-drawnow
 set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening
 UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
@@ -901,8 +868,7 @@
 
 %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
+TimeUnit='';%default
+TimeName='';%default
 XmlData.Time=[];%default
-XmlData.GeometryCalib=[];%default
-TimeUnit='';%default
-Time=[];
 imainfo=[];
 ColorType='falsecolor'; %default
@@ -912,18 +878,13 @@
     TimeUnit='s';
     if isempty(j1_series); %frame index along i
-        Time=zeros(imainfo.NumberOfFrames+1,2);
-        Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
+        XmlData.Time=zeros(imainfo.NumberOfFrames+1,2);
+        XmlData.Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     else
-        Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
+        XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
     end
     set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
-    if index==1
-    set(handles.TimeName,'String','video')
-    else
-        set(handles.TimeName_1,'String','video')
-    end
+    TimeName='video';
     ColorType='truecolor';
 elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
-%     testima=1;
     if ~isequal(SubDir,'')
         imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
@@ -948,4 +909,5 @@
 
 %% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
+XmlData.GeometryCalib=[];%default
 XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt);
 [tild,tild,DocExt]=fileparts(XmlFileName);
@@ -964,5 +926,5 @@
     end
     if ~isempty(XmlDataRead)
-        ImaDoc_str=['view ' DocExt];   
+        ImaDoc_str=['view ' DocExt];  % DocExt= '.xml' or .civ (obsolete case)
         XmlData=XmlDataRead;
         if isfield(XmlData,'TimeUnit')
@@ -990,17 +952,21 @@
     end
 end
-if (strcmp(FileType,'civdata')||strcmp(FileType,'civx')) && ((isfield(XmlData,'Time')&& ~isempty(XmlData.Time)))
-    if index==1
-    set(handles.TimeName,'String','xml')
-    else
-       set(handles.TimeName_1,'String','xml') 
-    end
-else
-    XmlData.Time=Time; %time set by video
-end
 if isempty(ImaDoc_str)
-    set(handles.view_xml,'Visible','off')
-else
-    set(handles.view_xml,'String',ImaDoc_str)
+    set(handles.view_xml,'Visible','off') % no .xml (or .civ) file detected
+else
+    set(handles.view_xml,'String',ImaDoc_str)% indicate that a xml file has been detected
+end
+
+%% Define timing
+% time not set by the input file: images or civ data: indicate that time is read from the xml file
+if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) && ...
+        (strcmp(FileType,'image')|| strcmp(FileType,'multimage')||strcmp(FileType,'civdata')||strcmp(FileType,'civx'))
+    TimeName='xml';
+end
+if index==1
+    set(handles.TimeName,'String',TimeName)
+else
+    set(handles.TimeName_1,'String',TimeName)
+    set(handles.TimeName_1,'Visible','on')
 end
 
@@ -1014,5 +980,5 @@
     nbfield_j=max(max(max(j1_series)));
 end
-if ~isempty(XmlData.Time)
+if isfield(XmlData,'Time')&& ~isempty(XmlData.Time)
     %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
     if isequal(size(XmlData.Time,1),1)
@@ -1075,7 +1041,4 @@
 
 %% update the data attached to the uvmat interface
-if ~isempty(TimeUnit)
-    set(handles.TimeName,'String',['time (' TimeUnit ')'])
-end
 UvData.TimeUnit=TimeUnit;
 UvData.XmlData{index}=XmlData;
@@ -1311,11 +1274,16 @@
 %------------------------------------------------------------------------
 % --- Executes on button press in view_xml.
+%------------------------------------------------------------------------
 function view_xml_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-%[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
- [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
-FileBase=fullfile(RootPath,RootFile);
+
+% if TimeName defined, open the xml file corresponding to the first file
+% series, else open the xml file corresponding to the second series
+if isempty(get(handles.TimeName,'String'))% open the xml file corresponding to the secodn file series
+    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
+else
+   [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
+end
 option=get(handles.view_xml,'String');
-if isequal(option,'view .xml')
+if isequal(option,'view .xml')     
     FileXml=fullfile(RootPath,[SubDir '.xml']);
     if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir
@@ -1616,9 +1584,9 @@
 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2));
 
+%         i1_1=i1;
+%         i2_1=i2;
+%         j1_1=j1;
+%         j2_1=j2;
 % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
-        i1_1=i1;
-        i2_1=i2;
-        j1_1=j1;
-        j2_1=j2;
 if CheckFixPair && isnumeric(increment)
     if get(handles.scan_i,'Value')==1% case of scanning along index i
@@ -2214,5 +2182,5 @@
         ParamIn_1.FieldName=FieldName_1;
         ParamIn_1.VelType=VelType_1;
-        ParamIn_1.GUIName='get_field_1';
+        %ParamIn_1.GUIName='get_field_1';
         end  
         [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1);
@@ -2320,10 +2288,14 @@
 end           
 
-%% display time
+%% display time value of the current file
 abstime=[];%default inputs
 dt=[];
 TimeUnit='';
+if isfield(UvData,'TimeUnit')
+TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo
+end
 % time from xml file or video movie
-if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time')
+TimeName=get(handles.TimeName,'String');% indicate that time is from xml
+if strcmp(TimeName,'xml')||strcmp(TimeName,'video')
     if isempty(num_i2)||isnan(num_i2)
         num_i2=num_i1;
@@ -2337,5 +2309,4 @@
     siz=size(UvData.XmlData{1}.Time);
     if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1+1,num_i2+1) && siz(2)>=max(num_j1+1,num_j2+1)
-        set(handles.TimeName,'String','xml')% indicate that time is from xml
         abstime=(UvData.XmlData{1}.Time(num_i1+1,num_j1+1)+UvData.XmlData{1}.Time(num_i2+1,num_j2+1))/2;%overset the time read from files
         dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
@@ -2345,25 +2316,8 @@
         end
     end
-    if numel(UvData.XmlData)==2
-        if isempty(i2_1)
-            i2_1=num_i1;
-        end
-        if isempty(j1_1)
-            j1_1=1;
-        end
-        if isempty(j2_1)
-            j2_1=j1_1;
-        end
-        siz=size(UvData.XmlData{2}.Time);
-        if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1)
-            abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files
-            Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1));
-        end
-    end
-end
-
-%% look for timing in the input file if not defined in a xml file or movie
+end
+
+% get time in the input file, not defined in a xml file or movie
 if isempty(abstime)
-    TimeName=get(handles.TimeName,'String');
     if ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:'))
         abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file
@@ -2382,10 +2336,37 @@
 end 
 set(handles.TimeValue,'String',num2str(abstime))
+
+%% display time value of the second current file if relevant
 abstime_1=[];
-TimeName_1=get(handles.TimeName_1,'String');
-if ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:'))
+if ~isempty(FileName_1)
+    TimeName_1=get(handles.TimeName_1,'String');% indicate whether time is from xml or video
+    % time from xml file or video movie as a second file series
+    if strcmp(TimeName_1,'xml')||strcmp(TimeName_1,'video')
+        if numel(UvData.XmlData)==2
+            if isempty(i2_1)
+                i2_1=num_i1;
+            end
+            if isempty(j1_1)
+                j1_1=1;
+            end
+            if isempty(j2_1)
+                j2_1=j1_1;
+            end
+            siz=size(UvData.XmlData{2}.Time);
+            if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1)
+                abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files
+                Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1));
+            end
+        end
+    end
+    
+    % get time in the input file of the second series, not defined in a xml file or movie
+    if isempty(abstime_1) && numel(Field)==2 &&...
+            ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:'))
         abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file
-end
-set(handles.TimeValue_1,'String',num2str(abstime_1,5))
+    end
+    set(handles.TimeValue_1,'String',num2str(abstime_1,5))
+end
+
 if isempty(dt)||isequal(dt,0)
     set(handles.Dt_txt,'String','')
@@ -2397,4 +2378,15 @@
     end
 end
+
+%% Time title with unit
+if isempty(abstime)&&isempty(abstime_1)
+    Time_title='';
+else
+    Time_title='Time';
+    if ~isempty(TimeUnit)
+        Time_title=['Time (' TimeUnit ')'];
+    end
+end
+set(handles.Time_title,'String',Time_title)
 
 %% store the current open names, fieldname and vel types in uvmat interface 
@@ -2418,5 +2410,4 @@
         end
     end
-    transform=get(handles.TransformPath,'UserData');
     switch nargin(transform)
         case 4
@@ -2538,12 +2529,14 @@
         set(handles.ListObject_1,'String',{'plane'})
     end
-    IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view
-    if IndexObj(1)> numel(UvData.ProjObject)
-        IndexObj(1)=1;%select the first object if the selected one does not exist
+    IndexObj=get(handles.ListObject_1,'Value');%selected projection object for main view
+    if IndexObj> numel(UvData.ProjObject)
+        IndexObj=1;%select the first object if the selected one does not exist
         set(handles.ListObject_1,'Value',1)
     end
-    IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view
-    if isequal(IndexObj(2),IndexObj(1))
-        IndexObj(2)=[];
+    if get(handles.CheckViewField,'Value')
+        IndexObj_2=get(handles.ListObject,'Value');%selected projection object for view_field
+        if ~isequal(IndexObj_2,IndexObj(1))
+            IndexObj(2)=IndexObj_2;
+        end
     end
     plot_handles{1}=handles;
@@ -2894,39 +2887,11 @@
 fin=close(nc);
 
-%-------------------------------------------------------------------
+%-----------------------------------------------------------------------
 % --- Executes on button press in SubField
+%-----------------------------------------------------------------------
 function SubField_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------------------
-UvData=get(handles.uvmat,'UserData');
-if get(handles.SubField,'Value')==0% if the subfield button is desactivated   
-    set(handles.RootPath_1,'String','')
-    set(handles.RootFile_1,'String','')
-    set(handles.SubDir_1,'String','');
-    set(handles.FileIndex_1,'String','');
-    set(handles.FileExt_1,'String','');
-    set(handles.RootPath_1,'Visible','off')
-    set(handles.RootFile_1,'Visible','off')
-    set(handles.SubDir_1,'Visible','off');
-    set(handles.NomType_1,'Visible','off');
-    set(handles.TimeValue_1,'Visible','off')
-    set(handles.FileIndex_1,'Visible','off');
-    set(handles.FileExt_1,'Visible','off');
-    set(handles.FieldName_1,'Value',1);%set to blank state
-    set(handles.VelType_1,'Value',1);%set to blank state
-    set(handles.num_Opacity,'String','')% desactivate opacity setting
-    FieldList=get(handles.FieldName,'String');
-    if numel(FieldList)>1   % if a choice of fields exists
-        set(handles.FieldName_1,'Value',1)% set second field choice to blank
-        set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option
-    else
-        set(handles.FieldName_1,'String',{''})% set second field choice to blank
-    end
-    if ~strcmp(get(handles.VelType,'Visible'),'on')
-        set(handles.VelType_1,'Visible','off')
-    end
-    if isfield(UvData,'XmlData_1')
-        UvData=rmfield(UvData,'XmlData_1');
-    end 
-    set(handles.uvmat,'UserData',UvData);
+
+if get(handles.SubField,'Value')==0% if the subfield button is desactivated  
+    desable_subfield(handles)
     transform_fct_list=get(handles.TransformName,'String');
     transform_fct=transform_fct_list(get(handles.TransformName,'Value'));
@@ -2938,13 +2903,9 @@
     end  
 else
-    %RootPath=get(handles.RootPath,'String');
-    %SubDir=get(handles.SubDir,'String');
     fileinput_1=uigetfile_uvmat('select a second input file:',get(handles.RootPath,'String'));
     if isempty(fileinput_1)
         set(handles.SubField,'Value',0)
-    else
-        
+    else       
         % refresh the current displayed field
-        set(handles.SubField,'Value',1)
         display_file_name(handles,fileinput_1,2)
         
@@ -2961,12 +2922,50 @@
         set(handles.MenuFile_5,'Label',MenuFile_5)
     end
-    %     MenuBrowse_1_Callback(hObject, eventdata, handles)
-end
+end
+
+%-----------------------------------------------------------------------
+% --- desactivate display used for a second file series
+%-----------------------------------------------------------------------
+function desable_subfield(handles)
+    
+set(handles.RootPath_1,'String','')
+set(handles.RootFile_1,'String','')
+set(handles.SubDir_1,'String','');
+set(handles.FileIndex_1,'String','');
+set(handles.FileExt_1,'String','');
+set(handles.RootPath_1,'Visible','off')
+set(handles.RootFile_1,'Visible','off')
+set(handles.SubDir_1,'Visible','off');
+set(handles.NomType_1,'Visible','off');
+set(handles.FileIndex_1,'Visible','off');
+set(handles.FileExt_1,'Visible','off');
+set(handles.TimeName_1,'String','');
+set(handles.TimeName_1,'Visible','off');
+set(handles.TimeValue_1,'String','');
+set(handles.TimeValue_1,'Visible','off');
+set(handles.FieldName_1,'Value',1);%set to blank state
+set(handles.VelType_1,'Value',1);%set to blank state
+set(handles.num_Opacity,'String','')% desactivate opacity setting
+FieldList=get(handles.FieldName,'String');
+if numel(FieldList)>1   % if a choice of fields exists
+    set(handles.FieldName_1,'Value',1)% set second field choice to blank
+    set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option
+else
+    set(handles.FieldName_1,'String',{''})% set second field choice to blank
+end
+if ~strcmp(get(handles.VelType,'Visible'),'on')
+    set(handles.VelType_1,'Visible','off')
+end
+UvData=get(handles.uvmat,'UserData');
+if isfield(UvData,'XmlData_1')
+    UvData=rmfield(UvData,'XmlData_1');
+end
+set(handles.uvmat,'UserData',UvData);
 
 %------------------------------------------------------------------------
 % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI
-
+%------------------------------------------------------------------------
 function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles)
-%------------------------------------------------------------------------
+
 InputFile=read_GUI(handles.InputFile);
 RootPath=InputFile.RootPath;
@@ -2979,6 +2978,7 @@
 %------------------------------------------------------------------------
 % ---- read the data displayed for the second input rootfile windows
+%------------------------------------------------------------------------
 function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles)
-%------------------------------------------------------------------------
+
 RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
 if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
@@ -3021,8 +3021,8 @@
 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
 
-switch field 
+switch field
     
     case 'get_field...'
-    %% fill the coordinates and variables from selections in get_field
+        %% fill the coordinates and variables from selections in get_field
         ParamIn=[];
         % in case of civ data, we use the civ choice as default input for the GUI get_field
@@ -3033,18 +3033,18 @@
             switch VelType
                 case 'civ1'
-                    ParamIn.TimeVarName='Civ1_Time';
+                    ParamIn.TimeAttrName='Civ1_Time';
                     ParamIn.vector_x='Civ1_U';
                     ParamIn.vector_y='Civ1_V';
                     ParamIn.vec_color='Civ1_C';
                 case 'filter1'
-                    ParamIn.TimeVarName='Civ1_Time';
+                    ParamIn.TimeAttrName='Civ1_Time';
                     ParamIn.vector_x='Civ1_U_smooth';
                     ParamIn.vector_y='Civ1_V_smooth';
                 case 'civ2'
-                    ParamIn.TimeVarName='Civ2_Time';
+                    ParamIn.TimeAttrName='Civ2_Time';
                     ParamIn.vector_x='Civ2_U';
                     ParamIn.vector_y='Civ2_V';
                 case 'filter2'
-                    ParamIn.TimeVarName='Civ2_Time';
+                    ParamIn.TimeAttrName='Civ2_Time';
                     ParamIn.vector_x='Civ2_U_smooth';
                     ParamIn.vector_y='Civ2_V_smooth';
@@ -3056,5 +3056,4 @@
         set(handles.FixVelType,'visible','off')
         set(handles.VelType,'Visible','off')
-        %set(handles.VelType_1,'Visible','off')
         
         %read selection from get_field
@@ -3077,39 +3076,36 @@
             case '1D plot'
                 YName=GetFieldData.PanelOrdinate.ordinate;
-            case 'civdata...'%return to civdata from get_field
-               % [FieldList,VecColorList]=set_field_list('U','V','C');
-                set(handles.FieldName,'Value',2)
-                set(handles.FixVelType,'visible','on')
-                set(handles.VelType,'Visible','on')
+            case 'civdata...'%reinitiate input, return to automatic civ data reading
+                display_file_name(handles,FileName,1)
         end
         if ~strcmp(GetFieldData.FieldOption,'civdata...')
             XName=GetFieldData.Coordinates.Coord_x;
-        TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
-        if strcmp(TimeNameStr,'file index')
-            set(handles.TimeName,'String','');
-        else
-            set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]);
-        end
-        if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index
-            set(handles.NomType,'String','*')
-            set(handles.RootFile,FileName)
-        end
-        %     set(handles.TimeValue,'String' SwitchVarIndexTime
-        set(handles.Coord_x,'String',XName)
-        if ischar(YName)
-            YName={YName};
-        end
-        set(handles.Coord_y,'Data',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)
-        end
-        run0_Callback(hObject, eventdata, handles)
-        
+            TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
+            if strcmp(TimeNameStr,'file index')
+                set(handles.TimeName,'String','');
+            else
+                set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]);
+            end
+            if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index
+                set(handles.NomType,'String','*')
+                set(handles.RootFile,FileName)
+            end
+            %     set(handles.TimeValue,'String' SwitchVarIndexTime
+            set(handles.Coord_x,'String',XName)
+            if ischar(YName)
+                YName={YName};
+            end
+            set(handles.Coord_y,'Data',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)
+        end
+       
     case 'image'
-    %% look for image corresponding to civ data
+        %% look for image corresponding to civ data
         if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
             imagename=UvData.Field.Civ2_ImageA;
@@ -3128,16 +3124,6 @@
         % display the selected field and related information
         display_file_name(handles,imagename)%display the image
-     otherwise
-%         ext=get(handles.FileExt,'String');
-%         if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
-%             [FileName,PathName] = uigetfile( ...
-%                 {'*.nc', ' (*.nc)';
-%                 '*.nc',' netcdf files'; ...
-%                 '*.*',  'All Files (*.*)'}, ...
-%                 'Pick a netcdf file',FileBase);
-%             if ~ischar(FileName),return,end %abandon if the browser is cancelled
-%             FullFileName=[PathName FileName];
-            % display the selected field and related information
-             run0_Callback(hObject, eventdata, handles)
+    otherwise
+        run0_Callback(hObject, eventdata, handles)
 end
 
@@ -3192,5 +3178,6 @@
         end
     case 'image'
-        % get the image name corresponding to the current netcdf name (no unique correspondance)
+        %% look for image corresponding to civ data
+        imagename='';
         if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
             imagename=UvData.Field.Civ2_ImageA;
@@ -3198,27 +3185,16 @@
             imagename=UvData.Field.Civ1_ImageA;
         else
-            SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.'
-            imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
-        end
-        if ~exist(imagename,'file') % browse for images if it is not found
-            [FileName,PathName] = uigetfile( ...
-                {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
-                '*.jpg',' jpeg image files'; ...
-                '*.png','.png image files'; ...
-                '*.tif','.tif image files'; ...
-                '*.avi;*.AVI','.avi movie files'; ...
-                '*.vol','.volume images (png)'; ...
-                '*.*',  'All Files (*.*)'}, ...
-                'Pick an image',imagename);
-            if ~ischar(FileName),return,end %abandon if the browser is cancelled
-            imagename=[PathName FileName];
-        end
-        if ~ischar(imagename)% quit if the browser has  been closed
+            SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
+            imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]);
+        end
+        if ~exist(imagename,'file')
+            imagename=uigetfile_uvmat('Pick an image file',imagename,'image');
+            
+        end
+        if isempty(imagename)
             set(handles.SubField,'Value',0)
-        else %valid browser input:  display the selected image
-            set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons
-            set(handles.num_Npx,'Visible','on')
-            set(handles.num_Npy,'Visible','on')
-            display_file_name(handles,imagename,2)%display the imag
+            return
+        else
+            display_file_name(handles,imagename,2)%display the image as second field
         end
     otherwise
@@ -3234,5 +3210,5 @@
                 set(handles.uvmat,'UserData',UvData)
                 set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields
-                transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
+                TransformName_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
                  check_refresh=0;
              end             
@@ -4575,6 +4551,5 @@
 %------------------------------------------------------------------------
 function Menuline_x_Callback(hObject, eventdata, handles)
-    msgbox_uvmat('ERROR','option not yet implemented, use line')
-    return
+
 data.Type='line_x';
 data.ProjMode='projection';%default
@@ -4586,6 +4561,5 @@
 % -----------------------------------------------------------------------
 function Menuline_y_Callback(hObject, eventdata, handles)
-    msgbox_uvmat('ERROR','option not yet implemented, use line')
-    return
+
 data.Type='line_y';
 data.ProjMode='projection';%default
@@ -4676,6 +4650,13 @@
 data.Name=data.Type;% default name=type
 data.Coord=[0 0]; %default
+check_plot=0;
 if isfield(UvData,'Field')
     Field=UvData.Field;
+    if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
+         data.Coord=[0 0 0]; %default
+    end
+    if isfield(Field,'CoordUnit')
+        data.CoordUnit=Field.CoordUnit;
+    end
     if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh)
         data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
@@ -4684,10 +4665,17 @@
                 data.RangeY=UvData.Field.CoordMesh;
             case 'line_x'
-                data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
+                check_plot=1; %plot the line directly when set_object is opened
+                data.Type='line';
+                data.RangeX=UvData.Field.XMin ;
                 data.RangeY=UvData.Field.CoordMesh;
-                data.Coord=[0 (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis
+                data.Coord=[UvData.Field.XMin (UvData.Field.YMin +UvData.Field.YMax)/2;...
+                           UvData.Field.XMax (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis
             case 'line_y'
+                check_plot=1; %plot the line directly when set_object is opened
+                data.Type='line';
+                data.RangeX=UvData.Field.YMin ;
                 data.RangeY=UvData.Field.CoordMesh;
-                data.Coord=[(UvData.Field.XMin +UvData.Field.XMax)/2 0];% put line at the middle of the x axis
+                data.Coord=[(UvData.Field.XMin+UvData.Field.XMax)/2 UvData.Field.YMin;...
+                            (UvData.Field.XMin +UvData.Field.XMax)/2 UvData.Field.YMax];% put line at the middle of the y axis
             case {'rectangle','ellipse'}
                 data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
@@ -4700,15 +4688,14 @@
         data.DY=UvData.Field.CoordMesh;
     end
-    if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
-         data.Coord=[0 0 0]; %default
-    end
-    if isfield(Field,'CoordUnit')
-        data.CoordUnit=Field.CoordUnit;
-    end
-end
+end
+
 hset_object=set_object(data,handles);% call the GUI set_object 
 hchild=get(hset_object,'children');
 set(hchild,'enable','on')
 set(handles.DeleteObject,'Visible','on')% make the object delete button visible
+if check_plot
+    hhset_object=guidata(hset_object);
+    set_object('PLOT_Callback',1,[],hhset_object);% call the GUI set_object 
+end
 
 %------------------------------------------------------------------------
@@ -4717,5 +4704,4 @@
 %get the object file 
 fileinput=uigetfile_uvmat('pick an xml object file:',get(handles.RootPath,'String'),'.xml');
-
 if ~isempty(fileinput)
     %read the file
