Index: trunk/src/compile.m
===================================================================
--- trunk/src/compile.m	(revision 746)
+++ trunk/src/compile.m	(revision 747)
@@ -11,5 +11,5 @@
     return
 else
-    hh=msgbox_uvmat('INFO',['compilation of ' FctName ' in progress...']);
+    hh=msgbox_uvmat('WAITING...',['compilation of ' FctName ' in progress...']);
 end
 disp(['compiling ' FctName ' ...'])
Index: trunk/src/disp_uvmat.m
===================================================================
--- trunk/src/disp_uvmat.m	(revision 746)
+++ trunk/src/disp_uvmat.m	(revision 747)
@@ -10,7 +10,8 @@
 %  checkrun: =0: batch mode: text display on log file
 
-function disp_uvmat(title,display_str,checkrun)
+function hh=disp_uvmat(title,display_str,checkrun)
+hh=[];
 if checkrun
-    msgbox_uvmat(title,display_str,'')
+    hh=msgbox_uvmat(title,display_str,'');
 else
     disp([title ': ' display_str])
Index: trunk/src/fill_GUI.m
===================================================================
--- trunk/src/fill_GUI.m	(revision 746)
+++ trunk/src/fill_GUI.m	(revision 747)
@@ -38,7 +38,4 @@
             set(handles.(fields{ifield}),'Visible','on')
             errormsg=fill_GUI(Param.(fields{ifield}),handles.(fields{ifield}));% recursively apply the function to the substructure
-%         elseif isfield(UserData,fields{ifield}) && isfield(handles,fields{ifield}) && isfield(Param.(fields{ifield}),'Name')
-%             UserData.(fields{ifield})=Param.(fields{ifield});
-%             set(handles.(fields{ifield}),'String',Param.(fields{ifield}).Name)
         end
     else
@@ -87,5 +84,5 @@
                             if isnumeric(input_data)
                                 if numel(input_data)>0
-                                    input_string=num2str(input_data(ibox));
+                                    input_string=num2str(input_data(ibox),4);
                                 end
                             else
@@ -95,5 +92,5 @@
                         case{'listbox','popupmenu'}
                             if isnumeric(input_data)
-                                input_data=num2str(input_data);
+                                input_data=num2str(input_data,4);
                             end
                             menu=get(hh(ibox),'String');
Index: trunk/src/find_field_bounds.m
===================================================================
--- trunk/src/find_field_bounds.m	(revision 746)
+++ trunk/src/find_field_bounds.m	(revision 747)
@@ -51,5 +51,5 @@
         if NbDim==3
             ZName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)};
-            CoordMax(imax(ind),1)=max(max(Field.(ZName)));
+            CoordMax(ind,1)=max(max(Field.(ZName)));
             CoordMin(ind,1)=min(min(Field.(ZName)));
         end
@@ -72,5 +72,5 @@
 if NbDim==3
     FieldOut.ZMax=max(CoordMax(ind,1));
-    FieldOut.ZMin=max(CoordMin(ind,1));
+    FieldOut.ZMin=min(CoordMin(ind,1));
 end
 % adjust the mesh to a value 1, 2 , 5 *10^n
Index: trunk/src/find_field_cells.m
===================================================================
--- trunk/src/find_field_cells.m	(revision 746)
+++ trunk/src/find_field_cells.m	(revision 747)
@@ -257,8 +257,8 @@
     DimIndices=[];
     for idim=1:numel(DimCell)
-        ind_dim=find(strcmp(DimCell{idim},ListDimName));%find the dim index in the list of coordinate variables
+        ind_dim=find(strcmp(DimCell{idim},ListDimName));%find the dim index in the list of dimensions ListDimName
         if ~isempty(ind_dim)
-            DimIndices=[DimIndices ind_dim]; %update the list of coord dimensions included in DimCell
-            if check_var && CoordSize(ind_dim)==2 % determine the size of the coordinate in case of coordiante variable limited to lower and upper bounds
+            DimIndices=[DimIndices ind_dim]; %update the list of dim indices included in DimCell
+            if check_var && CoordSize(ind_dim)==2 % determine the size of the coordinate in case of coordinate definition limited to lower and upper bounds
                 if isvector(Data.(ListVarName{ivardim})) 
                     if numel(Data.(ListVarName{ivardim}))>2
@@ -287,5 +287,5 @@
         NewNbDim(nbcell)=numel(DimIndices);
         NewCellInfo{nbcell}.CoordType='grid';
-        NewCellInfo{nbcell}.CoordSize=CoordSize;
+        NewCellInfo{nbcell}.CoordSize=CoordSize(DimIndices);
         NewCellInfo{nbcell}.CoordIndex=ListCoordIndex(DimIndices);
     end
Index: trunk/src/get_field.m
===================================================================
--- trunk/src/get_field.m	(revision 746)
+++ trunk/src/get_field.m	(revision 747)
@@ -34,5 +34,5 @@
 function varargout = get_field(varargin)
 
-% Last Modified by GUIDE v2.5 23-Oct-2013 23:44:17
+% Last Modified by GUIDE v2.5 21-Apr-2014 15:03:19
 
 % Begin initialization code - DO NOT EDIT
@@ -86,5 +86,5 @@
 Field.Display=Field;
 Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value
-NbVar=numel(Field.VarDimName);
+NbVar=numel(Field.VarDimName);%nbre of variables in the input data
 for ilist=1:NbVar
     if ischar(Field.VarDimName{ilist})
@@ -92,5 +92,5 @@
     end
     NbDim=numel(Field.VarDimName{ilist});
-    check_singleton=false(1,NbDim);
+    check_singleton=false(1,NbDim);%  check singleton, false by default
     for idim=1:NbDim
         dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions
@@ -101,5 +101,4 @@
     Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions
     end
-    %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons
 end
 if ~isfield(Field,'VarAttribute')
@@ -109,10 +108,11 @@
     Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute));
 end
-% Field.Display = list of variables and corresponding properties obtained after removal of singletons
-Field.Display.ListVarName=Field.ListVarName(~Field.Check0D);
+% Field.Display = list of variables and corresponding properties obtained after removal of variables with a single value and singleton dimensions
+Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); %list of variables available for plots, after eliminating variables with a single value
 Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D);
 Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D);
-Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);
-Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);
+Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);% list of non singleton dimension names
+Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);% corresponding list of non singleton dimension values
+
 
 %% analyse the input field cells
@@ -159,12 +159,12 @@
 set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components
 set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components
-set(handles.vector_z,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components
+set(handles.vector_z,'String',Field.Display.ListVarName)% fill the menu of y vector components
 set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components
 set(handles.scalar,'Value',1)% fill the menu of y vector components
-set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu of y vector components
+set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu for scalar
 set(handles.ordinate,'Value',1)% fill the menu of y vector components
-set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y vector components
+set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y coordinate for 1D plots
 if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata')
-    set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})
+    set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})% provides the possibility to come back to civdata
 else
     set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'})
@@ -238,26 +238,14 @@
 set(hObject,'Position',pos_view_field)
 set(handles.get_field,'WindowStyle','modal')% Make the GUI modal
+
+%% set z coordinate menu if relevant
+if Field.MaxDim>=3
+    set(handles.Check3D,'Value',1)
+else
+    set(handles.Check3D,'Value',0)
+end
+Check3D_Callback(hObject, eventdata, handles)
 drawnow
 uiwait(handles.get_field);
-
-return
-
-%% set z coordinate menu if relevant
-if Field.MaxDim>=3
-    set(handles.vector_z,'Visible','on')
-    set(handles.vector_z,'String',Field.ListVarName(~Field.Check0D))
-    set(handles.Coord_z,'Visible','on')
-    set(handles.SwitchVarIndexZ,'Visible','on')
-    set(handles.Z_title,'Visible','on')
-else
-    set(handles.vector_z,'Visible','off')
-    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
 
 %------------------------------------------------------------------------
@@ -431,5 +419,5 @@
             end
         end
-        scalar_index=find(~test_coord,1);%get the first variable not a coordiante
+        scalar_index=find(~test_coord,1);%get the first variable not a coordinate
         if isempty(scalar_index)
             set(handles.scalar,'Value',1)
@@ -589,7 +577,5 @@
 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
 dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable
-CheckDimensionX=get(handles.CheckDimensionX,'Value');
-CheckDimensionY=get(handles.CheckDimensionY,'Value');
-if ~CheckDimensionX  || ~CheckDimensionY
+if ~get(handles.CheckDimensionX,'Value')  || ~get(handles.CheckDimensionY,'Value')
     %look for coordinate variables among the other variables
     for ilist=1:numel(Field.Display.VarDimName)
@@ -616,12 +602,5 @@
     SwitchVarIndexTime_Callback([], [], handles)
 end
-% if numel(var_component)<2
-%     if numel(test_coord)<2
-%         ListCoord={''};
-%     else
-%         set(handles.Coord_x,'Value',2)
-%         set(handles.Coord_y,'Value',1)
-%     end
-% else
+
 coord_val=[0 0];
 % look for labelled unstructured coordinates
@@ -644,5 +623,5 @@
     end
 end
-if  CheckDimensionX
+if  get(handles.CheckDimensionX,'Value')
     set(handles.Coord_x,'Value',2)
     set(handles.Coord_x,'String',dim_var')
@@ -651,5 +630,5 @@
     set(handles.Coord_x,'String',ListCoord)
 end
-if  CheckDimensionY
+if  get(handles.CheckDimensionY,'Value')
     set(handles.Coord_y,'Value',1)
     set(handles.Coord_y,'String',dim_var')
@@ -657,4 +636,11 @@
     set(handles.Coord_y,'Value',coord_val(2))
     set(handles.Coord_y,'String',ListCoord)
+end
+if  get(handles.CheckDimensionZ,'Value')
+    set(handles.Coord_z,'Value',1)
+    set(handles.Coord_z,'String',dim_var')
+else
+    set(handles.Coord_z,'Value',coord_val(2))
+    set(handles.Coord_z,'String',ListCoord)
 end
 
@@ -860,4 +846,5 @@
 % --- Executes on selection change in SwitchVarIndexTime.
 %------------------------------------------------------------------------
+
 function SwitchVarIndexTime_Callback(hObject, eventdata, handles)
 
@@ -891,15 +878,21 @@
     case 'variable'% TimeName menu represents the available variables
         set(handles.TimeName, 'Visible','on')
-        TimeVarName=Field.Display.SingleVarName;% slist of variables with a single dimension (candidate for time)
-        List=get(handles.TimeName,'String');
-        option=List{get(handles.TimeName,'Value')};
-        ind=find(strcmp(option,TimeVarName));
-        if isempty(ind)
-            set(handles.TimeName, 'Value',1);
-        else
-            set(handles.TimeName, 'Value',ind);
-        end
-        set(handles.TimeName, 'String',TimeVarName)
-    case 'matrix_index'% TimeName menu represents the available dimensions
+        VarNbDim=cellfun('length',Field.Display.VarDimName); % check the nbre of dimensions of each input variable
+        TimeVarName=Field.Display.ListVarName(VarNbDim==1);% list of variables with a single dimension (candidate for time)
+        List=get(handles.TimeName,'String');% list of names on the menu for time
+        if isempty(List)
+            ind=1;
+        else
+            option=List{get(handles.TimeName,'Value')};% previous selected option
+            ind=find(strcmp(option,TimeVarName)); %check whether the previous selection is available in the newlist
+            if isempty(ind)
+                ind=1;
+            end
+        end
+        if ~isempty(TimeVarName)
+            set(handles.TimeName, 'Value',ind);% select first value in the menu if the option is not found
+            set(handles.TimeName, 'String',TimeVarName)% update the menu for time name
+        end
+    case 'matrix index'% TimeName menu represents the available dimensions
         set(handles.TimeName, 'Visible','on')     
         set(handles.TimeName, 'Value',1);
@@ -966,7 +959,41 @@
     case 'vectors'
 end
-% hObject    handle to CheckDimensionY (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hint: get(hObject,'Value') returns toggle state of CheckDimensionY
+
+
+% --- Executes on button press in CheckDimensionZ.
+function CheckDimensionZ_Callback(hObject, eventdata, handles)
+FieldList=get(handles.FieldOption,'String');
+FieldOption=FieldList{get(handles.FieldOption,'Value')};
+switch FieldOption
+    case '1D plot'
+        
+    case 'scalar'
+       scalar_Callback(hObject, eventdata, handles)
+    case 'vectors'
+end
+
+% --- Executes on selection change in TimeName.
+function TimeName_Callback(hObject, eventdata, handles)
+index=get(handles.SwitchVarIndexTime,'Value');
+if index==3 ; % TimeName is used to chose a variable
+    index=get(handles.TimeName,'Value');
+    string=get(handles.TimeName,'String');
+    VarName=string{index};
+end
+update_field(handles,VarName)
+
+
+% --- Executes on button press in Check3D.
+function Check3D_Callback(hObject, eventdata, handles)
+if get(handles.Check3D,'Value')
+    status='on';
+else
+    status='off';
+end
+set(handles.Coord_z,'Visible',status)
+set(handles.CheckDimensionZ,'Visible',status)
+set(handles.Z_title,'Visible',status)
+set(handles.vector_z,'Visible',status)
+set(handles.W_title,'Visible',status)   
+
+
Index: trunk/src/msgbox_uvmat.m
===================================================================
--- trunk/src/msgbox_uvmat.m	(revision 746)
+++ trunk/src/msgbox_uvmat.m	(revision 747)
@@ -6,12 +6,15 @@
 % OUTPUT:
 % answer  (text string)= 'yes', 'No', 'cancel', or the text string introduced as input
+% for title='WAITING...', the output is the handle of the figure, to allow deletion by the calling program.
 %
 %INPUT:
 % title: string indicating the type of message box:
-%          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). 
+%          title= 'INPUT_TXT','INPUT_Y-N','INPUT_MENU','ERROR', 'WARNING','CONFIMATION','WAITING...',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
+%          if title='CONFIMATION'', 'ERROR', 'WARNING','RULER' the figure remains  opened until a button 'OK' is pressed
+%             title='RULER' is used for display of length and angle from the ruler tool. 
 %          if title='INPUT_Y-N', an answer Yes/No is requested
-% display, displayed text
+%          if title='WAITING...' the figure remains open until the program deletes it
+% display: displayed text
 % default_answer: default answer in the edit box (only used with title='INPUT_TXT')
 
@@ -88,5 +91,5 @@
             testCancel=1; %no cancel button
             testNo=1; % button No activated
-        case {'RULER'}
+        case 'RULER'
             icontype='';
             testinputstring=1;
@@ -97,5 +100,5 @@
             testinputstring=2;
             testCancel=1; %no cancel button
-        case 'INFO'
+        case 'WAITING...'
             icontype='';
             testOK=0;
@@ -213,5 +216,5 @@
     if strcmp(get(handles.OK,'Visible'),'on')
     delete(handles.figure1);
-    else %case of INFO display (non modal)
+    else %case of WAITING... display (non modal)
         varargout{1}=hObject;
     end
Index: trunk/src/nc2struct.m
===================================================================
--- trunk/src/nc2struct.m	(revision 746)
+++ trunk/src/nc2struct.m	(revision 747)
@@ -28,12 +28,11 @@
 %         if ListVarName=[] or {}, no variable value is read (only global attributes and list of variables and dimensions)
 %         if ListVarName is absent, or = '*', ALL the variables of the netcdf file are read. 
-%         if ListVarName is a cell array with n lines, the set of variables will be sought by order of priority
-%                  in the list, while output names will be set by the first line
-%        - the string 'ListGlobalAttribute' followed by a list of attribute  names: reads only these attributes (fast reading)
-%        - the string 'TimeVarName', a string (the variable considered as
-%        time), an integer (the selected time index), the cell of other
-%        input variables limited to the input time index (considered as the last index of arrays)
-%        - the string 'TimeDimName', a string (the dimension considered as time), an integer (the selected time index), the cell of other
-%        input variables limited to the input time index (considered as the last index of arrays)
+%         if ListVarName is a cell array with n lines, the set of variables will be sought by order of priority in the list,
+%            while output names will be set by the first line
+%       - the string 'ListGlobalAttribute' followed by a list of attribute  names: reads only these attributes (fast reading)
+%       - the string 'TimeVarName', a string (the variable considered as time), an integer or vector with integer values 
+%            representing time indices to select, the cell of other input variable names.
+%       - the string 'TimeDimName', a string (the name of the dimension considered as time), an integer or vector with integer values 
+%            representing time indices to select, the cell of other input variable names.
 
 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@@ -53,6 +52,6 @@
 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    
-function [Data,var_detect,ichoice]=nc2struct(nc,varargin)
-
+function [Data,var_detect,ichoice,errormsg]=nc2struct(nc,varargin)
+errormsg='';%default error message
 if isempty(varargin)
     varargin{1}='*';
@@ -67,16 +66,16 @@
     
     %% open the netcdf file for reading
-    if ischar(nc) 
+    if ischar(nc)
         if exist(nc,'file')
             try
-            nc=netcdf.open(nc,'NC_NOWRITE');
-            testfile=1;
+                nc=netcdf.open(nc,'NC_NOWRITE');
+                testfile=1;
             catch ME
-              Data.Txt=['ERROR opening ' nc ': ' ME.message];
-              return
+                errormsg=['ERROR opening ' nc ': ' ME.message];
+                return
             end
         else
-           Data.Txt=['ERROR:file ' nc ' does not exist'];
-           return
+            errormsg=['ERROR:file ' nc ' does not exist'];
+            return
         end
     else
@@ -89,5 +88,5 @@
             valuestr=[];%default
             try
-            valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist});
+                valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist});
             catch ME
             end
@@ -95,21 +94,24 @@
         end
         netcdf.close(nc)
-       return
+        return
     end
     
     %% time variable or dimension
     input_index=1;
+    CheckTimeVar=0;
+    TimeVarName='';
     if isequal(varargin{1},'TimeVarName')
         TimeVarName=varargin{2};
-        TimeVarIndex=varargin{3};
-        input_index=4;
+        CheckTimeVar=1;
+        TimeIndex=varargin{3};
+        input_index=4;% list of varibles to read is at fourth argument
     elseif isequal(varargin{1},'TimeDimName')
         TimeDimName=varargin{2};
-        TimeVarIndex=varargin{3};
+        TimeIndex=varargin{3};
         input_index=4;
     end
-
+    
     %% full reading: get the nbre of dimensions, variables, global attributes
-    ListVarName=varargin{input_index}; 
+    ListVarName=varargin{input_index};
     [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, global attributes, in the netcdf file
     
@@ -130,5 +132,5 @@
                 eval(['Data.' keystr '=valuestr;'])
             else
-                eval(['Data.' keystr '='';']) 
+                eval(['Data.' keystr '='';'])
             end
             att_key{iatt}=keystr;
@@ -139,5 +141,5 @@
     end
     Data.ListGlobalAttribute=att_key;
-
+    
     %%  -------- read dimension names-----------
     ListDimNameNetcdf=cell(1,ndims);
@@ -146,19 +148,19 @@
         [ListDimNameNetcdf{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);%get name and value of each dimension
     end
-    if ~isempty(ListDimNameNetcdf) 
+    if ~isempty(ListDimNameNetcdf)
         flag_used=zeros(1,ndims);%initialize the flag indicating the selected dimensions in the list (0=unused)
     end
     if isequal(varargin{1},'TimeDimName')% time dimension introduced
-        TimeDimIndex=find(strcmp(varargin{2},ListDimNameNetcdf));
+        TimeDimIndex=find(strcmp(TimeDimName,ListDimNameNetcdf));
         if isempty(TimeDimIndex)
-            Data.Txt=['requested time dimension ' varargin{2} ' not found'];
+            errormsg=['requested time dimension ' varargin{2} ' not found'];
             return
         end
         if dim_value(TimeDimIndex)<varargin{3}
-            Data.Txt=['requested time index ' num2str(varargin{3}) ' exceeds matrix dimension'];
+           errormsg=['requested time index ' num2str(varargin{3}) ' exceeds matrix dimension'];
             return
         end
-    end
- 
+    end  
+    
     %%  -------- read names of variables -----------
     ListVarNameNetcdf=cell(1,nvars); %default
@@ -166,13 +168,12 @@
     nbatt=zeros(1,nvars);
     for ncvar=1:nvars %loop on the variables of the netcdf file
-        %get name, type, dimensions and attribute numbers of each variable 
+        %get name, type, dimensions and attribute numbers of each variable
         [ListVarNameNetcdf{ncvar},xtype(ncvar),dimids{ncvar},nbatt(ncvar)] = netcdf.inqVar(nc,ncvar-1);
-    end  
-    testmulti=0;
+    end
+%     testmulti=0;
     if isequal(ListVarName,'*')||isempty(ListVarName)
-        var_index=1:nvars; %all the variables are selected in the netcdf file 
+        var_index=1:nvars; %all the variables are selected in the netcdf file
         Data.ListVarName=ListVarNameNetcdf;
     else   %select input variables, if requested by the input ListVarName
-        ind_remove=[];
         check_keep=ones(1,size(ListVarName,2));
         for ivar=1:size(ListVarName,2) % check redondancy of variable names
@@ -181,9 +182,8 @@
             end
         end
-        ListVarName=ListVarName(:,logical(check_keep));          
+        ListVarName=ListVarName(:,logical(check_keep));
         sizvar=size(ListVarName);
-        testmulti=(sizvar(1)>1);%test for multiple choice of variable ranked by order of priority
         var_index=zeros(1,sizvar(2));%default
-        if testmulti %multiple choice of variable ranked by order of priority
+        if sizvar(1)>1 %multiple choice of variable ranked by order of priority
             for iline=1:sizvar(1)
                 search_index=find(strcmp(ListVarName{iline,1},ListVarNameNetcdf),1);%look for the first variable name in the list of netcdf variables
@@ -196,5 +196,15 @@
             iline=1;
         end
-        for ivar=1:sizvar(2)
+        %ListVarName=ListVarName(iline,:);% select the appropriate option for input variable (lin ein the input name matrix)
+        if CheckTimeVar
+            TimeVarIndex=find(strcmp(TimeVarName,ListVarNameNetcdf),1); %look for the index of the time variable in the netcdf list
+            if isempty(TimeVarIndex)
+                errormsg='requested variable for time is missing';
+                return
+            end
+            TimeDimIndex=dimids{TimeVarIndex}(1)+1;
+            ListVarName=[ListVarName {TimeVarName}];
+        end
+        for ivar=1:size(ListVarName,2)
             search_index=find(strcmp(ListVarName{iline,ivar},ListVarNameNetcdf),1);%look for the variable name in the list of netcdf file
             if ~isempty(search_index)
@@ -202,12 +212,12 @@
             end
         end
-        var_detect=(var_index~=0);%=1 for detected variables          
+        var_detect=(var_index~=0);%=1 for detected variables
         list_index=find(var_index);% indices in the input list corresponding to a detected variable
         var_index=var_index(list_index);% netcdf variable indices corresponding to the output list of read variable
         Data.ListVarName=ListVarName(1,list_index);%the first line of ListVarName sets the output names of the variables
     end
-     
-  %% get the dimensions and attributes associated to  variables
-  var_dim=cell(size(var_index));% initiate list of dimensions for variables
+    
+    %% get the dimensions and attributes associated to  variables
+    var_dim=cell(size(var_index));% initiate list of dimensions for variables
     for ivar=1:length(var_index)
         var_dim{ivar}=dimids{var_index(ivar)}+1; %netcdf dimension indices used by the variable #ivar
@@ -222,11 +232,11 @@
             end
             try
-             if isempty(valuestr)
-                Data.VarAttribute{ivar}.(attname)=valuestr;
-            end
+                if isempty(valuestr)
+                    Data.VarAttribute{ivar}.(attname)=valuestr;
+                end
             catch ME
                 display(attname)
                 display(valuestr)
-                display(ME.message)         
+                display(ME.message)
                 Data.VarAttribute{ivar}.(['atrr_' num2str(iatt)])='not read';
             end
@@ -234,10 +244,12 @@
     end
     
-
     %% select the dimensions used for the set of input variables
-    if ~isempty(var_index)      
-        dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions 
-        Data.ListDimName=ListDimNameNetcdf(dim_index); 
+    if ~isempty(var_index)
+        dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions
+        Data.ListDimName=ListDimNameNetcdf(dim_index);
         Data.DimValue=dim_value(dim_index);
+        if input_index==4% if a dimension is selected as time
+            Data.DimValue(TimeDimIndex)=numel(TimeIndex);
+        end
     end
     
@@ -246,18 +258,24 @@
         for ivar=1:length(var_index)
             VarName=Data.ListVarName{ivar};
-            VarName=regexprep(VarName,'-',''); %suppress '-' if it exists in the netcdf variable name
-            CheckSub=0;
+            VarName=regexprep(VarName,'-','_'); %suppress '-' if it exists in the netcdf variable name (leads to errors in matlab)
+%             CheckSub=0;
             if input_index==4% if a dimension is selected as time
-                if var_dim{ivar}(end)==TimeDimIndex% if the last dim of the variable is the time
-                    slice_length=prod(var_dim{ivar}(1:end-1));
-                    Data.(VarName)=double(netcdf.getVar(nc,var_index(ivar)-1,TimeIndex*slice_length,slice_length)); %read the variable data
-                    CheckSub=1;
-                end
-            end
-            if ~CheckSub
+                ind_vec=zeros(1,numel(var_dim{ivar}));% vector with zeros corresponding to al the dimensions of the variable VarName
+                ind_size=dim_value(var_dim{ivar});% vector giving the size of the variable VarName
+                index_time=find(var_dim{ivar}==TimeDimIndex);
+                if ~isempty(index_time)
+                    ind_vec(index_time)=TimeIndex-1;% selected index(or indices) to read
+                    ind_size(index_time)=numel(TimeIndex);%length of the selected set of time indices
+                    if numel(TimeIndex)==1 && ~strcmp(VarName,TimeVarName)
+                        Data.VarDimName{ivar}(index_time)=[];% for a single selected time remove the time in the list of dimensions (except for tTime itself) 
+                    end
+                end                   
+                Data.(VarName)=double(netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size)); %read the variable data
+                Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension
+            else
                 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data
-                if xtype(var_index(ivar))==5
+            end
+            if xtype(var_index(ivar))==5
                 Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision
-                end
             end
         end
@@ -267,8 +285,8 @@
     %%  -------- close fle-----------
     if testfile==1
-        netcdf.close(nc) 
-    end
-    
-%% old netcdf library 
+        netcdf.close(nc)
+    end
+    
+    %% old netcdf library
 else
     [Data,var_detect,ichoice]=nc2struct_toolbox(nc,varargin);
Index: trunk/src/proj_field.m
===================================================================
--- trunk/src/proj_field.m	(revision 746)
+++ trunk/src/proj_field.m	(revision 747)
@@ -1296,4 +1296,7 @@
                     Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});
                     Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)});
+                    if NbDim==3
+                        Coord{3}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(3)});
+                    end
                     if numel(Coord{NbDim-1})==2
                         DY=(Coord{NbDim-1}(2)-Coord{NbDim-1}(1))/(DimValue(1)-1);
@@ -1302,24 +1305,42 @@
                         DX=(Coord{NbDim}(2)-Coord{NbDim}(1))/(DimValue(2)-1);
                     end
-                    if testYMin%test_direct(indY)
-                        YIndexMin=(YMin-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the min y value for the new field
-                        YIndexMax=(YMax-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the max y value for the new field
+                    if testYMax
+                         YIndexMax=(YMax-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the max y value for the new field
+                        if testYMin%test_direct(indY)
+                            YIndexMin=(YMin-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the min x value for the new field
+                        else
+                            YIndexMin=1;
+                        end          
                     else
-                        YIndexMin=(Coord{NbDim-1}(1)-YMax)/DY+1;
-                        YIndexMax=(Coord{NbDim-1}(1)-YMin)/DY+1;
-                        Ybound(2)=Coord{NbDim-1}(1)-DY*(YIndexMax-1);
-                        Ybound(1)=Coord{NbDim-1}(1)-DY*(YIndexMin-1);
-                    end
-                    if testXMin%test_direct(NbDim)==1
-                        XIndexMin=(XMin-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the min x value for the new field
-                        XIndexMax=(XMax-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the max x value for the new field
-                        Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1);%  x value corresponding to XIndexMin
-                        Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1);%  x value corresponding to XIndexMax
+                        YIndexMax=Coord{NbDim-1}(end)/DY;
+                        YIndexMin=1;
+                    end
+                    if testXMax
+                         XIndexMax=(XMax-Coord{NbDim}(1))/DY+1;% matrix index corresponding to the max y value for the new field
+                        if testYMin%test_direct(indY)
+                            XIndexMin=(XMin-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the min x value for the new field
+                        else
+                            XIndexMin=1;
+                        end          
                     else
-                        XIndexMin=(Coord{NbDim}(1)-XMax)/DX+1;
-                        XIndexMax=(Coord{NbDim}(1)-XMin)/DX+1;
-                        Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1);
-                        Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1);
-                    end
+                        XIndexMax=Coord{NbDim}(end)/DX;
+                        XIndexMin=1;
+                    end
+%                         YIndexMin=(Coord{NbDim-1}(1)-YMax)/DY+1;
+% %                         YIndexMax=(Coord{NbDim-1}(1)-YMin)/DY+1;
+%                         Ybound(2)=Coord{NbDim-1}(1)-DY*(YIndexMax-1);
+%                         Ybound(1)=Coord{NbDim-1}(1)-DY*(YIndexMin-1);
+%                     end
+%                     if testXMin%test_direct(NbDim)==1
+%                         XIndexMin=(XMin-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the min x value for the new field
+%                         XIndexMax=(XMax-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the max x value for the new field
+%                         Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1);%  x value corresponding to XIndexMin
+%                         Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1);%  x value corresponding to XIndexMax
+%                     else
+%                         XIndexMin=(Coord{NbDim}(1)-XMax)/DX+1;
+%                         XIndexMax=(Coord{NbDim}(1)-XMin)/DX+1;
+%                         Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1);
+%                         Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1);
+%                     end
                     YIndexRange(1)=ceil(min(YIndexMin,YIndexMax));%first y index to select from the previous field
                     YIndexRange(1)=max(YIndexRange(1),1);% avoid bound lower than the first index
@@ -1346,6 +1367,8 @@
                     else
                         if NbDim==3
+                            DZ=(Coord{1}(end)-Coord{1}(1))/(numel(Coord{1})-1);
                             DimCell(1)=[]; %suppress z variable
                             DimValue(1)=[];
+                            test_direct=1;%TOdo; GENERALIZE, SEE CASE OF points
                             if test_direct(1)
                                 iz=ceil((ObjectData.Coord(1,3)-Coord{1}(1))/DZ)+1;
Index: trunk/src/read_field.m
===================================================================
--- trunk/src/read_field.m	(revision 746)
+++ trunk/src/read_field.m	(revision 747)
@@ -36,5 +36,5 @@
 errormsg='';
 if ~exist(FileName,'file')
-    erromsg=['input file ' FileName ' does not exist'];
+    errormsg=['input file ' FileName ' does not exist'];
     return
 end
@@ -92,5 +92,4 @@
                 end
             else  % an operator 'vec' or 'norm' is used
-                %Operator=r.Operator;
                 if ~check_colorvar(ilist) && strcmp(r.Operator,'norm')
                     ProjModeRequestVar='interp_lin';%scalar field (requires interpolation for plot)
@@ -121,10 +120,11 @@
         end
         if isfield(ParamIn,'TimeDimName')% case of reading of a single time index in a multidimensional array
-            [Field,var_detect,ichoice]=nc2struct(FileName,'TimeDimName',ParamIn.TimeDimName,num,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]);
-        else
-            [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]);
-        end
-        if isfield(Field,'Txt')
-            errormsg=Field.Txt;
+            [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,'TimeDimName',ParamIn.TimeDimName,num,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]);
+        elseif isfield(ParamIn,'TimeVarName')% case of reading of a single time  in a multidimensional array
+            [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,'TimeVarName',ParamIn.TimeVarName,num,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]);
+        else
+            [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,[ParamIn.Coord_x (ParamIn.Coord_y) (ParamIn.Coord_z) ListVar]);
+        end
+        if ~isempty(errormsg)
             return
         end
Index: trunk/src/set_object.m
===================================================================
--- trunk/src/set_object.m	(revision 746)
+++ trunk/src/set_object.m	(revision 747)
@@ -701,4 +701,7 @@
     norm_plane(3)=OmAxis(3)*coeff+cos_om;
 end
+Coord=get(handles.Coord,'Data');
+Coord(3)=Z_value;
+set(handles.Coord,'Data',Coord)
 
 % update graph
Index: trunk/src/uvmat.m
===================================================================
--- trunk/src/uvmat.m	(revision 746)
+++ trunk/src/uvmat.m	(revision 747)
@@ -195,11 +195,11 @@
 set(handles.PlotAxes,'UserData',AxeData)
 % position of table Coord_y
-set(handles.Coord_y,'Unit','pixel')
-Pos=get(handles.Coord_y,'Position');
-set(handles.Coord_y,'Unit','normalized')
-set(handles.Coord_y,'ColumnWidth',{Pos(3)})
-set(handles.Coord_y,'ColumnFormat',{'char'})
-set(handles.Coord_y,'ColumnEditable',false)
-set(handles.Coord_y,'ColumnName',{''})
+%set(handles.Coord_y,'Unit','pixel')
+% Pos=get(handles.Coord_y,'Position');
+% set(handles.Coord_y,'Unit','normalized')
+% set(handles.Coord_y,'ColumnWidth',{Pos(3)})
+% set(handles.Coord_y,'ColumnFormat',{'char'})
+% set(handles.Coord_y,'ColumnEditable',false)
+% set(handles.Coord_y,'ColumnName',{''})
 
 %% set functions for the mouse and keyboard
@@ -994,5 +994,5 @@
 % 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'))
+        (strcmp(FileType,'image')|| strcmp(FileType,'multimage'))%||strcmp(FileType,'civdata')||strcmp(FileType,'civx'))
     TimeName='xml';
 elseif strcmp(FileType,'civdata')
@@ -1110,8 +1110,7 @@
         set(handles.ColorScalar,'String',ColorList)
         set(handles.Vectors,'Visible','on')
-        set(handles.Coord_x,'Value',1);
+        %set(handles.Coord_x,'Value',1);
         set(handles.Coord_x,'String','X');
-%         set(handles.Coord_y,'Value',1);
-        set(handles.Coord_y,'Data',{'Y'});
+        set(handles.Coord_y,'String','Y');
     case 'netcdf'
         set(handles_Fields,'Value',1)
@@ -1125,11 +1124,11 @@
         set(handles_Fields,'Value',1) % set menu to 'image'
         set(handles_Fields,'String',{'image'})
-        set(handles.Coord_x,'Value',1);
+        %set(handles.Coord_x,'Value',1);
         set(handles.Coord_x,'String','AX');
-    set(handles.Coord_y,'Data',{'AY'});
+    set(handles.Coord_y,'String','AY');
 end
 set(handles.uvmat,'UserData',UvData)
 
-%% set index navigation options and inputfilerefresh plots
+%% set index navigation options 
 scan_option='i';%default
 state_j='off'; %default
@@ -1623,17 +1622,4 @@
 FileExt=InputFile.FileExt;
 NomType=InputFile.NomType;
-% i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
-% i2=[];%default
-% if strcmp(get(handles.i2,'Visible'),'on')
-%     i2=str2num(get(handles.i2,'String'));
-% end
-% j1=[];
-% if strcmp(get(handles.j1,'Visible'),'on')
-%     j1=stra2num(get(handles.j1,'String'));
-% end
-% j2=j1;
-% if strcmp(get(handles.j2,'Visible'),'on')
-%     j2=stra2num(get(handles.j2,'String'));
-% end
 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used
 if isempty(i1)
@@ -1700,5 +1686,5 @@
         end
     else % free increment
-        runaction=get(gcbo,'tag');
+       % runaction=get(gcbo,'tag');
         if strcmp(increment,'+')% if runplus or movie is activated
             step=1;
@@ -1817,5 +1803,5 @@
 filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2);
 
-%% inputfilerefresh plots
+%% refresh plots
 if sub_value
     filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileExt_1,InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1);
@@ -2149,5 +2135,5 @@
         end
     case {'video','mmreader'}
-        ParamIn=UvData.MovieObject{1};      
+        ParamIn=UvData.MovieObject{1}; % movie object     
         if strcmp(NomType,'*')
             frame_index=num_i1;%frame index from a single movies or multimage
@@ -2174,10 +2160,21 @@
     ParamIn.VelType=VelType;
     ParamIn.Coord_x=get(handles.Coord_x,'String');
-    ParamIn.Coord_y=get(handles.Coord_y,'Data');
-end
-check_tps = 0;         
-if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') 
-       check_tps=1;%tps needed to get the requested field
-end
+    ParamIn.Coord_y=get(handles.Coord_y,'String');
+    ParamIn.Coord_z=get(handles.Coord_z,'String');
+    TimeName=get(handles.TimeName,'String');
+    r=regexp(TimeName,'^(?<type>(dim:)|(var:))','names');%look for 'var:' or 'dim:' at the beginning of time name
+    if ~isempty(r)
+        frame_index=num_i1;%time index chosen by i1
+        if strcmp(r.type,'dim:')
+            ParamIn.TimeDimName=TimeName(5:end);
+        elseif strcmp(r.type,'var:')
+            ParamIn.TimeVarName=TimeName(5:end);
+        end
+    end 
+end
+% check_tps = 0;         
+% if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') 
+%        check_tps=1;%tps needed to get the requested field
+% end
 [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index);
 if ~isempty(errormsg)
@@ -2224,5 +2221,5 @@
         case {'video','mmreader'}
             ParamIn_1=UvData.MovieObject{2};
-                        if ~strcmp(NomType_1,'*')
+            if ~strcmp(NomType_1,'*')
                 frame_index_1=j1_1;%frame index for movies or multimage
             else
@@ -2245,5 +2242,5 @@
     end
     if isequal(get(handles.NomType_1,'Visible'),'on')
-    NomType_1=get(handles.NomType_1,'String');
+        NomType_1=get(handles.NomType_1,'String');
     else
         NomType_1=get(handles.NomType,'String');
@@ -2261,5 +2258,5 @@
         ParamIn_1.VelType=VelType_1;
         ParamIn_1.Coord_x=get(handles.Coord_x,'String');
-        ParamIn_1.Coord_y=get(handles.Coord_y,'Data');
+        ParamIn_1.Coord_y=get(handles.Coord_y,'String');
         end  
         [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1);
@@ -2312,11 +2309,6 @@
 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
 elseif ~test_keepdata_1
     if (strcmp(UvData.FileType{2},'civx')||strcmp(UvData.FileType{2},'civdata'))&& ~strcmp(FieldName_1,'get_field...')
-%     if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...')
         test_veltype_1=1;
         set(handles.VelType_1,'Visible','on')
@@ -2373,8 +2365,9 @@
 TimeUnit='';
 if isfield(UvData,'TimeUnit')
-TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo
-end
+    TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo
+end
+TimeName=get(handles.TimeName,'String');
+
 % time from xml file or video movie
-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)
@@ -2398,23 +2391,26 @@
 end
 
-% get time in the input file, not defined in a xml file or movie
+% time in the input file, not defined in a xml file or movie
 if isempty(abstime)
     if strcmp(TimeName,'civdata')||strcmp(TimeName,'civx')
         abstime=Field{1}.Time;
-    elseif ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^var:'))
-        abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file
+    elseif ~isempty(regexp(TimeName,'^att:', 'once'))
+        abstime=Field{1}.(TimeName(5:end));%the time is an attribute  selected by get_file 
+        if isfield(Field{1},[TimeName(5:end) 'Unit'])
+            TimeUnit=Field{1}.([TimeName(5:end) 'Unit']);
+        else
+            TimeUnit='';
+        end
+    elseif  ~isempty(regexp(TimeName,'^var:'))
+        abstime=Field{1}.(TimeName(5:end));%the time is a variale selected by get_file
+        % TODO: look for time unit attribute
     elseif ~isempty(regexp(TimeName,'^dim:'))
         abstime=str2num(get(handles.i1,'String'));
+        TimeUnit='index';
     end
     if isfield(Field{1},'Dt')
         dt=Field{1}.Dt;%dt read from the netcdf input file
-        if isfield(Field{1},'TimeUnit')
-            TimeUnit=Field{1}.TimeUnit;
-        end
     elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first
         dt=Field{2}.Dt;%dt read from the netcdf input file
-        if isfield(Field{2},'TimeUnit')
-            TimeUnit=Field{2}.TimeUnit;
-        end
     end
 end 
@@ -2523,59 +2519,6 @@
 UvData.Field=find_field_bounds(UvData.Field);
 
-if UvData.Field.NbDim>1
-    % default projection plane
-    if isempty(UvData.ProjObject{1})
-        UvData.ProjObject{1}.Type='plane';%main plotting plane
-        UvData.ProjObject{1}.ProjMode='projection';%main plotting plane
-       % UvData.ProjObject{1}.Coord=[0 0 0];
-        UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
-        UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
-    end
-    %% 3D case (menuvolume)
-    if UvData.Field.NbDim==3% && UvData.NewSeries
-        test_set_object=1;
-        hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
-        ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
-        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
-        if ~isempty(hset_object) %if set_object is detected
-            delete(hset_object);% delete the GUI set_object if it does not fit
-        end
-        if test_set_object% reinitiate the GUI set_object
-            delete_object(1);% delete the current projection object in the list UvData.ProjObject, delete its graphic representations and update the list displayed in handles.ListObject and 2
-            UvData.ProjObject{1}.NbDim=NbDim;%test for 3D objects
-            UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane
-            UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
-            UvData.ProjObject{1}.Angle=[0 0 0];
-            UvData.ProjObject{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
-            UvData.ProjObject{1}.Name='1-PLANE';
-            UvData.ProjObject{1}.enable_plot=1;
-            set_object(UvData.ProjObject{1},handles,ZBounds);
-            set(hset_object,'name','set_object');% rename if set_object already used with series
-            set(handles.ListObject,'Value',1);
-            set(handles.ListObject,'String',{'1-PLANE'});
-            set(handles.CheckEditObject,'Value',1)% put the plane in edit mode to enable the z cursor
-            CheckEditObject_Callback([],[], handles)
-        end
-        %multilevel case (single menuplane in a 3D space)
-    elseif isfield(UvData,'Z')
-        if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
-            XmlData=UvData.XmlData{1};
-            if isfield(XmlData,'PlanePos')
-                UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
-            end
-            if isfield(XmlData,'PlaneAngle')
-                siz=size(XmlData.PlaneAngle);
-                indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
-                UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
-            end
-        elseif isfield(UvData,'ZIndex')
-            UvData.ProjObject{1}.ZObject=UvData.ZIndex;
-        end
-    end
-end
-
 testnewseries=UvData.NewSeries;
 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
-set(handles.uvmat,'UserData',UvData)
 
 %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
@@ -2588,6 +2531,4 @@
 if UvData.Field.NbDim<=1
     set(handles.Objects,'Visible','off')
-%     set(handles.ListObject_1_title,'Visible','off')
-%     set(handles.ListObject_1,'Visible','off')
     [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat));
     errormsg=fill_GUI(PlotParamOut,handles.uvmat);
@@ -2597,15 +2538,12 @@
         end
     end
-    
+    set(handles.uvmat,'UserData',UvData)
 %% 2D or 3D fieldname are generally projected
 else
     set(handles.Objects,'Visible','on')
-%     set(handles.ListObject_1_title,'Visible','on')
-%     set(handles.ListObject_1,'Visible','on')
     
     %% Plot the projections on the selected  projection objects
-    % main projection object (uvmat display)
-    list_object=get(handles.ListObject_1,'String');
-    if isequal(list_object,{''})||isequal(list_object,' ')%refresh list of objects if the menu is empty
+    %if no projection object exists, create a default one
+    if isempty(UvData.ProjObject{1})
         set(handles.ListObject,'Value',1)
         set(handles.ListObject,'String',{'plane'})
@@ -2616,4 +2554,27 @@
         set(handles.ListObject_1,'Value',1)
         set(handles.ListObject_1,'String',{'plane'})
+        if UvData.Field.NbDim==3 %3D case
+%             ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
+%             ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
+            UvData.ProjObject{1}.NbDim=3;%test for 3D objects
+            UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane
+            UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
+            UvData.ProjObject{1}.Angle=[0 0 0];
+        elseif isfield(UvData,'Z')
+            %multilevel case (single menuplane in a 3D space)
+            if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
+                XmlData=UvData.XmlData{1};
+                if isfield(XmlData,'PlanePos')
+                    UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
+                end
+                if isfield(XmlData,'PlaneAngle')
+                    siz=size(XmlData.PlaneAngle);
+                    indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
+                    UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
+                end
+            elseif isfield(UvData,'ZIndex')
+                UvData.ProjObject{1}.ZObject=UvData.ZIndex;
+            end
+        end
     end
     IndexObj=get(handles.ListObject_1,'Value');%selected projection object for main view
@@ -2648,5 +2609,5 @@
     
     %% second projection object (view_field display)
-    if length( IndexObj)>=2
+    if length( IndexObj)==2
         view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
         if ~isempty(view_field_handle)
@@ -2654,5 +2615,4 @@
             haxes(2)=plot_handles{2}.PlotAxes;
             PlotParam{2}=read_GUI(view_field_handle);
-           % PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface
             PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
         end
@@ -2665,4 +2625,10 @@
         if numel(UvData.ProjObject)<iobj
             break
+        end
+        if UvData.Field.NbDim==3% TO GENERALISE
+            UvData.ProjObject{iobj}.NbDim=3;%test for 3D objects
+            UvData.ProjObject{iobj}.RangeZ=UvData.Field.CoordMesh;%main plotting plane
+            UvData.ProjObject{iobj}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
+            UvData.ProjObject{iobj}.Angle=[0 0 0];
         end
         [ObjectData,errormsg]=proj_field(UvData.Field,UvData.ProjObject{iobj});% project field on the object
@@ -2727,4 +2693,6 @@
     end
     
+    set(handles.uvmat,'UserData',UvData)
+    
     %% update the mask
     if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
@@ -2778,4 +2746,8 @@
     end
 end
+
+if UvData.Field.NbDim==3
+    CheckEditObject_Callback(handles.uvmat, [], handles)
+end   
 ResizeFcn(handles.uvmat,[],handles)
 set(handles.uvmat,'Pointer',pointer)
@@ -2784,15 +2756,17 @@
 function histo1_menu_Callback(hObject, eventdata, handles)
 %--------------------------------------------
+%% get the current field stored in uvmat user data
+UvData=get(handles.uvmat,'UserData');
+Field=UvData.Field;
+
+%% get from the menu 'histo1_menu' the name(s) of the fields to use
 histo_menu=get(handles.histo1_menu,'String');
 histo_value=get(handles.histo1_menu,'Value');
 FieldName=histo_menu{histo_value};
-
-UvData=get(handles.uvmat,'UserData');
-Field=UvData.Field;
 r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names');
 FieldName_2='';
 if ~isempty(r)
-    FieldName=r.var1;
-    FieldName_2=r.var2;
+    FieldName=r.var1;% name of first variable
+    FieldName_2=r.var2;% name of second variable
 end
 if ~isfield(UvData.Field,FieldName)
@@ -2800,16 +2774,35 @@
     return
 end
-FieldHisto=Field.(FieldName);
-if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
+
+%% extract the fields to use
+% eliminate false data if relevant (false flag FF exists)
+check_false=0;
+if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(Field.(FieldName)))
     indsel=find(Field.FF==0);%find values marked as false
     if ~isempty(indsel)
-        FieldHisto=FieldHisto(indsel);
+        FieldHisto=Field.(FieldName)(indsel);%field of the first variable (U)
         if ~isempty(FieldName_2)
-            FieldHisto(:,:,2)=Field.(FieldName_2)(indsel);
-        end
-    end
-elseif ~isempty(FieldName_2)
-    FieldHisto(:,:,2)=Field.(FieldName_2);
-end
+            if isfield(Field,'NbDim') && Field.NbDim==3
+                 FieldHisto(:,:,:,2)=Field.(FieldName_2)(indsel);%field of the second variable (U)
+            else
+            FieldHisto(:,:,2)=Field.(FieldName_2)(indsel);%field of the second variable (U)
+            end
+        end
+        check_false=1;
+    end
+end
+% no false data
+if ~check_false
+    FieldHisto=Field.(FieldName);%field of the first variable (U)
+    if ~isempty(FieldName_2)
+        if isfield(Field,'NbDim') && Field.NbDim==3
+            FieldHisto(:,:,:,2)=Field.(FieldName_2);%field of the second variable (V)
+        else
+            FieldHisto(:,:,2)=Field.(FieldName_2);%field of the second variable (V)
+        end
+    end
+end
+
+%% calculate and plot histogram
 if isempty(Field)
     msgbox_uvmat('ERROR',['empty field ' FieldName])
@@ -2844,5 +2837,5 @@
             Histo.VarAttribute{1}.units=units;
         end
-        eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
+        Histo.(FieldName)=linspace(Amin,Amax,50); %absissa values for histo
         if isfield(Field,'NbDim') && isequal(Field.NbDim,3)
             C=reshape(double(FieldHisto),1,[]);% reshape in a vector
@@ -3102,5 +3095,6 @@
 %------------------------------------------------------------------------
 % --- Executes on menu selection FieldName
-function FieldName_Callback(hObject, eventdata, handles)
+
+    function FieldName_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
 
@@ -3114,6 +3108,5 @@
 [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
@@ -3156,9 +3149,13 @@
         FieldList={};
         VecColorList={''};
+        ZName='';
         switch GetFieldData.FieldOption
             case 'vectors'
                 UName=GetFieldData.PanelVectors.vector_x;
                 VName=GetFieldData.PanelVectors.vector_y;
-                YName={GetFieldData.Coordinates.Coord_y};
+                YName=GetFieldData.Coordinates.Coord_y;
+                if isfield(GetFieldData.Coordinates,'Coord_z')
+                ZName=GetFieldData.Coordinates.Coord_z;
+                end
                 CName=GetFieldData.PanelVectors.vec_color;
                 FieldList={['vec(' UName ',' VName ')'];...
@@ -3172,5 +3169,8 @@
             case 'scalar'
                 AName=GetFieldData.PanelScalar.scalar;
-                YName={GetFieldData.Coordinates.Coord_y};
+                YName=GetFieldData.Coordinates.Coord_y;
+                if isfield(GetFieldData.Coordinates,'Coord_z')
+                ZName=GetFieldData.Coordinates.Coord_z;
+                end
                 FieldList={AName};
             case '1D plot'
@@ -3179,4 +3179,5 @@
                 display_file_name(handles,FileName,1)
         end
+        % get time as file index, attribute, variable or matrix index
         if ~strcmp(GetFieldData.FieldOption,'civdata...')
             XName=GetFieldData.Coordinates.Coord_x;
@@ -3191,18 +3192,21 @@
                     set(handles.NomType,'String','*')
                     set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
+                    set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix)
                     set(handles.FileIndex,'String','')
                     ParamIn.TimeVarName=GetFieldData.Time.TimeName;
-                case 'matrix_index'
+                case 'matrix index'
                     set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]);
                     set(handles.NomType,'String','*')
                     set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
+                    set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix)
                     set(handles.FileIndex,'String','')
                     ParamIn.TimeDimName=GetFieldData.Time.TimeName;
             end
             set(handles.Coord_x,'String',XName)
-            if ischar(YName)
-                YName={YName};
-            end
-            set(handles.Coord_y,'Data',YName)
+%             if ischar(YName)
+%                 YName={YName};
+%             end
+            set(handles.Coord_y,'String',YName)
+            set(handles.Coord_z,'String',ZName)
             set(handles.FieldName,'Value',1)
             set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
@@ -3313,5 +3317,5 @@
                 UName=GetFieldData.PanelVectors.vector_x;
                 VName=GetFieldData.PanelVectors.vector_y;
-                YName={GetFieldData.Coordinates.Coord_y};
+                YName=GetFieldData.Coordinates.Coord_y;
                 CName=GetFieldData.PanelVectors.vec_color;
                 FieldList={['vec(' UName ',' VName ')'];...
@@ -3325,5 +3329,5 @@
             case 'scalar'
                 AName=GetFieldData.PanelScalar.scalar;
-                YName={GetFieldData.Coordinates.Coord_y};
+                YName=GetFieldData.Coordinates.Coord_y;
                 FieldList={AName};
             case '1D plot'
@@ -3354,8 +3358,8 @@
             end
             set(handles.Coord_x,'String',XName)
-            if ischar(YName)
-                YName={YName};
-            end
-            set(handles.Coord_y,'Data',YName)
+%             if ischar(YName)
+%                 YName={YName};
+%             end
+            set(handles.Coord_y,'String',YName)
             set(handles.FieldName_1,'Value',1)
             set(handles.FieldName_1,'String',[FieldList; {'get_field...'}]);
@@ -3796,5 +3800,4 @@
 
 %% adapt the GUI to the input/output conditions of the selected transform fct
-DataOut=[];
 CoordUnit='';
 CoordUnitPrev='';
@@ -3804,6 +3807,5 @@
 if ~isempty(list_path{ichoice}) 
     if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData)
-        %XmlData=UvData.XmlData{1};
-        DataOut=feval(transform_handle,'*',UvData.XmlData{1});
+        DataOut=feval(transform_handle,'*',UvData.XmlData{1});% execute the transform fct to get the required conditions
         if isfield(DataOut,'CoordUnit')% set the requested coord unit (info used to possibly delete the current projection objects)
             CoordUnit=DataOut.CoordUnit;
@@ -3814,14 +3816,7 @@
         if isfield(DataOut,'TransformInput')%  used to add transform parameters at selection of the transform fct
             UvData.XmlData{1}.TransformInput=DataOut.TransformInput;
-%             ListFields=fieldnames(DataOut.XmlData);
-%             for ilist=1:numel(ListFields)
-%             UvData.XmlData{1}.(ListFields{ilist})=DataOut.XmlData.(ListFields{ilist});
-%             end
-        end
-%     else
-%         DataOut=feval(transform_handle,'*');
-    end
-end
-
+        end
+    end
+end
 
 %% delete drawn objects if the output CooordUnit is different from the previous one
@@ -4306,6 +4301,4 @@
     ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
     [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interface
-    
-    %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
     haxes=findobj(hview_field,'tag','axes3');
     pos=get(hview_field,'Position');  
@@ -4485,5 +4478,4 @@
         end
     end
-    %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
     haxes=findobj(hview_field,'tag','axes3');
     pos=get(hview_field,'Position');
@@ -4494,5 +4486,4 @@
     else
         Data=get(hview_field,'UserData');
-%         set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots
     end
 else
@@ -5545,6 +5536,6 @@
 Param.TransformName=TransformList{get(handles.TransformName,'Value')};
 Param.Coord_x_str=get(handles.Coord_x,'String');
-Param.Coord_x_val=get(handles.Coord_x,'Value');
-Param.Coord_y_str=get(handles.Coord_y,'Data');
+%Param.Coord_x_val=get(handles.Coord_x,'Value');
+Param.Coord_y_str=get(handles.Coord_y,'String');
 
 % --------------------------------------------------------------------
@@ -5562,23 +5553,4 @@
 % end
 
-% --- Executes on selection change in Coord_y.
-function Coord_y_Callback(hObject, eventdata, handles)
-
-% --- Executes on selection change in Coord_x.
-function Coord_x_Callback(hObject, eventdata, handles)
-
-
-% --- Executes on button press in CheckColorBar.
-function CheckColorBar_Callback(hObject, eventdata, handles)
-
-
-
-function TransformPath_Callback(hObject, eventdata, handles)
-% hObject    handle to TransformPath (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of TransformPath as text
-%        str2double(get(hObject,'String')) returns contents of TransformPath as a double
 
 
@@ -5692,2 +5664,25 @@
     set(handles.TableDisplay,'Visible','off')
 end
+
+
+
+function Coord_z_Callback(hObject, eventdata, handles)
+% hObject    handle to Coord_z (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of Coord_z as text
+%        str2double(get(hObject,'String')) returns contents of Coord_z as a double
+
+
+% --- Executes during object creation, after setting all properties.
+function Coord_z_CreateFcn(hObject, eventdata, handles)
+% hObject    handle to Coord_z (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    empty - handles not created until after all CreateFcns called
+
+% Hint: edit controls usually have a white background on Windows.
+%       See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+    set(hObject,'BackgroundColor','white');
+end
