Index: /trunk/src/cell2tab.m
===================================================================
--- /trunk/src/cell2tab.m	(revision 127)
+++ /trunk/src/cell2tab.m	(revision 128)
@@ -4,33 +4,39 @@
 %
 % OUTPUT:
-% Tabchar: character array suitable for table display
+% Tabchar: column cell of char strings suitable for display (equal length)
 %
 % INPUT:
-% Tabcell: (ni,nj) cell table, for ni lines 
-% separator: character used for separating displayed columns
+% Tabcell: (ni,nj) cell matrix of char strings to be displayed as  ni lines , nj column
+% separator: char string used for separating displayed columns
 
 function Tabchar=cell2tab(Tabcell,separator) 
-Tabchar={};%default
 [ni,nj]=size(Tabcell);
 
 %determine width of each column
-widthcolumn=max(cellfun(@length,Tabcell));
+if isequal(ni,1)
+    widthcolumn=cellfun('length',Tabcell);% case of a single line, no justification used
+else
+    widthcolumn=max(cellfun('length',Tabcell));
+end
+lsep=numel(separator); %nbre of characters of the separator
+nbchar_line=(sum(widthcolumn)+(nj-1)*lsep); %total nbre of characters in each output line
+default_line=blanks(nbchar_line); %default blank line
+Tabmat=reshape(blanks(nbchar_line*ni),ni,nbchar_line);
+Tabchar=mat2cell(Tabmat,ones(1,ni),nbchar_line); %default output
 
 %justify table
 for itab=1:ni    
-    charchain=[];         
+    charchain=default_line;  
     for jtab=1:nj% read line
         textlu=Tabcell{itab,jtab};
-        if widthcolumn(jtab)>length(textlu)
-            blankstr=char(32*ones(1,widthcolumn(jtab)-length(textlu)));
-            textlu=[textlu blankstr];
+        if jtab==1
+            charchain(1:length(textlu))=textlu;%introduce separator chain string except for the first column
+            ind_column=widthcolumn(1);%new current char index in the line
+        else
+            charchain(ind_column+1:ind_column+lsep)=separator;%introduce separator chain string except for the first column
+            charchain(ind_column+lsep+1:ind_column+lsep+length(textlu))=textlu;%introduce separator chain string except for the first column
+            ind_column=ind_column+widthcolumn(jtab)+lsep;
         end
-        if ~isempty(charchain)
-            textlu=[separator textlu];
-        end
-        charchain=[charchain textlu];
     end
     Tabchar(itab,1)={charchain};
 end
-
-%nb : char(Tabchar(:,jtab)) gives directly a column with the blanks filled
Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 127)
+++ /trunk/src/civ.m	(revision 128)
@@ -92,4 +92,5 @@
 if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat
     set(handles.ImaExt,'String',ext)
+    browse.ext_ima=ext;
     if exist('nom_type_read','var')
         browse.nom_type_ima=nom_type_read; % the image nomenclature is stored
@@ -452,5 +453,5 @@
 pxcmy_search=[];%default
 filebase=get(handles.RootName,'String');
-ext=get(handles.ImaDoc,'String');
+ext_imadoc=get(handles.ImaDoc,'String');
 browse=get(handles.browse_root,'UserData')%default
 if isfield(browse,'nom_type_ima')
@@ -498,17 +499,17 @@
 
 %look for an image documentation file
-if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI')
+if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi')
     if exist([filebase '.xml'],'file')
-        ext='.xml';
+        ext_imadoc='.xml';
     elseif exist([filebase '.civxml'],'file')
-        ext='.civxml';
+        ext_imadoc='.civxml';
     elseif exist([filebase '.civ'],'file')
-        ext='.civ';
+        ext_imadoc='.civ';
     elseif exist([filebase '.avi'],'file')
-        ext='.avi';
+        ext_imadoc='.avi';
     elseif exist([filebase '.AVI'],'file')
-        ext='.AVI';
-    end
-    set(handles.ImaDoc,'String',ext)
+        ext_imadoc='.AVI';
+    end
+    set(handles.ImaDoc,'String',ext_imadoc)
 end
 
@@ -517,8 +518,8 @@
 set(handles.ImaDoc,'BackgroundColor',[1 1 0])
 drawnow
-if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ')
+if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ')
     set(handles.ref_i,'Visible','On')%use a reference index
     set(handles.ref_j,'Visible','On')
-elseif isequal(ext,'.avi') || isequal(ext,'.AVI')
+elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI')
     set(handles.ref_j,'Visible','Off')
 else
@@ -527,5 +528,5 @@
 end
 testima_xml=0;
-if isequal(ext,'.civxml')%TO ABANDON
+if isequal(ext_imadoc,'.civxml')%TO ABANDON
     [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']);
     mode='pair j1-j2';
@@ -533,5 +534,5 @@
         nom_type_ima='_i_j';
     end
-elseif isequal(ext,'.xml')
+elseif isequal(ext_imadoc,'.xml')
     [XmlData,warntext]=imadoc2struct([filebase '.xml']);
     ext_ima_read=[];
@@ -577,28 +578,27 @@
         end
     end
-    if ~isempty(ext_ima_read) && ~isempty(nom_type_read)
-%         if isempty(ext_ima)
-%             ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously
-%         else   %keep the image extension
-%             if  ~strcmp(ext_ima_read,ext_ima)
-%                 msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image'])
-%             end
-%         end
-        nom_type_ima=nom_type_read;
-    end
-elseif strcmp(ext,'.civ')% case of .civ image documentation file
+%     if ~isempty(ext_ima_read) && ~isempty(nom_type_read)
+% %         if isempty(ext_ima)
+% %             ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously
+% %         else   %keep the image extension
+% %             if  ~strcmp(ext_ima_read,ext_ima)
+% %                 msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image'])
+% %             end
+% %         end
+%         nom_type_ima=nom_type_read;
+%     end
+elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file
     [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']);
     if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']);
     elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
     end
-    %         ImaExt='.png';
-    nom_type_ima='png_old';
-elseif strcmpi(ext,'.avi')
+    nom_type_ima='001a';
+elseif strcmpi(ext_imadoc,'.avi')
     nom_type_ima='*';
-    ext_ima=ext;
+    ext_ima=ext_imadoc;
     set(handles.mode,'String',{'series(Di)'})
     dt=0.04;%default
-    if exist([filebase ext],'file')==2
-        info=aviinfo([filebase ext]);%read infos on the avi movie
+    if exist([filebase ext_imadoc],'file')==2
+        info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie
         dt=1/info.FramesPerSecond;%time interval between successive frames
         nbfield=info.NumFrames;%number of frames
@@ -627,15 +627,6 @@
                 appendix=char(96+first_j);
                 dirima=dir([filebase '*' num2str(first_i) appendix '.*']);
-%                 if ~isempty(dirima)
-%                     [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
-%                 end
-%             else
-%                 [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
-            end
-%         else
-%             [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
-        end
-%     else
-%         [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
+            end
+        end
     end
 end
@@ -651,5 +642,5 @@
 % no image documentation file found: look for a series of existing files,images by priority or .nc files
 if isempty(nom_type_ima)
-    ext_search=ext;
+    ext_search=ext_imadoc;
     nom_type_search=nom_type_nc;
 else
@@ -2988,10 +2979,18 @@
         %create the new subdir_civ1
         if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir')
-            [xx,m2]=mkdir(subdir_civ1_new);
-            if ~isequal(m2,'')
-                msgbox_uvmat('ERROR', m2)%error message for directory creation
+            [xx,msg1]=mkdir(subdir_civ1_new);
+            if ~strcmp(msg1,'')
+                msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation
                 cd(currentdir)
                 filecell={};
                 return
+            else
+                [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g)
+                if ~strcmp(msg2,'')
+                    msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg2])%error message for directory creation
+                    cd(currentdir)
+                    filecell={};
+                    return
+                end
             end
         end
@@ -3024,10 +3023,18 @@
             %create the new subdir_civ1
             if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir')
-                [xx,m2]=mkdir(subdir_civ1_new);
-                if ~isequal(m2,'')
-                    msgbox_uvmat('ERROR', m2)
+                [xx,msg1]=mkdir(subdir_civ1_new);
+                if ~strcmpl(msg1,'')
+                    msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])
                     cd(currentdir)
                     filecell={};
                     return
+                else
+                    [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g)
+                    if ~strcmp(msg2,'')
+                        msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation
+                        cd(currentdir)
+                        filecell={};
+                        return
+                    end
                 end
             end
@@ -3151,9 +3158,10 @@
             end
         end
-        %create the new subdir_civ2
-        if ~exist(fullfile(Path_ima,subdir_civ2),'dir')
-            [xx,m2]=mkdir(subdir_civ2);
+        %create the new subdir_civ2_new
+        if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir')
+            [xx,m2]=mkdir(subdir_civ2_new);
+            [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g)
             if ~isequal(m2,'')
-                msgbox_uvmat('ERROR', m2)
+                msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2])
                 filecell={};
                 cd(currentdir)
@@ -3188,6 +3196,7 @@
             if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir')
                 [xx,m2]=mkdir(subdir_civ2_new);
+                 [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g)
                 if ~isequal(m2,'')
-                    msgbox_uvmat('ERROR', m2)%error message for directory creation
+                    msgbox_uvmat('ERROR', ['cannot create ' subdir_civ2_new ': ' m2])%error message for directory creation
                     cd(currentdir)
                     filecell={};
Index: /trunk/src/dataview.m
===================================================================
--- /trunk/src/dataview.m	(revision 127)
+++ /trunk/src/dataview.m	(revision 128)
@@ -32,5 +32,5 @@
                    'gui_LayoutFcn',  [] , ...
                    'gui_Callback',   []);
-if nargin & ischar(varargin{1})
+if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))              
     gui_State.gui_Callback = str2func(varargin{1});
 end
@@ -119,5 +119,8 @@
 function browser_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
-CurrentFile='/raid/PROJETS';%get(handles.RootDirectory,'String');
+CurrentFile=fileparts(get(handles.RootDirectory,'String'));
+if ~exist(CurrentFile,'dir')
+    CurrentFile='/fsnet/project/coriolis';
+end
 set(handles.SubCampaignTest,'Value',0)
 CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser
@@ -129,5 +132,8 @@
 function OpenSubCampaign_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
-CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String');
+CurrentFile=get(handles.RootDirectory,'String');
+if ~exist(CurrentFile,'dir')
+    CurrentFile='/fsnet/project/coriolis';
+end
 set(handles.SubCampaignTest,'Value',1)
 CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser
@@ -184,7 +190,9 @@
 set(handles.ListDevices,'String',[{'*'};ListDevices'])
 set(handles.ListXml,'String',[{'*'};ListXml'])
+'TEST'
+testList
 if testList
     DataviewData=get(handles.figure,'UserData');
-    DataView.List=List;
+    DataviewData.List=List;
     set(handles.figure,'UserData',DataviewData)
 end
@@ -502,10 +510,10 @@
 message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)';
 answer=msgbox_uvmat('INPUT_Y-N',message);
-if ~isequal(answer{1},'OK')
+if ~isequal(answer,'Yes')
     return
 end
 set(handles.ListExperiments,'Value',1)
 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
-DataviewData=get(handles.figure,'UserData');
+DataviewData=get(handles.figure,'UserData')
 List=DataviewData.List;
 Currentpath=get(handles.RootDirectory,'String');
Index: /trunk/src/geometry_calib.m
===================================================================
--- /trunk/src/geometry_calib.m	(revision 127)
+++ /trunk/src/geometry_calib.m	(revision 128)
@@ -54,5 +54,5 @@
                    'gui_LayoutFcn',  [] , ...
                    'gui_Callback',   []);
-if nargin && ischar(varargin{1})
+if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))
     gui_State.gui_Callback = str2func(varargin{1});
 end
@@ -95,6 +95,5 @@
 if exist('inputfile','var')&& ~isempty(inputfile)
     struct.XmlInputFile=inputfile;
-    set(hObject,'UserData',struct)
-    [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(inputfile);
+    [Pathsub,RootFile,field_count,str2,str_a,str_b,ext]=name2display(inputfile);
     if ~strcmp(ext,'.xml')
         inputfile=[fullfile(Pathsub,RootFile) '.xml'];%xml file corresponding to the input file
@@ -103,6 +102,10 @@
 set(handles.ListCoord,'String',{'......'})
 if exist(inputfile,'file')
-    loadfile(handles,inputfile)% load the point coordiantes existing in the xml file
-end
+    Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file
+end
+if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
+    struct.Campaign=Heading.Campaign;
+end
+set(hObject,'UserData',struct)
 set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
 
@@ -213,4 +216,6 @@
     ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];...
     ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']});
+
+%% record the calibration parameters and display the current image of uvmat in the new phys coordinates
 if strcmp(answer,'Yes')
     if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration
@@ -219,5 +224,5 @@
             Z_plane=0; %default
         else
-            Z_plane=str2num(answer_1);
+            Z_plane=str2double(answer_1);
         end
         GeometryCalib.NbSlice=1;
@@ -228,4 +233,5 @@
         msgbox_uvmat('ERROR',errormsg);
     end
+    
     %display image with new calibration in the currently opened uvmat interface
     hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers
@@ -251,12 +257,11 @@
 %------------------------------------------------------------------
 % --- Executes on button press in calibrate_lin.
+
 function REPLICATE_Callback(hObject, eventdata, handles)
-% %%%%%%Todo: correct on the model of APPLY_Callback%%%%%%%%%%
-%------------------------------------------------------------------------
-calib_cell=get(handles.calib_type,'String');
-val=get(handles.calib_type,'Value');
-Coord_cell=get(handles.ListCoord,'String');
-Object=read_geometry_calib(Coord_cell);
-GeometryCalib=feval(['calib_' calib_cell{val}],Object.Coord,handles);
+%------------------------------------------------------------------------
+
+%% Apply calibration
+calib_cell=get(handles.calib_type,'String'); %#ok<NASGU>
+val=get(handles.calib_type,'Value'); %#ok<NASGU>
 
 %read the current calibration points
@@ -288,5 +293,5 @@
     [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima));
     [EM,ind_dim]=max(GeometryCalib.ErrorMax);
-    index=index(ind_dim);
+%     index=index(ind_dim);
     %set the Z position of the reference plane used for calibration
     Z_plane=[];
@@ -295,5 +300,5 @@
     end
     answer_1=msgbox_uvmat('INPUT_TXT',' Z= ',num2str(Z_plane)); 
-    Z_plane=str2num(answer_1);
+    Z_plane=str2double(answer_1);
     GeometryCalib.NbSlice=1;
     GeometryCalib.SliceCoord=[0 0 Z_plane];
@@ -304,9 +309,7 @@
     %record the points
     GeometryCalib.SourceCalib.PointCoord=Coord;
-%     errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file
-%     if ~strcmp(errormsg,'')
-%         msgbox_uvmat('ERROR',errormsg);
-%     end
-end
+end
+
+%% display calibration paprameters
 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters
 
@@ -319,24 +322,5 @@
 set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
 
-% indicate the plane of the calibration grid if defined
-% huvmat=findobj(allchild(0),'Name','uvmat');
-% hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
-% RootPath='';
-% RootFile='';
-% if ~isempty(hhuvmat.RootPath)& ~isempty(hhuvmat.RootFile)
-%     testhandle=1;
-%     RootPath=get(hhuvmat.RootPath,'String');
-%     RootFile=get(hhuvmat.RootFile,'String');
-%     filebase=fullfile(RootPath,RootFile);
-%     outputfile=[filebase '.xml'];
-% else
-%     question={'save the calibration data and point coordinates in'};
-%     def={fullfile(RootPath,['ObjectCalib.xml'])};
-%     options.Resize='on';
-%     answer=inputdlg(question,'save average in a new file',1,def,options);
-%     outputfile=answer{1};
-% end
-
-%open and read the dataview GUI
+%% open the GUI dataview 
 h_dataview=findobj(allchild(0),'name','dataview');
 if ~isempty(h_dataview)
@@ -344,47 +328,64 @@
 end
 CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata
-
+InputFile='';
 if isfield(CalibData,'XmlInputFile')
-    XmlInput=fileparts(CalibData.XmlInputFile);
-    [XmlInput,filename,ext]=fileparts(XmlInput);
+    InputDir=fileparts(CalibData.XmlInputFile);
+    [InputDir,DirName]=fileparts(InputDir);
 end
 SubCampaignTest='n'; %default
-testinput=0;
-if isfield(CalibData,'Heading')
-    Heading=CalibData.Heading;
-    if isfield(Heading,'Record') && isequal([filename ext],Heading.Record)
-        [XmlInput,filename,ext]=fileparts(XmlInput);
-    end
-    if isfield(Heading,'Device') && isequal([filename ext],Heading.Device)
-        [XmlInput,filename,ext]=fileparts(XmlInput);
-        Device=Heading.Device;
-    end
-    if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment)
-        [PP,filename,ext]=fileparts(XmlInput);
-    end
-    testinput=0;
-    if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign)
-        SubCampaignTest='y';
-        testinput=1;
-    elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign)
-        testinput=1;
-    end 
-end
-if ~testinput
-    filename='PROJETS';%default
-    if isfield(CalibData,'XmlInputFile')
-         [pp,filename]=fileparts(CalibData.XmlInputFile);
-    end
-    while ~isequal(filename,'PROJETS') && numel(filename)>1
-        filename_1=filename;
-        pp_1=pp;
-        [pp,filename]=fileparts(pp);
-    end
-    XmlInput=fullfile(pp_1,filename_1);
-    testinput=1;
-end
-if testinput
-    outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib);
-end
+testup=0;
+if isfield(CalibData,'SubCampaign')
+    SubCampaignTest='y';
+    dir_ref=CalibData.SubCampaign;
+    testup=1;
+elseif isfield(CalibData,'Campaign')
+    dir_ref=CalibData.Campaign;
+    testup=1;
+end
+while testup
+    [InputDir,DirName]=fileparts(InputDir);
+    if strcmp(DirName,dir_ref)
+        break
+    end
+end
+InputDir=fullfile(InputDir,DirName);
+answer=msgbox_uvmat('INPUT_TXT','Campaign ?',InputDir); 
+if strcmp(answer,'Cancel')
+    return
+end
+
+dataview(answer,SubCampaignTest,GeometryCalib);
+        
+%     if isfield(Heading,'Device') && isequal([filename ext],Heading.Device)
+%         [XmlInput,filename,ext]=fileparts(XmlInput);
+%         Device=Heading.Device;
+%     end
+%     if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment)
+%         [PP,filename,ext]=fileparts(XmlInput);
+%     end
+%     testinput=0;
+%     if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign)
+%         SubCampaignTest='y';
+%         testinput=1;
+%     elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign)
+%         testinput=1;
+% %     end 
+% end
+% if ~testinput
+%     filename='PROJETS';%default
+%     if isfield(CalibData,'XmlInputFile')
+%          [pp,filename]=fileparts(CalibData.XmlInputFile);
+%     end
+%     while ~isequal(filename,'PROJETS') && numel(filename)>1
+%         filename_1=filename;
+%         pp_1=pp;
+%         [pp,filename]=fileparts(pp);
+%     end
+%     XmlInput=fullfile(pp_1,filename_1);
+%     testinput=1;
+% end
+% if testinput
+%     outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib);
+% end
 
 %------------------------------------------------------------------------
@@ -434,5 +435,5 @@
 R=[R;[0 0]];
 GeometryCalib.R=[R [0;0;1]];
-GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0]
+GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0];
 %------------------------------------------------------------------------
 % determine the tsai parameters for a view normal to the grid plane
@@ -700,5 +701,5 @@
 
 %--------------------------------------------------------------------------
-function GeometryCalib=calib_tsai(Coord,handles)% old version using gauthier's bianry ccal_fo
+function GeometryCalib=calib_tsai(Coord,handles)% OBSOLETE: old version using gauthier's bianry ccal_fo
 % NOT USED
 %------------------------------------------------------------------------
@@ -811,6 +812,6 @@
 huvmat=findobj(allchild(0),'Name','uvmat');
 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
-RootPath='';
-RootFile='';
+% RootPath='';
+% RootFile='';
 if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile)
     testhandle=1;
@@ -830,5 +831,5 @@
         listfile={outputfile};
     else
-        listfile=[listfile;{outputfile}]%update the list of coord files
+        listfile=[listfile;{outputfile}];%update the list of coord files
     end
     set(handles.coord_files,'string',listfile);
@@ -901,5 +902,5 @@
 end
 coord_str=Coord_cell{val};
-k=findstr('|',coord_str);
+k=findstr(' | ',coord_str);
 if isempty(k)%last line '.....' selected
     if ~isempty(hhh)
@@ -1000,7 +1001,7 @@
 %------------------------------------------------------------------------
 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
-UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
+%UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
 hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
-hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
+%hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
 h_menu_coord=findobj(huvmat,'Tag','transform_fct');
 menu=get(h_menu_coord,'String');
@@ -1079,5 +1080,5 @@
 
 %size(data.Coord,1)
-Tabchar=cell2tab(Coord,'    |    ');
+Tabchar=cell2tab(Coord,' | ');
 Tabchar=[Tabchar ;{'......'}];
 set(handles.ListCoord,'String',Tabchar)
@@ -1236,5 +1237,5 @@
      Coord{ipoint,5}=num2str(Ypx(ipoint),4);%display coordiantes with 4 digits
 end
-Tabchar=cell2tab(Coord(end:-1:1,:),'    |    ');
+Tabchar=cell2tab(Coord(end:-1:1,:),' | ');
 Tabchar=[Tabchar ;{'......'}];
 set(handles.ListCoord,'Value',1)
@@ -1266,5 +1267,5 @@
    end
 end
-Tabchar=cell2tab(Coord,'    |    ');
+Tabchar=cell2tab(Coord,' | ');
 Tabchar=[Tabchar; {'.....'}];
 %set(handles.ListCoord,'Value',1)
@@ -1310,5 +1311,5 @@
    end
 end
-Tabchar=cell2tab(Coord,'    |    ');
+Tabchar=cell2tab(Coord,'| ');
 Tabchar=[Tabchar;{'......'}];
 set(handles.ListCoord,'Value',1)
@@ -1460,5 +1461,5 @@
 end
 CoordCell=reshape(CoordCell,[],5);
-Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
+Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
 Tabchar=[Tabchar;{'......'}];
 set(handles.ListCoord,'Value',1)
@@ -1541,7 +1542,16 @@
 
 % -----------------------------------------------------------------------
-function loadfile(handles,fileinput)
-%------------------------------------------------------------------------
+function Heading=loadfile(handles,fileinput)
+%------------------------------------------------------------------------
+Heading=[];%default
 [s,errormsg]=imadoc2struct(fileinput,'GeometryCalib');
+if ~isempty(errormsg)
+    msgbox_uvmat('ERROR',['Error for reading ' fileinput ': '  errormsg])
+    return
+end
+if ~isempty(s.Heading)
+    Heading=s.Heading;
+end
+    
 GeometryCalib=s.GeometryCalib;
 fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
@@ -1585,5 +1595,5 @@
     end
     CoordCell=reshape(CoordCell,[],5);
-    Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
+    Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
     MenuPlot_Callback(handles.geometry_calib, [], handles)
 end
Index: /trunk/src/get_field.m
===================================================================
--- /trunk/src/get_field.m	(revision 127)
+++ /trunk/src/get_field.m	(revision 128)
@@ -32,5 +32,5 @@
                    'gui_LayoutFcn',  [] , ...
                    'gui_Callback',   []);
-if nargin & isstr(varargin{1})
+if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
     gui_State.gui_Callback = str2func(varargin{1});
 end
@@ -48,14 +48,19 @@
 %------------------------------------------------------------------------
 global nb_builtin
+
+%% look at the existing figues in the work space
 browse_fig(handles.list_fig)
 
-% Choose default command line output for get_field
+%% Choose default command line output for get_field
 handles.output = hObject;
 
-% Update handles structure
+%% Update handles structure
 guidata(hObject, handles);
 
-%ACTION menu: builtin fcts
-menu_str={'PLOT';'FFT';'filter_band';'histogram'}; %list of functions included in 'get_field.m'
+%% activate the mouse action function: visualise the current field on work space by right click action
+set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})
+
+%% prepare the list of builtin fcts and set their paths
+menu_str={'PLOT';'FFT';'filter_band';'histogram'}; %list of functions included by default in 'get_field.m'
 nb_builtin=numel(menu_str);
 path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat'
@@ -72,5 +77,4 @@
 end
 rmpath(fullfile(path_uvmat,'get_field'))
-
 dir_perso=prefdir;
 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
@@ -102,6 +106,7 @@
 set(handles.path_action,'String',fullfile(path_uvmat,'get_field'))
 set(handles.ACTION,'Value',1)% PLOT option selected
-set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})%set mouse click action function
-if exist('filename','var')& ischar(filename)
+
+%% settings for 'slave' mode, called by uvamt, or 'master' mode
+if exist('filename','var') && ischar(filename) %transfer input file name in slave mode
     set(handles.inputfile,'String',filename)% prefill the input file name 
     set(handles.inputfile,'Enable','off')% desactivate the input file edit box   
@@ -113,37 +118,40 @@
     set(handles.MenuHelp,'Visible','off')
     inputfile_Callback(hObject, eventdata, handles)
-else
+else  %master mode
     set(handles.inputfile,'String','')   
-end
-%ACTION_Callback(hObject, eventdata, handles) 
-if exist('Field','var') & isstruct(Field)
+    % load the list of previously browsed files for the upper bar menu Open 
+    dir_perso=prefdir;
+    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');%
+    if exist(profil_perso,'file')
+        h=load (profil_perso);
+        if isfield(h,'MenuFile_1')
+            set(handles.MenuFile_1,'Label',h.MenuFile_1);
+        end
+        if isfield(h,'MenuFile_1')
+            set(handles.MenuFile_2,'Label',h.MenuFile_2);
+        end
+        if isfield(h,'MenuFile_1')
+            set(handles.MenuFile_3,'Label',h.MenuFile_3);
+        end
+        if isfield(h,'MenuFile_1')
+            set(handles.MenuFile_4,'Label',h.MenuFile_4);
+        end
+        if isfield(h,'MenuFile_1')
+            set(handles.MenuFile_5,'Label',h.MenuFile_5);
+        end
+    end
+end
+%transfer input field  in slave mode
+if exist('Field','var') && isstruct(Field)
         Field_input(eventdata,handles,Field)
-        if exist('haxes','var')
-            Field.PlotAxes=haxes;
-        end
+%         if exist('haxes','var')
+%             'TESTget'
+%             get(haxes,'Tag')
+%             Field.PlotAxes=haxes;
+%         end
     set(hObject,'UserData',Field);
 end
 
-%load the list of previously browsed files in menus Open 
- dir_perso=prefdir;
- profil_perso=fullfile(dir_perso,'uvmat_perso.mat');%
- if exist(profil_perso,'file')
-      h=load (profil_perso);
-      if isfield(h,'MenuFile_1')
-          set(handles.MenuFile_1,'Label',h.MenuFile_1);
-      end
-      if isfield(h,'MenuFile_1')
-          set(handles.MenuFile_2,'Label',h.MenuFile_2);
-      end
-      if isfield(h,'MenuFile_1')
-          set(handles.MenuFile_3,'Label',h.MenuFile_3);
-      end
-      if isfield(h,'MenuFile_1')
-          set(handles.MenuFile_4,'Label',h.MenuFile_4);
-      end
-      if isfield(h,'MenuFile_1')
-          set(handles.MenuFile_5,'Label',h.MenuFile_5);
-     end
- end
+
 
 %------------------------------------------------------------------------
@@ -822,57 +830,57 @@
 end
 
-%------------------------------------------------
-% --- Executes on button press in Plot_histo.
-%RUN global histograms
-%-------------------------------------------------
-function RUN_histo_Callback(hObject, eventdata, handles)
-% hObject    handle to RUN (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-%time plots
-leg={};
-n=0;
-if (get(handles.cm_switch,'Value')==1)
-    Uval_p=Uval_cm;
-    Vval_p=Vval_cm;
-    Uhist_p=Uhist_cm;
-    Vhist_p=Vhist_cm;
-    xlab='velocity (cm/s)';
-else
-    Uval_p=Uval;
-    Vval_p=Vval;
-    Uhist_p=Uhist;
-    Vhist_p=Vhist;
-    xlab='velocity (pixels)';
-end
-if (get(handles.vector_y,'Value') == 1)
-   hhh=figure(2);
-   hold on
-   title([filebase ', ' strindex ', ' fieldtitle])
-   plot(Uval_p,Uhist_p,'b-')
-   n=n+1;
-   leg{n}='Uhist';
-   xlabel(xlab)
-end
-if (get(handles.Vhist_input,'Value') == 1)
-   hhh=figure(2);
-   hold on
-   title([filebase ', ' strindex ', ' fieldtitle])
-   plot(Vval_p,Vhist_p,'r-')
-   n=n+1;
-   leg{n}='Vhist';
-   xlabel(xlab);
-end
-if (get(handles.Chist_input,'Value') == 1)
-   hhhh=figure(3);
-   hold on
-   title([filebase ', ' strindex ', ' fieldtitle])
-   plot(Cval,Chist,'k-')
-   leg{1}='Chist';
-end
-% hold off
-grid on
-legend(leg);
+% %------------------------------------------------
+% % --- Executes on button press in Plot_histo.
+% %RUN global histograms
+% %-------------------------------------------------
+% function RUN_histo_Callback(hObject, eventdata, handles)
+% % hObject    handle to RUN (see GCBO)
+% % eventdata  reserved - to be defined in a future version of MATLAB
+% % handles    structure with handles and user data (see GUIDATA)
+% 
+% %time plots
+% leg={};
+% n=0;
+% if (get(handles.cm_switch,'Value')==1)
+%     Uval_p=Uval_cm;
+%     Vval_p=Vval_cm;
+%     Uhist_p=Uhist_cm;
+%     Vhist_p=Vhist_cm;
+%     xlab='velocity (cm/s)';
+% else
+%     Uval_p=Uval;
+%     Vval_p=Vval;
+%     Uhist_p=Uhist;
+%     Vhist_p=Vhist;
+%     xlab='velocity (pixels)';
+% end
+% if (get(handles.vector_y,'Value') == 1)
+%    hhh=figure(2);
+%    hold on
+%    title([filebase ', ' strindex ', ' fieldtitle])
+%    plot(Uval_p,Uhist_p,'b-')
+%    n=n+1;
+%    leg{n}='Uhist';
+%    xlabel(xlab)
+% end
+% if (get(handles.Vhist_input,'Value') == 1)
+%    hhh=figure(2);
+%    hold on
+%    title([filebase ', ' strindex ', ' fieldtitle])
+%    plot(Vval_p,Vhist_p,'r-')
+%    n=n+1;
+%    leg{n}='Vhist';
+%    xlabel(xlab);
+% end
+% if (get(handles.Chist_input,'Value') == 1)
+%    hhhh=figure(3);
+%    hold on
+%    title([filebase ', ' strindex ', ' fieldtitle])
+%    plot(Cval,Chist,'k-')
+%    leg{1}='Chist';
+% end
+% % hold off
+% grid on
+% legend(leg);
 
 % %-------------------------------------------------------------
@@ -1028,5 +1036,5 @@
     var_select=list_var{index};
     set(handles.attributes_txt,'String', ['attributes of ' var_select])
-    if isfield(Field,'VarAttribute')& length(Field.VarAttribute)>=index-1
+    if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1
 %         nbline=0;
         VarAttr=Field.VarAttribute{index-1};
@@ -1050,4 +1058,5 @@
     Tabchar=[{''};Tabchar];
 end
+set(handles.attributes,'Value',1);% select the first item
 set(handles.attributes,'String',Tabchar);
 
Index: /trunk/src/get_plot_handles.m
===================================================================
--- /trunk/src/get_plot_handles.m	(revision 127)
+++ /trunk/src/get_plot_handles.m	(revision 128)
@@ -19,5 +19,5 @@
 PlotHandles.Contours=handles.Contours;
 PlotHandles.IncrA=handles.IncrA;
-PlotHandles.SCALAR_title=handles.SCALAR_title;
+%PlotHandles.SCALAR_title=handles.SCALAR_title;
 PlotHandles.min_title=handles.min_title;
 PlotHandles.max_title=handles.max_title;
@@ -30,5 +30,5 @@
 %For vector field representation
 PlotHandles.frame_vect=handles.frame_vect;
-PlotHandles.VECT_title=handles.VECT_title;
+%PlotHandles.VECT_title=handles.VECT_title;
 PlotHandles.VecScale=handles.VecScale;
 PlotHandles.AutoVec=handles.AutoVec;
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 127)
+++ /trunk/src/plot_field.m	(revision 128)
@@ -105,5 +105,5 @@
 % use htext: handles of the text edit box (uicontrol)
 % introduce PlotParam.Hold: 'on' or 'off' (for curves)
-  
+
 %default output
 if ~exist('PlotParam','var'),PlotParam=[];end;
@@ -127,5 +127,5 @@
     if ishandle(haxes)
         if isequal(get(haxes,'Type'),'axes')
-            axes(haxes)
+%             axes(haxes)
             testnewfig=0;
             AxeData=get(haxes,'UserData');
@@ -139,4 +139,5 @@
     end
 end
+
 if testnewfig% create a new figure and axes if the plotting axes does not exist
     hfig=figure;
@@ -157,6 +158,4 @@
     haxes=axes;
     set(haxes,'position',[0.13,0.2,0.775,0.73])
-else
-    hstack=findobj(allchild(0),'Type','figure');%current stack order of figures in matlab
 end
 if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
@@ -182,9 +181,11 @@
     [Data.NbDim]=max(NbDim);
 end
+errormsg=[];
 if isequal(Data.NbDim,0) 
         AxeData=plot_text(Data,htext);
         PlotType='text';
+        errormsg=[];
 elseif isequal(Data.NbDim,1)
-    [AxeData,haxes]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);% 
+    [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);% 
     if testzoomaxes
         [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam);
@@ -192,22 +193,23 @@
     end
     PlotType='line';
+    errormsg=[];
 elseif isequal(Data.NbDim,2)
     ind_select=find(NbDim>=2);
     if numel(ind_select)>2
-        msgbox_uvmat('ERROR','more than two fields to map')
-        display('more than two fields to map')
-        return
-    end
-    [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar);
-    if testzoomaxes
-        [AxeData,zoomaxes,PlotParamOut]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
-        %AxeData.ZoomAxes=zoomaxes;
-        Data.ZoomAxes=zoomaxes;
+        errormsg='more than two fields to map';
+    else
+        [AxeData,xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar);
+        if testzoomaxes && isempty(errormsg)
+            [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
+            %AxeData.ZoomAxes=zoomaxes;
+            Data.ZoomAxes=zoomaxes;
+        end
     end
 elseif isequal(Data.NbDim,3)
+    errormsg='volume plot not implemented yet';
+end
+if ~isempty(errormsg)
     msgbox_uvmat('ERROR','volume plot not implemented yet')
     return
-% else
-%     testnbdim=0;
 end
 
@@ -234,8 +236,8 @@
 %set(haxes,'UserData',AxeData)
 set(haxes,'UserData',Data)
-if ~testnewfig
-set(0,'Children',hstack);%put back the initial figure stack after plot creation
-%set(haxes,'Tag','uvmat'); 
-end
+% if ~testnewfig
+% %set(0,'Children',hstack);%put back the initial figure stack after plot creation
+% 
+% end
 
 
@@ -303,5 +305,6 @@
 function [AxeData,haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
 %-------------------------------------------------------------------
-%axes(haxes)
+%TODO: modify existing plot if it exists
+
 hfig=get(haxes,'parent');
 AxeData=data;
@@ -322,8 +325,8 @@
 legend_str={};
 
-%initiates string of the plot command
+%% prepare the string for plot command
+%initiate  the plot command
 plotstr='hhh=plot(';
 textmean={};
-% abscissa_name='';
 coord_x_index=[];
 test_newplot=1;
@@ -331,12 +334,8 @@
 % num_curve=numel(hh);
 % icurve=0;
+
+%loop on input  fields
 for icell=1:length(CellVarIndex)
-    testfalse=0;
     VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list data.ListVarName
-    DimCell=data.VarDimName{VarIndex(1)};
-    if ischar(DimCell)
-        DimCell={DimCell};
-    end
-    XName=DimCell{1}; %first dimension considered as abscissa
     if ~isempty(VarType{icell}.coord_x)
         coord_x_index=VarType{icell}.coord_x;
@@ -353,94 +352,82 @@
     end
     testplot=ones(size(data.ListVarName));%default test for plotted variables
-    testcoordvar=0;
-    charplot_0='''-''';%default
-    if isfield(data,'ObjectProjMode')&& isequal(data.ObjectProjMode,'projection')
-        charplot_0='+';
-    end
-    xtitle='';  
-    
     xtitle=data.ListVarName{coord_x_index};
     eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x
     if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=coord_x_index && isfield(data.VarAttribute{coord_x_index},'units')
-         xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units ')'];
+        xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units ')'];
     end
     eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x
-%     testcoordvar=1;
     testplot(coord_x_index)=0;
     if ~isempty(VarType{icell}.ancillary')
-            testplot(VarType{icell}.ancillary)=0;
+        testplot(VarType{icell}.ancillary)=0;
     end
     if ~isempty(VarType{icell}.warnflag')
-            testplot(VarType{icell}.warnflag)=0;
-    end
- 
+        testplot(VarType{icell}.warnflag)=0;
+    end
     if isfield(data,'VarAttribute')
         VarAttribute=data.VarAttribute;
-        for ivar=1:length(VarIndex) 
-             if length(VarAttribute)>=VarIndex(ivar) && isfield(VarAttribute{VarIndex(ivar)},'long_name')
-                 plotname{VarIndex(ivar)}=VarAttribute{VarIndex(ivar)}.long_name;
-             else
-                 plotname{VarIndex(ivar)}=data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE
-             end
-        end
-    end  
-%     test_newplot=0;%default
-%     if num_curve>=icurve+numel(find(testplot(VarIndex)))%update existing curves
-%         if ~isempty(VarType{icell}.discrete')
-%             charplot_0='+';
-%             LineStyle='none';
-%         else
-%             charplot_0='none';
-%             LineStyle='-';
-%         end
-%         for ivar=1:length(VarIndex)
-%             if testplot(VarIndex(ivar))
-%                 icurve=icurve+1;
-%                 VarName=data.ListVarName{VarIndex(ivar)};
-%                 eval(['data.' VarName '=squeeze(data.' VarName ');'])
-%                 set(hh(icurve),'LineStyle',LineStyle)
-%                 set(hh(icurve),'Marker',charplot_0)
-%                 set(hh(icurve),'XData',coord_x{icell})
-%                 eval(['yy=data.' VarName ';'])
-%                 set(hh(icurve),'YData',yy);
-%             end
-%         end
-%     else% new plot
-        if ~isempty(VarType{icell}.discrete')
-            charplot_0='''+''';
-        else
-            charplot_0='''-''';
-        end
         for ivar=1:length(VarIndex)
-            if testplot(VarIndex(ivar))
-                VarName=data.ListVarName{VarIndex(ivar)};
-                eval(['data.' VarName '=squeeze(data.' VarName ');'])
-%                 if isequal(VarName,'A')
-%                     charplot='''-''';
-%                 else
-%                     charplot=charplot_0;
-%                 end
-                plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
-                eval(['nbcomponent2=size(data.' VarName ',2);']);
-                eval(['nbcomponent1=size(data.' VarName ',1);']);
-                if numel(coord_x{icell})==2
-                    coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
-                end
-                eval(['varmean=mean(double(data.' VarName '));']);%mean value
-                textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];
-                if nbcomponent1==1|| nbcomponent2==1
-                    legend_str=[legend_str {VarName}]; %variable with one component
-                else  %variable with severals  components
-                    for ic=1:min(nbcomponent1,nbcomponent2)
-                        legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components 
-                    end                                                   % labeled by their index (e.g. color component)
-                end
-            end
-        end
-%     end
-end
+            if length(VarAttribute)>=VarIndex(ivar) && isfield(VarAttribute{VarIndex(ivar)},'long_name')
+                plotname{VarIndex(ivar)}=VarAttribute{VarIndex(ivar)}.long_name;
+            else
+                plotname{VarIndex(ivar)}=data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE
+            end
+        end
+    end
+    %     test_newplot=0;%default
+    %     if num_curve>=icurve+numel(find(testplot(VarIndex)))%update existing curves
+    %         if ~isempty(VarType{icell}.discrete')
+    %             charplot_0='+';
+    %             LineStyle='none';
+    %         else
+    %             charplot_0='none';
+    %             LineStyle='-';
+    %         end
+    %         for ivar=1:length(VarIndex)
+    %             if testplot(VarIndex(ivar))
+    %                 icurve=icurve+1;
+    %                 VarName=data.ListVarName{VarIndex(ivar)};
+    %                 eval(['data.' VarName '=squeeze(data.' VarName ');'])
+    %                 set(hh(icurve),'LineStyle',LineStyle)
+    %                 set(hh(icurve),'Marker',charplot_0)
+    %                 set(hh(icurve),'XData',coord_x{icell})
+    %                 eval(['yy=data.' VarName ';'])
+    %                 set(hh(icurve),'YData',yy);
+    %             end
+    %         end
+    %     else% new plot
+    if ~isempty(VarType{icell}.discrete')
+        charplot_0='''+''';
+    else
+        charplot_0='''-''';
+    end
+    for ivar=1:length(VarIndex)
+        if testplot(VarIndex(ivar))
+            VarName=data.ListVarName{VarIndex(ivar)};
+            eval(['data.' VarName '=squeeze(data.' VarName ');'])
+            plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
+            eval(['nbcomponent2=size(data.' VarName ',2);']);
+            eval(['nbcomponent1=size(data.' VarName ',1);']);
+            if numel(coord_x{icell})==2
+                coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
+            end
+            eval(['varmean=mean(double(data.' VarName '));']);%mean value
+            textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];
+            if nbcomponent1==1|| nbcomponent2==1
+                legend_str=[legend_str {VarName}]; %variable with one component
+            else  %variable with severals  components
+                for ic=1:min(nbcomponent1,nbcomponent2)
+                    legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components
+                end                                                   % labeled by their index (e.g. color component)
+            end
+        end
+    end
+end
+
+%% activate the plot
 if test_newplot && ~isequal(plotstr,'hhh=plot(')
     plotstr=[plotstr '''tag'',''plot_line'');'];
                 %execute plot (instruction  plotstr)  
+    axes(haxes)% select the plotting axes for plot operation
     eval(plotstr)
    
@@ -502,6 +489,7 @@
 
 %-------------------------------------------------------------------
-function [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar)
+function [AxeData,haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar)
 %-------------------------------------------------------------------
+
 grid(haxes, 'off')
 %default plotting parameters
@@ -517,6 +505,4 @@
 end
 PlotParamOut=PlotParam;%default
-
-%plotting axes
 hfig=get(haxes,'parent');
 hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
@@ -530,5 +516,5 @@
     AxeData.ObjectCoord=Data.ObjectCoord;
 end
-
+errormsg=[];%default
 test_ima=0; %default: test for image or map plot
 test_vec=0; %default: test for vector plots
@@ -548,5 +534,5 @@
     ivar_C=[VarType.scalar VarType.image VarType.color VarType.ancillary]; %defines index (indices) for the scalar or ancillary fields
     if numel(ivar_C)>1
-        msgbox_uvmat('ERROR','error in plot_field: too many scalar inputs')
+        errormsg= 'error in plot_field: too many scalar inputs';
         return
     end
@@ -558,8 +544,8 @@
     end
 %     idim_Y=[];  
-    test_grid=0;
+%     test_grid=0;
     if ~isempty(ivar_U) && ~isempty(ivar_V)% vector components detected
         if test_vec
-            msgbox_uvmat('ERROR','error in plot_field: attempt to plot two vector fields')
+            errormsg='error in plot_field: attempt to plot two vector fields';
             return
         else
@@ -570,5 +556,5 @@
                 eval(['vec_X=Data.' Data.ListVarName{ivar_X} ';']) 
                 eval(['vec_Y=Data.' Data.ListVarName{ivar_Y} ';'])
-            elseif numel(VarType.coord)==2 & VarType.coord~=[0 0];%coordinates defines by dimension variables
+            elseif numel(VarType.coord)==2 && ~isequal(VarType.coord,[0 0]);%coordinates defines by dimension variables
                 eval(['y=Data.' Data.ListVarName{VarType.coord(1)} ';']) 
                 eval(['x=Data.' Data.ListVarName{VarType.coord(2)} ';'])
@@ -581,5 +567,5 @@
                 [vec_X,vec_Y]=meshgrid(x,y);  
             else
-                msgbox_uvmat('ERROR','error in plot_field: invalid coordinate definition for vector field')
+                errormsg='error in plot_field: invalid coordinate definition for vector field';
                 return
             end
@@ -605,5 +591,5 @@
     elseif ~isempty(ivar_C) %scalar or image
         if test_ima
-             msgbox_uvmat('ERROR','attempt to plot two scalar fields or images')
+             errormsg='attempt to plot two scalar fields or images';
             return
         end
@@ -635,5 +621,5 @@
                     x_units=['(' Data.VarAttribute{VarType.coord(2)}.units ')'];
                 end
-                if numel(Data.VarAttribute)>=VarType.coord(1) & isfield(Data.VarAttribute{VarType.coord(1)},'units')
+                if numel(Data.VarAttribute)>=VarType.coord(1) && isfield(Data.VarAttribute{VarType.coord(1)},'units')
                     y_units=['(' Data.VarAttribute{VarType.coord(1)}.units ')'];
                 end
@@ -644,5 +630,5 @@
                 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 # ' ListVarName{VarType.coord(1)} ];
+                     errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarType.coord(1)} ];
                       return
                 end 
@@ -654,5 +640,5 @@
                 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 # ' ListVarName{VarType.coord(2)} ];
+                     errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarType.coord(2)} ];
                       return
                 end 
@@ -682,12 +668,12 @@
             AY=[AY(1) AY(end)];
         else
-            msgbox_uvmat('ERROR','error in plot_field: invalid coordinate definition ')
+            errormsg='error in plot_field: invalid coordinate definition ';
             return
         end
-          x_label=[Data.ListVarName{ivar_X} '(' x_units ')'];
+          %x_label=[Data.ListVarName{ivar_X} '(' x_units ')'];
     end          
 end 
 
-%%%%%%%%%%%%%%%%%%%%%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
+%%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
 
 if ~isfield(PlotParam.Scalar,'Contours')
@@ -700,5 +686,5 @@
     siz=numel(np);
     if siz>3
-        msgbox_uvmat('ERROR',['unrecognized scalar type: ' num2str(siz) ' dimensions'])
+       errormsg=['unrecognized scalar type: ' num2str(siz) ' dimensions'];
             return
     end
@@ -709,8 +695,9 @@
             siz=3;%color image
         else
-             msgbox_uvmat('ERROR',['unrecognized scalar type: ' num2str(np(3)) ' color components'])
+            errormsg=['unrecognized scalar type: ' num2str(np(3)) ' color components'];
             return
         end
     end
+    
     %set the color map
     if isfield(PlotParam.Scalar,'BW')
@@ -719,5 +706,7 @@
         BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default
     end
-    if siz==2 %for black and white images
+    
+    %case of grey level images or contour plot
+    if siz==2 
         if ~isfield(PlotParam.Scalar,'AutoScal')
             PlotParam.Scalar.AutoScal=0;%default
@@ -729,5 +718,5 @@
             PlotParam.Scalar.MaxA=[];%default
         end
-        if isequal(PlotParam.Scalar.AutoScal,0)|isempty(PlotParam.Scalar.MinA)|~isa(PlotParam.Scalar.MinA,'double')  %correct if there is no numerical data in edit box
+        if isequal(PlotParam.Scalar.AutoScal,0)||isempty(PlotParam.Scalar.MinA)||~isa(PlotParam.Scalar.MinA,'double')  %correct if there is no numerical data in edit box
             MinA=double(min(min(A)));
         else
@@ -741,7 +730,8 @@
         PlotParamOut.Scalar.MinA=MinA;
         PlotParamOut.Scalar.MaxA=MaxA;
-        axes(haxes)
+        
+        % case of contour plot
         if isequal(PlotParam.Scalar.Contours,1)
-            if ~isempty(hima) & ishandle(hima)
+            if ~isempty(hima) && ishandle(hima)
                 delete(hima)
             end
@@ -770,5 +760,5 @@
             txt=ver;%version of Matlab
             Release=txt(1).Release;
-            relnumb=str2num(Release(3:4));
+            relnumb=str2double(Release(3:4));
             if relnumb >= 14
                     vec=linspace(0,1,(abscontmax-abscontmin)/intercont);%define a greyscale colormap with steps intercont
@@ -788,4 +778,6 @@
             colormap(map);
         end
+        
+        % set  colormap for  image display
         if ~isequal(PlotParam.Scalar.Contours,1)  
             % rescale the grey levels with min and max, put a grey scale colorbar
@@ -799,6 +791,7 @@
             end
         end
-    else %color images
-        axes(haxes)
+        
+    % case of color images 
+    else 
         if BW
             B=uint16(sum(A,3));
@@ -809,6 +802,8 @@
         MaxA=255;
     end
-    if ~isequal(PlotParam.Scalar.Contours,1)
-        %interpolate to increase resolution
+    
+    % display usual image
+    if ~isequal(PlotParam.Scalar.Contours,1)      
+        % interpolate field to increase resolution of image display
         test_interp=1;
         if max(np) <= 64 
@@ -829,14 +824,18 @@
             yi=linspace(AY(1),AY(2),npxy(1));
             B = interp2(X,Y,double(B),xi,yi');
-        end        
+        end           
+        % create new image if there  no image handle is found
         if isempty(hima)
+           % axes(haxes)% set haxes the current axes for image creation
+            set(hfig,'CurrentAxes',haxes) % set haxes the current axes for image creation 
             tag=get(haxes,'Tag');
             if MinA<MaxA
                 hima=imagesc(AX,AY,B,[MinA MaxA]);
-            else
+            else % to deal with uniform field
                 hima=imagesc(AX,AY,B,[MaxA-1 MaxA]);
             end
             set(hima,'Tag','ima','HitTest','off')
-            set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!)       
+            set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!)            
+        % update an existing image
         else
             set(hima,'CData',B);
@@ -857,4 +856,5 @@
     AxeData.AY=[AY(1) AY(end)];
     test_ima=1;
+    
     %display the colorbar code for B/W images if Poscolorbar not empty
     if siz==2 && exist('PosColorbar','var')&& ~isempty(PosColorbar)
@@ -865,5 +865,5 @@
                  set(hcol,'Position',PosColorbar)           
         end 
-        YTick=0;%default
+        %YTick=0;%default
         if MaxA>MinA
             if isequal(PlotParam.Scalar.Contours,1)
@@ -873,5 +873,5 @@
                 YTick_scaled=colbarlim(1)+scale_bar*(YTick-abscontmin);
                 set(hcol,'YTick',YTick_scaled);
-            elseif (isfield(PlotParam.Scalar,'BW') & isequal(PlotParam.Scalar.BW,1))|isa(A,'uint8')| isa(A,'uint16')%images
+            elseif (isfield(PlotParam.Scalar,'BW') && isequal(PlotParam.Scalar.BW,1))||isa(A,'uint8')|| isa(A,'uint16')%images
                 hi=get(hcol,'children');
                 if iscell(hi)%multiple images in colorbar
@@ -879,5 +879,5 @@
                 end
                 set(hi,'YData',[MinA MaxA])
-                set(hi,'CData',[1:256]')
+                set(hi,'CData',(1:256)')
                 set(hcol,'YLim',[MinA MaxA])
                 YTick=colbartick(MinA,MaxA);
@@ -889,5 +889,5 @@
                 end
                 set(hi,'YData',[MinA MaxA])
-                set(hi,'CData',[1:64]')
+                set(hi,'CData',(1:64)')
                 YTick=colbartick(MinA,MaxA); 
                 set(hcol,'YLim',[MinA MaxA])
@@ -912,5 +912,5 @@
 end
 
-%%%%%%%%%%%%%%%%%%%%%   vector plot %%%%%%%%%%%%%%%%%%%%%%%%%%
+%%   vector plot %%%%%%%%%%%%%%%%%%%%%%%%%%
 if test_vec
    %vector scale representation
@@ -927,5 +927,5 @@
     if  ~isfield(PlotParam.Vectors,'AutoVec') || isequal(PlotParam.Vectors.AutoVec,0)|| ~isfield(PlotParam.Vectors,'VecScale')...
                ||isempty(PlotParam.Vectors.VecScale)||~isa(PlotParam.Vectors.VecScale,'double') %automatic vector scale
-        scale=[];
+%         scale=[];
         if test_false %remove false vectors
             indsel=find(AxeData.FF==0);%indsel =indices of good vectors
@@ -1045,5 +1045,5 @@
 listdim={'AY','AX',{'AY','AX'},'nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors'};
 Role={'coord_y','coord_x','scalar','coord_x','coord_y','vector_x','vector_y','scalar','vector_z','warnflag','errorflag'};
-ind_select=[];
+%ind_select=[];
 nbvar=0;
 AxeData.ListVarName={};
@@ -1168,5 +1168,9 @@
     isn=isnan(colorlist(icolor,:));%test if color NaN
     if 2*icolor > sizh(1) %if icolor exceeds the number of existing ones
-        axes(haxes)
+        %axes(haxes)
+        hfig=get(haxes,'parent');
+%         axes(haxes)
+        set(0,'CurrentFigure',hfig)
+        set(hfig,'CurrentAxes',haxes)
         if ~isn(1) %if the vectors are visible color not nan
             if n(2)>0
Index: /trunk/src/read_geometry_calib.m
===================================================================
--- /trunk/src/read_geometry_calib.m	(revision 127)
+++ /trunk/src/read_geometry_calib.m	(revision 128)
@@ -9,24 +9,24 @@
     k=findstr('|',coord_str);%find separators '|'
     if length(k)>=4 % test for separators '|'
-        data1=str2num(coord_str(1:k(1)-5));
-        data2=str2num(coord_str(k(1)+5:k(2)-5));
-        data3=str2num(coord_str(k(2)+5:k(3)-5));
-        data4=str2num(coord_str(k(3)+5:k(4)-5));
-        data5=str2num(coord_str(k(4)+5:end));
-        if ~isempty(data1)||~isempty(data2)||~isempty(data3)||~isempty(data4)||~isempty(data5)
+        data1=str2double(coord_str(1:k(1)-2));
+        data2=str2double(coord_str(k(1)+2:k(2)-2));
+        data3=str2double(coord_str(k(2)+2:k(3)-2));
+        data4=str2double(coord_str(k(3)+2:k(4)-2));
+        data5=str2double(coord_str(k(4)+2:end));
+        if ~isnan(data1)||~isnan(data2)||~isnan(data3)||~isnan(data4)||~isnan(data5)
             iline=iline+1;
-            if ~isempty(data1)
+            if ~isnan(data1)
                 data.Coord(iline,1)=data1;
             end    
-            if ~isempty(data2)
+            if ~isnan(data2)
                 data.Coord(iline,2)=data2;
             end
-            if ~isempty(data3)
+            if ~isnan(data3)
                 data.Coord(iline,3)=data3;
             end
-            if ~isempty(data4)
+            if ~isnan(data4)
                 data.Coord(iline,4)=data4;
             end
-            if isempty(data5)
+            if isnan(data5)
                 data.Coord(iline,5)=0;
             else
Index: /trunk/src/series/aver_stat.m
===================================================================
--- /trunk/src/series/aver_stat.m	(revision 127)
+++ /trunk/src/series/aver_stat.m	(revision 128)
@@ -277,4 +277,10 @@
     if ~isequal(m2,'')
          msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation
+    end
+    [xx,msg2] = fileattrib(subdir_result,'+w','g'); %yield writing access (+w) to user group (g)
+    if ~strcmp(msg2,'')
+        msgbox_uvmat('ERROR',['pb of permission for ' subdir_result ': ' msg2])%error message for directory creation
+        cd(curdir)
+        return
     end
     cd(dircur) %back to the initial working directory
Index: /trunk/src/series/ima_levels.m
===================================================================
--- /trunk/src/series/ima_levels.m	(revision 127)
+++ /trunk/src/series/ima_levels.m	(revision 128)
@@ -21,4 +21,11 @@
 cd(path);
 mkdir([subdir_ima '_levels']);
+  [xx,msg2] = fileattrib(subdir_ima,'+w','g'); %yield writing access (+w) to user group (g)
+if ~strcmp(msg2,'')
+    msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation
+    cd(dircur)
+    return
+end
+cd(dircur);
 cd(curdir);
 basename_new=fullfile(path,[subdir_ima '_levels'],namebase);
Index: /trunk/src/series/merge_proj.m
===================================================================
--- /trunk/src/series/merge_proj.m	(revision 127)
+++ /trunk/src/series/merge_proj.m	(revision 128)
@@ -234,9 +234,15 @@
     succeed=mkdir(subdir);
     if succeed
-    cd(dircur);
+        [xx,msg2] = fileattrib(res_subdir,'+w','g'); %yield writing access (+w) to user group (g)
+        if ~strcmp(msg2,'')
+            msgbox_uvmat('ERROR',['pb of permission for ' res_subdir ': ' msg2])%error message for directory creation
+            cd(dircur)
+            return
+        end
+        cd(dircur);
     else
-    msgbox_uvmat('ERROR',['Cannot create directory ' fulldir])
-    return
-    end        
+        msgbox_uvmat('ERROR',['Cannot create directory ' fulldir])
+        return
+    end
 end
 filebasesub=fullfile(res_subdir,Series.RootFile{1});
Index: /trunk/src/series/relabel_i_j.m
===================================================================
--- /trunk/src/series/relabel_i_j.m	(revision 127)
+++ /trunk/src/series/relabel_i_j.m	(revision 128)
@@ -21,4 +21,10 @@
 cd(path);
 mkdir([subdir_ima '_ij']);
+[xx,msg2] = fileattrib(subdir_ima,'+w','g'); %yield writing access (+w) to user group (g)
+if ~strcmp(msg2,'')
+    msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation
+    cd(dircur)
+    return
+end
 cd(curdir);
 basename_new=fullfile(path,[subdir_ima '_ij'],namebase);
Index: /trunk/src/series/sub_background.m
===================================================================
--- /trunk/src/series/sub_background.m	(revision 127)
+++ /trunk/src/series/sub_background.m	(revision 128)
@@ -115,4 +115,10 @@
 cd(path);
 mkdir([subdir_ima '_b']);
+[xx,msg2] = fileattrib(subdir_ima,'+w','g'); %yield writing access (+w) to user group (g)
+if ~strcmp(msg2,'')
+    msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation
+    cd(curdir)
+    return
+end
 cd(curdir);
 filebase_b=fullfile(path,[subdir_ima '_b'],namebase);
Index: /trunk/src/series/time_series.m
===================================================================
--- /trunk/src/series/time_series.m	(revision 127)
+++ /trunk/src/series/time_series.m	(revision 128)
@@ -278,4 +278,10 @@
     if ~isequal(m2,'')
          msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation
+    end
+    [xx,msg2] = fileattrib(subdir_result,'+w','g'); %yield writing access (+w) to user group (g)
+    if ~strcmp(msg2,'')
+        msgbox_uvmat('ERROR',['pb of permission for ' subdir_result ': ' msg2])%error message for directory creation
+        cd(dircur)
+        return
     end
     cd(dircur) %back to the initial working directory
Index: /trunk/src/struct2nc.m
===================================================================
--- /trunk/src/struct2nc.m	(revision 127)
+++ /trunk/src/struct2nc.m	(revision 128)
@@ -42,7 +42,7 @@
     return
 end 
-hhh=which('netcdf.create');% look for built-in matlab library
+hhh=which('netcdf.create');% look for built-in matlab netcdf library
 
-%USE OF built-in  netcdf library
+%USE OF built-in matlab netcdf library
 if ~isequal(hhh,'')
     FilePath=fileparts(flname);
@@ -68,9 +68,7 @@
                 if ~testvar               
                     eval(['cte=Data.' keys{iattr} ';'])
-                    if (ischar(cte) ||isnumeric(cte)) &&  ~isempty(cte)&& ~isequal(cte,'')
+                    if (ischar(cte) ||isnumeric(cte)) &&  ~isempty(cte)%&& ~isequal(cte,'')
+                        %write constant only if it is numeric or char string, and not empty
                         netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),keys{iattr},cte)
-                    else
-                        errormsg='global attributes must be characters or numbers';
-                        return
                     end
                 end
@@ -79,7 +77,7 @@
     end
     %create dimensions
-    dimid=[];
+    dimid=zeros(1,length(Data.ListDimName));
     for idim=1:length(Data.ListDimName)
-         dimid(idim) = netcdf.defDim(nc,Data.ListDimName{idim},Data.DimValue(idim)); 
+         dimid(idim) = netcdf.defDim(nc,Data.ListDimName{idim},Data.DimValue(idim));
     end
     VarAttribute={}; %default
@@ -89,7 +87,7 @@
         testattr=1;
     end
-    varid=[];
+    varid=zeros(1,length(Data.ListVarName));
     for ivar=1:length(ListVarName)
-        varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'double',dimid(Data.VarDimIndex{ivar}));%define variable  
+        varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'nc_double',dimid(Data.VarDimIndex{ivar}));%define variable  
     end
      %write variable attributes
@@ -117,7 +115,7 @@
                 VarDimName={VarDimName};
             end
-            testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);
-            testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), Data.DimValue(VarDimIndex));
-            testcolumn=isequal(length(siz),2) && isequal(siz(1), Data.DimValue(VarDimIndex))&& isequal(siz(2),1);
+            testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);% case of a coordinate defined on a regular mesh by the first and last values.
+            testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), Data.DimValue(VarDimIndex));%matlab vector
+            testcolumn=isequal(length(siz),2) && isequal(siz(1), Data.DimValue(VarDimIndex))&& isequal(siz(2),1);%matlab column vector
             if ~testrange && ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex))
                 errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
@@ -126,15 +124,13 @@
             if testline || testrange
                 if testrange
-                    VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));
+                    VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));% restitute the whole array of coordinate values
                 end
-               %nc{ListVarName{ivar}}=ncfloat(Data.ListDimName(VarDimIndex));%vector of x coordinates
-               netcdf.putVar(nc,varid(ivar), double(VarVal'));
+                netcdf.putVar(nc,varid(ivar), double(VarVal'));
             else
                 netcdf.putVar(nc,varid(ivar), double(VarVal));
-                %nc{ListVarName{ivar}}(:) = VarVal;
-            end
-            
+            end      
         end
     end
+    netcdf.close(nc)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %OLD netcdf toolbox
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 127)
+++ /trunk/src/uvmat.m	(revision 128)
@@ -181,5 +181,5 @@
                    'gui_LayoutFcn',     [], ...
                    'gui_Callback',      []);
-if nargin && ischar(varargin{1})
+if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
     gui_State.gui_Callback = str2func(varargin{1});
 end
@@ -1151,5 +1151,5 @@
    set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
    set(handles.Fields_1,'Value',2) % set menu to 'image'
-elseif isequal(FileExt_1,'.nc')|isequal(FileExt_1,'.cdf')
+elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
    Data=nc2struct(fileinput_1,[]);
    if isfield(Data,'absolut_time_T0')
@@ -1621,7 +1621,7 @@
 %-------------------------------------------------------------------
 huvmat=get(handles.MenuExport,'parent');
-UvData=get(huvmat,'UserData');
+%UvData=get(huvmat,'UserData');
 hfig=figure;
-newaxes=copyobj(handles.axes3,hfig);
+copyobj(handles.axes3,hfig);
 map=colormap(handles.axes3);
 colormap(map);%transmit the current colormap to the zoom fig
@@ -1641,7 +1641,15 @@
 set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
 drawnow
-increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
-runpm(hObject,eventdata,handles,increment)
-set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button in yellow
+%TODO: introduce the option: increment ='*' to move to the next available view
+increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
+if isnan(increment)
+    set(handles.increment_scan,'String','1')%default value
+    increment=1;
+end
+errormsg=runpm(hObject,eventdata,handles,increment);
+if ~isempty(errormsg)
+    msgbox_uvmat('ERROR',errormsg);
+end
+set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
 
 %-------------------------------------------------------------------
@@ -1653,7 +1661,14 @@
 set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
 drawnow
-increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
-runpm(hObject,eventdata,handles,increment)
-set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button in yellow
+increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
+if isnan(increment)
+    set(handles.increment_scan,'String','1')%default value
+    increment=1;
+end
+errormsg=runpm(hObject,eventdata,handles,increment);
+if ~isempty(errormsg)
+    msgbox_uvmat('ERROR',errormsg);
+end
+set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
 
 %-------------------------------------------------------------------
@@ -1663,10 +1678,13 @@
 set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
 drawnow
-increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
+increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
+if isnan(increment)
+    set(handles.increment_scan,'String','1')%default value
+    increment=1;
+end
 set(handles.STOP,'Visible','on')
 set(handles.speed,'Visible','on')
 set(handles.speed_txt,'Visible','on')
 set(handles.Movie,'BusyAction','queue')
-testavi=0;
 UvData=get(handles.uvmat,'UserData');
 
@@ -1674,4 +1692,5 @@
         errormsg=runpm(hObject,eventdata,handles,increment);
         if ~isempty(errormsg)
+            set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
             return
         end
@@ -1690,15 +1709,19 @@
 set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
 drawnow
-increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
+increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
+if isnan(increment)
+    set(handles.increment_scan,'String','1')%default value
+    increment=1;
+end
 set(handles.STOP,'Visible','on')
 set(handles.speed,'Visible','on')
 set(handles.speed_txt,'Visible','on')
 set(handles.MovieBackward,'BusyAction','queue')
-testavi=0;
 UvData=get(handles.uvmat,'UserData');
 
-while get(handles.speed,'Value')~=0 & isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
+while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
         errormsg=runpm(hObject,eventdata,handles,increment);
         if ~isempty(errormsg)
+            set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
             return
         end
@@ -1760,5 +1783,5 @@
      num1=num1+increment;
      num2=num2+increment;
-     [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir)
+     [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
      if sub_value% set the second field name and indices
         num1_1=num1_1+increment;
@@ -1779,5 +1802,4 @@
 % refresh plots
 errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
-
 if isempty(errormsg)  %update the index counters
     set(handles.i1,'String',num2stra(num1,NomType,1)); 
@@ -1803,8 +1825,5 @@
         movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
     end
-else
-     msgbox_uvmat('ERROR',errormsg);
-end
-
+end
 
 
@@ -1974,4 +1993,5 @@
 end    
 set(handles.run0,'BackgroundColor',[1 0 0])
+
 %------------------------------------------------------------------------
 % --- read the input files and refresh all the plots, including projection.
@@ -1983,11 +2003,9 @@
 % num_i1,num_i2,num_j1,num_j2; frame indices
 % Field: structure describing an optional input field (then replace the input file)
-
 function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
 %------------------------------------------------------------------------
 
 %initialisation
-
-errormsg=[]; % default error message
+% errormsg=[]; % default error message
 abstime=[];
 abstime_1=[];
@@ -2012,5 +2030,5 @@
 end
 
-% determine the main input file information for action
+%% determine the main input file information for action
 FileType=[];%default
 if ~isempty(filename)
@@ -2023,5 +2041,5 @@
     %update the z position index
     nbslice_str=get(handles.nb_slice,'String');
-    z_index=1;%default
+   % z_index=1;%default
     if isequal(nbslice_str,'volume')
         z_index=num_j1;
@@ -2074,10 +2092,9 @@
     end
 end
-
-% choose a second field if Subfield option is 'on'
+%% choose a second field if Subfield option is 'on'
 FieldName_1=[];
 scal_color=[];
 VelType_1=setfield_1(handles);
-sub_value=get(handles.SubField,'Value');
+% sub_value=get(handles.SubField,'Value');
 FileType_1='none';%default
 if ~isempty(filename_1)
@@ -2137,5 +2154,5 @@
 end
 
-%read the input field(s)
+%% read the input field(s)
 %read images
 if ~isempty(filename) && isequal(FieldName,'image')
@@ -2241,14 +2258,14 @@
                 hget_field= get_field(filename);%open the get_field GUI   
                 set(hget_field,'name','uvmat_field')
-            elseif UvData.NewSeries
+            elseif UvData.NewSeries% refresh the fet_field GUI for a new series
                 delete(hget_field)
                 hget_field= get_field(filename);%open the get_field GUI 
-                set(hget_field,'name','uvmat_field')
+                set(hget_field,'name','uvmat_field')%rename  get_field GUI for the 'slave' mode
             end
             hhget_field=guidata(hget_field);
             funct_list=get(hhget_field.ACTION,'UserData');
             funct_index=get(hhget_field.ACTION,'Value');
-            funct=funct_list{funct_index};
-            Field{1}=funct(hget_field); %read the names of the variables to plot in the get_field GUI
+            funct=funct_list{funct_index};%select  the current action in get_field, e;g. PLOT
+            Field{1}=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot 
             CivStage=0;
             VelType_out=[];    
@@ -2290,5 +2307,5 @@
 end
 
-%update the display buttons for the first velocity type (first menuline)
+%% update the display buttons for the first velocity type (first menuline)
 veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
 if ~isequal(FileType,'netcdf')
@@ -2304,5 +2321,5 @@
 end
 
-%update the display buttons for the second velocity type (second menuline)
+%% update the display buttons for the second velocity type (second menuline)
 veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
 if ~isequal(FileType_1,'netcdf')
@@ -2318,5 +2335,5 @@
 end
 
-%introduce w as background image by default for a new series (only for nbdim=2)
+%% introduce w as background image by default for a new series (only for nbdim=2)
 if ~isfield(UvData,'NewSeries')
     UvData.NewSeries=1;
@@ -2342,5 +2359,5 @@
         set(handles.Fields_1,'Visible','on');
         Field{1}.AName='w';
-        testscal=1;
+%         testscal=1;
     end
 end           
@@ -2350,9 +2367,9 @@
       isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
        siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
-       if siz(1)>1
-           NbSlice=siz(1);
-       else
-           NbSlice=1;
-       end
+%        if siz(1)>1
+%            NbSlice=siz(1);
+%        else
+%            NbSlice=1;
+%        end
 end
 
@@ -2368,5 +2385,5 @@
 end
 
-%coordinate transform or user fct
+%% coordinate transform or user fct
 XmlData=[];%default
 if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
@@ -2377,14 +2394,12 @@
    XmlData_1=UvData.XmlData_1;
 end
-menu_transform=get(handles.transform_fct,'String');
+% menu_transform=get(handles.transform_fct,'String');
 choice_value=get(handles.transform_fct,'Value');
 transform_list=get(handles.transform_fct,'UserData');
 transform=transform_list{choice_value};%selected function handles
-
 % z index
 if ~isempty(filename)
     Field{1}.ZIndex=z_index;
 end
-
 %px to phys or other transform on field
 if ~isempty(transform) 
@@ -2400,5 +2415,5 @@
 end 
 
-%calculate scalar
+%% calculate scalar
 if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
     Field{1}=calc_field(InputField,Field{1});
@@ -2407,5 +2422,4 @@
     Field{2}=calc_field(InputField_1,Field{2});
 end
-
 % combine the two input fields (e.g. substract velocity fields)
 if numel(Field)==2
@@ -2415,5 +2429,5 @@
 end
 
-% test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
+%% test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
 test_x=0;
 test_z=0;% test for unstructured z coordinate
@@ -2478,4 +2492,5 @@
     end
 end
+
 %case of structured coordinates
 if isfield(UvData.Field,'AX') && isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')
@@ -2572,5 +2587,5 @@
 %multilevel case (single menuplane in a 3D space)
 elseif isfield(UvData,'Z')
-    if isfield(UvData,'CoordType')& isequal(UvData.CoordType,'phys') & isfield(UvData,'XmlData')
+    if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
         XmlData=UvData.XmlData;
         if isfield(XmlData,'PlanePos')
@@ -2589,125 +2604,124 @@
 end
 
-%Plot the projections on all existing  projection objects
-keeplim=get(handles.FixedLimits,'Value');
-%reset the min and max of scalar if only the mask is displayed
-if isfield(UvData,'Mask')&~isfield(UvData,'A')
+%% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
+if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
     set(handles.MinA,'String','0')
     set(handles.MaxA,'String','255')
 end
-IndexObj(1)=get(handles.list_object_1,'Value');
-haxes_1=handles.axes3;
+
+%% Plot the projections on the selected  projection objects
+
+% main projection object (uvmat display)
+IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
 if IndexObj(1)> numel(UvData.Object)
-    IndexObj(1)=1;
-    haxes_1=handles.axes3;
-end
-view_field_handle=[];
-IndexObj_2=get(handles.list_object_2,'Value');
-if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)
+    IndexObj(1)=1;%select the first object if the selected one does not exist
+    set(handles.list_object_1,'Value',1)
+end
+plot_handles{1}=handles;
+haxes(1)=handles.axes3;
+PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
+keeplim(1)=get(handles.FixedLimits,'Value');% test for fixed graph limits
+PosColorbar{1}=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
+
+% second projection object (view_field display)
+IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
+if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
     IndexObj(2)=IndexObj_2;
-    view_field_handle=findobj(allchild(0),'tag','view_field');
-end
+    view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
+    if ~isempty(view_field_handle)
+        plot_handles{2}=guidata(view_field_handle);
+        haxes(2)=plot_handles{2}.axes3;
+        PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the uvmat interface
+        keeplim(2)=get(plot_handles{2}.FixedLimits,'Value');
+        PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
+    end
+end
+
+%loop on the projection objects: one or two
 for imap=1:numel(IndexObj)
-    iobj=IndexObj(imap);
-    if ~isempty(UvData.Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes)
-        %Projeter les champs sur l'objet:*
-        ObjectData=proj_field(UvData.Field,UvData.Object{iobj},iobj);
-        %use of mask
-        if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
-            if isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
-                 flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
-                 AX=ObjectData.AX;
-                 AY=ObjectData.AY;
-                 MaskX=ObjectData.MaskX;
-                 MaskY=ObjectData.MaskY;
-                 if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
-                     nxy=size(flag_mask);
-                     sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
-                     sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
-                     x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display 
-                     y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
-                     %project on the positions of the scalar
-                     npxy=size(ObjectData.A);
-                     dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
-                     dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
-                     xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
-                     yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);      
-                     [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
-                    flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
-                 end
-                 AClass=class(ObjectData.A);
-                 ObjectData.A=flag_mask.*double(ObjectData.A);
-                 ObjectData.A=feval(AClass,ObjectData.A);
-                 ind_off=[];
-                 if isfield(ObjectData,'ListVarName')
-                      for ilist=1:length(ObjectData.ListVarName)
-                           if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
-                               ind_off=[ind_off ilist];
-                           end
-                      end
-                      ObjectData.ListVarName(ind_off)=[];
-                      ObjectData.VarDimIndex(ind_off)=[];
-                      ind_off=[];        
-                      for ilist=1:length(ObjectData.ListDimName)       
-                           if isequal(ObjectData.ListDimName{ilist},'MaskX')|isequal(ObjectData.ListDimName{ilist},'MaskY')
-                               ind_off=[ind_off ilist];
-                           end
-                      end
-                      ObjectData.ListDimName(ind_off)=[];
-                      ObjectData.DimValue(ind_off)=[];
-                 end
-            end  
-        end
-        if ~isempty(ObjectData)
-%             haxes=[];%default
-%             if isfield(UvData.Object{iobj},'plotaxes')
-%                 haxes=UvData.Object{iobj}.plotaxes;%axes used for representing the projection on the object
-%             end
-            PosColorbar=[];%default: no colorbar
-            if ishandle(haxes_1) & isequal(get(haxes_1,'Tag'),'axes3')& isfield(UvData,'PosColorbar')
-                PosColorbar=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
+    iobj=IndexObj(imap);    
+    ObjectData=proj_field(UvData.Field,UvData.Object{iobj},iobj);% project field on the object
+    
+    %use of mask (TODO: check)
+    if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
+        flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
+        AX=ObjectData.AX;%x coordiantes for the scalar field
+        AY=ObjectData.AY;%y coordinates for the scalar field
+        MaskX=ObjectData.MaskX;%x coordiantes for the mask
+        MaskY=ObjectData.MaskY;%y coordiantes for the mask
+        if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
+            nxy=size(flag_mask);
+            sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
+            sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
+            x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display
+            y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
+            %project on the positions of the scalar
+            npxy=size(ObjectData.A);
+            dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
+            dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
+            xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
+            yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);
+            [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
+            flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
+        end
+        AClass=class(ObjectData.A);
+        ObjectData.A=flag_mask.*double(ObjectData.A);
+        ObjectData.A=feval(AClass,ObjectData.A);
+        ind_off=[];
+        if isfield(ObjectData,'ListVarName')
+            for ilist=1:length(ObjectData.ListVarName)
+                if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
+                    ind_off=[ind_off ilist];
+                end
+            end
+            ObjectData.ListVarName(ind_off)=[];
+            ObjectData.VarDimIndex(ind_off)=[];
+            ind_off=[];
+            for ilist=1:length(ObjectData.ListDimName)
+                if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')
+                    ind_off=[ind_off ilist];
+                end
+            end
+            ObjectData.ListDimName(ind_off)=[];
+            ObjectData.DimValue(ind_off)=[];
+        end
+    end
+    
+    if ~isempty(ObjectData)
+        PlotType='none'; %default
+        if imap==2 && isempty(view_field_handle)
+            view_field(ObjectData)
+        else
+            [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},keeplim(imap),PosColorbar{imap});
+             write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
+        end
+        if isequal(PlotType,'none')
+            hget_field=findobj(allchild(0),'name','get_field');
+            if isempty(hget_field)
+                get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
             else
-                PosColorbar='*';%default position
+                errormsg='The field defined by get_field cannot be plotted';
+                return
             end
-            if imap==1 %plot on uvmat
-                PlotParam=read_plot_param(handles);%read plotting parameters on the uvmat interface
-                [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,haxes_1,PlotParam,keeplim,PosColorbar);
-            elseif ~isempty(view_field_handle)
-                view_field_hh=guidata(view_field_handle);
-                PlotParam=read_plot_param(view_field_hh);%read plotting parameters on the uvmat interface
-                [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,view_field_hh.axes3,PlotParam,keeplim,PosColorbar);
-            else
-                [pt,so,UvData.Object{iobj}.plotaxes]=view_field(ObjectData);
-            end
-            
-            if isequal(PlotType,'none')
-                hget_field=findobj(allchild(0),'name','get_field');
-                if isempty(hget_field)
-                    get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
-                else
-                    errormsg='The field defined by get_field cannot be plotted';
-                    return
-                end 
-            end  
-            UvData.Object{iobj}.PlotParam=ScalOut; %record the plotting parameters
-        end       
-    end
-end
-
-%display the updated plotting parameters for the base menuplane
-write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
+        end
+    end
+end
+
+%write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
 set(handles.uvmat,'UserData',UvData)
 
-%update the mask
+%% update the mask
 if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
    update_mask(handles,num_i1,num_i2);
 end
 
-%prepare the menus of histograms (for the whole menuvolume in 3D case)
-menu_histo=(UvData.Field.ListVarName)';
+%% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
+menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
 ind_bad=[];
 nb_histo=1;
-for ivar=1:numel(menu_histo)
+
+% suppress coordinates from the histogram menu
+for ivar=1:numel(menu_histo)%l loop on field variables: 
     if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
         Role=UvData.Field.VarAttribute{ivar}.Role;
@@ -2731,10 +2745,14 @@
 end
 menu_histo(ind_bad)=[];
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% display menus and plot histograms
 test_v=0;
 if ~isempty(menu_histo)
     set(handles.histo1_menu,'Value',1)
     set(handles.histo1_menu,'String',menu_histo)
-    histo1_menu_Callback(handles.histo1_menu, [], handles)
-    if nb_histo > 1
+    histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram 
+    % case of more than one variables (eg vector components)
+    if nb_histo > 1 
         test_v=1;
         set(handles.histo2_menu,'Visible','on')
@@ -2742,5 +2760,5 @@
         set(handles.histo2_menu,'String',menu_histo)
         set(handles.histo2_menu,'Value',2)
-        histo2_menu_Callback(handles.histo2_menu,[], handles)
+        histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram 
     end
 end
@@ -2751,6 +2769,7 @@
     set(handles.histo2_menu,'Value',1)
 end
-
-%display time
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% display time
 testimedoc=0;
 if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
@@ -2765,5 +2784,5 @@
     end
     siz=size(UvData.XmlData.Time);
-    if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
+    if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
         abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
         dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
@@ -2772,20 +2791,20 @@
 end
 if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
-    [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
-    num_i2=str2num(str2);
+    [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
+    num_i2=str2double(str2);
     if isempty(num_i2)
         num_i2=num_i1;
     end
-    num_j1=str2num(str_a);
+    num_j1=str2double(str_a);
     if isempty(num_j1)
         num_j1=1;
     end
-    num_j2=str2num(str_b);
+    num_j2=str2double(str_b);
     if isempty(num_j2)
         num_j2=num_j1;
     end
-    num_i1=str2num(str1);
+    num_i1=str2double(str1);
     siz=size(UvData.XmlData_1.Time);
-    if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
+    if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
         abstime_1=(UvData.XmlData_1.Time(num_i1,num_j1)+UvData.XmlData_1.Time(num_i2,num_j2))/2;%overset the time read from files
     end
@@ -2805,10 +2824,11 @@
     end
 end
-%update the input file name in the get_field GUI
+
+%% update the input file name in the get_field GUI
 if isequal(FieldName,'get_field...')
     set(hhget_field.inputfile,'String',filename)
     Tabchar={''};%default
     Tabcell=[];
-    if isfield(Field{1},'ListGlobalAttribute')& ~isempty(Field{1}.ListGlobalAttribute)
+    if isfield(Field{1},'ListGlobalAttribute')&& ~isempty(Field{1}.ListGlobalAttribute)
         for iline=1:length(Field{1}.ListGlobalAttribute)
             Tabcell{iline,1}=Field{1}.ListGlobalAttribute{iline};
@@ -2852,5 +2872,4 @@
     set(hhget_field_1.attributes,'String',Tabchar);%update list of global attributes in get_field 
 end
-
 
 
@@ -4015,5 +4034,5 @@
 histo_value=get(handles.histo1_menu,'Value');
 FieldName=histo_menu{histo_value};
-UvData=get(huvmat,'UserData');
+% UvData=get(huvmat,'UserData');
 update_histo(handles.histo_u,huvmat,FieldName)
 
@@ -4026,5 +4045,5 @@
 histo_value=get(handles.histo2_menu,'Value');
 FieldName=histo_menu{histo_value};
-UvData=get(huvmat,'UserData');
+% UvData=get(huvmat,'UserData');
 update_histo(handles.histo_v,huvmat,FieldName)
 
@@ -4034,5 +4053,4 @@
 function update_histo(haxes,huvmat,FieldName)
 UvData=get(huvmat,'UserData');
-
 if ~isfield(UvData.Field,FieldName)
     msgbox_uvmat('ERROR',['no field  ' FieldName ' for histogram'])
@@ -4041,5 +4059,5 @@
 Field=UvData.Field;
 FieldHisto=eval(['Field.' FieldName]);
-if isfield(Field,'FF') & ~isempty(Field.FF) & isequal(size(Field.FF),size(FieldHisto))
+if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
     indsel=find(Field.FF==0);%find values marked as false
     if ~isempty(indsel)
@@ -4264,5 +4282,4 @@
 AxeData=get(haxes,'UserData');
 PlotParam=read_plot_param(handles);
-PlotParam.Scalar
 [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
 write_plot_param(handles,PlotParamOut); %update the auto plot parameters
@@ -4476,9 +4493,9 @@
 dlg_title = 'select properties of the output avi movie';
 num_lines= 1;
-nbfield_cell=get(handles.last_i,'String');
+% nbfield_cell=get(handles.last_i,'String');
 def     = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
 answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
 aviname=answer{1};
-fps=str2num(answer{2});
+fps=str2double(answer{2});
 % check for existing file with output name aviname
 if exist(aviname,'file')
@@ -4504,5 +4521,5 @@
 newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
 set(newaxes,'Tag','movieaxes')
-nbpix=[512 384]*str2num(answer{3});
+nbpix=[512 384]*str2double(answer{3});
 set(gcf,'Position',[1 1 nbpix])% resolution XVGA 
 set(newaxes,'Position',eval(answer{4}));
@@ -4513,5 +4530,9 @@
 UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
 set(huvmat,'UserData',UvData);
-increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
+increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
+if isnan(increment)
+    set(handles.increment_scan,'String','1')%default value
+    increment=1;
+end
 set(handles.STOP,'Visible','on')
 set(handles.speed,'Visible','on')
@@ -4519,6 +4540,6 @@
 set(handles.Movie,'BusyAction','queue')
 
-imin=str2num(get(handles.i1,'String'));
-imax=str2num(answer{5});
+%imin=str2double(get(handles.i1,'String'));
+imax=str2double(answer{5});
 % if isfield(UvData,'Time')
 htitle=get(newaxes,'Title');
@@ -4530,6 +4551,6 @@
 set(handles.speed,'Value',1)
 for i=1:imax
-    if get(handles.speed,'Value')~=0 & isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
-            runpm(hObject,eventdata,handles,increment)
+    if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
+            runpm(hObject,eventdata,handles,increment)% run plus 
             drawnow
             time_str=get(handles.abs_time,'String');
@@ -4541,5 +4562,5 @@
     end
 end
-aviobj=close(aviobj);
+close(aviobj);
 UvData.Object{1}.plotaxes=handles.axes3;
 set(huvmat,'UserData',UvData);
@@ -4789,7 +4810,7 @@
 end
 if isequal(get(handles.scan_i,'Value'),1)
-    param.incr_i=str2num(get(handles.increment_scan,'String'));
+    param.incr_i=str2double(get(handles.increment_scan,'String'));
 elseif isequal(get(handles.scan_j,'Value'),1)
-    param.incr_j=str2num(get(handles.increment_scan,'String'));
+    param.incr_j=str2double(get(handles.increment_scan,'String'));
 end
 param.list_fields=get(handles.Fields,'String');% list menu fields
Index: /trunk/src/write_plot_param.m
===================================================================
--- /trunk/src/write_plot_param.m	(revision 127)
+++ /trunk/src/write_plot_param.m	(revision 128)
@@ -66,5 +66,5 @@
 function set_scal_display(handles,state)
 %------------------------------------------------------------------
-set(handles.SCALAR_title,'Visible',state)
+% set(handles.SCALAR_title,'Visible',state)
 set(handles.MaxA,'Visible',state)
 set(handles.MinA,'Visible',state)
@@ -73,5 +73,4 @@
 set(handles.BW,'Visible',state)
 set(handles.Contours,'Visible',state)
-set(handles.SCALAR_title,'Visible',state)
 set(handles.min_title,'Visible',state)
 set(handles.max_title,'Visible',state)
@@ -88,5 +87,5 @@
 %------------------------------------------------------------------
 set(handles.frame_vect,'Visible',state)
-set(handles.VECT_title,'Visible',state)
+% set(handles.VECT_title,'Visible',state)
 set(handles.VecScale,'Visible',state)
 set(handles.AutoVec,'Visible',state)
