Index: trunk/src/uvmat.m
===================================================================
--- trunk/src/uvmat.m	(revision 579)
+++ trunk/src/uvmat.m	(revision 580)
@@ -1025,4 +1025,8 @@
         set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
         set(handles_Fields,'Value',2) % set menu to 'velocity
+        if index==1
+            set(handles.FieldName_1,'Value',1);
+            set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field
+        end
         set(handles.ColorScalar,'Value',1)
         set(handles.ColorScalar,'String',ColorList)
@@ -2138,5 +2142,5 @@
         return
     end
-    Name=FileName_1;
+   % Name=FileName_1;
     switch UvData.FileType{2}
         case {'civx','civdata','netcdf'};
@@ -2188,5 +2192,5 @@
     test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
     if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1')
-           test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1);
+           test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;
     end
     if test_keepdata_1
@@ -2199,5 +2203,5 @@
         ParamIn_1.GUIName='get_field_1';
         end  
-        [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1);
+        [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1);
         if ~isempty(errormsg)
             errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg];
@@ -2256,8 +2260,8 @@
 test_veltype_1=0;
 if isempty(FileName_1)
-%     set(handles.FieldName_1,'Value',1); %update the field menu
-%     if isstruct(ParamOut)
-%     set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu
-%     end
+    %     set(handles.FieldName_1,'Value',1); %update the field menu
+    %     if isstruct(ParamOut)
+    %     set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu
+    %     end
 elseif ~test_keepdata_1
     if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...')
@@ -2273,15 +2277,17 @@
     % update the second field menu: the same quantity
     if isstruct(ParamOut_1)
-    set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
-    % display the FieldName menu from the input file and pick the selected one: 
-    field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
-    set(handles.FieldName_1,'Value',find(field_index,1)+1)  
-    end
-    
+%        set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
+        % display the FieldName menu from the input file and pick the selected one:
+        FieldList=get(handles.FieldName_1,'String');
+        field_index=strcmp(ParamOut_1.FieldName,FieldList);
+        if ~isempty(field_index)
+            set(handles.FieldName_1,'Value',find(field_index,1))
+        end
+    end
 end
 if test_veltype||test_veltype_1
-     set(handles.FixVelType,'Visible','on')
+    set(handles.FixVelType,'Visible','on')
 else
-     set(handles.FixVelType,'Visible','off')
+    set(handles.FixVelType,'Visible','off')
 end
 
@@ -2963,4 +2969,11 @@
     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')
@@ -3194,8 +3207,18 @@
         end
     otherwise
-        if check_new
-            UvData.FileType{2}=UvData.FileType{1};
+        check_refresh=1;
+        if check_new% if a second field was not previously entered, we just read another field in the first input file
             set(handles.FileIndex_1,'String',get(handles.FileIndex,'String'))
             set(handles.FileExt_1,'String',get(handles.FileExt,'String'))
+            
+            UvData.FileType{2}=UvData.FileType{1};
+            UvData.XmlData{2}= UvData.XmlData{1};
+            transform=get(handles.path_transform,'UserData');
+             if (~isa(transform,'function_handle')||nargin(transform)<3)
+                set(handles.uvmat,'UserData',UvData)
+                set(handles.transform_fct,'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
+                 check_refresh=0;
+             end             
         end
         if ~isequal(field,'image')
@@ -3205,5 +3228,6 @@
         end
         set(handles.uvmat,'UserData',UvData)
-        if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
+ 
+        if check_refresh && ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
             run0_Callback(hObject, eventdata, handles)
         end
@@ -3280,8 +3304,8 @@
         FileName_1='';% we plot the first input field without the second field
         set(handles.SubField,'Value',0)
-        SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current display, removing the second field
+        SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current plot, removing the second field
 elseif get(handles.SubField,'Value')% if subfield is already 'on'
      FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file
-     check_refresh=1;%will refresh the current display
+     check_refresh=1;%will refresh the current plot
 else% we introduce the same file (with a different field) for the second series
      FileName_1=FileName;% we compare two fields in the same file 
@@ -3291,6 +3315,7 @@
      transform=get(handles.path_transform,'UserData');
      if (~isa(transform,'function_handle')||nargin(transform)<3)
-        set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields
-        transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current display
+        set(handles.uvmat,'UserData',UvData)
+        set(handles.transform_fct,'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
      else
          check_refresh=1;
@@ -3298,5 +3323,5 @@
 end
 
-% refresh the current display if it has not been done previously
+% refresh the current plot if it has not been done previously
 if check_refresh
     UvData.FileName_1='';% desactivate the use of a constant second file
@@ -3321,7 +3346,9 @@
 end
 
-%-----------------------------------------------
+
+%-----------------------------------------------------------------------
 % --- reset civ buttons
 function reset_vel_type(handles_civ0,handle1)
+%-----------------------------------------------------------------------
 for ibutton=1:length(handles_civ0)
     set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
@@ -3332,8 +3359,8 @@
 end
 
-%-------------------------------------------------------
+%-----------------------------------------------------------------------
 % --- Executes on button press in MENUVOLUME.
-%-------------------------------------------------------
 function VOLUME_Callback(hObject, eventdata, handles)
+%-----------------------------------------------------------------------
 %errordlg('command VOL not implemented yet')
 if ishandle(handles.UVMAT_title)
