Index: unk/src/ListDir.m
===================================================================
--- /trunk/src/ListDir.m	(revision 7)
+++ 	(revision )
@@ -1,98 +1,0 @@
-%'ListDir': scan the structure of the directory tree (for dataview.m)
-%------------------------------------------------------------------------
-function [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices_in,ListRecords_in)
-
-ListRecords={};
-ListDevices={};
-ListXml={};
-irecord_tot=0;
-idevice_tot=0;
-ixml_tot=0;
-for iexp=1:length(ListExperiments) 
-    List.Experiment{iexp}.name=ListExperiments{iexp};
-    hdir=dir(fullfile(CurrentPath,ListExperiments{iexp}));
-    idevice=0;
-    for isub=1:length(hdir)% scan the sub-directories  of the current experiment       
-        if hdir(isub).isdir
-            name=hdir(isub).name;%name of the current device
-            if ~isequal(name(1),'.')% subdirectory of the current experiment
-                [testnew,testselect]=test_select(name,ListDevices,ListDevices_in);
-                if testselect
-                    idevice=idevice+1;
-                    List.Experiment{iexp}.Device{idevice}.name=name;             
-                    if testnew
-                         idevice_tot=idevice_tot+1;
-                         ListDevices{idevice_tot}=name;
-                    end
-                    CurrentDevice=fullfile(CurrentPath,ListExperiments{iexp},name);
-                    hsubxml=dir(fullfile(CurrentDevice,'*.xml'));%look at xml files in the subdirectory of the current device
-                    if isempty(hsubxml) % the subdirectory of the current device contains directories 'Record'' 
-                        hsubdir=dir(fullfile(CurrentPath,ListExperiments{iexp},name));%list what is inside the directory 'Device'   
-                        irecord=0;
-                        for isubsub=1:length(hsubdir)% subdirectories of the current device
-                            if hsubdir(isubsub).isdir                       
-                                RecordName=hsubdir(isubsub).name;  
-                                if ~isequal(RecordName(1),'.')
-                                    [testnew,testselect]=test_select(RecordName,ListRecords,ListRecords_in);
-                                    if testselect
-                                        if testnew
-                                            irecord_tot=irecord_tot+1;
-                                            ListRecords{irecord_tot}=RecordName;
-                                        end
-                                        irecord=irecord+1;
-                                        List.Experiment{iexp}.Device{idevice}.Record{irecord}.name=RecordName;
-                                        hsubsubxml=dir(fullfile(CurrentDevice,RecordName,'*.xml'));%
-                                        for ixml=1:length(hsubsubxml)
-                                            XmlName=hsubsubxml(ixml).name;
-                                            List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}=XmlName;
-                                            testnew=test_select(XmlName,ListXml,{});
-                                            if testnew
-                                                ixml_tot=ixml_tot+1;
-                                                ListXml{ixml_tot}=XmlName;
-                                            end
-                                        end 
-                                    end              
-                                end
-                            end
-                        end
-                    else
-                        for ixml=1:length(hsubxml)
-                            XmlName=hsubxml(ixml).name;
-                            List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}=XmlName;
-                            testnew=test_select(XmlName,ListXml,{});
-                            if testnew
-                                ixml_tot=ixml_tot+1;
-                                ListXml{ixml_tot}=XmlName;
-                            end
-                        end
-                    end
-                end
-            end
-        end
-    end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function [testnew,testselect]=test_select(name,ListDevices,ListDevices_in)
-if ~isempty(ListDevices_in)
-    testnew=0;
-    testselect=0;
-    for ilist=1:length(ListDevices_in)
-        if isequal(name,ListDevices_in{ilist})
-            testnew=1;
-            testselect=1; 
-            break
-        end
-    end
-else
-    testnew=1; 
-    testselect=1;
-end
-if testnew
-    for ilist=1:length(ListDevices)
-         if isequal(name,ListDevices{ilist})
-              testnew=0;
-              break
-         end
-    end
-end
Index: unk/src/RUN_FIX.m
===================================================================
--- /trunk/src/RUN_FIX.m	(revision 7)
+++ 	(revision )
@@ -1,145 +1,0 @@
-%'RUN_FIX': function for fixing velocity fields:
-%-----------------------------------------------
-% RUN_FIX(filename,field,flagindex,thresh_vecC,thresh_vel,iter,flag_mask,maskname,fileref,fieldref)
-%
-%filename: name of the netcdf file (used as input and output)
-%field: structure specifying the field to fix (field.vel_type='civ1' or 'civ2')
-%flagindex: flag specifying which values of vec_f are removed: 
-        % if flagindex(1)=1: vec_f=-2 vectors are removed
-        % if flagindex(2)=1: vec_f=3 vectors are removed
-        % if flagindex(3)=1: vec_f=2 vectors are removed (if iter=1) or vec_f=4 vectors are removed (if iter=2)
-%iter=1 for civ1 fields and iter=2 for civ2 fields
-%thresh_vecC: threshold in the image correlation vec_C
-%flag_mask: =1 mask used to remove vectors (0 else)
-%maskname: name of the mask image file for fix
-%thresh_vel: threshold on velocity, or on the difference with the reference file fileref if exists
-%inf_sup=1: remove values smaller than threshold thresh_vel, =2, larger than threshold
-%fileref: .nc file name for a reference velocity (='': refrence 0 used)
-%fieldref: 'civ1','filter1'...feld used in fileref
-
-function error=RUN_FIX(filename,field,flagindex,iter,thresh_vecC,flag_mask,maskname,thresh_vel,inf_sup,fileref,fieldref)
-error=[]; %default
-vel_type{1}=field.vel_type;
-Field=read_civxdata(filename,[],field.vel_type);
-if isfield(Field,'Txt')
-    error=Field.Txt; %error in reading
-    return
-end
-
-if ~isfield(Field,'X') || ~isfield(Field,'Y') || ~isfield(Field,'U') || ~isfield(Field,'V')
-    error=['input file ' filename ' does not contain vectors in RUN_FIX.m']; %bad input file
-    return
-end
-if ~isfield(Field,'C')
-    Field.C=ones(size(Field.X));%correlation=1 by default
-end
-if ~isfield(Field,'F')
-    Field.F=ones(size(Field.X));%warning flag=1 by default
-end
-if ~isfield(Field,'FF')
-    Field.FF=zeros(size(Field.X));%fixflag=0 by default
-end
-
-vec_f_unit=abs(Field.F)-10*double(uint16(abs(Field.F)/10)); %unityterm of vec_F in abs value
-vec_f_sign=sign(Field.F).*vec_f_unit;% gives the unity digit of vec_f with correct sign
-flag1=(flagindex(1)==1)&(vec_f_sign==-2);%removed vectors vec_f=-2
-flag2=(flagindex(2)==1)&(vec_f_sign==3);%removed vectors vec_f=3
-if iter==1
-        flag3=(flagindex(3)==1)&(vec_f_sign==2); % Hart vectors
-elseif iter==2
-        flag3=(flagindex(3)==1)&(vec_f_sign==4); % 
-end
-flag4=(Field.C < thresh_vecC)&(flag1~=1)&(flag2~=1)&(flag3~=1); % =1 for low vec_C vectors not previously removed
-
-% criterium on velocity values
-delta_u=Field.U;%default without ref file
-delta_v=Field.V;
-if exist('fileref','var') && ~isempty(fileref)
-    if ~exist(fileref,'file')
-        error='reference file not found in RUN_FIX.m';
-        display(error);
-        return
-    end
-    FieldRef=read_civxdata(fileref,[],fieldref);   
-    if isfield(FieldRef,'FF')
-        index_true=find(FieldRef.FF==0);
-        FieldRef.X=FieldRef.X(index_true);
-        FieldRef.Y=FieldRef.Y(index_true);
-        FieldRef.U=FieldRef.U(index_true);
-        FieldRef.V=FieldRef.V(index_true);
-    end
-    if ~isfield(FieldRef,'X') || ~isfield(FieldRef,'Y') || ~isfield(FieldRef,'U') || ~isfield(FieldRef,'V')
-        error='reference file is not a velocity field in RUN_FIX.m '; %bad input file
-        return
-    end
-    if length(FieldRef.X)<=1
-        errordlg('reference field with one vector or less in RUN_FIX.m')
-        return
-    end
-    vec_U_ref=griddata_uvmat(FieldRef.X,FieldRef.Y,FieldRef.U,Field.X,Field.Y);  %interpolate vectors in the ref field
-    vec_V_ref=griddata_uvmat(FieldRef.X,FieldRef.Y,FieldRef.V,Field.X,Field.Y);  %interpolate vectors in the ref field to the positions  of the main field     
-    delta_u=Field.U-vec_U_ref;%take the difference with the interpolated ref field
-    delta_v=Field.V-vec_V_ref;
-end
-
-thresh_vel_x=thresh_vel; 
-thresh_vel_y=thresh_vel; 
-if isequal(inf_sup,1)
-    flag5=abs(delta_u)<thresh_vel_x & abs(delta_v)<thresh_vel_y &(flag1~=1)&(flag2~=1)&(flag3~=1)&(flag4~=1);
-elseif isequal(inf_sup,2)
-    flag5=(abs(delta_u)>thresh_vel_x | abs(delta_v)>thresh_vel_y) &(flag1~=1)&(flag2~=1)&(flag3~=1)&(flag4~=1);
-end
-
-            % flag7 introduce a grey mask, matrix M
-if isequal (flag_mask,1)
-   M=imread(maskname);
-   nxy=size(M);
-   M=reshape(M,1,nxy(1)*nxy(2));
-   rangx0=[0.5 nxy(2)-0.5];
-   rangy0=[0.5 nxy(1)-0.5];
-   vec_x1=Field.X-Field.U/2;%beginning points
-   vec_x2=Field.X+Field.U/2;%end points of vectors
-   vec_y1=Field.Y-Field.V/2;%beginning points
-   vec_y2=Field.Y+Field.V/2;%end points of vectors
-   indx=1+round((nxy(2)-1)*(vec_x1-rangx0(1))/(rangx0(2)-rangx0(1)));% image index x at abcissa vec_x
-   indy=1+round((nxy(1)-1)*(vec_y1-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y   
-   test_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside
-   indx=indx.*test_in+(1-test_in); %replace indx by 1 out of the mask range
-   indy=indy.*test_in+(1-test_in); %replace indy by 1 out of the mask range
-   ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector
-   Mvalues=M(ICOMB);
-   flag7b=((20 < Mvalues) & (Mvalues < 200))| ~test_in';
-   indx=1+round((nxy(2)-1)*(vec_x2-rangx0(1))/(rangx0(2)-rangx0(1)));% image index x at abcissa Field.X
-   indy=1+round((nxy(1)-1)*(vec_y2-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y
-   test_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside
-   indx=indx.*test_in+(1-test_in); %replace indx by 1 out of the mask range
-   indy=indy.*test_in+(1-test_in); %replace indy by 1 out of the mask range
-   ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector
-   Mvalues=M(ICOMB);
-   flag7e=((Mvalues > 20) & (Mvalues < 200))| ~test_in';
-   flag7=(flag7b|flag7e)';
-else
-   flag7=0;
-end   
-flagmagenta=flag1|flag2|flag3|flag4|flag5|flag7;
-
-%write fix flags
-[errorread,message]=fileattrib(filename);
-
-if ~isempty(message) && ~isequal(message.UserWrite,1)
-     msgbox_uvmat('ERROR',['no writting access to ' filename ' (RUN_FIX.m)']);
-    return
-end
-nc=netcdf(filename,'write'); %open netcdf file for writing
-result=redef(nc);
-if isempty(result), errordlg('##Bad redef operation.'),end  
-if iter==1
-    nc.fix=1;
-elseif iter==2
-    nc.fix2=1;
-end
-%theDim=nc(field.nb) ;% get the number of velocity vectors
-nc{field.fixflag}=ncfloat(field.nb);
-fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag
-nc{field.fixflag}(:)=fixflag_unit+10*flagmagenta;
-close(nc);
Index: unk/src/RUN_STLIN.m
===================================================================
--- /trunk/src/RUN_STLIN.m	(revision 7)
+++ 	(revision )
@@ -1,202 +1,0 @@
-%'RUN_STLIN': combine velocity fields for stereo PIV
-% file_A,file_B: input velocity files
-%vel_type: string ='civ1' or 'civ2'
-function RUN_STLIN(file_A,file_B,vel_type,file_st,nx_patch,ny_patch,thresh_patch,fileAxml,fileBxml)
-                
- [XmlDataA,error]=imadoc2struct(fileAxml); 
- [XmlDataB,error]=imadoc2struct(fileBxml);
- npxA=[]; npyA=[]; pxB=[]; npyB=[];
- if isfield(XmlDataA,'Camera') && isfield(XmlDataB,'Camera')
-      if isfield(XmlDataA.Camera,'ImageSize')&& isfield(XmlDataB.Camera,'ImageSize')
-          ImageSizeA=XmlDataA.Camera.ImageSize;
-          ImageSizeB=XmlDataB.Camera.ImageSize;
-          if ~isempty(ImageSizeA)&& ~isempty(ImageSizeB)
-               xindex=findstr(ImageSizeA,'x');
-               if length(xindex)>=2
-                    npxA=str2num(ImageSizeA(1:xindex(1)-1));
-                    npyA=str2num(ImageSizeA(xindex(1)+1:xindex(2)-1));
-               end
-               xindex=findstr(ImageSizeB,'x');
-               if length(xindex)>=2
-                    npxB=str2num(ImageSizeB(1:xindex(1)-1));
-                    npyB=str2num(ImageSizeB(xindex(1)+1:xindex(2)-1));
-               end
-          end
-     end
- end
- if isempty(npxA) ||isempty(npxB)
-     warndlg_uvmat('The size of image A needs to be defined in the xml file ImaDoc','ERROR')
-     return
- elseif isempty(npxB) || isempty(npyB)
-      warndlg_uvmat('The size of image B needs to be defined in the xml file ImaDoc','ERROR')
-     return
- end
- if isfield(XmlDataA,'GeometryCalib')
-     tsaiA=XmlDataA.GeometryCalib;
- else
-     warndlg_uvmat('no geometric calibration available for image A','ERROR')
-     return
- end
- if isfield(XmlDataB,'GeometryCalib')
-     tsaiB=XmlDataB.GeometryCalib;
- else
-     warndlg_uvmat('no geometric calibration available for image B','ERROR')
-     return
- end
- 
- %corners of each image in real coordinates:
- cornerA(:,1)=[0 0 npxA npxA]';%x positions
- cornerA(:,2)=[0 npyA 0 npyA]';%y positions
- cornerB(:,1)=[0 0 npxB npxB]';%x positions
- cornerB(:,2)=[0 npyB 0 npyB]';%y positions
-[xyA(:,1),xyA(:,2)]=phys_XYZ(tsaiA,cornerA(:,1),cornerA(:,2));
-[xyB(:,1),xyB(:,2)]=phys_XYZ(tsaiB,cornerB(:,1),cornerB(:,2));
- max_x=max(max(xyA(:,1)),max(xyB(:,1)));%maximum on the 4 corners of the the images
- min_x=min(min(xyA(:,1)),min(xyB(:,1)));%minimum on the 4 corners of the the images
- max_y=max(max(xyA(:,2)),max(xyB(:,2)));
- min_y=min(min(xyA(:,2)),min(xyB(:,2)));
- array_realx=[min_x:(max_x-min_x)/(nx_patch-1):max_x];
- array_realy=[min_y:(max_y-min_y)/(ny_patch-1):max_y];
- [grid_realx,grid_realy]=meshgrid(array_realx,array_realy);
- grid_real(:,1)=reshape(grid_realx,nx_patch*ny_patch,1);
- grid_real(:,2)=reshape(grid_realy,nx_patch*ny_patch,1);
- grid_real(:,3)=zeros(nx_patch*ny_patch,1);
-[grid_imaA(:,1),grid_imaA(:,2)]=px_XYZ(tsaiA,grid_real(:,1),grid_real(:,2));
-[grid_imaB(:,1),grid_imaB(:,2)]=px_XYZ(tsaiB,grid_real(:,1),grid_real(:,2));
-
- flagA=grid_imaA(:,1)>0 & grid_imaA(:,1)<npxA & grid_imaA(:,2)>0 & grid_imaA(:,2)<npyA;
- flagB=grid_imaB(:,1)>0 & grid_imaB(:,1)<npxB & grid_imaB(:,2)>0 & grid_imaB(:,2)<npyB;
- ind_good=find(flagA==1&flagB==1);
- XimaA=grid_imaA(ind_good,1);
- YimaA=grid_imaA(ind_good,2);
- XimaB=grid_imaB(ind_good,1);
- YimaB=grid_imaB(ind_good,2);
- grid_real_x=grid_real(ind_good,1);
- grid_real_y=grid_real(ind_good,2);
-
-% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %read the velocity fields
-% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% 
-% [dt,time1,pixcmx,pixcmy,vec_X,vec_Y,vec_Z,vec_U,vec_V,vec_W,vec_C,vec_F,fixflag,vel_type_out,error,nb_coord,nb_dim]...
-%     =read_vel({filecell_ncA},{vel_type});
-%read field A
-[Field,VelTypeOut]=read_civxdata(file_A,[],vel_type);
-%interpolate on XimaA
-Field.X=Field.X(find(Field.FF==0));
-Field.Y=Field.Y(find(Field.FF==0));
-Field.U=Field.U(find(Field.FF==0));
-Field.V=Field.V(find(Field.FF==0));
-dXa= griddata_uvmat(Field.X,Field.Y,Field.U,XimaA,YimaA);
-dYa= griddata_uvmat(Field.X,Field.Y,Field.V,XimaA,YimaA);
-dt=Field.dt;
-time=Field.Time;
-
-%read field B
-% [dt,time2,pixcmx,pixcmy,vec_X,vec_Y,vec_Z,vec_U,vec_V,vec_W,vec_C,vec_F,fixflag,vel_type_out,error,nb_coord,nb_dim]...
-%     =read_vel({file_B},{vel_type});
-[Field,VelTypeOut]=read_civxdata(file_B,FieldNames,vel_type);
-if ~isequal(Field.dt,dt)
-    warndlg_uvmat('different time intervals for the two velocity fields ','ERROR')
-     return
-end
-if ~isequal(Field.Time,time)
-    warndlg_uvmat('different times for the two velocity fields ','ERROR')
-     return
-end
-%interpolate on XimaB
-Field.X=Field.X(find(Field.FF==0));
-Field.Y=Field.Y(find(Field.FF==0));
-Field.U=Field.U(find(Field.FF==0));
-Field.V=Field.V(find(Field.FF==0));
-dXb=griddata_uvmat(Field.X,Field.Y,Field.U,XimaB,YimaB);
-dYb=griddata_uvmat(Field.X,Field.Y,Field.V,XimaB,YimaB);
-%eliminate Not-a-Number 
-ind_Nan=find(and(~isnan(dXa),~isnan(dXb)));
-dXa=dXa(ind_Nan);
-dYa=dYa(ind_Nan);
-dXb=dXb(ind_Nan);
-dYb=dYb(ind_Nan); 
-grid_phys1(:,1)=grid_real_x(ind_Nan);
-grid_phys1(:,2)=grid_real_y(ind_Nan);
- 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
-%compute the coefficients
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
-[A11,A12,A13,A21,A22,A23]=pxcm_tsai(tsaiA,grid_phys1);
-[B11,B12,B13,B21,B22,B23]=pxcm_tsai(tsaiB,grid_phys1);
-
-C1=A11.*A22-A12.*A21;
-C2=A13.*A22-A12.*A23;
-C3=A13.*A21-A11.*A23;
-D1=B11.*B22-B12.*B21;
-D2=B13.*B22-B12.*B23;
-D3=B13.*B21-B11.*B23;
-A1=(A22.*D1.*(C1.*D3-C3.*D1)+A21.*D1.*(C2.*D1-C1.*D2));
-A2=(A12.*D1.*(C3.*D1-C1.*D3)+A11.*D1.*(C1.*D2-C2.*D1));
-B1=(B22.*C1.*(C3.*D1-C1.*D3)+B21.*C1.*(C1.*D2-C2.*D1));
-B2=(B12.*C1.*(C1.*D3-C3.*D1)+B11.*C1.*(C2.*D1-C1.*D2));
-Lambda=(A1.*dXa+A2.*dYa+B1.*dXb+B2.*dYb)./(A1.*A1+A2.*A2+B1.*B1+B2.*B2);
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Projection for compatible displacements
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-Ua=dXa-Lambda.*A1;
-Va=dYa-Lambda.*A2;
-Ub=dXb-Lambda.*B1;
-Vb=dYb-Lambda.*B2;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Calculations of displacements and error
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-U=(A22.*D2.*Ua-A12.*D2.*Va-B22.*C2.*Ub+B12.*C2.*Vb)./(C1.*D2-C2.*D1);
-V=(A21.*D3.*Ua-A11.*D3.*Va-B21.*C3.*Ub+B11.*C3.*Vb)./(C3.*D1-C1.*D3);
-W=(A22.*D1.*Ua-A12.*D1.*Va-B22.*C1.*Ub+B12.*C1.*Vb)./(C2.*D1-C1.*D2);
-W1=(-A21.*D1.*Ua+A11.*D1.*Va+B21.*C1.*Ub-B11.*C1.*Vb)./(C1.*D3-C3.*D1);
-
-error=sqrt((A1.*dXa+A2.*dYa+B1.*dXb+B2.*dYb).*(A1.*dXa+A2.*dYa+B1.*dXb+B2.*dYb)./(A1.*A1+A2.*A2+B1.*B1+B2.*B2));
-
-ind_error=(find(error<thresh_patch));
-U=U(ind_error);
-V=V(ind_error);
-W=W(ind_error);%correction for water interface
-error=error(ind_error);
-
-%create nc grid file
-Result.ListGlobalAttribute={'nb_coord','nb_dim','constant_pixcm','absolut_time_T0','hart','dt','civ'};
-Result.nb_coord=3;%grid file, no velocity
-Result.nb_dim=2;
-Result.constant_pixcm=0;%no linear correspondance with images
-Result.absolut_time_T0=time;%absolute time of the field
-Result.hart=0;
-Result.dt=dt;%time interval for image correlation (put  by default)
-% cte.title='grid';
-Result.civ=0;%not a civ file (no direct correspondance with an image)
-Result.ListDimName={'nb_vectors'}
-Result.DimValue=length(U);
-Result.ListVarName={'vec_X';'vec_Y';'vec_U';'vec_V';'vec_W';'vec_E'};
-Result.VarDimIndex: {[1]  [1]  [1]  [1]  [1]  [1]}
-Result.vec_X= grid_phys1(ind_error,1);
-Result.vec_Y= grid_phys1(ind_error,2);
-Result.vec_U=U/dt;
-Result.vec_V=V/dt;
-Result.vec_W=W/dt;
-Result.vec_E=error; 
-% error=write_netcdf(file_st,cte,fieldlabels,grid_phys);
-error=struct2nc(file_st,Result);
-display([file_st ' written'])
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: unk/src/calc_field.m
===================================================================
--- /trunk/src/calc_field.m	(revision 7)
+++ 	(revision )
@@ -1,312 +1,0 @@
-%'calc_field': defines fields (velocity, vort, div...) from civx data and calculate them  
-%---------------------------------------------------------------------
-
-%
-% OUTPUT: 
-% Scal: matlab vector representing the scalar values (length nbvec defined by var_read)  
-            % if no input , Scal=list of programmed scalar names (to put in menus)
-            % if only the sclar name is put as input, vec_A=type of scalar, which can be:
-%                   'vel': scalar calculated solely from velocity components
-%                   'der': needs spatial derivatives     
-%                   'var': the scalar name directly corresponds to a field name in the netcdf files
-% error: error flag
-            % error = 0; OK
-            % error = 1; the prescribed scalar cannot be read or calculated from available fields
-% INPUT:
-% ScalName: string representing the name of the scalar
-% DataIn: structure representing the field, as defined in check_field_srtructure.m
-
-% FUNCTION related
-% varname_generator.m: determines the field names to read in the netcdf file, depending on the scalar
-
-function [DataOut,errormsg]=calc_field(FieldName,DataIn)
-
-%list of defined scalars to display in menus (in addition to 'ima_cor').
-% a type is associated to each scalar: 
-%              'discrete': related to the individual velocity vectors, not interpolated by patch
-%              'vel': calculated from velocity components, continuous field (interpolated with velocity)              
-%              'der': needs spatial derivatives     
-%              'var': the scalar name corresponds to a field name in the netcdf files
-% a specific variable name for civ1 and civ2 fields are also associated, if
-% '' the scalar is calculated from other fields, as explicited below
-%list_scal={title, type, civ1 var name,civ2 var name}
-list_field={'velocity';...%image correlation corresponding to a vel vector
-            'ima_cor';...%image correlation corresponding to a vel vector
-           'norm_vel';...%norm of the velocity
-           'vort';...%vorticity
-           'div';...%divergence
-           'strain';...%rate of strain
-           'u';... %u velocity component
-           'v';... %v velocity component
-           'w';... %w velocity component
-           'w_normal';... %w velocity component normal to the plane
-          'error'}; %error associated to a vector (for stereo or patch)
-errormsg=[]; %default error message
-if ~exist('FieldName','var') 
-    DataOut=list_field;% gives the list of possible fields in the absence of input
-else
-    if ~exist('DataIn','var')
-        DataIn=[];
-    end
-    if ischar(FieldName)
-        FieldName={FieldName};
-    end
-    if isfield(DataIn,'Z')&& isequal(size(DataIn.Z),size(DataIn.X))
-        nbcoord=3;
-    else
-        nbcoord=2;
-    end    
-    DataOut=DataIn; %reporduce global attribute
-    ListVarName={};
-    ValueList={};
-    RoleList={};
-    units_cell={};
-    for ilist=1:length(FieldName)  
-        [VarName,Value,Role,units]=feval(FieldName{ilist},DataIn);%calculate field with appropriate function named FieldName{ilist}
-        ListVarName=[ListVarName VarName];
-        ValueList=[ValueList Value];
-        RoleList=[RoleList Role];
-        units_cell=[units_cell units];
-    end   
-       %erase previous data (except coordinates)
-    for ivar=nbcoord+1:length(DataOut.ListVarName)
-        VarName=DataOut.ListVarName{ivar};
-        DataOut=rmfield(DataOut,VarName);
-    end  
-    DataOut.ListVarName=DataOut.ListVarName(1:nbcoord);
-    if isfield(DataOut,'VarDimName')
-        DataOut.VarDimName=DataOut.VarDimName(1:nbcoord);
-    else
-        errormsg='element .VarDimName missing in input data';
-        return
-    end
-    DataOut.VarAttribute=DataOut.VarAttribute(1:nbcoord);
-    %append new data
-    DataOut.ListVarName=[DataOut.ListVarName ListVarName];
-    for ivar=1:length(ListVarName)
-        DataOut.VarDimName{nbcoord+ivar}=DataOut.VarDimName{1};      
-        DataOut.VarAttribute{nbcoord+ivar}.Role=RoleList{ivar};  
-        DataOut.VarAttribute{nbcoord+ivar}.units=units_cell{ivar};
-        eval(['DataOut.' ListVarName{ivar} '=ValueList{ivar};'])
-    end
-end
-
-%%%%%%%%%%%%% velocity fieldn%%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units_cell]=velocity(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units_cell={};
-if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
-    units=[DataIn.CoordUnit '/' DataIn.TimeUnit];
-else
-    units='pixel';
-end
-if isfield(DataIn,'U')
-    VarName=[VarName {'U'}];
-    ValCell=[ValCell {DataIn.U}];
-    Role=[Role {'vector_x'}];
-    units_cell=[units_cell {units}];
-end
-if isfield(DataIn,'V')
-    VarName=[VarName {'V'}];
-    ValCell=[ValCell {DataIn.V}];
-    Role=[Role {'vector_y'}];  
-    units_cell=[units_cell {units}];
-end
-if isfield(DataIn,'W')
-    VarName=[VarName {'W'}];
-    ValCell=[ValCell {DataIn.W}];
-    Role=[Role {'vector_z'}];
-    units_cell=[units_cell {units}];
-end
-if isfield(DataIn,'F')
-    VarName=[VarName {'F'}];
-    ValCell=[ValCell {DataIn.F}];
-    Role=[Role {'warnflag'}];
-    units_cell=[units_cell {[]}];
-end
-if isfield(DataIn,'FF')
-    VarName=[VarName,{'FF'}];
-    ValCell=[ValCell {DataIn.FF}];
-    Role=[Role {'errorflag'}];
-    units_cell=[units_cell {[]}];
-end
-
-%%%%%%%%%%%%% ima cor%%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=ima_cor(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'C')
-    VarName{1}='C';
-    ValCell{1}=DataIn.C;
-    Role={'ancillary'};
-    units={[]};
-end
-
-%%%%%%%%%%%%% norm_vec %%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=norm_vel(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'U') && isfield(DataIn,'V')
-    VarName{1}='norm_vel';
-     ValCell{1}=DataIn.U.*DataIn.U+ DataIn.V.*DataIn.V;
-     if isfield(DataIn,'W') && isequal(size(DataIn.W),size(DataIn.U))
-         ValCell{1}=ValCell{1}+DataIn.W.*DataIn.W;
-     end
-     ValCell{1}=sqrt(ValCell{1});
-     Role{1}='scalar';
-     if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
-        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
-     else
-        units={'pixel'};
-     end
-end  
-
-
-
-%%%%%%%%%%%%% vorticity%%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=vort(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'DjUi')
-    VarName{1}='vort';
-    ValCell{1}=DataIn.DjUi(:,1,2)-DataIn.DjUi(:,2,1);  %vorticity
-    siz=size(ValCell{1});
-    ValCell{1}=reshape(ValCell{1},siz(1),1);
-    Role{1}='scalar';
-    if isfield(DataIn,'TimeUnit')
-        units={[DataIn.TimeUnit '-1']};
-    else
-        units={[]};
-    end
-end  
-
-%%%%%%%%%%%%% divergence%%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=div(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'DjUi')
-    VarName{1}='div';
-    ValCell{1}=DataIn.DjUi(:,1,1)+DataIn.DjUi(:,2,2); %DUDX+DVDY
-    siz=size(ValCell{1});
-    ValCell{1}=reshape(ValCell{1},siz(1),1);
-    Role{1}='scalar';
-    if isfield(DataIn,'TimeUnit')
-        units={[DataIn.TimeUnit '-1']};
-    else
-        units={[]};
-    end
-end  
-
-%%%%%%%%%%%%% strain %%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=strain(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'DjUi')
-   VarName{1}='strain'; 
-   ValCell{1}=DataIn.DjUi(:,1,2)+DataIn.DjUi(:,2,1);%DVDX+DUDY
-   siz=size(ValCell{1});    
-   ValCell{1}=reshape(ValCell{1},siz(1),1); 
-   if isfield(DataIn,'TimeUnit')
-        units={[DataIn.TimeUnit '-1']};
-   else
-        units={[]};
-   end
-end  
-
-%%%%%%%%%%%%% u %%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=u(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'U')
-    VarName{1}='U';
-    ValCell{1}=DataIn.U;
-    Role{1}='scalar';
-    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
-        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
-    else
-        units={'pixel'};
-    end
-end
-
-%%%%%%%%%%%%% v %%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=v(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'V')
-    VarName{1}='V';
-    ValCell{1}=DataIn.V;
-    Role{1}='scalar';
-    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
-        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
-    else
-        units={'pixel'};
-    end
-end
-
-%%%%%%%%%%%%% w %%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=w(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'W')
-    VarName{1}='W';
-    ValCell{1}=DataIn.W;
-    Role{1}='scalar';%will remain unchanged by projection
-    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
-        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
-    else
-        units={'pixel'};
-    end
-end
-
-%%%%%%%%%%%%% w_normal %%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=w_normal(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'W')
-    VarName{1}='W';
-    ValCell{1}=DataIn.W;
-    Role{1}='vector_z';%will behave like a vector component  by projection 
-    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
-        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
-    else
-        units={'pixel'};
-    end
-end
-
-%%%%%%%%%%%%% error %%%%%%%%%%%%%%%%%%%%
-function [VarName,ValCell,Role,units]=error(DataIn)
-VarName={};
-ValCell={};
-Role={};
-units={};
-if isfield(DataIn,'E')
-    VarName{1}='E';
-    ValCell{1}=DataIn.E;
-    Role{1}='ancillary'; %TODO CHECK units in actual fields
-    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
-        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
-    else
-        units={'pixel'};
-    end
-end
-
Index: unk/src/cell2tab.m
===================================================================
--- /trunk/src/cell2tab.m	(revision 7)
+++ 	(revision )
@@ -1,33 +1,0 @@
-%'cell2tab': transform a Matlab cell in a character array suitable for display in a table
-% INPUT:
-% Tabcell: (nx,ny) cell table, for nx lines
-% separator: character used for separating displayed columns
-function Tabchar=cell2tab(Tabcell,separator) 
-Tabchar={};%default
-[nx,ny]=size(Tabcell);
-%determine width withcolumn(jtab) of each column
-for jtab=1:ny 
-    widthcolumn(jtab)=0;%default
-    for itab=1:nx% read line
-        if widthcolumn(jtab)<length(Tabcell{itab,jtab})
-            widthcolumn(jtab)=length(Tabcell{itab,jtab});
-        end
-    end
-end
-%justify table
-for itab=1:nx    
-    charchain=[];         
-    for jtab=1:ny% read line
-        textlu=Tabcell{itab,jtab};
-        if widthcolumn(jtab)>length(textlu)
-            blankstr=char(32*ones(1,widthcolumn(jtab)-length(textlu)));
-            textlu=[textlu blankstr];
-        end
-        if ~isempty(charchain)
-            textlu=[separator textlu];
-        end
-        charchain=[charchain textlu];
-    end
-    %Tabchar(itab)={charchain};
-    Tabchar(itab,1)={charchain};
-end
Index: unk/src/check_field_structure.m
===================================================================
--- /trunk/src/check_field_structure.m	(revision 7)
+++ 	(revision )
@@ -1,151 +1,0 @@
-%'check_field_structure': check the validity of the field struture representation consitant with the netcdf format
-%----------------------------------------------------------------------
-% function [DataOut,errormsg]=check_field_structure(Data)
-%
-% OUTPUT:
-%  Data: structure reproducing the input structure Data, with the additional elements:
-%           with fields:
-%
-%            .ListDimName: cell listing the names of the array dimensions
-%             .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
-%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
-%            .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName
-% errormsg: error message which is not empty when the input structure does not have the right form
-%
-%INPUT:
-% Data:   structure containing 
-%         (optional) .ListGlobalAttribute: cell listing the names of the global attributes
-%                    .Att_1,Att_2... : values of the global attributes
-%         (requested)  .ListVarName: list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} ) 
-%         (requested)  .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)                         
-%         (requested) .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
-
-
-function [DataOut,errormsg]=check_field_structure(Data)
-DataOut=[]; %default
-errormsg=[];
-if ~isstruct(Data)
-    errormsg='input field is not a structure';
-    return
-end
-if isfield(Data,'ListVarName') && iscell(Data.ListVarName)
-    nbfield=numel(Data.ListVarName); 
-else
-    errormsg='input field does not contain the list of variables .ListVarNames';
-    return
-end
-%check dimension names
-% definition by VarDimIndex (obsolete)
-% if ~isfield(Data,'VarDimName') && isfield(Data,'VarDimIndex') && isfield(Data,'ListDimName')%old convention
-%     for ivar=1:nbfield
-%         DimCell=Data.VarDimIndex{ivar};
-%         if isnumeric(DimCell)
-%             if DimCell <= numel(Data.ListDimName)
-%                 Data.VarDimName{ivar}=Data.ListDimName(DimCell);
-%             else                      
-%                 errormsg='dimension names not defined';
-%                 return 
-%             end
-%         else 
-%             errormsg='unrecognized format for .VarDimIndex';
-%         end
-%     end
-% end
-if ~(isfield(Data,'VarDimName') && iscell(Data.VarDimName))
-    errormsg='input field does not contain the list of dimensions .VarDimName';
-    return
-end
-if isfield(Data,'DimValue')
-    Data=rmfield(Data,'DimValue');
-end
-if isfield(Data,'VarDimName') && iscell(Data.VarDimName)
-    nbdim=0;
-    if numel(Data.VarDimName)==nbfield
-        for ivar=1:nbfield
-            VarName=Data.ListVarName{ivar};
-            if ~isfield(Data,VarName)
-                errormsg=['the listed variable ' VarName ' is not found'];
-                return
-            else             
-                eval(['sizvar=size(Data.' VarName ');'])% sizvar = dimension of variable
-                DimCell=Data.VarDimName{ivar};
-                if ischar(DimCell)
-                    DimCell={DimCell};
-                elseif ~iscell(DimCell)
-                    errormsg=['wrong format for .VarDimName{' num2str(ivar) ' (must be the cell of dimension names of the variable ' VarName];
-                    return
-                end
-                nbcoord=numel(sizvar);
-                if numel(DimCell)==0
-                    errormsg=['empty declared dimension .VarDimName{' num2str(ivar) '} for ' VarName];
-                    return
-                elseif numel(DimCell)==1% one dimension declared
-                    if nbcoord==2 
-                        if sizvar(1)==1 
-                            nbcoord=1;
-                            sizvar(1)=sizvar(2);
-                        elseif sizvar(2)==1
-                            nbcoord=1;
-                        else
-                            errormsg=['1 dimension declared in .VarDimName{' num2str(ivar) '} inconsistent with the nbre of dimensions =2 of the variable ' VarName];
-                            return
-                        end
-                    else
-                          errormsg=['1 dimension declared in .VarDimName{' num2str(ivar) '} inconsistent with the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName];
-                          return      
-                    end  
-                else
-                    if numel(DimCell)>nbcoord
-                        DimCell=DimCell(end-nbcoord+1:end);%first singleton diemnsions omitted, 
-                    elseif nbcoord > numel(DimCell)
-                        errormsg=['nbre of declared dimensions in .VarDimName{' num2str(ivar) '} smaller than the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName];
-                        return
-                    end
-                end
-                DimIndex=[];
-                for idim=1:nbcoord %loop on the coordinates of variable #ivar   
-                    DimName=DimCell{idim};
-                    testprev=0;
-                    for iprev=1:nbdim %check previously listed dimension names
-                        if strcmp(Data.ListDimName{iprev},DimName)
-                           if ~isequal(Data.DimValue(iprev),sizvar(idim))
-                               if isequal(Data.DimValue(iprev),0)  % the dimension has been already detected as a range [min max]
-                                   Data.DimValue(idim)=sizvar(idim); %update with actual value 
-                               elseif sizvar(idim)==2 && strcmp(DimName,VarName)
-                                    %case of a regularly spaced coordinate defined by the first and last values: dimension will be determined later                          
-                               else
-                                   errormsg=['dimension declaration inconsistent with the size =[' num2str(sizvar) '] for ' VarName];
-                                   return 
-                               end
-                           end
-                           DimIndex=[DimIndex iprev];
-                           testprev=1;
-                           break
-                        end
-                    end
-                    if ~testprev % a new dimension is appended to the list
-                        nbdim=nbdim+1;
-                        if sizvar(idim)==2 && strcmp(DimName,VarName)
-                            Data.DimValue(nbdim)=0; %to be updated for a later variable
-%                             Data.VarType{ivar}='range';
-                        else
-                            Data.DimValue(nbdim)=sizvar(idim);
-                        end
-                        Data.ListDimName{nbdim}=DimName;
-                        DimIndex=[DimIndex nbdim];
-                    end
-                end
-                Data.VarDimIndex{ivar}=DimIndex;
-            end
-        end                               
-    else
-        errormsg=' .ListVarNames and .VarDimName have different lengths';
-        return
-    end
-else
-    errormsg='input field does not contain the cell of dimension names .VarDimName for variables';
-    return
-end
-DataOut=Data;
-    
-   
Index: unk/src/check_functions.m
===================================================================
--- /trunk/src/check_functions.m	(revision 7)
+++ 	(revision )
@@ -1,117 +1,0 @@
-%'check_functions': check the path and modification date for all the
-%  function in the toolbox UVMAT. Called at the opening of uvmat.fig
-%----------------------------------------------------------------------
-% function [errormsg,date_str]=check_functions
-%
-% OUTPUT:
-% errormsg: error message listing functions whose paths are not in the directory of uvmat.m
-% date_str: date of the most recent modification of a file in the toolbox
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function [errormsg,date_str]=check_functions
-errormsg={};%default
-list_fct={'calc_field';...% defines fields (velocity, vort, div...) from civx data and calculate them  
-          'cell2tab';... %transform a Matlab cell in a character array suitable for display in a table
-          'check_functions';...  
-          'civ';...   %function associated with the interface 'civ.fig' for PIV and spline interpolation
-          'civ.fig';...
-          'civ_3D';... function associated with the interface 'civ_3D.fig' for PIV in volume (in progress) 
-          'civ_3D.fig';...
-          'close_fig';...% function  activated when a figure is closed
-          'copyfields';...%copy fields between two matlab structures
-          'delete_object';...%delete a projection object, defined by its index in the Uvmat list or by its graphic handle
-          'editxml';...%display and edit xml files using a xls schema
-          'editxml.fig';...%interface for editxml
-          'find_field_indices';...% group the variables of a nc-formated Matlab structure into 'fields' with common dimensions
-          'geometry_calib';...%performs geometric calibration from a set of reference points
-          'geometry_calib.fig';...%interface for geometry_calib
-          'get_field';...% choose and plot a field from a Netcdf file
-          'get_field.fig';...%interface for get_field
-          'get_plot_handles';... %provides handles of elements setting the plotting parameters in the uvmat interface
-          'griddata_uvmat';...%make 2D linear interpolation using griddata, with input appropriate for both Matlab 6.5 and 7
-          'hist_update';...%  update of a current global histogram by inclusion of a new field  
-          'imadoc2struct';...%convert the image documentation file ImaDoc into a Matlab structure
-          'keyboard_callback';... % function activated when a key is pressed on the keyboard 
-          'ListDir';... scan the structure of the directory tree (for dataview.m)
-          'mouse_down';% function activated when the mouse button is pressed on a figure (callback for 'WindowButtonDownFcn')
-          'mouse_motion';...% permanently called by mouse motion over a figure (callback for 'WindowButtonMotionFcn')
-          'mouse_up';... % function to be activated when the mouse button is released (callback for 'WindowButtonUpFcn')
-          'msgbox_uvmat';... associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls
-          'msgbox_uvmat.fig';...
-          'name2display';...% extracts the root name and field numbers from an input filename 
-          'name_generator';...%creates a file name from a root name and indices. 
-          'nc2struct';...% transform a netcdf file in a corresponding matlab structure
-          'peaklock';...%
-          'phys';...% transforms fields from image (px) to real world (phys) coordinates using geometric calibration parameters
-          'phys_polar';... transform image coordinates (px) to physical ploar coordinates
-          'phys_XYZ';...%transforms image (px) to real world (phys) coordinates using geometric calibration parameters
-          'px';...% transform fields from physical to px coordinates using geometrical calibration parameters
-          'px_XYZ';...% ransform physical to px coordinates using geometrical calibration parameters
-          'plot_field';...%displays a vector field and/or scalar or images
-          'plot_object';...%draws a projection object (points, line, plane...)
-          'proj_field';...%project a field on a projection object (plane, line,...)
-          'read_civxdata';...reads civx data from netcdf files
-          'read_imatext';...%read .civ files (obsolete, but can be adapted to other text documentation files)
-           'read_plot_param';... %read the plotting option parameters on the uvmat interface
-           'read_set_object';...%read the data on the set_object interface
-           'read_xls';...%read excel files containing the list of the experiments
-           'reinit';...% suppress the personal parameter file 'uvmat_perso.mat' 
-           'RUN_FIX';...% fix velocity fields
-           'RUN_STLIN';...% combine 2 displacement fields for stereo PIV
-           'series';...% master function for analysis field series, with interface 'series.fig'
-           'series.fig';...% interface for 'series'
-           'set_col_vec';...
-           'set_grid';...% creates a grid for PIV
-           'set_grid.fig';...% interface for set_grid
-           'set_object.m';...%  edit a projection object
-           'set_object.fig';...% interface for set_object
-           'sub_field';...% combine the two input fields, 
-           'struct2nc';...% %write fields in netcdf files
-           'uvmat';...% master function for file scanning and visualisation of 2D fields
-           'uvmat.fig';...  %interface for uvmat  
-           'update_obj';... update the object representation graph and its projection field, record it in the uvmat interface
-           'update_waitbar';... update the waitbar display, used for ACTION functions in the GUI 'series'
-           'warndlg_uvmat';...% display messages (error, warning, confirmation) , OBSOLETE, use msgbox_uvmat 
-            'write_plot_param'};%update plotting parameters after plot 
- dir_fct=which('uvmat');% path to uvmat
-[pathuvmat,name,ext]=fileparts(dir_fct);
-icount=0;
-% loop on the list of functions in the uvmat package
- for i=1:length(list_fct)
-    dir_fct=which(list_fct{i});% path to fct
-    if isempty(dir_fct)
-        icount=icount+1;
-        errormsg{icount}=[list_fct{i} ' not found'];% test for function not found
-    else
-       [pth,name,ext]=fileparts(dir_fct);
-       if ~isequal(pathuvmat,pth)
-           icount=icount+1;
-           errormsg{icount}=[dir_fct ' overrides the package UVMAT'];% bad path for the function
-       end
-       datfile=dir(dir_fct);
-       date_str=datfile.date;%string of the date of last modification
-       datnum(i)=0;%default
-       char_code=double(date_str);% code of the date characters
-       special_char=(char_code>127); %non standard Ascii character (e.g. date in french)
-       if isempty(find(special_char))% standard Ascii character 
-          datnum(i)=datenum(date_str);
-       end
-   end
-end
-errormsg=errormsg';
-date_str=datestr(max(datnum));
Index: unk/src/close_fig.m
===================================================================
--- /trunk/src/close_fig.m	(revision 7)
+++ 	(revision )
@@ -1,12 +1,0 @@
-%'close_fig': function  activated when a figure is closed
-%----------------------------------------------------------------
-% function close_fig(ggg,eventdata,hparent,type)
-% activated by the command:
-%set(hObject,'DeleteFcn',{@close_fig,hparent,type})
-% where hObject is the handle of the figure
-%
-
-function close_fig(ggg,eventdata,hparent,type)
-if isequal(type,'zoom')
-    delete(hparent)  % delete the rectangle showing the zoom graph in the parent fig
-end
Index: unk/src/copyfields.m
===================================================================
--- /trunk/src/copyfields.m	(revision 7)
+++ 	(revision )
@@ -1,22 +1,0 @@
-%'copyfields' copy fields between two matlab structures
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% OUPUT:
-% NewData: resulting structure
-%
-%INPUT:
-% listfields: cell arrays representing the list of field names to be copied
-% SourceData: structure containing the source data to copy in NewData
-% OldData: (optional) preexisting data structure.
-
-function NewData=copyfields(listfields,SourceData,OldData)
-if ~exist('OldData','var')
-    OldData=[];
-end
-NewData=OldData;%default
-for ifield=1:length(listfields)
-    if isfield(SourceData,listfields{ifield}) & ~isempty(eval(['SourceData.' listfields{ifield}]))
-        eval(['NewData.' listfields{ifield} '=SourceData.' listfields{ifield} ';']); 
-    elseif isfield(OldData,listfields{ifield})
-        NewData=rmfield(NewData,listfields{ifield});
-    end
-end
Index: unk/src/datenum_uvmat.m
===================================================================
--- /trunk/src/datenum_uvmat.m	(revision 7)
+++ 	(revision )
@@ -1,602 +1,0 @@
-%'datenum_uvmat': like the Matlab function datenum.m but gives empty output instead of stopping for input error
-%--------------------------------------------------------------------------
-function n = datenum_uvmat(arg1,arg2,arg3,h,min,s)
-%DATENUM Serial date number.
-%	N = DATENUM(V) converts one or more date vectors V into serial date 
-%	numbers N. Input V can be an M-by-6 or M-by-3 matrix containing M full 
-%	or partial date vectors respectively.  DATENUM returns a column vector
-%	of M date numbers.
-%
-%	A date vector contains six elements, specifying year, month, day, hour, 
-%	minute, and second. A partial date vector has three elements, specifying 
-%	year, month, and day.  Each element of V must be a positive double 
-%	precision number.  A serial date number of 1 corresponds to Jan-1-0000.  
-%	The year 0000 is merely a reference point and is not intended to be 
-%	interpreted as a real year.
-%
-%	N = DATENUM(S,F) converts one or more date strings S to serial date 
-%	numbers N using format string F. S can be a character array where each
-%	row corresponds to one date string, or one dimensional cell array of 
-%	strings.  DATENUM returns a column vector of M date numbers, where M is 
-%	the number of strings in S. 
-%
-%	All of the date strings in S must have the same format F, which must be
-%	composed of date format symbols according to Table 2 in DATESTR help.
-%	Formats with 'Q' are not accepted by DATENUM.  
-%
-%	Certain formats may not contain enough information to compute a date
-%	number.  In those cases, hours, minutes, and seconds default to 0, days
-%	default to 1, months default to January, and years default to the
-%	current year. Date strings with two character years are interpreted to
-%	be within the 100 years centered around the current year.
-%
-%	N = DATENUM(S,F,P) or N = DATENUM(S,P,F) uses the specified format F
-%	and the pivot year P to determine the date number N, given the date
-%	string S.  The pivot year is the starting year of the 100-year range in 
-%	which a two-character year resides.  The default pivot year is the 
-%	current year minus 50 years.
-%
-%	N = DATENUM(Y,MO,D) and N = DATENUM([Y,MO,D]) return the serial date
-%	numbers for corresponding elements of the Y,MO,D (year,month,day)
-%	arrays. Y, MO, and D must be arrays of the same size (or any can be a
-%	scalar).
-%
-%	N = DATENUM(Y,MO,D,H,MI,S) and N = DATENUM([Y,MO,D,H,MI,S]) return the
-%	serial date numbers for corresponding elements of the Y,MO,D,H,MI,S
-%	(year,month,day,hour,minute,second) arrays.  The six arguments must be
-%	arrays of the same size (or any can be a scalar).
-%
-%	N = DATENUM(S) converts the string or date vector (as defined by 
-%	DATEVEC) S into a serial date number.  If S is a string, it must be in 
-%	one of the date formats 0,1,2,6,13,14,15,16,23 as defined by DATESTR.
-%	This calling syntax is provided for backward compatibility, and is
-%	significantly slower than the syntax which specifies the format string.
-%	If the format is known, the N = DATENUM(S,F) syntax should be used.
-%
-%	N = DATENUM(S,P) converts the date string S, using pivot year P. If the 
-%	format is known, the N = DATENUM(S,F,P) or N = DATENUM(S,P,F) syntax 
-%	should be used.
-%
-%	Note:  The vectorized calling syntax can offer significant performance
-%	improvement for large arrays.
-%
-%	Examples:
-%		n = datenum('19-May-2000') returns n = 730625. 
-%		n = datenum(2001,12,19) returns n = 731204. 
-%		n = datenum(2001,12,19,18,0,0) returns n = 731204.75. 
-%		n = datenum('19.05.2000','dd.mm.yyyy') returns n = 730625.
-%
-%	See also NOW, DATESTR, DATEVEC, DATETICK.
-
-%   Copyright 1984-2004 The MathWorks, Inc.
-%   $Revision: 1.24.4.7 $  $Date: 2004/10/27 23:53:57 $
-
-if (nargin<1) || (nargin>6)
-    error('MATLAB:datenumr:Nargin',nargchk(1,6,nargin));
-end
-
-% parse input arguments
-isdatestr = ~isnumeric(arg1);
-isdateformat = false;
-if nargin == 2
-    isdateformat = ischar(arg2);
-elseif nargin == 3
-    isdateformat = [ischar(arg2),ischar(arg3)];
-end
-% try to convert date string or date vector to a date number
-try
-    switch nargin
-        case 1 
-            if isdatestr
-                n = datenummx(datevec(arg1));
-            elseif (size(arg1,2)==3) || (size(arg1,2)==6)
-                n = datenummx(arg1);
-            else
-                n = arg1;
-            end
-        case 2
-            if isdateformat
-                if ischar(arg1)
-					arg1 = cellstr(arg1);
-				end
-                n = dtstr2dtnummx(arg1,cnv2icudf(arg2));
-            else
-                n = datenummx(datevec(arg1,arg2));
-            end
-        case 3
-			if any(isdateformat)
-				if isdateformat(1) 
-					format = arg2;
-					pivot = arg3;
-				elseif isdateformat(2)
-					format = arg3;
-					pivot = arg2;
-				end
-				if ischar(arg1)
-					arg1 = cellstr(arg1);
-				end
-				icu_dtformat = cnv2icudf(format);
-				showyr =  strfind(icu_dtformat,'y'); 
-				if ~isempty(showyr)
-					wrtYr =  numel(showyr);
-					checkYr = diff(showyr);
-					if any(checkYr~=1)
-						error('MATLAB:datenum:YearFormat','Unrecognized year format');
-					end
-					switch wrtYr
-						case 4,
-							icu_dtformat = strrep(icu_dtformat,'yyyy','yy');
-						case 3,
-							icu_dtformat = strrep(icu_dtformat,'yyy','yy');
-					end
-				end
-				n = dtstr2dtnummx(arg1,icu_dtformat,pivot);
-			else
-                n = datenummx(arg1,arg2,arg3);
-			end
-        case 6, n = datenummx(arg1,arg2,arg3,h,min,s);
-        otherwise, error('MATLAB:datenum:Nargin',...
-                         'Incorrect number of arguments');
-    end
-catch
-    err = lasterror;
-    err.message = sprintf('DATENUM failed.\n%s',err.message);
-    
-    if (nargin == 1 && ~isdatestr)
-        err.identifier = 'MATLAB:datenum:ConvertDateNumber';
-    elseif (nargin == 1 && isdatestr) || (isdatestr && any(isdateformat))
-        err.identifier = 'MATLAB:datenum:ConvertDateString';
-    elseif (nargin > 1) && ~isdatestr && ~any(isdateformat)
-        err.identifier = 'MATLAB:datenum:ConvertDateVector';
-    end
- 
-    rethrow(err);
-end
-end
-
-function [y,mo,d,h,mi,s] = datevec(t,varargin)
-%DATEVEC Date components.
-%	V = DATEVEC(N) converts one or more date numbers N to date vectors V. N
-%	can be a scalar, vector, or multidimensional array of positive date
-%	numbers. DATEVEC returns an M-by-6 matrix containing M date vectors,
-%	where M is the total number of date numbers in N.
-%
-%	V = DATEVEC(S,F) converts one or more date strings S to date vectors
-%	V using format string F to interpret the date strings in S. S can be a
-%	cell array of strings or a character array where each row corresponds
-%	to one date string. All of the date strings in S must have the same
-%	format which must be composed of date format symbols according to 
-%	Table 2 in DATESTR help. Formats with 'Q' are not accepted by DATEVEC. 
-%	DATEVEC returns an M-by-6 matrix of date vectors, where M is the number 
-%	of date strings in S.
-%
-%	Certain formats may not contain enough information to compute a date
-%	vector.  In those cases, hours, minutes, and seconds default to 0, days
-%	default to 1, months default to January, and years default to the
-%	current year. Date strings with two character years are interpreted to
-%	be within the 100 years centered around the current year.
-%
-%	V = DATEVEC(S,F,P) or V = DATEVEC(S,P,F) converts the date string S to
-%	a date vector V, using the pivot year P and the date format F.  The 
-%	pivot year is the starting year of the 100-year range in which a 
-%	two-character year resides.  The default pivot year is the current year 
-%	minus 50 years.
-%
-%	[Y,MO,D,H,MI,S] = DATEVEC(...) takes any of the two syntaxes shown
-%	above and returns the components of the date vector as individual
-%	variables.  
-%
-%	V = DATEVEC(S) converts date string S to date vector V. S must be in 
-%	one of the date formats 0,1,2,6,13,14,15,16,23 as defined by DATESTR.  
-%	This calling syntax is provided for backward compatibility, and is
-%	significantly slower than the syntax which specifies the format string.
-%	If the format is known, the V = DATEVEC(S,F) syntax should be used.
-%
-%	V = DAVEVEC(S,P) converts the date string S using pivot year P.
-%	If the format is known, the V = DATEVEC(S,F,P) or V = DATEVEC(S,P,F) 
-%	syntax should be used.
-%
-%	Note 1:  If more than one input argument is used, the first argument 
-%	must be a date string or array of date strings.
-%
-%	Note 2:  The vectorized calling syntax can offer significant performance
-%	improvement for large arrays.
-%
-%	Examples
-%		d = '12/24/1984';
-%		t = 725000.00;
-%		c = datevec(d) or c = datevec(t) produce c = [1984 12 24 0 0 0].
-%		[y,m,d,h,mi,s] = datevec(d) returns y=1984, m=12, d=24, h=0, mi=0, s=0.
-%		c = datevec('5/6/03') produces c = [2003 5 6 0 0 0] until 2054.
-%		c = datevec('5/6/03',1900) produces c = [1903 5 6 0 0 0].
-%		c = datevec('19.05.2000','dd.mm.yyyy') produces c = [2000 5 19 0 0 0].
-%
-%	See also DATENUM, DATESTR, CLOCK, DATETICK. 
-
-%	Copyright 1984-2004 The MathWorks, Inc. 
-%	$Revision: 1.28.4.11 $  $Date: 2004/10/27 23:53:59 $
-
-if (nargin<1) || (nargin>3)
-%     error('MATLAB:datevec:Nargin',nargchk(1,3,nargin));
-    return
-end
-
-% parse input arguments
-isdatestr = ~isnumeric(t);
-isdateformat = false;
-if ~isdatestr && nargin > 1
-    warning('MATLAB:datevec:Inputs', ...
-        'Unless the first input argument is a date string, all subsequent\narguments will be ignored.');
-elseif nargin > 1
-    isdateformat = cellfun('isclass',varargin,'char');
-    if (nargin == 3)
-        if ~isdateformat(1)
-            pivotyear = varargin{1};
-        elseif ~isdateformat(2)
-            pivotyear = varargin{2};
-        elseif isdateformat(1) && isdateformat(2)
-%             error('MATLAB:datevec:DateFormat',...
-%                 'You specified two date format strings.\nThere can only be one.');
-           return
-        end 
-    elseif (nargin == 2) && ~isdateformat
-        pivotyear = varargin{1};
-    end
-end
-
-if isdatestr && isempty(t)
-    if nargout <= 1
-        y = zeros(0,6);
-	else
-		[y,mo,d,h,mi,s] = deal(zeros(0,0));
-    end;
-	warning('MATLAB:datevec:EmptyDate',...
-		'Usage of DATEVEC with empty date strings is not supported.\nResults may change in future versions.');
-    return;
-end
-
-% branch to appropriate date string parser
-if  isdatestr
-    % a date format string was specified
-    % map date format to ICU date format tokens
-    if ischar(t)
-        % convert to cellstring.
-        t = cellstr(t);
-    end
-    icu_dtformat = {};
-    if ~any(isdateformat)
-        format = getformat(t);
-        if ~isempty(format)
-            icu_dtformat = cnv2icudf(format);
-        end
-    else
-        icu_dtformat = cnv2icudf(varargin{isdateformat});
-    end
-    if ~isempty(icu_dtformat) 
-        % call ICU MEX function to parse date string to date vector
-        try
-            if nargin < 2 || (nargin == 2 && any(isdateformat))
-                y = dtstr2dtvecmx(t,icu_dtformat);
-            else
-				showyr =  findstr(icu_dtformat,'y'); 
-				if ~isempty(showyr)
-					wrtYr =  numel(showyr);
-					if showyr(end) - showyr(1) >= wrtYr
-% 						error('MATLAB:datevec:YearFormat','Unrecognized year format');
-                        return
-					end
-					switch wrtYr
-						case 4,
-							icu_dtformat = strrep(icu_dtformat,'yyyy','yy');
-						case 3,
-							icu_dtformat = strrep(icu_dtformat,'yyy','yy');
-					end
-				end
-                y = dtstr2dtvecmx(t,icu_dtformat,pivotyear);
-            end
-            if nargout > 1
-                mo = y(:,2);
-                d  = y(:,3);
-                h  = y(:,4);
-                mi = y(:,5);
-                s  = y(:,6);
-                y  = y(:,1);
-            end
-        catch
-            err = lasterror;
-            err.identifier = 'MATLAB:datevec:dtstr2dtvecmx';
-            err.message = sprintf(['DATEVEC failed, calling DTSTR2DTVECMX.\n'... 
-                    '%s'],err.message);
-            rethrow(err);
-        end 
-    else
-        %last resort!!!
-       if ischar(t)
-          m = size(t,1);
-       else
-          m = length(t);
-       end
-       y = zeros(m,6);
-       t = lower(t);
-%        ampmtokens = lower(getampmtokensmx);
-        amtok = 'am'; %ampmtokens{1};
-       amtok0 = 'am';
-        pmtok = 'pm';%ampmtokens{2};
-       pmtok0 = 'pm';
-       M={'jan';'feb';'mar';'apr';'may';'jun';'jul';'aug';'sept';'oct';'nov';'dec'};
-       M0=M;
-%        M = lower(getmonthnames);
-%        M0 = lower(getmonthnames(0)); % fall-back list of English short month names.
-       try
-           for i = 1:m
-               % Convert date input to date vector
-               % Initially, the six fields are all unknown.
-               c(1,1:6) = NaN;
-               pm = -1; % means am or pm is not in datestr
-               if ischar(t)
-                   str = t(i,:);
-               else
-                   str = t{i};
-               end
-               d = [' ' str ' '];
-
-               % Replace 'a ' or 'am', 'p ' or 'pm' with ': '.
-               p = max(find(d == amtok(1) | d == pmtok(1) | ...
-                            d == amtok0(1)| d == pmtok0(1)));
-               if ~isempty(p)
-                   if (d(p+1) == amtok(2) | ...
-                       d(p+1) == amtok0(2)| isspace(d(p+1))) & ...
-                       d(p-1) ~= lower('e')
-                       pm = (d(p) == pmtok(1) | d(p) == pmtok0(1));
-                       if d(p-1) == ' '
-                           d(p-1:p+1) = ':  ';
-                       else
-                           d(p:p+1) = ': ';
-                       end
-                   end
-               end
-
-               % Any remaining letters must be in the month field
-               p = find(isletter(d));
-
-               % Test length of string to catch a bogus date string.
-               % Get index of month in list of months of year
-               % replace with spaces, month name in date string.
-               % If native month name lookup fails, fall back on 
-               % list of English month names.
-               if ~isempty(p) && numel(d)>4
-                   k = min(p);
-                   if d(k+3) == '.', d(k+3) = ' '; end
-                   monthidx = ~cellfun('isempty',strfind(M,d(k:k+2)));
-                   if ~any(monthidx)
-                       monthidx = ~cellfun('isempty',strfind(M0,d(k:k+2)));
-                       if ~any(monthidx)
-%                            error('MATLAB:datevec:MonthOfYear',...
-%                                'Failed to lookup month of year.');
-                          return
-                       end
-                   end
-                   c(2) = find(monthidx);
-                   d(p) = char(' '*ones(size(p)));
-               end
-
-               % Find all nonnumbers.
-               p = find((d < '0' | d > '9') & (d ~= '.'));
-
-               % Pick off and classify numeric fields, one by one.
-               % Colons delinate hour, minutes and seconds.
-
-               k = 1;
-               while k < length(p)
-                   if d(p(k)) ~= ' ' && d(p(k)+1) == '-'
-                       f = str2double(d(p(k)+1:p(k+2)-1));
-                       k = k+1;
-                   else
-                       f = str2double(d(p(k)+1:p(k+1)-1));
-                   end
-                   if ~isnan(f)
-                       if d(p(k))==':' || d(p(k+1))==':'
-                           if isnan(c(4))
-                               c(4) = f;             % hour
-                               % Add 12 if pm specified and hour isn't 12
-                               if pm == 1 && f ~= 12 
-                                   c(4) = f+12;
-                               elseif pm == 0 && f == 12
-                                   c(4) = 0;
-                               end
-                           elseif isnan(c(5))
-                               c(5) = f;             % minutes
-                           elseif isnan(c(6)) 
-                               c(6) = f;             % seconds
-                           else
-%                                error('MATLAB:datevec:NumberOfTimeFields',...
-%                                    'Too many time fields in %s', str);
-                                return
-                           end
-                       elseif isnan(c(2))
-                           if f > 12
-%                                error('MATLAB:datevec:IllegalDateField',...
-%                                    '%s is too large to be a month.',num2str(f));
-                                return
-                           end
-                           c(2) = f;                % month
-                       elseif isnan(c(3))
-                           c(3) = f;                % date
-                       elseif isnan(c(1))
-                           if (f >= 0) & (p(k+1)-p(k) == 3) % two char year
-                               if nargin < 2
-                                   clk = clock;
-                                   pivotyear = clk(1)-50;  %(current year-50 years)
-                               end
-                               % Moving 100 year window centered around current year
-                               c(1) = pivotyear+rem(f+100-rem(pivotyear,100),100);
-                           else
-                               c(1) = f;             % year
-                           end
-                       else
-%                            error('MATLAB:datevec:NumberOfDateFields',...
-%                                'Too many date fields in %s', str);
-                            return
-                       end
-                   end
-                   k = k+1;
-               end
-
-               if sum(isnan(c)) >= 5
-%                    error('MATLAB:datevec:ParseDateString',...
-%                        'Cannot parse date %s', str);
-                    return
-               end
-              % If any field has not been specified
-               if isnan(c(1)), clk = clock; c(1) = clk(1); end
-               if isnan(c(2)), c(2) = 1; end;
-               if isnan(c(3)), c(3) = 1; end;
-               if isnan(c(4)), c(4) = 0; end;               
-               if isnan(c(5)), c(5) = 0; end;                   
-               if isnan(c(6)), c(6) = 0; end;
-
-               % Normalize components to correct ranges.
-               y(i,:) = datevecmx(datenummx(c));
-           end
-       catch
-           err = lasterror;
-           err.message = sprintf('Failed to parse date string.\n%s',...
-                                 err.message);
-           rethrow(err);
-       end 
-       if nargout > 1
-           mo = y(:,2);
-           d  = y(:,3);
-           h  = y(:,4);
-           mi = y(:,5);
-           s  = y(:,6);
-           y  = y(:,1);
-       end
-    end
-elseif nargout <= 1
-   % date number was specified 
-   y = datevecmx(t);
-elseif nargout == 3
-    % date number was specified and first three date fields for output
-   [y,mo,d] = datevecmx(t);
-else
-   % date number was specified and all six date fields for output
-   [y,mo,d,h,mi,s] = datevecmx(t);
-end
-end
-%--------------------------------------------------------------------------
-%--
-function [format] = getformat(str)
-  format = '';
-  formatstr = cell(11,1);
-  formatstr(1) = {'dd-mmm-yyyy HH:MM:SS'};
-  formatstr(2) = {'dd-mmm-yyyy'};
-  formatstr(3) = {'mm/dd/yy'};
-  formatstr(4) = {'mm/dd'};
-  formatstr(5) = {'HH:MM:SS'};
-  formatstr(6) = {'HH:MM:SS PM'};
-  formatstr(7) = {'HH:MM'};
-  formatstr(8) = {'HH:MM PM'};
-  formatstr(9) = {'mm/dd/yyyy'};
-  formatstr(10) = {'dd-mmm-yyyy HH:MM'};  %used by finance
-  formatstr(11) = {'dd-mmm-yy'};  %used by finance
-  
-  AlphaFormats = [1 1 0 0 0 1 0 1 0 1 1];
-  %[1 2 6 8 10 11];
-  SlashFormats = [ 0 0 1 1 0 0 0 0 1 0 0];
-  %[3 4 9];
-  TwoSlashFormats = [ 0 0 1 0 0 0 0 0 1 0 0];
-  %[3 9];
-  DashFormats = [ 1 1 0 0 0 0 0 0 0 1 1];
-  %[1 2 10 11];
-  ColonFormats = [1 0 0 0 1 1 1 1 0 1 0];
-  %[1 5 6 7 8 10];
-  TwoColonFormats = [1 0 0 0 1 1 0 0 0 0 0];
-  %[1 5 6];
-  SpaceFormats = [1 0 0 0 0 1 0 1 0 1 0];
-  %[1 6 8 10];
-  
-  bMask = [ 1 1 1 1 1 1 1 1 1 1 1];
-  
-  if length(str) > 1
-      str = str(1,1);
-  end
-  str = strtrim(char(str));
-  slashes = strfind(str, '/');
-  if ~isempty(slashes)
-	  bMask = bMask & SlashFormats;
-	  if (length(slashes) > 0 && slashes(1) == 2)
-		  if (length(slashes) > 1 && slashes(2) == 4)
-			  str = ['0' str(1:slashes(1)) '0' str(slashes(1)+1:end)];
-		  else
-			  str = ['0' str];
-		  end
-	  elseif (length(slashes) > 1 && slashes(2) - slashes(1) == 2)
-		  str = [str(1:slashes(1)) '0' str(slashes(1)+1:end)];
-	  end
-	  if length(slashes) > 1
-		  bMask = bMask & TwoSlashFormats;
-	  else
-		  bMask = bMask & ~TwoSlashFormats;
-	  end
-  else
-	  bMask = bMask & ~SlashFormats;
-  end
-  
-  dashes = strfind(str,'-');
-  if ~isempty(dashes)
-	  bMask = bMask & DashFormats;
-	  if (length(dashes) > 0 && dashes(1) == 2)
-		str = ['0' str];
-	  end
-  else
-	  bMask = bMask & ~DashFormats;	  
-  end
-  
-  colons = strfind(str,':');
-  if ~isempty(colons)
-	  bMask = bMask & ColonFormats;
-	  if (length(colons) > 0) && (colons(1) == 2) && (length(str) - colons(end) > 3)
-		str = ['0' str];
-	  end
-	  if length(colons) > 1
-		  bMask = bMask & TwoColonFormats;
-	  else
-		  bMask = bMask & ~TwoColonFormats;
-	  end	  
-  else
-	  bMask = bMask & ~ColonFormats;
-  end      
-  
-  spaces = strfind(str,' ');
-  if ~isempty(spaces)
-	  bMask = bMask & SpaceFormats;
-  else
-	  bMask = bMask & ~SpaceFormats;
-  end
-  
-  for i = 1:11
-	  if bMask(i)
-		  try
-			  str1 = dateformverify(str,char(formatstr(i)));
-			if (strcmpi(str, strtrim(str1)) == 1)
-				format = char(formatstr(i));
-				break;
-			end
-		  catch
-			   lasterr('');
-		  end
-		  if AlphaFormats(i)
-			  try
-				str1 = dateformverify(str,char(formatstr(i)),'local');
-				if (strcmpi(str, strtrim(str1)) == 1)
-					format = char(formatstr(i));
-					break;
-				end
-			  catch
-				lasterr('');
-			  end       
-		  end
-	  end
-  end
- end 
Index: unk/src/delete_object.m
===================================================================
--- /trunk/src/delete_object.m	(revision 7)
+++ 	(revision )
@@ -1,73 +1,0 @@
-%'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
-%
-%INPUT:
-% hObject: object index (if integer) or handle of the graphic object. If
-% hObject is a subobject, the parent object is detected and deleted. 
-
-function delete_object(hObject)
-
-huvmat=findobj('Name','uvmat');%handles of the uvmat interface
-UvData=get(huvmat,'UserData');
-hlist_object=findobj(huvmat,'Tag','list_object');%handles of the object liçst in the uvmat interface
-list_str=get(hlist_object,'String');%objet list
-ObjectData=[];%default
-hdisplay=[];
-if isequal(floor(hObject),hObject) %case of an index
-    if  ~isempty(UvData) & isfield(UvData, 'Object') & length(UvData.Object)>=hObject 
-        if isfield(UvData.Object{hObject},'HandlesDisplay') 
-            hdisplay=UvData.Object{hObject}.HandlesDisplay;
-            for iview=1:length(hdisplay)
-                if ishandle(hdisplay(iview)) & ~isequal(hdisplay(iview),0)
-                    ObjectData=get(hdisplay(iview),'UserData');
-                    if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
-                        delete(ObjectData.SubObject);
-                    end
-                    if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
-                        delete(ObjectData.DeformPoint);
-                    end
-                    delete(hdisplay(iview))
-                end
-                ishandle(hdisplay(iview))
-            end
-        end   
-        for iobj=hObject+1:length(UvData.Object)
-            hdisplay=UvData.Object{iobj}.HandlesDisplay;
-            for iview=1:length(hdisplay)
-                if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
-                    PlotData=get(hdisplay(iview),'UserData');
-                    PlotData.IndexObj=iobj-1;
-                    set(hdisplay(iview),'UserData',PlotData);
-                end
-            end
-        end
-        UvData.Object(hObject)=[];  
-        list_str(hObject)=[];
-    end
-elseif ishandle(hObject)%object handle
-    userdata=get(hObject,'UserData');
-    if ishandle(userdata)%the selected line depends on a parent line
-        hdisplay=userdata;% the parent object becomes the current one
-    else
-        hdisplay=hObject;% the selected object becomes the current one
-    end
-    PlotData=get(hdisplay,'UserData');
-    if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
-            delete(PlotData.SubObject);
-    end
-    if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
-           delete(PlotData.DeformPoint);
-    end
-    delete(hdisplay);
-    if isfield(PlotData,'IndexObj')
-        IndexObj=PlotData.IndexObj;
-        if  isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj
-            if isfield(UvData,'Object')& length(UvData.Object) > IndexObj
-               UvData.Object(IndexObj)=[];
-            end
-            list_str(IndexObj)=[];
-        end
-    end
-end
-set(huvmat,'UserData',UvData);
-set(hlist_object,'String',list_str)
-set(hlist_object,'Value',length(list_str))
Index: unk/src/find_field_indices.m
===================================================================
--- /trunk/src/find_field_indices.m	(revision 7)
+++ 	(revision )
@@ -1,181 +1,0 @@
-%'find_file_indices': test field structure for input in proj_field and plot_field
-%group the variables  into 'fields' with common dimensions
-%----------------------------------------------------------------------
-% function [DimVarIndex,CellVarIndex,NbDim,VarType]=find_field_indices(Data)
-%
-%OUTPUT:
-% CellVaxIndex: cell whose elements are arrays of indices in the list data.ListVarName  
-%              CellvarIndex{i} represents a set of variables with the same dimensions
-% NbDim: array with the length of CellVarIndex, giving its  space dimension
-% VarType: cell array of structures with fields
-%      .coord_x, y, z: indices (in .ListVarname) of variables representing  unstructured coordinates x, y, z 
-%      .vector_x,_y,_z: indices of variables giving the vector components x, y, z
-%      .warnflag: index of warnflag
-%      .errorflag: index of error flag
-%      .ancillary: indices of ancillary variables
-%      .image   : B/W image, (behaves like scalar)
-%      .color : color image, the last index, which is not a coordinate variable, represent the 3 color components rgb
-%      .discrete: like scalar, but set of data points without continuity, represented as dots in a usual plot, instead of continuous lines otherwise
-%      .scalar: scalar field (default)
-
-%   
-%INPUT:
-% Data: structure representing fields, output of check_field_structure
-%            .ListDimName: cell listing the names of the array dimensions
-%            .ListVarName: cell listing the names of the variables
-%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
-%
-% HELP: 
-% to get the dimensions of arrays common to the field #icell
-%         VarIndex=CellVarIndex{icell}; % list of variable indices
-%         DimIndex=Data.VarDimIndex{VarIndex(1)} % list of dimensions for each variable in the cell #icell
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data)
-CellVarIndex={};
-NbDim=[];
-VarType=[];
-errormsg=[];
-nbvar=numel(Data.ListVarName);%number of field variables
-icell=0;
-ivardim=0;
-VarDimIndex=[];
-VarDimName={};
-
-if ~isfield(Data,'VarDimName')
-    errormsg='missing .VarDimName';
-    return
-end
-
-%loop on the list of variables
-for ivar=1:nbvar
-    DimCell=Data.VarDimName{ivar}; %dimensions associated with the variable #ivar
-    if ischar(DimCell)
-        DimCell={DimCell};
-        Data.VarDimName{ivar}={Data.VarDimName{ivar}};%transform char chain into cell
-    end
-    testnewcell=1;
-    for icell_prev=1:numel(CellVarIndex)%detect whether the dimensions of ivar fit with an existing cell
-        PrevVarIndex=CellVarIndex{icell_prev};
-        PrevDimName=Data.VarDimName{PrevVarIndex(1)};
-        if isequal(PrevDimName,DimCell)
-            CellVarIndex{icell_prev}=[CellVarIndex{icell_prev} ivar];% add variable index #ivar to the cell #icell_prev
-            testnewcell=0; %existing cell detected
-            break
-        end
-    end
-    if testnewcell
-        icell=icell+1;
-        CellVarIndex{icell}=ivar;%put the current variabl index in the new cell 
-    end
-    
-    %look for dimension variables
-    if numel(DimCell)==1% if the variable has a single dimension 
-        Role='';
-        if isfield(Data,'VarAttribute') && length(Data.VarAttribute)>=ivar && isfield(Data.VarAttribute{ivar},'Role')
-            Role=Data.VarAttribute{ivar}.Role;
-        end
-        if strcmp(DimCell{1},Data.ListVarName{ivar}) || strcmp(Role,'dimvar')
-            ivardim=ivardim+1;
-            VarDimIndex(ivardim)=ivar;%index of the variable
-            VarDimName{ivardim}=DimCell{1};%name of the dimension
-        end
-    end
-end
-
-% find the spatial dimensions and vector components 
-ListRole={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','warnflag','errorflag',...
-    'ancillary','image','color','discrete','scalar'};
-for icell=1:length(CellVarIndex)
-    for ilist=1:numel(ListRole)
-        eval(['ivar_' ListRole{ilist} '=[];'])
-    end
-    VarIndex=CellVarIndex{icell};%set of variable indices with the same dim 
-    DimCell=Data.VarDimName{VarIndex(1)};% list of dimensions for each variable in the cell #icell
-    if isfield(Data,'VarAttribute');
-        VarAttribute=Data.VarAttribute;
-    else
-        VarAttribute={};
-    end
-    test_2D=0;
-    for ivar=VarIndex
-        if length(VarAttribute)>=ivar
-            if isfield(VarAttribute{ivar},'Role') 
-                role=VarAttribute{ivar}.Role;
-                switch role
-                    case ListRole
-                        eval(['ivar_' role '=[ivar_' role ' ivar];']) 
-                    otherwise
-                       ivar_scalar=[ivar_scalar ivar];%variables are consiered as 'scalar' by default (in the absence of attribute 'Role')
-                end
-            else
-              ivar_scalar=[ivar_scalar ivar];% variable considered as scalar in the absence of Role attribute  
-            end
-            if isfield(VarAttribute{ivar},'Coord_2')
-                test_2D=1; %obsolete convention
-            end
-        else
-            ivar_scalar=[ivar_scalar ivar];%variables are consiered as 'scalar' by default (in the absence of attribute 'Role')
-        end
-    end
-    for ilist=1:numel(ListRole)
-        eval(['VarType{icell}.' ListRole{ilist} '=ivar_' ListRole{ilist} ';'])
-    end    
-    if numel(ivar_coord_x)>1 || numel(ivar_coord_y)>1 || numel(ivar_coord_z)>1
-        errormsg='multiply defined coordinates  in the same cell';
-        return
-    end
-    if numel(ivar_vector_x)>1 || numel(ivar_vector_y)>1 || numel(ivar_vector_z)>1
-        errormsg='multiply defined vector components in the same cell';
-        return
-    end  
-    if numel(ivar_errorflag)>1
-        errormsg='multiply defined error flag in the same cell';
-        return
-    end
-    if numel(ivar_warnflag)>1
-        errormsg='multiply defined warning flag in the same cell';
-        return
-    end
-    NbDim(icell)=0;% nbre of space dimensions 
-    if ~isempty(ivar_coord_z)
-        NbDim(icell)=3;
-    elseif ~isempty(ivar_coord_y)
-        NbDim(icell)=2;
-    elseif ~isempty(ivar_coord_x)
-        NbDim(icell)=1;
-    end
-           
-    % look at coordinates variables  
-    coord=zeros(1,numel(DimCell));%default
-    if NbDim(icell)==0 && ~isempty(VarDimName)% no unstructured coordinate found 
-        for idim=1:numel(DimCell)   %loop on the dimensions of the variables in cell #icell
-            for ivardim=1:numel(VarDimName)
-                if strcmp(VarDimName{ivardim},DimCell{idim})
-                    coord(idim)=VarDimIndex(ivardim);
-                    break
-                end
-            end
-        end
-        NbDim(icell)=numel(find(coord));  
-    end  
-    VarType{icell}.coord=coord; 
-    if NbDim(icell)==0 && test_2D %look at attributes Coord_1, coord_2 (obsolete convention)
-        NbDim(icell)=2;
-    end
-end
Index: unk/src/get_field.asv
===================================================================
--- /trunk/src/get_field.asv	(revision 7)
+++ 	(revision )
@@ -1,1958 +1,0 @@
-%'get_field': display variables and attributes from a Netcdf file, and RUN selected fields
-%------------------------------------------------------------------------
-%function varargout = get_field(varargin)
-% associated with the GUI get_field.fig
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function varargout = get_field(varargin)
-
-% Last Modified by GUIDE v2.5 13-Nov-2009 22:14:18
-
-% Begin initialization code - DO NOT EDIT
-gui_Singleton = 0;
-gui_State = struct('gui_Name',       mfilename, ...
-                   'gui_Singleton',  gui_Singleton, ...
-                   'gui_OpeningFcn', @get_field_OpeningFcn, ...
-                   'gui_OutputFcn',  @get_field_OutputFcn, ...
-                   'gui_LayoutFcn',  [] , ...
-                   'gui_Callback',   []);
-if nargin & isstr(varargin{1})
-    gui_State.gui_Callback = str2func(varargin{1});
-end
-
-if nargout
-    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
-else
-    gui_mainfcn(gui_State, varargin{:});
-end
-% End initialization code - DO NOT EDIT
-
-
-% --- Executes just before get_field is made visible.
-function get_field_OpeningFcn(hObject, eventdata, handles,filename,Field,haxes)
-
-set(handles.dimensions,'enable','on')% should be put by guide
-browse_fig(handles.list_fig)
-
-% Choose default command line output for get_field
-handles.output = hObject;
-
-% Update handles structure
-guidata(hObject, handles);
-pathuvmat=fileparts(which('uvmat'));
-% addpath(fullfile(pathuvmat,'FIELD_FCT'))
-set(handles.attributes,'enable','on')% TO BE SET BY GUIDE
-set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})%set mouse click action function
-if exist('filename','var')& ischar(filename)
-    set(handles.inputfile,'String',filename)
-    inputfile_Callback(hObject, eventdata, handles)
-else
-    set(handles.inputfile,'String','')
-    %loads the information stored in prefdir to initiate the browser and the list of functions
-    menu_str={'PLOT'};%list of functions included in 'get_field.m'
-    %menu_str(end)=[];%remove from the list the last option 'more...'
-    path_get_field=which('get_field');%path of the function 'get_field'
-    for ilist=1:length(menu_str)
-        fct_path{ilist,1}=path_get_field;%paths of the fuctions buil-in in 'get_field.m'
-    end
-     dir_perso=prefdir;
-     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
-     if exist(profil_perso,'file')
-        % menu={'RUN';'raw2phys';'histogram';'FFT';'peaklocking'};
-          h=load (profil_perso);
-         if isfield(h,'get_field_fct') && iscell(h.get_field_fct)
-             for ilist=1:length(h.get_field_fct)
-                [path,file]=fileparts(h.get_field_fct{ilist});
-                fct_path=[fct_path; {path}];%concatene the list of paths
-                menu_str=[menu_str; {file}];
-             end
-             
-         end
-     end
-     menu_str=[menu_str;{'more...'}];
-     set(handles.ACTION,'String',menu_str)
-     set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION  
-     % display the GUI for the default action 'check_files'
-     ACTION_Callback(hObject, eventdata, handles) 
-end
-%                  menu=[menu;h.fct_get_field];
-%                  menu=[menu;{'more...'}];
-%                  fct_path=h.fct_path_get_field;
-%                  set(handles.ACTION,'String',menu)
-%                  set(handles.ACTION,'UserData',fct_path)
-%                  for ipath=1:length(fct_path)
-%                      if exist(fct_path{ipath},'dir')
-%                         addpath(fct_path{ipath})
-%                      end
-%                  end
-%          end
-%      end
-% end
-if exist('Field','var') & isstruct(Field)
-        Field_input(eventdata,handles,Field)
-        if exist('haxes','var')
-            Field.PlotAxes=haxes;
-        end
-    set(hObject,'UserData',Field);
-end
-
-
-
-
-
-
-%-----------------------------------------------------------
-% --- Outputs from this function are returned to the command line.
-function varargout = get_field_OutputFcn(hObject, eventdata, handles)
-varargout{1} = handles.output;
-
-%-----------------------------------------------------------
-% --- Executes on button press in browse.
-function browse_Callback(hObject, eventdata, handles)
-
-
-
-
-%---------------------------------------------------------
-function inputfile_Callback(hObject, eventdata, handles)
-inputfile=get(handles.inputfile,'String');
-Field=nc2struct(inputfile,[]);% reads only the lists of fields, dimensions and attributes
-hfig=get(handles.inputfile,'parent');
-set(hfig,'UserData',Field);
-Field_input(eventdata,handles,Field);
-
-
-%---------------------------------------------------------
-function Field_input(eventdata,handles,Field)
-
-if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName)
-    Tabcell(:,1)=Field.ListDimName;
-    for iline=1:length(Field.ListDimName)
-        Tabcell{iline,2}=num2str(Field.DimValue(iline));
-    end
-    Tabchar=cell2tab(Tabcell,'=');
-    set(handles.dimensions,'String',Tabchar)
-end
-if ~isfield(Field,'ListVarName')
-    return
-end
-Txt=Field.ListVarName;
-set(handles.variables,'Value',1)
-set(handles.variables,'String',[{'*'} Txt])
-variables_Callback(handles.variables,[], handles)
-set(handles.abscissa,'String',[{''} Txt ])
-set(handles.ordinate,'String',Txt)
-set(handles.vector_x,'String',[Txt ])
-set(handles.vector_y,'String',[Txt ])
-set(handles.vector_z,'String',[{''} Txt ])
-set(handles.vec_color,'String',[{''} Txt ])
-set(handles.coord_x_scalar,'String',[{''} Txt ])
-set(handles.coord_y_scalar,'String',[{''} Txt ])
-set(handles.coord_x_vectors,'String',[{''} Txt ])
-set(handles.coord_y_vectors,'String',[{''} Txt ])
-set(handles.coord_z_scalar,'String',[{''} Txt ])
-set(handles.coord_z_vectors,'String',[{''} Txt ])
-set(handles.scalar,'Value',1)
-set(handles.scalar,'String', Txt )
-
-[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Field);
-if ~isempty(errormsg)  
-    msgbox_uvmat('ERROR',['error in get_field/Field_input/find_field_indices: ' errormsg])
-    return
-end  
-[maxdim,imax]=max(NbDim);
-   
-if maxdim>=3
-    set(handles.vector_z,'Visible','on')
-    set(handles.vector_z,'String',[{''} Txt ])
-    set(handles.coord_z_vectors,'Visible','on')
-    set(handles.coord_z_vectors,'String',[{''} Txt ])
-    set(handles.coord_z_scalar,'Visible','on')
-    set(handles.coord_z_scalar,'String',[{''} Txt ])
-else
-    set(handles.vector_z,'Visible','off')
-    set(handles.coord_z_vectors,'Visible','off')
-    set(handles.coord_z_scalar,'Visible','off')
-end
-if maxdim>=2 
-    set(handles.check_1Dplot,'Value',0)
-    if ~isempty(VarType{imax}.vector_x) && ~isempty(VarType{imax}.vector_y)      
-        set(handles.check_vector,'Value',1)
-        set(handles.vector_x,'Value',VarType{imax}.vector_x)
-        set(handles.vector_y,'Value',VarType{imax}.vector_y)
-        set(handles.check_scalar,'Value',0)
-    else
-        set(handles.check_scalar,'Value',1)
-        set(handles.check_vector,'Value',0)
-        if isfield(VarType{imax},'scalar') && length(VarType{imax}.scalar)>=1
-            set(handles.scalar,'Value',VarType{imax}.scalar(1))
-        end
-    end
-    check_1Dplot_Callback(handles.check_1Dplot, eventdata, handles)
-    check_scalar_Callback(handles.check_scalar, eventdata, handles)
-    check_vector_Callback(handles.check_vector, eventdata, handles)
-end
-
-
-%----------------------------------------------------------
-function ordinate_Callback(hObject, eventdata, handles)
-%update_field(hObject, eventdata, handles)
-% A REVOIR
-hselect_field=get(handles.inputfile,'parent');
-Field=get(hselect_field,'UserData');
-% xindex=get(handles.abscissa,'Value');
-list=get(handles.ordinate,'String');
-yindex=get(handles.ordinate,'Value');
-yindex=name2index(list{yindex(1)},Field.ListVarName);
-if ~isempty(yindex)
-    set(handles.variables,'Value',yindex+1)
-    variables_Callback(hObject, eventdata, handles)
-end
-[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Field);
-for icell=1:numel(CellVarIndex)
-    VarIndex=CellVarIndex{icell};
-    if ~isempty(find(VarIndex==yindex)) && (isempty(VarType{icell}.coord_x)||~isequal(VarType{icell}.coord_x,VarIndex))
-        cell_select=icell;
-        break
-    end
-end
-
-val=get(handles.abscissa,'Value');
-set(handles.abscissa,'Value',min(val,2));
-coord_x_index=VarType{cell_select}.coord;
-coord_x_index=coord_x_index(find(coord_x_index));
-set(handles.abscissa,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))'])
-% Field.VarIndex.y=yindex;
-% set(hselect_field,'UserData',Field);
-%update_UserData(handles)
-
-%----------------------------------------------------------------------
-% --- Executes on selection change in abscissa.
-function abscissa_Callback(hObject, eventdata, handles)
- hselect_field=get(handles.inputfile,'parent');
- Field=get(hselect_field,'UserData');%current input field
- xdispindex=get(handles.abscissa,'Value');%index in the list of abscissa
-% test_2D=get(handles.check_vector,'Value');% =1 for vector fields
-% test_scalar=get(handles.check_scalar,'Value');% =1 for scalar fields
-%if isequal(xdispindex,1)% blank selection, no selected variable for abscissa
-%     Txt=Field.ListVarName;
-%     set(handles.ordinate,'String',[{''} Txt ])% display all the varaibles in the list of ordinates
-%     xindex=[];
-% else
-     xlist=get(handles.abscissa,'String');%list of abscissa
-     VarName=xlist{xdispindex}; %selected variable name
-     update_field(hObject, eventdata, handles,VarName)
-%      xindex=name2index(xname,Field.ListVarName); %index of the selection in the total list of variables
-%      if ~isempty(xindex)
-%         set(handles.variables,'Value',xindex+1)
-%         variables_Callback(hObject, eventdata, handles)
-%      end
-%     set(handles.variables,'Value',xindex+1)%outline  in the list of variables 
-%     variables_Callback(hObject, eventdata, handles)  %display properties of the variable (dim, attributes)
-%     if  ~test_2D &  ~test_scalar% look for possible varaibles to RUN in ordinate    
-%         index=Field.VarDimIndex{xindex};%dimension indices of the variable selected for abscissa
-%         VarIndex=[];
-%         for ilist=1:length(Field.VarDimIndex)%detect 
-%             index_i=Field.VarDimIndex{ilist};
-%             if ~isempty(index_i)
-%                 if isequal(index_i(1),index(1))%if the first dimension of the variable coincide with the selected one, RUN is possible
-%                     VarIndex=[VarIndex ilist];
-%                 end
-%             end
-%         end
-% %         set(handles.ordinate,'Value',1)
-%         set(handles.ordinate,'String',Field.ListVarName(VarIndex))
-%     end
-% end
-% 
-% update_UserData(handles)
-
-%-------------------------------------------------------
-% --- Executes on selection change in scalar menu.
-function scalar_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-Aindex=get(handles.scalar,'Value');
-Astring=get(handles.scalar,'String');
-VarName=Astring{Aindex};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in coord_x_scalar.
-function coord_x_scalar_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-index=get(handles.coord_x_scalar,'Value');
-string=get(handles.coord_x_scalar,'String');
-VarName=string{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in coord_y_scalar.
-function coord_y_scalar_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-index=get(handles.coord_y_scalar,'Value');
-string=get(handles.coord_y_scalar,'String');
-VarName=string{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in coord_z_scalar.
-function coord_z_scalar_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-index=get(handles.coord_z_scalar,'Value');
-string=get(handles.coord_z_scalar,'String');
-VarName=string{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in vector_x.
-function vector_x_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-index=get(handles.vector_x,'Value');
-string=get(handles.vector_x,'String');
-VarName=string{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in vector_y.
-function vector_y_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-index=get(handles.vector_y,'Value');
-string=get(handles.vector_y,'String');
-VarName=string{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in vector_z.
-function vector_z_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-index=get(handles.vector_z,'Value');
-string=get(handles.vector_z,'String');
-VarName=Astring{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in coord_x_vectors.
-function coord_x_vectors_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-index=get(handles.coord_x_vectors,'Value');
-string=get(handles.coord_x_vectors,'String');
-VarName=string{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in coord_y_vectors.
-%-------------------------------------------------------
-function coord_y_vectors_Callback(hObject, eventdata, handles)
-index=get(handles.coord_y_vectors,'Value');
-string=get(handles.coord_y_vectors,'String');
-VarName=string{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in coord_z_scalar.
-function coord_z_vectors_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-index=get(handles.coord_z_vectors,'Value');
-string=get(handles.coord_z_vectors,'String');
-VarName=string{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%-------------------------------------------------------
-% --- Executes on selection change in vec_color.
-function vec_color_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------
-index=get(handles.vec_color,'Value');
-string=get(handles.vec_color,'String');
-VarName=string{index};
-update_field(hObject, eventdata, handles,VarName)
-
-%---------------------------------
-function update_field(hObject, eventdata, handles,VarName)
-% VarName= input variable name for scalar or vector plots
-%if ischar(VarName)
-hselect_field=get(handles.inputfile,'parent');
-Field=get(hselect_field,'UserData');
-index=name2index(VarName,Field.ListVarName);
-if ~isempty(index)
-    set(handles.variables,'Value',index+1)
-    variables_Callback(hObject, eventdata, handles)
-end
-% 
-% 
-% hselect_field=get(handles.inputfile,'parent');
-% Field=get(hselect_field,'UserData');
-% ivar_sel=[];%default
-% for ivar=1:length(Field.ListVarName)%detect 
-%     if isequal(Field.ListVarName{ivar},VarName)
-%         ivar_sel=ivar; %ivar_sel = index of the input variable in the list ListVarName
-%         break
-%     end
-% end
-% if isempty(ivar_sel)
-%     return
-% end
-% set(handles.variables,'Value',ivar_sel+1)%select the corresponding item in the displayed  list 'variables'
-% variables_Callback(hObject, eventdata, handles)%show the dimensions and attributes of the input variable
-% 
-% index=Field.VarDimIndex{ivar_sel};%dimension indices of the input variable
-% DimValue=Field.DimValue(index);%dimension values of the input variable
-% ind_1=find(DimValue==1);
-% index(ind_1)=[];%Mremove singletons
-% 
-% 
-% % detect possible variables for abscissa and ordinate
-% VarIndex=[];%initiate list of selected variable indices
-% ind_coordvar=[]; %initiate list of coordinate variables
-% for ilist=1:length(Field.VarDimIndex)
-%     if ~isequal(ilist,ivar_sel)        
-%         index_i=Field.VarDimIndex{ilist};%indices of dimensions associated with variable #ilist
-%         if length(index_i)>1
-%             DimValue=Field.DimValue(index_i);
-%             ind_1=find(DimValue==1);
-%             index_i(ind_1)=[];%Mremove singletons
-%             if isequal(index,index_i)
-%                 VarIndex=[VarIndex ilist]; %selected variable withb the same dimensions of the input variable
-%             end
-%         else
-%             idim=find(index==index_i(1));
-%             if ~isempty(idim)
-%                  VarIndex=[VarIndex ilist]; %possible dimension variable
-%                  if isequal(Field.ListDimName{index_i(1)},Field.ListVarName{ilist})
-%                      ind_coordvar=[ind_coordvar length(VarIndex)];
-%                  end
-%             end
-%         end
-%     end
-% end
-% % val=get(handles.abscissa,'Value');
-% % if val>length(Field.ListVarName(VarIndex))+1
-% %     set(handles.abscissa,'Value',length(Field.ListVarName(VarIndex))+1)
-% % end
-% % val=get(handles.ordinate,'Value');
-% % if val>length(Field.ListVarName(VarIndex))+1
-% %     set(handles.abscissa,'Value',length(Field.ListVarName(VarIndex))+1)
-% % end
-% % val=get(handles.coord_z_vectors_scalar,'Value');
-% % if val>length(Field.ListVarName(VarIndex))+1
-% %     set(handles.abscissa,'Value',length(Field.ListVarName(VarIndex))+1)
-% % end
-% set(handles.abscissa,'Value',1)%default
-% set(handles.ordinate,'Value',1)%default
-% set(handles.coord_z_scalar,'Value',1)%default
-% set(handles.abscissa,'String',[{''} Field.ListVarName(VarIndex) ])
-% set(handles.ordinate,'String',[{''} Field.ListVarName(VarIndex) ])
-% set(handles.coord_z_scalar,'String',[{''} Field.ListVarName(VarIndex) ])
-% if length(ind_coordvar)>=1
-%     set(handles.abscissa,'Value',ind_coordvar(1)+1)
-% elseif length(index)==1 && length(VarIndex)>=1
-%     set(handles.abscissa,'Value',2)
-% end
-% if length(ind_coordvar)>=2
-%     set(handles.ordinate,'Value',ind_coordvar(2)+1)
-% elseif length(index)==1 && length(VarIndex)>=2
-%     set(handles.ordinate,'Value',3)
-% end
-% if length(ind_coordvar)>=3
-%     set(handles.coord_z_scalar,'Value',ind_coordvar(3)+1)
-% elseif length(index)==1 && length(VarIndex)>=3
-%     set(handles.coord_z_scalar,'Value',4)
-% end
-
-%---------------------------------------------------------
-% update the UserData Field for use of the selected variables outsde get_field (taken from RUN_Callback)
-function update_UserData(handles)
-%---------------------------------------------------------
-return
-% global SubField
-hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface
-Field=get(hselect_field,'UserData');% read the current field Structure in the get_field interface
-if isfield(Field,'VarAttribute')
-    VarAttribute=Field.VarAttribute;
-else
-    VarAttribute={};
-end
-
-
-% select the indices of field variables for 2D plots
-test_check_1Dplot=get(handles.check_1Dplot,'Value');
-test_scalar=get(handles.check_scalar,'Value');
-test_vector=get(handles.check_vector,'Value');
-
-%transform if needed (calibration)
-list=get(handles.menu_coord,'String');
-index=get(handles.menu_coord,'Value');
-transform=list{index};
-if ~isequal(transform,'')
-    Field=feval(transform,Field);
-end
-VarIndex.u=[];
-VarIndex.v=[];
-VarIndex.w=[];
-VarIndex.A=[];
-VarIndex_tot=[];
-iuA=[];
-if test_scalar
-    Astring=get(handles.scalar,'String');
-    Aindex=get(handles.scalar,'Value');%selected indices in the ordinate listbox
-    list_var=Astring(Aindex);
-    VarIndex.A=name2index(list_var,Field.ListVarName);%index of the variable A in ListVarName
-    VarIndex_tot= [VarIndex_tot VarIndex.A];
-    DimIndex=Field.VarDimIndex{VarIndex.A};%dimension indices of the variable
-    DimValue=Field.DimValue(DimIndex);
-    ind=find(DimValue==1);
-    DimIndex(ind)=[];%Mremove singleton
-end
-if test_vector
-    Ustring=get(handles.vector_x,'String');
-    Uindex=get(handles.vector_x,'Value'); %selected indices in the ordinate listbox
-    list_var=Ustring{Uindex};%name of the selected scalar
-    VarIndex.u=name2index(list_var,Field.ListVarName);
-    Vstring=get(handles.vector_y,'String');
-    Vindex=get(handles.vector_y,'Value'); %selected indices in the ordinate listbox
-    list_var=Ustring{Vindex};%name of the selected scalar
-    VarIndex.v=name2index(list_var,Field.ListVarName);
-    if isequal(VarIndex.u,VarIndex.A)|isequal(VarIndex.v,VarIndex.A)
-        iuA=VarIndex.A; %same variable used for vector and scalar
-        VarIndex_tot(iuA)=[];
-    end
-    VarIndex_tot=[VarIndex_tot VarIndex.u VarIndex.v];
-    %dimensions
-    DimIndex_u=Field.VarDimIndex{VarIndex.u};%dimension indices of the variable
-    DimValue=Field.DimValue(DimIndex_u);
-    ind=find(DimValue==1);
-    DimIndex_u(ind)=[];%Mremove singleton
-    DimIndex_v=Field.VarDimIndex{VarIndex.v};%dimension indices of the variable
-    DimValue=Field.DimValue(DimIndex_v);
-    ind=find(DimValue==1);
-    DimIndex_v(ind)=[];%Mremove singleton
-    if ~isequal(DimIndex_u,DimIndex_v)
-        warndlg_uvmat('inconsistent dimensions for u and v','ERROR')
-        set(handles.vector_y,'Value',1); 
-        return
-    elseif  test_scalar & ~isequal(DimIndex_u,DimIndex)
-         warndlg_uvmat('inconsistent dimensions for vector and scalar represented as vector color','ERROR')
-         set(handles.scalar,'Value',1); 
-         return
-    end
-    DimIndex=DimIndex_u;
-    %TODO possibility of selecting 3 times the same variable for u, v, w components
-end
-
-
-% select the variable  index (or indices) for z coordinates
-test_grid=0;
-if test_scalar | test_vector
-    nbdim=length(DimIndex);
-    if nbdim > 3
-        warndlg_uvmat('array with more than three dimensions, not supported','ERROR')
-        return
-    else
-        perm_ind=[1:nbdim];
-    end
-    if nbdim==3
-        zstring=get(handles.coord_z_vectors_scalar,'String');
-        zindex=get(handles.coord_z_vectors_scalar,'Value'); %selected indices in the ordinate listbox
-        list_var=zstring(zindex);
-        VarIndex_z=name2index(list_var,Field.ListVarName);%index of the selected variable 
-        if isequal(VarIndex.A,VarIndex_z)|isequal(VarIndex.u,VarIndex_z)|isequal(VarIndex.v,VarIndex_z)|isequal(VarIndex.w,VarIndex_z)
-            if zindex ~= 1
-                set(handles.coord_z_vectors_scalar,'Value',1)%ordinate cannot be the same as scalar or vector components
-                return
-            end
-        else 
-            VarIndex_tot=[VarIndex_tot VarIndex_z];
-            DimIndex_z=Field.VarDimIndex{VarIndex_z};
-            DimValue=Field.DimValue(DimIndex_z);
-            ind=find(DimValue==1);          
-            DimIndex_z(ind)=[];%Mremove singleton
-            if isequal(DimIndex_z,DimIndex)
-                VarAttribute{VarIndex_z}.Role='coord_z';%unstructured coordinates
-            elseif length(DimIndex_z)==1
-                VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z};  %dimension variable
-                ind_z=find(DimIndex==DimIndex_z(1));
-                perm_ind(ind_z)=1;
-                test_grid=1;
-            else
-                warndlg_uvmat('multiple dimensions for the z coordinate','ERROR')
-                return
-            end
-        end
-%         if ~isempty(VarIndex_z)
-%             DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the variable    
-%             if length(DimIndex_z)==1 & nbdim==3 %dimension variable
-%                 VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z};
-%                 ind_z=find(DimIndex==DimIndex_z(1));
-%                 perm_ind(ind_z)=1;
-%                 test_grid=1;
-%             end
-%         end
-    end
-end
-
-% select the variable  index (or indices) for ordinate
-ystring=get(handles.ordinate,'String');
-yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox
-list_var=ystring(yindex);
-VarIndex.y=name2index(list_var,Field.ListVarName);
-if isequal(VarIndex.A,VarIndex.y)
-    set(handles.coord_y_scalar,'Value',1)
-elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y)
-   set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components
-else
-    for ivar=1:length(VarIndex.y)
-        VarAttribute{VarIndex.y(ivar)}.Role='coord_y';
-    end
-    VarIndex_tot=[VarIndex_tot VarIndex.y];
-end
-if (test_scalar | test_vector) &  ~isempty(VarIndex.y)
-    DimIndex_y=Field.VarDimIndex{VarIndex.y};%dimension indices of the variable
-    if length(DimIndex_y)==1 
-        ind_y=find(DimIndex==DimIndex_y(1));
-        test_grid=1;
-        if nbdim==3
-            VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};
-            perm_ind(ind_y)=2;
-        elseif nbdim==2
-            VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};
-             perm_ind(ind_y)=1;
-        end
-    elseif test_grid
-        warndlg_uvmat('the dimension of the y coordinate variable should be 1','ERROR')   
-    end
-end
-
-%select the variable index for the abscissa
-xstring=get(handles.abscissa,'String');
-xindex=get(handles.abscissa,'Value');
-list_var=xstring(xindex);
-VarIndex.x=name2index(list_var,Field.ListVarName);%var index corresponding to var name list_var
-if length(VarIndex.x)==1    
-    DimIndex_x=Field.VarDimIndex{VarIndex.x};
-    DimValue=Field.DimValue(DimIndex_x);
-    ind=find(DimValue==1);          
-    DimIndex_x(ind)=[];%Mremove singleton                      
-    VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};  %dimension variable           
-%     VarAttribute{VarIndex.x}.Role='coord_x';%default (may be modified)
-    index_detect=find(VarIndex_tot==VarIndex.x);
-else
-    index_detect=[];%coord x variable not already used
-end
-if isempty(index_detect)
-    VarIndex_tot=[VarIndex_tot VarIndex.x]; 
-elseif ~test_check_1Dplot
-    VarIndex.x=[];
-    set(handles.abscissa,'Value',1)%vchosen abscissa already chosen, suppres it as abscissa
-end
-
-if (test_scalar | test_vector) &  ~isempty(VarIndex.x)
-    DimIndex_x=Field.VarDimIndex{VarIndex.x};%dimension indices of the variable
-    if length(DimIndex_x)==1 
-        ind_x=find(DimIndex==DimIndex_x(1)); 
-        if nbdim==3
-            %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};
-            perm_ind(ind_x)=3;
-        elseif nbdim==2
-            %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};
-             perm_ind(ind_x)=2;
-        end
-        if isequal(perm_ind,1:nbdim)
-            test_grid=0;
-        end
-        DimIndex=DimIndex(perm_ind);
-    elseif test_grid
-        warndlg_uvmat('the dimension of the x coordinate variable should be 1','ERROR')   
-    end
-    if isequal(DimIndex_x,DimIndex)
-                VarAttribute{VarIndex.x}.Role='coord_x';%unstructured coordinates
-    end
-end
-
-%defined the selected sub-field SubField
-SubField.ListGlobalAttribute{1}='InputFile';
-SubField.InputFile=get(handles.inputfile,'String');
-SubField.ListDimName=Field.ListDimName;
-SubField.DimValue=Field.DimValue;
-SubField.ListVarName=Field.ListVarName(VarIndex_tot);
-SubField.VarDimIndex=Field.VarDimIndex(VarIndex_tot);
-
-testperm=0;
-testattr=0;
-for ivar=VarIndex.u
-    VarAttribute{ivar}.Role='vector_x';
-    testattr=1;
-    if test_grid
-        VarDimIndex{ivar}=DimIndex; %permute dimensions
-        testperm=1;
-    end
-end
-for ivar=VarIndex.v
-    VarAttribute{ivar}.Role='vector_y';
-    testattr=1;
-     if test_grid
-        VarDimIndex{ivar}=DimIndex;%permute dimensions
-        testperm=1;
-    end
-end
-for ivar=VarIndex.A
-    if test_grid
-        VarDimIndex{ivar}=DimIndex;%permute dimensions
-        testperm=1;
-    end
-    if isempty(iuA)
-        VarAttribute{ivar}.Role='scalar';%Role =scalar
-        testattr=1;
-    else
-       VarAttribute=[VarAttribute VarAttribute(ivar)]; %duplicate the attribute for a new variable
-       nbattr=length(VarAttribute);
-       VarAttribute{nbattr}.Role='scalar';
-       testattr=1;
-    end
-end
-if testperm
-    SubField.VarDimIndex=VarDimIndex(VarIndex_tot);
-end
-if testattr
-    SubField.VarAttribute=VarAttribute(VarIndex_tot);
-end
-set(hselect_field,'UserData',Field)
-
-%---------------------------------------------------------
-% --- Executes on button press in RUN.
-function RUN_Callback(hObject, eventdata, handles)
-%---------------------------------------------------------
-list=get(handles.ACTION,'String');
-index=get(handles.ACTION,'Value');
-ACTION=list{index};
-hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface
-feval(ACTION,hselect_field);
-browse_fig(handles.list_fig); %update the list of new existing figures
-
-%---------------------------------------------------------
-% --- Executes on button press in RUN.
-function PLOT(hget_field)
-%---------------------------------------------------------
-[SubField,errormsg]=read_get_field(hget_field);
-if ~isempty(errormsg)
-    msgbox_uvmat('ERROR',['error in get_field/PLOT input:' errormsg])
-    return
-end
-handles=guidata(hget_field);
-list_fig=get(handles.list_fig,'String');
-val=get(handles.list_fig,'Value');
-if strcmp(list_fig{val},'uvmat')
-    uvmat(SubField)
-else
-hfig=str2num(list_fig{val});% chosen figure number from tyhe GUI
-if isempty(hfig)
-    hfig=figure;
-    list_fig=[list_fig;num2str(hfig)];
-    set(handles.list_fig,'String',list_fig);
-    haxes=axes;
-else
-    figure(hfig);
-end
-haxes=findobj(hfig,'Type','axes');
-
-plot_field(SubField,haxes) 
-end
-
-
-% 
-% return
-%  testuvmat=0;
-%     if test_scalar|test_vector
-%          [DimVarIndex,CellVarIndex,NbDim]=find_field_indices(SubField);
-%          NbDim=max(NbDim);
-%          if NbDim==3
-%            testuvmat=1; %uvmat interface needed for 3D plots
-%          end
-%     end
-%     if iscell(list_fig)
-%         RUN_fig=list_fig{fig_index}; 
-%     else
-%         RUN_fig='new fig...';%new plotting axes must be created
-%     end
-%     if isequal(RUN_fig,'new fig...') &  (test_scalar|test_vector)
-%         RUN_fig='uvmat';%use uvmat for a new fig
-%     end
-%     if testuvmat
-%         RUN_fig='uvmat';
-%     end
-%     if isequal(RUN_fig,'uvmat')
-%         
-%         huvmat=uvmat(SubField);
-%         menu=update_menu(handles.list_fig,'uvmat');%add the selected fct to the menu
-%     else
-%         test_new=1;
-%         if ~isequal(RUN_fig,'new fig...')
-%             sep=regexp(RUN_fig,'_')%look for subaxes in a fig
-%             if isempty(sep)
-%                 axe_index=1;
-%             else
-%                 axe_index=str2num(RUN_fig(sep+1:end))
-%                 RUN_fig=RUN_fig([1:sep-1])             
-%             end
-%             if ishandle(str2num(RUN_fig))
-%                 haxes=findobj(str2num(RUN_fig),'Type','axes')
-%                 for iaxe=1:length(haxes)
-%                     Tag=get(haxes(iaxe),'Tag');
-%                     if isequal(Tag,'Colorbar')|isequal(Tag,'legend')
-%                        iselect(iaxe)=0;
-%                     else
-%                        iselect(iaxe)=1; 
-%                     end
-%                 end
-%                 haxes=haxes(find(iselect));   
-%                 if length(haxes)>=axe_index
-%                     test_new=0
-%                     haxes=haxes(axe_index);
-%                     set(haxes,'NextPlot','add')
-%                 end
-%             end
-%         end
-%         if test_new
-%             hfig=figure;
-%             haxes=axes;
-%             menu=update_menu(handles.list_fig,num2str(hfig));%add the selected fct to the menu
-%         end  
-%         RUN_field(SubField,haxes)       
-%     end
-% end
-% 
-% 
-% 
-% 
-%  w components
-% end
-% 
-% 
-% % select the variable  index (or indices) for z coordinates
-% test_grid=0;
-% if test_scalar | test_vector
-%     nbdim=length(DimIndex);
-%     if nbdim > 3
-%         warndlg_uvmat('array with more than three dimensions, not supported','ERROR')
-%         return
-%     else
-%         perm_ind=[1:nbdim];
-%     end
-%     if nbdim==3
-%         zstring=get(handles.coord_z_vectors_scalar,'String');
-%         zindex=get(handles.coord_z_vectors_scalar,'Value'); %selected indices in the ordinate listbox
-%         list_var=zstring(zindex);
-%         VarIndex_z=name2index(list_var,Field.ListVarName);%index of the selected variable 
-%         if isequal(VarIndex.A,VarIndex_z)|isequal(VarIndex.u,VarIndex_z)|isequal(VarIndex.v,VarIndex_z)|isequal(VarIndex.w,VarIndex_z)
-%             if zindex ~= 1
-%                 set(handles.coord_z_vectors_scalar,'Value',1)%ordinate cannot be the same as scalar or vector components
-%                 return
-%             end
-%         else 
-%             VarIndex_tot=[VarIndex_tot VarIndex_z];
-%             DimIndex_z=Field.VarDimIndex{VarIndex_z};
-%             DimValue=Field.DimValue(DimIndex_z);
-%             ind=find(DimValue==1);          
-%             DimIndex_z(ind)=[];%Mremove singleton
-%             if isequal(DimIndex_z,DimIndex)
-%                 VarAttribute{VarIndex_z}.Role='coord_z';%unstructured coordinates
-%             elseif length(DimIndex_z)==1
-%                 VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z};  %dimension variable
-%                 ind_z=find(DimIndex==DimIndex_z(1));
-%                 perm_ind(ind_z)=1;
-%                 test_grid=1;
-%             else
-%                 warndlg_uvmat('multiple dimensions for the z coordinate','ERROR')
-%                 return
-%             end
-%         end
-% %         if ~isempty(VarIndex_z)
-% %             DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the variable    
-% %             if length(DimIndex_z)==1 & nbdim==3 %dimension variable
-% %                 VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z};
-% %                 ind_z=find(DimIndex==DimIndex_z(1));
-% %                 perm_ind(ind_z)=1;
-% %                 test_grid=1;
-% %             end
-% %         end
-%     end
-% end
-% 
-% % select the variable  index (or indices) for ordinate
-% ystring=get(handles.ordinate,'String');
-% yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox
-% list_var=ystring(yindex);
-% VarIndex.y=name2index(list_var,Field.ListVarName);
-% if isequal(VarIndex.A,VarIndex.y)|isequal(VarIndex.u,VarIndex.y)|isequal(VarIndex.v,VarIndex.y)|isequal(VarIndex.w,VarIndex.y)
-%    set(handles.ordinate,'Value',1)%ordinate cannot be the same as scalar or vector components
-% else
-%     for ivar=1:length(VarIndex.y)
-%         VarAttribute{VarIndex.y(ivar)}.Role='coord_y';
-%     end
-%     VarIndex_tot=[VarIndex_tot VarIndex.y];
-% end
-% if (test_scalar | test_vector) &  ~isempty(VarIndex.y)
-%     DimIndex_y=Field.VarDimIndex{VarIndex.y};%dimension indices of the variable
-%     if length(DimIndex_y)==1 
-%         ind_y=find(DimIndex==DimIndex_y(1));
-%         test_grid=1;
-%         if nbdim==3
-%             VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};
-%             perm_ind(ind_y)=2;
-%         elseif nbdim==2
-%             VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};
-%              perm_ind(ind_y)=1;
-%         end
-%     elseif test_grid
-%         warndlg_uvmat('the dimension of the y coordinate variable should be 1','ERROR')   
-%     end
-% end
-% 
-% %select the variable index for the abscissa
-% xstring=get(handles.abscissa,'String');
-% xindex=get(handles.abscissa,'Value');
-% list_var=xstring(xindex);
-% VarIndex.x=name2index(list_var,Field.ListVarName);%var index corresponding to var name list_var
-% if length(VarIndex.x)==1    
-%     DimIndex_x=Field.VarDimIndex{VarIndex.x};
-%     DimValue=Field.DimValue(DimIndex_x);
-%     ind=find(DimValue==1);          
-%     DimIndex_x(ind)=[];%Mremove singleton                      
-%     VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};  %dimension variable           
-% %     VarAttribute{VarIndex.x}.Role='coord_x';%default (may be modified)
-%     index_detect=find(VarIndex_tot==VarIndex.x);
-% else
-%     index_detect=[];%coord x variable not already used
-% end
-% if isempty(index_detect)
-%     VarIndex_tot=[VarIndex_tot VarIndex.x]; 
-% else
-%     VarIndex.x=[];
-%     set(handles.abscissa,'Value',1)%vchosen abscissa already chosen, suppres it as abscissa
-% end
-% 
-% if (test_scalar | test_vector) &  ~isempty(VarIndex.x)
-%     DimIndex_x=Field.VarDimIndex{VarIndex.x};%dimension indices of the variable
-%     if length(DimIndex_x)==1 
-%         ind_x=find(DimIndex==DimIndex_x(1)); 
-%         if nbdim==3
-%             %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};
-%             perm_ind(ind_x)=3;
-%         elseif nbdim==2
-%             %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};
-%              perm_ind(ind_x)=2;
-%         end
-%         if isequal(perm_ind,[1:nbdim])
-%             test_grid=0;
-%         end
-%         DimIndex=DimIndex(perm_ind);
-%     elseif test_grid
-%         warndlg_uvmat('the dimension of the x coordinate variable should be 1','ERROR')   
-%     end
-%     if isequal(DimIndex_x,DimIndex)
-%                 VarAttribute{VarIndex.x}.Role='coord_x';%unstructured coordinates
-%     end
-% end
-% 
-% %defined the selected sub-field SubField
-% SubField.ListGlobalAttribute{1}='InputFile';
-% SubField.InputFile=get(handles.inputfile,'String');
-% SubField.ListVarName=Field.ListVarName(VarIndex_tot);
-% VarDimIndex=Field.VarDimIndex;
-% 
-% for ivar=VarIndex.u
-%     VarAttribute{ivar}.Role='vector_x';
-%     if test_grid
-%         VarDimIndex{ivar}=DimIndex; %permute dimensions
-%     end
-% end
-% for ivar=VarIndex.v
-%     VarAttribute{ivar}.Role='vector_y';
-%      if test_grid
-%         VarDimIndex{ivar}=DimIndex;%permute dimensions
-%     end
-% end
-% for ivar=VarIndex.A
-%     if test_grid
-%         VarDimIndex{ivar}=DimIndex;%permute dimensions
-%     end
-%     if isempty(iuA)
-%         VarAttribute{ivar}.Role='scalar';%Role =scalar
-%     else
-%        VarAttribute=[VarAttribute VarAttribute{ivar}]; %duplicate the attribute for a new variable
-%        nbattr=length(VarAttribute);
-%        VarAttribute{nbattr}.Role='scalar';
-%     end
-% end
-% SubField.VarDimIndex=VarDimIndex(VarIndex_tot);
-% SubField.VarAttribute=VarAttribute(VarIndex_tot);
-% % Field.SubListVarName=SubField.ListVarName;
-% % Field.SubVarDimIndex=SubField.VarDimIndex;
-% % Field.SubVarAttribute=SubField.VarAttribute;
-% set(hselect_field,'UserData',Field);
-% % copy variables on SubField
-% for ivar=1:length(VarIndex_tot)
-%     VarName=Field.ListVarName{VarIndex_tot(ivar)};
-%     eval(['SubField.' VarName '=Field.' VarName ';'])
-% end
-% if test_grid
-%     for ivar=1:length(VarIndex.u)
-%          VarName=Field.ListVarName{VarIndex.u(ivar)};
-%         eval(['SubField.' VarName '=permute(SubField.' VarName ',perm_ind);'])
-%     end 
-% 
-%     for ivar=1:length(VarIndex.v)
-%          VarName=Field.ListVarName{VarIndex.v(ivar)};
-%         eval(['SubField.' VarName '=permute(SubField.' VarName ',perm_ind);'])
-%     end 
-%     for ivar=1:length(VarIndex.A)
-%          VarName=Field.ListVarName{VarIndex.A(ivar)};
-%         eval(['SubField.' VarName '=permute(SubField.' VarName ',perm_ind);'])
-%     end   
-% end    
-% if ~isempty(iuA)
-%     VarName= ['A' Field.ListVarName{iuA}]; %create the new variable to distinguish the scaler form the velocity component
-%     SubField.ListVarName=[SubField.ListVarName VarName];
-%     SubField.VarDimIndex=[SubField.VarDimIndex Field.VarDimIndex(iuA)];
-%     eval(['SubField.' VarName '=Field.'  Field.ListVarName{iuA} ';'])
-% end 
-% % dimension of SubField
-% if test_scalar|test_vector
-%    % SubField.NbDim=2;
-%     SubField.InputFile=get(handles.inputfile,'String');
-%     SubField.get_field_handle=hselect_field;
-% else
-%     SubField.NbDim=1;
-% end
-% 
-% list_fig=get(handles.list_fig,'String');
-% fig_index=get(handles.list_fig,'Value');
-% %ACTION on SubField
-% index=get(handles.ACTION,'Value');
-
-%  
-% %     if (test_scalar|test_vector) 
-% %         RUN_fig='uvmat';
-% %     elseif iscell(list_fig)
-%     testuvmat=0;
-%     if test_scalar|test_vector
-%          [DimVarIndex,CellVarIndex,NbDim]=find_field_indices(SubField);
-%          NbDim=max(NbDim);
-%          if NbDim==3
-%            testuvmat=1; %uvmat interface needed for 3D plots
-%          end
-%     end
-%     if iscell(list_fig)
-%         RUN_fig=list_fig{fig_index}; 
-%     else
-%         RUN_fig='new fig...';%new plotting axes must be created
-%     end
-%     if isequal(RUN_fig,'new fig...') &  (test_scalar|test_vector)
-%         RUN_fig='uvmat';%use uvmat for a new fig
-%     end
-%     if testuvmat
-%         RUN_fig='uvmat';
-%     end
-%     if isequal(RUN_fig,'uvmat')
-%         
-%         huvmat=uvmat(SubField);
-%         menu=update_menu(handles.list_fig,'uvmat');%add the selected fct to the menu
-%     else
-%         test_new=1;
-%         if ~isequal(RUN_fig,'new fig...')
-%             sep=regexp(RUN_fig,'_')%look for subaxes in a fig
-%             if isempty(sep)
-%                 axe_index=1;
-%             else
-%                 axe_index=str2num(RUN_fig(sep+1:end))
-%                 RUN_fig=RUN_fig([1:sep-1])             
-%             end
-%             if ishandle(str2num(RUN_fig))
-%                 haxes=findobj(str2num(RUN_fig),'Type','axes')
-%                 for iaxe=1:length(haxes)
-%                     Tag=get(haxes(iaxe),'Tag');
-%                     if isequal(Tag,'Colorbar')|isequal(Tag,'legend')
-%                        iselect(iaxe)=0;
-%                     else
-%                        iselect(iaxe)=1; 
-%                     end
-%                 end
-%                 haxes=haxes(find(iselect));   
-%                 if length(haxes)>=axe_index
-%                     test_new=0
-%                     haxes=haxes(axe_index);
-%                     set(haxes,'NextPlot','add')
-%                 end
-%             end
-%         end
-%         if test_new
-%             hfig=figure;
-%             haxes=axes;
-%             menu=update_menu(handles.list_fig,num2str(hfig));%add the selected fct to the menu
-%         end  
-%         RUN_field(SubField,haxes)       
-%     end
-% end
-% %Field.VarIndex=VarIndex; %save for use in uvmat
-% % set(hselect_field,'UserData',Field)
-
-
-%------------------------------------------------
-% --- 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 Save_input.
-% function Save_input_Callback(hObject, eventdata, handles)
-% list_str=get(handles.abscissa,'String');
-% val=get(handles.abscissa,'Value');
-% var=list_str{val};
-% hselect_field=get(handles.Save_input,'parent')
-% set(hselect_field,'UserData',var);
-% set(hselect_field,'Tag','idle')
-
-%     
-% %-------------------------------------------------------------
-% % --- Executes on button press in save_histo.
-% function save_histo_Callback(hObject, eventdata, handles)
-% global filebase
-% 
-% pathstr = fileparts(filebase)
-% if (get(handles.Chist_input,'Value') == 1)
-%     def = {[pathstr pathstr(1) 'PIV_corr_histo.fig']};
-%     else
-
-%     def = {[pathstr pathstr(1) 'vel_histo.fig']};
-% end
-% prompt={'save figure(2) as'}
-% dlg_title = 'save figure';
-% num_lines= 1;
-% answer = inputdlg(prompt,dlg_title,num_lines,def)
-% saveas(2,answer{1})
- 
-% 
-% % --- Executes on selection change in spectrum.
-% function Field=FFT(Field)
-% 'TESTFFT'
-% Field
-% nbfield=length(Field.ListVarName);
-% if nbfield==0
-%     warndlg_uvmat('no field selected for FFT','ERROR')
-% elseif nbfield>2
-%     warndlg_uvmat('select only one field for FFT','ERROR')
-% end
-% if nbfield==2
-% % list_fields=get(handles.spectrum,'String');% list menu fields
-% % index_fields=get(handles.spectrum,'Value');% selected string index
-% % fields= list_fields{index_fields(1)}; % selected action
-% % func=eval(fields);
-%     dtmin=min(diff(time));%time step
-%     time1=time(1);timend=time(end);
-%     timeq=[time1:dtmin:timend];%equal time spacing
-%     funcinterp=interp1(time,func,timeq); %interpolated func
-% else
-%     varname=Field.ListVarName{1};
-%     eval(['funcinterp=Field.' varname ';'])
-% end
-% np=length(funcinterp);
-% funcinterp=funcinterp-sum(funcinterp)/np; %substract mean
-% fourier=fft(funcinterp);%take fft (complex)
-% spec=abs(fourier).*abs(fourier);% take sqare of the modulus
-% spec=spec([1:floor(np/2)]);%keep only the first half (the other is symmetric)
-% eval(['Field.' varname '=spec;'])
-% Field
-% % dfreq=1/(time(end)-time(1));%frequency interval
-% % freq=[0:dfreq:(floor(np/2)-1)*dfreq];
-% % figure(1)
-% % hold on
-% % RUN(freq,spec)
-% % xlabel('frequency (Hz)')
-% % ylabel('spectral intensity')
-% % title(['spectrum of' fields]);
-% % grid on
-
-
-
-
-
-%%-------------------------------------------------------
-% --- Executes on button press in peaklocking.
-%-------------------------------------------------
-function peaklocking(handles)
-%evaluation of peacklocking errors
-%use splinhist: give spline coeff cc for a smooth histo (call spline4)
-%use histsmooth(x,cc): calculate the smooth histo for any value x
-%use histder(x,cc): calculate the derivative of the smooth histo
-global hfig1 hfig2 hfig3
-global nbb Uval Vval Uhist Vhist % nbb resolution of the histogram nbb=10: 10 values in unity interval
-global xval xerror yval yerror
-
-set(handles.vector_y,'Value',1)% trigger the option Uhist on the interface
-set(handles.Vhist_input,'Value',1)
-set(handles.cm_switch,'Value',0) % put the switch to 'pixel'
-
-%adjust the extremal values of the histogram in U with respect to integer
-%values
-minimU=round(min(Uval)-0.5)+0.5; %first value of the histogram with integer bins 
-maximU=round(max(Uval)-0.5)+0.5;
-minim_fin=(minimU-0.5+1/(2*nbb)); % first bin valueat the beginning of an integer interval
-maxim_fin=(maximU+0.5-1/(2*nbb)); % last integer value
-nb_bin_min= round(-(minim_fin - min(Uval))*nbb); % nbre of bins added below
-nb_bin_max=round((maxim_fin -max(Uval))*nbb); %nbre of bins added above
-Uval=[minim_fin:(1/nbb):maxim_fin];
-histu_min=zeros(nb_bin_min,1);
-histu_max=zeros(nb_bin_max,1);
-Uhist=[histu_min; Uhist ;histu_max]; % column vector
-
-%adjust the extremal values of the histogram in V
-minimV=round(min(Vval-0.5)+0.5);
-maximV=round(max(Vval-0.5)+0.5);
-minim_fin=minimV-0.5+1/(2*nbb); % first bin valueat the beginning of an integer interval
-maxim_fin=maximV+0.5-1/(2*nbb); % last integer value
-nb_bin_min=round((min(Vval) - minim_fin)*nbb); % nbre of bins added below
-nb_bin_max=round((maxim_fin -max(Vval))*nbb);
-Vval=[minim_fin:(1/nbb):maxim_fin];
-histu_min=zeros(nb_bin_min,1);
-histu_max=zeros(nb_bin_max,1);
-Vhist=[histu_min; Vhist ;histu_max]; % column vector
-
-% RUN_histo_Callback(hObject, eventdata, handles)
-% %adjust the histogram to integer values:
-
-%histoU and V
-[Uhistinter,xval,xerror]=peaklock(nbb,minimU,maximU,Uhist);
-[Vhistinter,yval,yerror]=peaklock(nbb,minimV,maximV,Vhist);
-
-% selection of value ranges such that histo>=10 (enough statistics)
-Uval_ind=find(Uhist>=10);
-ind_min=min(Uval_ind);
-ind_max=max(Uval_ind);
-U_min=Uval(ind_min);% minimum allowed value 
-U_max=Uval(ind_max);%maximum allowed value
-
-% selection of value ranges such that histo>=10 (enough statistics)
-Vval_ind=find(Vhist>=10);
-ind_min=min(Vval_ind);
-ind_max=max(Vval_ind);
-V_min=Vval(ind_min);% minimum allowed value 
-V_max=Vval(ind_max);%maximum allowed value
-
-figure(4)% plot U histogram with smoothed one
-plot(Uval,Uhist,'b')
-grid on
-hold on
-plot(Uval,Uhistinter,'r');
-hold off
-
-figure(5)% plot V histogram with smoothed one
-plot(Vval,Vhist,'b')
-grid on
-hold on
-plot(Vval,Vhistinter,'r');
-hold off
-
-figure(6)% plot pixel error in two subplots
-hfig4=subplot(2,1,1);
-hfig5=subplot(2,1,2);
-axes(hfig4)
-plot(xval,xerror)
-axis([U_min U_max -0.4 0.4])
-xlabel('velocity u (pix)')
-ylabel('peaklocking error (pix)')
-grid on
-axes(hfig5)
-plot(yval,yerror)
-axis([V_min V_max -0.4 0.4]);
-xlabel('velocity v (pix)')
-ylabel('peaklocking error (pix)')
-grid on
-
-
-% ------------------------------------------------------------------
-function variables_Callback(hObject, eventdata, handles)
-Tabchar={''};%default
-Tabcell=[];
-hselect_field=get(handles.variables,'parent');
-Field=get(hselect_field,'UserData');
-index=get(handles.variables,'Value');%index in the list 'variables'
-if isequal(index,1) 
-    set(handles.attributes_txt,'String','global attributes')
-% list global attribute names and values if index=1 (blank variable display) is selected
-    if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute)
-        for iline=1:length(Field.ListGlobalAttribute)
-            Tabcell{iline,1}=Field.ListGlobalAttribute{iline};   
-            if isfield(Field, Field.ListGlobalAttribute{iline})
-                eval(['val=Field.' Field.ListGlobalAttribute{iline} ';'])
-                if ischar(val);
-                    Tabcell{iline,2}=val;
-                else
-                    Tabcell{iline,2}=num2str(val);
-                end
-            end
-        end
-        Tabchar=cell2tab(Tabcell,'=');
-    end
-else
-%list attribute names and values associated to the variable # injdex-1   
-    list_var=get(handles.variables,'String');
-    var_select=list_var{index};
-    set(handles.attributes_txt,'String', ['attributes of ' var_select])
-    if isfield(Field,'VarAttribute')& length(Field.VarAttribute)>=index-1
-%         nbline=0;
-        VarAttr=Field.VarAttribute{index-1};
-        if isstruct(VarAttr)
-            attr_list=fieldnames(VarAttr);
-            for iline=1:length(attr_list)
-                Tabcell{iline,1}=attr_list{iline};
-                eval(['val=VarAttr.' attr_list{iline} ';']) 
-                if ischar(val);
-                    Tabcell{iline,2}=val;
-                else
-                     Tabcell{iline,2}=num2str(val);
-                end
-            end
-        end
-    end
-
-end
-if ~isempty(Tabcell)
-    Tabchar=cell2tab(Tabcell,'=');
-    Tabchar=[{''};Tabchar];
-end
-set(handles.attributes,'String',Tabchar);
-
-% list_var=get(handles.dimensions,'String');
-% val=get(handles.dimensions,'Value');
-
-% update dimensions;
-if isfield(Field,'VarDimIndex')
-    Tabdim={};%default
-    if isequal(index,1)
-        dim_indices=1:length(Field.ListDimName);
-        set(handles.dimensions_txt,'String', 'dimensions')
-    else
-        dim_indices=Field.VarDimIndex{index-1};
-        set(handles.dimensions_txt,'String', ['dimensions of ' var_select])
-    end
-    for iline=1:length(dim_indices)
-        Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)};
-        Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline)));
-    end
-    Tabchar=cell2tab(Tabdim,'=');
-    Tabchar=[{''} ;Tabchar];
-    set(handles.dimensions,'String',Tabchar)  
-end  
-
-% --- Executes on button press in check_1Dplot.
-function check_1Dplot_Callback(hObject, eventdata, handles)
-val=get(handles.check_1Dplot,'Value');
-if isequal(val,0)
-    set(handles.Panel1Dplot,'Visible','off')
-%      set(handles.scalar,'Visible','off')
-%     set(handles.ordinate,'Max',2.0)%allow multiple ordinate input option
-%     if isequal(get(handles.check_vector,'Value'),0);
-%         set(handles.coord_z_vectors_scalar,'Visible','off')
-%     end
-else
-    set(handles.Panel1Dplot,'Visible','on')
-%     set(handles.scalar,'Visible','on')
-%     val=get(handles.ordinate,'Value');
-%     val=val(1);
-%     set(handles.ordinate,'Value',val);%suppress multiple ordinates
-%     set(handles.ordinate,'Max',1.0);%suppress multiple ordinate input option
-%       set(handles.coord_z_vectors_scalar,'Visible','on')
-end
-
-% --- Executes on button press in check_scalar.
-function check_scalar_Callback(hObject, eventdata, handles)
-val=get(handles.check_scalar,'Value');
-if isequal(val,0)
-    set(handles.PanelScalar,'Visible','off')
-%      set(handles.scalar,'Visible','off')
-%     set(handles.ordinate,'Max',2.0)%allow multiple ordinate input option
-%     if isequal(get(handles.check_vector,'Value'),0);
-%         set(handles.coord_z_vectors_scalar,'Visible','off')
-%     end
-else
-    set(handles.PanelScalar,'Visible','on')
-%     set(handles.scalar,'Visible','on')
-%     val=get(handles.ordinate,'Value');
-%     val=val(1);
-%     set(handles.ordinate,'Value',val);%suppress multiple ordinates
-%     set(handles.ordinate,'Max',1.0);%suppress multiple ordinate input option
-%       set(handles.coord_z_vectors_scalar,'Visible','on')
-end
-
-%---------------------------
-% --- Executes on button press in check_vector.
-function check_vector_Callback(hObject, eventdata, handles)
-val=get(handles.check_vector,'Value');
-if isequal(val,0)
-    set(handles.PanelVectors,'Visible','off')
-else
-    set(handles.PanelVectors,'Visible','on')
-end
-
-
-
-%-----------------------------
-function mouse_up_gui(ggg,eventdata,handles)
-if isequal(get(ggg,'SelectionType'),'alt') 
-    message='';  
-    global CurData
-    inputfield=get(handles.inputfile,'String');
-    if exist(inputfield,'file')
-        CurData=nc2struct(inputfield);
-    else
-        CurData=get(ggg,'UserData');% get_field opened from a input field, not a file
-    end
-  %%%% TODO: put the matalb command window in front
-    evalin('base','global CurData')%make CurData global in the workspace
-    evalin('base','CurData') %display CurData in the workspace
-end
-
-%---------------------------------------------
-% --- Executes on selection change in ACTION.
-function ACTION_Callback(hObject, eventdata, handles)
-list_ACTION=get(handles.ACTION,'String');% list menu fields
-index_ACTION=get(handles.ACTION,'Value');% selected string index
-ACTION= list_ACTION{index_ACTION}; % selected string
-path_get_field=which('get_field');%path to series.m
-list_path=get(handles.ACTION,'UserData');
-nb_builtin=0;
-list_path
-if iscell(list_path)
-for ilist=1:length(list_path)
-    if isequal(list_path{ilist},path_get_field)
-        nb_builtin=nb_builtin+1;
-    else
-        break
-    end
-end
-end
-if nb_builtin==0% the path to get_field has been changed, reinitialize
-    get_field_OpeningFcn(hObject, eventdata, handles)
-    return
-end
-
-% add a new function to the menu
-if isequal(ACTION,'more...')
-    pathfct=fileparts(path_get_field);
-    browse_name=fullfile(path_get_field,'FIELD_FCT');
-    if length(list_path)>nb_builtin
-        browse_name=list_path{end};% initialize browser with  the path of the last introduced function
-    end
-%     fct_name='';
-%     dir_perso=prefdir;
-%     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
-%     display(profil_perso)
-%     if exist(profil_perso,'file')
-%           h=load (profil_perso);
-%           if isfield(h,'get_field_fct')
-%             fct_name=h.get_field_fct;
-%           end
-%     else
-%         path_to_uvmat=which ('uvmat');% check the path of uvmat
-%         pathfct=fileparts(path_to_uvmat);
-%         fct_name=fullfile(pathfct,'USR_FCT');%go to UVMAT/USR_FCT by default
-%     end
-    [FileName, PathName] = uigetfile( ...
-       {'*.m', ' (*.m)';
-        '*.m',  '.m files '; ...
-        '*.*', 'All Files (*.*)'}, ...
-        'Pick a file',browse_name);
-    if length(FileName)<2
-        return
-    end
-    ext_fct=FileName(end-1:end);
-    if ~isequal(ext_fct,'.m')
-        msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
-        return
-    end
-    ACTION=FileName(1:end-2);% ACTION choice updated by the selected item
-    
-    % insert the choice in the action menu
-   menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed
-   index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list
-   list_path{index_ACTION}=PathName;
-   if length(menu_str)>nb_builtin+5;
-       nbremove=length(menu_str)-nb_builtin-5;
-       menu_str(nb_builtin+1:end-5)=[];
-       list_path(nb_builtin+1:end-4)=[];
-       index_ACTION=index_ACTION-nbremove;
-       set(handles.ACTION,'Value',index_ACTION)
-       set(handles.ACTION,'String',menu_str)
-   end
-   list_path{index_ACTION}=PathName;
-   set(handles.ACTION,'UserData',list_path);
-   set(handles.path_action,'enable','inactive')% indicate that the current path is accessible (not 'off')
-   
-   %record the current menu in personal file profil_perso
-   dir_perso=prefdir;
-   profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
-   for ilist=nb_builtin+1:length(menu_str)-1
-       get_field_fct{ilist-nb_builtin}=fullfile(list_path{ilist},[menu_str{ilist} '.m']);
-   end
-   if exist(profil_perso,'file')
-        save(profil_perso,'get_field_fct','-append')
-   else
-        txt=ver;
-        Release=txt(1).Release;
-        relnumb=str2num(Release(3:4));
-        if relnumb >= 14
-            save(profil_perso,'get_field_fct','-V6')
-        else
-            save(profil_perso, 'get_field_fct')
-        end
-   end
-end
-
-   %check the current path to the selected function
-PathName=list_path{index_ACTION};%current recorded path
-if ~isequal(path_get_field,PathName)
-    CurrentPath=fileparts(which(ACTION));
-    if ~isequal(PathName,CurrentPath)
-        addpath(PathName) 
-        errormsg=check_functions;
-        msgbox_uvmat('CONFIRMATION',[['path ' PathName ' added to the current Matlab pathes'];errormsg])
-    end
-end
-set(handles.path_action,'String',PathName); %show the path to the senlected function 
-    
-    
-%     fct_name=fullfile(PathName, FileName);
-%     if ~exist(fct_name,'file')
-%            msgbox_uvmat('ERROR',['procesing fct ' fct_name ' not found'])
-%     else
-%        ACTION=FileName(1:end-2);% 
-%        menu=update_menu(handles.ACTION,ACTION);%add the selected fct to the menu
-%        index_ACTION=get(handles.ACTION,'Value');% selected string index
-%        list_path{index_ACTION}=PathName;
-%        set(handles.ACTION,'UserData',list_path)
-%        if exist(profil_perso,'file')
-%             save (profil_perso,'coord_fct','-append'); %store the root name for future opening of uvmat
-%         end
-%     end   
-%     
-%     
-%     fileinput=FileName;%complete file name 
-%     eval(['spath=which(''' FileName ''');'])% current path to the function FileName
-%     if ~isequal(spath,PathName)
-%         addpath(PathName)
-%     end
-%     FileName([end-1:end])=[];
-%     
-%    % insert the choice in the action menu
-%     nbACTION=length(list_ACTION);
-%     index=0;
-%     for ilist=1:nbACTION
-%        if isequal(FileName,list_ACTION{ilist})%look for the selected scalar in the fields_input menu
-%             index=ilist;% 
-%        end
-%     end
-%     if index==0
-%        list_ACTION{nbACTION}=FileName; %put the chosen fct at the penultimate place in the fields_input menu
-%        list_path{nbACTION}=PathName;
-%        index=nbACTION;
-%        list_ACTION{nbACTION+1}='more...';
-%        set(handles.ACTION,'String',list_ACTION)
-%     end
-%     set(handles.ACTION,'Value',index);% store the selected scalar type
-%     set(handles.ACTION,'UserData',list_path);
-%     usr_defined_fct=fct_name;
-%     nbmenu=length(list_ACTION);
-%     nbadd=nbmenu-5;
-%     ilist=0;
-%     for imenu=nbmenu-min(4,nbadd):nbmenu-1
-%       ilist=ilist+1;
-%       fct_get_field{ilist,1}=list_ACTION{imenu};
-%       fct_path_get_field{ilist}=list_path{imenu};
-%     end
-%     if exist(profil_perso,'file')
-%         save(profil_perso,'usr_defined_fct','fct_get_field','fct_path_get_field','-append')
-%     else
-%        save(profil_perso,'usr_defined_fct','fct_get_field','fct_path_get_field','-V6')
-%     end
-% end
-
-% %check the current path to the selected function
-% list_path
-% PathName=list_path{index_ACTION}
-% CurrentPath=fileparts(which(ACTION))
-% if ~isequal(PathName,CurrentPath)
-%     addpath(PathName) 
-%     errormsg=check_functions;
-%     msgbox_uvmat('WARNING',[['path ' PathName ' added to the current Matlab pathes'];errormsg])
-% end
-% set(handles.path_action,'String',fullfile(PathName,' ')); %show the path to the senlected function
-
-%default setting for the visibility of the GUI elements*
-if ~isequal(ACTION,'PLOT')
-    varargout=feval(ACTION);% input list asked by the selected function
-    test_1Dplot=[];
-    test_scalar=[];
-    test_vector=[];
-    for ilist=1:length(varargout)-1
-        switch varargout{ilist}
-                           %RootFile always visible
-            case 'check_1Dplot'   
-                 test_1Dplot=isequal(lower(varargout{ilist+1}),'y');
-            case 'check_scalar'
-                 test_scalar=isequal(lower(varargout{ilist+1}),'y');    
-            case 'check_vector'   
-                 test_vector=isequal(lower(varargout{ilist+1}),'y'); 
-        end
-    end
-    if test_1Dplot==0
-        set(handles.check_1Dplot,'Value',0);
-    end
-    if test_1Dplot==1
-        set(handles.check_1Dplot,'Value',1);
-    end
-    if test_scalar==0
-        set(handles.check_scalar,'Value',0); 
-    end
-    if test_scalar==1
-        set(handles.check_scalar,'Value',1); 
-    end
-    if test_vector==0
-        set(handles.check_vector,'Value',0);
-    end
-    if test_vector==1
-        set(handles.check_vector,'Value',1);
-    end
-    check_1Dplot_Callback(hObject, eventdata, handles)
-    check_scalar_Callback(hObject, eventdata, handles)
-    check_vector_Callback(hObject, eventdata, handles)
-end
-% 
-% % --- Executes on selection change in menu_coord.
-% function menu_coord_Callback(hObject, eventdata, handles)
-% hget_field=get(handles.menu_coord,'parent');
-% menu=get(handles.menu_coord,'String');
-% ind_coord=get(handles.menu_coord,'Value');
-% coord_option=menu{ind_coord};
-% if isequal(coord_option,'more...'); 
-%     fct_name='';
-%     if exist('./TMP/current_usr_fct.mat','file')% if a file is found
-%         h=load('./TMP/current_usr_fct.mat');
-%         if isfield(h,'fct_name'); 
-%             fct_name=h.fct_name;
-%         end
-%     end
-%     prompt = {'Enter the name of the transform function'};
-%     dlg_title = 'user defined transform';
-%     num_lines= 1;
-%     [FileName, PathName, filterindex] = uigetfile( ...
-%        {'*.m', ' (*.m)';
-%         '*.m',  '.m files '; ...
-%         '*.*', 'All Files (*.*)'}, ...
-%         'Pick a file', fct_name);
-%     fct_name=fullfile(PathName,FileName);
-%     addpath(PathName);%add the path to the selected fct
-%     [errormsg,date_str]=check_functions;%check whether new functions can oversed the uvmat package A UTILISER
-%     if ~exist(fct_name,'file')
-%            warndlg_uvmat(['image procesing fct ' fct_name ' not found'],'WARNING')
-%     else
-%         transform=FileName(1:end-2);% 
-%         menu=update_menu(handles.menu_coord,transform);%add the selected fct to the menu
-% %         set(handles.mouse_coord,'String',menu([1:end-1])')%update the mouse coord menu 
-%       save ('./TMP/current_usr_fct.mat','fct_name');
-%     end   
-% end
-
-% --- Executes on selection change in menu_coord.
-function HELP_Callback(hObject, eventdata, handles)
-path_to_uvmat=which ('uvmat');% check the path of uvmat
-pathelp=fileparts(path_to_uvmat);
-helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
-if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
-else
-web([helpfile '#get_field'])    
-end
-
-%-----------------------------------------------------
-% --- browse existing figures
-%-----------------------------------------------------
-function browse_fig(menu_handle)
-hh=findobj(allchild(0),'Type','figure');
-ilist=0;
-list={};
-for ifig=1:length(hh)  %look for all existing figures
-    name=get(hh(ifig),'Name');
-     if ~isequal(name,'uvmat')%case of uvmat GUI
-%         ilist=ilist+1;
-%         list{ilist,1}='uvmat';
-%     else        %other figures
-        hchild=get(hh(ifig),'children');% look for axes contained in each figure
-        nbaxe=0;
-        for ichild=1:length(hchild)           
-            Type=get(hchild(ichild),'Type');
-            Tag=get(hchild(ichild),'Tag');
-            if isequal(Type,'axes')
-                if ~isequal(Tag,'Colorbar')& ~isequal(Tag,'legend')% don't select colorbars for plotting
-                     nbaxe=nbaxe+1;%count the existing axis
-                end 
-            end
-        end    
-        if nbaxe==1
-             ilist=ilist+1;%add a line in the list of axis
-            list{ilist,1}=num2str(hh(ifig));
-        elseif nbaxe>1
-            for iaxe=1:nbaxe
-               ilist=ilist+1;%add a line in the list of axis
-               list{ilist,1}=[num2str(hh(ifig)) '_' num2str(iaxe)];
-            end
-        end
-     end
-end
-list=['new fig...';'uvmat';list];
-set(menu_handle,'Value',1)
-set(menu_handle,'String',list)
-
-
-%-----------------------------------------------------
-function list_fig_Callback(hObject, eventdata, handles)
-%-----------------------------------------------------
-list_fig=get(handles.list_fig,'String');
-fig_val=get(handles.list_fig,'Value');
-plot_fig=list_fig{fig_val};
-if isequal(plot_fig,'uvmat')
-    huvmat=findobj(allchild(0),'name','uvmat');
-    if ~isempty(huvmat)
-        uistack(huvmat,'top')
-    end    
-elseif ~isequal(plot_fig,'new fig...') & ~isequal(plot_fig,'uvmat')
-    sep=regexp(plot_fig,'_');
-    if ~isempty(sep)
-        plot_fig=plot_fig([1:sep-1]);
-    end
-    if ishandle(str2num(plot_fig))
-        figure(str2num(plot_fig))% display existing figure
-    else
-        browse_fig(handles.list_fig); %reset the current list of figures
-    end
-end
-
-
-%-------------------------------------------------
-% give index numbers of the strings str in the list ListvarName
-function VarIndex_y=name2index(cell_str,ListVarName)
-VarIndex_y=[];
-if ischar(cell_str)
-    for ivar=1:length(ListVarName)
-        varlist=ListVarName{ivar};
-        if isequal(varlist,cell_str)
-            VarIndex_y= ivar;
-            break
-        end
-    end
-elseif iscell(cell_str)
-    for isel=1:length(cell_str)
-        varsel=cell_str{isel};
-        for ivar=1:length(ListVarName)
-            varlist=ListVarName{ivar};
-            if isequal(varlist,varsel)
-                VarIndex_y=[VarIndex_y ivar];
-            end
-        end
-    end
-end
-
-% --------------------------------------------------------------------
-function MenuOpen_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuOpen (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuExport_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuExport (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuBrowse_Callback(hObject, eventdata, handles)
-
-oldfile=get(handles.inputfile,'String');
-testrootfile=0;
-testsubdir=0;
-if isempty(oldfile)|isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
-        oldfile=''; 
-        dir_perso=prefdir;
-         profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
-         if exist(profil_perso,'file')
-              h=load (profil_perso);
-             if isfield(h,'RootPath')
-                  RootPath=h.RootPath;
-             end
-             if isfield(h,'SubDir')
-                  SubDir=h.SubDir;
-                  if ~isempty(SubDir)
-                    testsubdir=1;
-                  end
-             end
-             if isfield(h,'RootFile')
-                  RootFile=h.RootFile;
-                  if ~isempty(RootFile)
-                    testrootfile=1;
-                  end
-             end
-         end
-end
-if testrootfile
-    if ~testsubdir
-        oldfile=fullfile(RootPath,RootFile);
-    else
-        oldfile=fullfile(RootPath,SubDir,RootFile);
-    end
-end
-[FileName, PathName] = uigetfile( ...
-       {'*.nc', ' *.nc';...
-       '*.cdf', ' *.cdf';...
-        '*.*',  'All Files (*.*)'}, ...
-        'Pick a file',oldfile);
-
-%global inputfile
-fileinput=[PathName FileName];%complete file name 
-testblank=findstr(fileinput,' ');%look for blanks
-if ~isempty(testblank)
-    warndlg_uvmat(['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'],'ERROR')
-    return
-end
-sizf=size(fileinput);
-if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
-set(handles.inputfile,'String',fileinput)
-inputfile_Callback(hObject, eventdata, handles)
-
-
-%update list of recent files in the menubar
-MenuFile_1=fileinput;
-MenuFile_2=get(handles.MenuFile_1,'Label');
-MenuFile_3=get(handles.MenuFile_2,'Label');
-MenuFile_4=get(handles.MenuFile_3,'Label');
-MenuFile_5=get(handles.MenuFile_4,'Label');
-set(handles.MenuFile_1,'Label',MenuFile_1)
-set(handles.MenuFile_2,'Label',MenuFile_2)
-set(handles.MenuFile_3,'Label',MenuFile_3)
-set(handles.MenuFile_4,'Label',MenuFile_4)
-set(handles.MenuFile_5,'Label',MenuFile_5)
-
-
-% %store input file in personal file uvmat_perso.mat
-% dir_perso=prefdir;
-% profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
-% if exist(profil_perso,'file')
-%     save (profil_perso,'RootPath','SubDir','RootFile','NomType', 'ext','-append'); %store the root name for future opening of uvmat
-% else
-%    save (profil_perso,'RootPath','SubDir','RootFile','NomType', 'ext'); %store the root name for future opening of uvmat 
-% end   
-
-
-% --------------------------------------------------------------------
-function MenuFile_1_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_1 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuFile_2_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_2 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuFile_3_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_3 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuFile_4_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_4 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function MenuFile_5_Callback(hObject, eventdata, handles)
-% hObject    handle to MenuFile_5 (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
-% --------------------------------------------------------------------
-function ExportField_Callback(hObject, eventdata, handles)
-% hObject    handle to ExportField (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-
Index: unk/src/get_plot_handles.m
===================================================================
--- /trunk/src/get_plot_handles.m	(revision 7)
+++ 	(revision )
@@ -1,73 +1,0 @@
-%'get_plot_handles': list the  handles of elements setting the plotting parameters in the uvmat interface
-%--------------------------------------------------------
-%function [PlotHandles]=get_plot_handles(handles)
-%
-% OUTPUT:
-% PlotHandles: structure containing the  used to set plotting parameters
-% INPUT:
-% handles: structure of the handles of the graphic elements in the uvmat interface
-%            -- TODO: needs to be replaced by a cell listing the element tags --
-
-function PlotHandles=get_plot_handles(handles)
-PlotHandles.auto_xy=handles.auto_xy;
-%For scalar field representation
-PlotHandles.MaxA=handles.MaxA;
-PlotHandles.MinA=handles.MinA;
-PlotHandles.AutoScal=handles.AutoScal;
-PlotHandles.BW=handles.BW;
-PlotHandles.Contours=handles.Contours;
-PlotHandles.IncrA=handles.IncrA;
-PlotHandles.SCALAR_title=handles.SCALAR_title;
-PlotHandles.min_title=handles.min_title;
-PlotHandles.max_title=handles.max_title;
-PlotHandles.frame_scal=handles.frame_scal;
-PlotHandles.npx=handles.npx;
-PlotHandles.npy=handles.npy;
-PlotHandles.npx_title=handles.npx_title;
-PlotHandles.npy_title=handles.npy_title;
-
-%For vector field representation
-PlotHandles.frame_vect=handles.frame_vect;
-PlotHandles.VECT_title=handles.VECT_title;
-PlotHandles.VecScale=handles.VecScale;
-PlotHandles.AutoVec=handles.AutoVec;
-PlotHandles.HideFalse=handles.HideFalse;
-PlotHandles.HideWarning=handles.HideWarning;
-PlotHandles.record=handles.record;
-PlotHandles.col_vec=handles.col_vec;
-PlotHandles.Color_title=handles.Color_title;
-PlotHandles.color_code=handles.color_code;
-PlotHandles.colcode1=handles.colcode1;
-PlotHandles.colcode2=handles.colcode2;
-PlotHandles.vec_col_bar=handles.vec_col_bar;
-PlotHandles.slider1=handles.slider1;
-PlotHandles.slider2=handles.slider2;
-PlotHandles.max_vec=handles.max_vec;
-PlotHandles.min_vec=handles.min_vec;
-PlotHandles.scale_title=handles.scale_title;
-PlotHandles.AutoVecColor=handles.AutoVecColor;
-PlotHandles.decimate4=handles.decimate4;
-PlotHandles.min_C_title=handles.min_C_title;
-PlotHandles.max_C_title=handles.max_C_title;
-PlotHandles.MenuVectors=handles.MenuVectors;
-PlotHandles.MenuEditVectors=handles.MenuEditVectors;
-PlotHandles.edit_vect=handles.edit_vect;
-%menu for the choice of the current plotting axes
-%PlotHandles.MenuAxes=handles.MenuAxes;
-
-%handles for move_mouse
-PlotHandles.mouse_coord=handles.mouse_coord;
-% PlotHandles.POINTS=handles.POINTS;
-% PlotHandles.LINE=handles.LINE;
-% PlotHandles.PLANE=handles.PLANE;
-% PlotHandles.PATCH=handles.PATCH;
-PlotHandles.cal=handles.cal;
-%PlotHandles.makemask=handles.makemask;
-PlotHandles.edit=handles.edit;
-PlotHandles.text_display_1=handles.text_display_1;
-PlotHandles.text_display_2=handles.text_display_2;
-PlotHandles.text_display_3=handles.text_display_3;
-PlotHandles.text_display_4=handles.text_display_4;
-
-%handles for mouse_up
-PlotHandles.zoom=handles.zoom;
Index: unk/src/hist_update.m
===================================================================
--- /trunk/src/hist_update.m	(revision 7)
+++ 	(revision )
@@ -1,54 +1,0 @@
-%'hist_update': update of a current global histogram by inclusion of a new field
-%------------------------------------------------------------------------
-%[val,HIST]=hist_update(val,HIST,C,dC)
-%
-% OUTPUT:
-% val: vector of field values at which the histogram is determined (middle of bins)
-% HIST(:,icolor): nbre of occurence of the field value in the bins whose middle is given by val
-%           can be a column vector, same size as val, or a matrix with three columns, for color images
-%
-% INPUT:
-% val: existing field values from the current histogram, =[] if there is no current histogram
-% HIST(:,icolor): current histogram,  =[] if there is none
-%       can be a column vector (icolor=1), same size as val, or a matrix with three columns, for color images      
-% C(:,icolor): vector representing the current field values
-%       can be a column vector (icolor=1), or a matrix with three columns, for color images 
-% dC: width of the new bins extending val to account for the new field.
-
-function [val,HIST]=hist_update(val,HIST,C,dC)
-
-valplus=[];valminus=[];
-HISTplus=[];HISTminus=[];
-if isempty(HIST)
-    HIST=0;
-end
-siz=size(C);nbfields=siz(2);
-C=double(C);
-valmin=min(val); 
-valmax=max(val);
-Cmin=min(min(C)); Cmax=max(max(C));
-if isempty(val)%no current histogram
-    val=[Cmin-dC/2:dC:Cmax+dC/2];
-else %extending the current histogram beyond its maximum value
-    if Cmax>=valmax+dC/2;
-        valplus=[valmax+dC:dC:Cmax+dC/2];% we extend the values val
-        HISTplus=zeros(length(valplus),nbfields);% we put histogram to zero at these values
-    end
-    %extending the current histogram below its minimum value
-    if Cmin<=valmin-dC/2;
-        valminus=[valmin-dC:-dC:Cmin-dC/2];% we extend the values val
-        valminus=sort(valminus);% we reverse the order
-        HISTminus=zeros(length(valminus),nbfields);% we put histogram to zero at these values
-    end
-    val=[valminus val valplus];
-end
-HIST=[HISTminus;HIST;HISTplus];
-if nbfields==1
-    histC=(hist(C,val))';% initiate the global histogram 
-elseif nbfields==3
-    HIST1=(hist(C(:,1),val))';
-    HIST2=(hist(C(:,2),val))';
-    HIST3=(hist(C(:,3),val))';
-    histC=[HIST1 HIST2 HIST3];
-end
-HIST=HIST+histC;
Index: unk/src/imadoc2struct.m
===================================================================
--- /trunk/src/imadoc2struct.m	(revision 7)
+++ 	(revision )
@@ -1,250 +1,0 @@
-%'imadoc2struct': reads the xml file for image documentation 
-%
-%function [s,errormsg]=imadoc2struct(ImaDoc) 
-%--------------------------------------------------------
-% OUTPUT:
-% s: structure representing ImaDoc
-%   s.Heading: information about the data hierarchical structure
-%   s.Time: matrix of times
-%   s.TimeUnit
-%  s.GeometryCalib: substructure containing the parameters for geometric calibration
-% errormsg: error message
-%
-% INPUT:
-% ImaDoc: full name of the xml input file with head key ImaDoc
-%function [s,error,Heading,nom_type_ima,ext_ima,abs_time,TimeUnit,mode,NbSlice]=imadoc2struct(ImaDoc) 
-function [s,errormsg]=imadoc2struct(ImaDoc) 
-
-errormsg=[];%default
-s.Heading=[];%default
-s.Time=[]; %default
-s.TimeUnit=[]; %default
-s.GeometryCalib=[];
-nom_type_ima=[];%default
-ext_ima=[];%default
-% abs_time=[];%initiation
-% GeometryCalib.CoordUnit='cm';%default
-mode=[]; %default
-NbSlice=1;%default
-npx=[];%default
-npy=[];%default
-% GeometryCalib.Pxcmx=1;
-% GeometryCalib.Pxcmy=1;
-% GeometryCalib=[];
-NbDtj=1;
-tsai=[];%default
-% if ~exist('testime','var')
-%     testime=1;%default
-
-if exist(ImaDoc,'file')~=2, errormsg=[ ImaDoc ' does not exist']; return;end;%input file does not exist
-try
-    t=xmltree(ImaDoc);
-catch
-    errormsg={[ImaDoc ' is not a valid xml file']; lasterr};
-    display(errormsg);
-    return
-end
-
-uid_root=find(t,'/ImaDoc');
-if isempty(uid_root), errormsg=[ImaDoc ' is not an image documentation file ImaDoc']; return; end;%not an ImaDoc .xml file
-
-%Heading
-uid_Heading=find(t,'/ImaDoc/Heading');
-if ~isempty(uid_Heading), 
-    uid_Campaign=find(t,'/ImaDoc/Heading/Campaign');
-    uid_Exp=find(t,'/ImaDoc/Heading/Experiment');
-    uid_Device=find(t,'/ImaDoc/Heading/Device');
-    uid_Record=find(t,'/ImaDoc/Heading/Record');
-    uid_FirstImage=find(t,'/ImaDoc/Heading/ImageName');
-    s.Heading.Campaign=get(t,children(t,uid_Campaign),'value');
-    s.Heading.Experiment=get(t,children(t,uid_Exp),'value');
-    s.Heading.Device=get(t,children(t,uid_Device),'value');
-    if ~isempty(uid_Record)
-        s.Heading.Record=get(t,children(t,uid_Record),'value');
-    end
-    s.Heading.ImageName=get(t,children(t,uid_FirstImage),'value');
-    FirstImage=s.Heading.ImageName;
-    if ~isempty(FirstImage)
-        [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type_ima]=name2display(FirstImage);
-    end
-end
-
-%Camera   
-uid_Camera=find(t,'/ImaDoc/Camera');
-if ~isempty(uid_Camera)
-    uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');
-    if ~isempty(uid_ImageSize);
-        ImageSize=get(t,children(t,uid_ImageSize),'value');
-        xindex=findstr(ImageSize,'x');
-        if length(xindex)>=2
-            npx=str2num(ImageSize(1:xindex(1)-1));
-            npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1));
-        end
-    end
-    uid_NbSlice=find(t,'/ImaDoc/Camera/NbSlice');
-    if ~isempty(uid_NbSlice)
-        NbSlice=str2num(get(t,children(t,uid_NbSlice),'value'));
-        if isempty(NbSlice),NbSlice=1;end; %default
-    end
-    uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');
-    if ~isempty(uid_TimeUnit)
-        s.TimeUnit=get(t,children(t,uid_TimeUnit),'value');
-    end
-    uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');
-    if ~isempty(uid_BurstTiming)
-        for k=1:length(uid_BurstTiming)
-            Dtj=[];%default
-            NbDtj=1;%default
-            subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming
-             % reading Dtk
-            Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1);
-            Dtj=get_value(subt,'/BurstTiming/Dtj',[]);
-            Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
-            NbDtj=get_value(subt,'/BurstTiming/NbDtj',1);
-            Dti=get_value(subt,'/BurstTiming/Dti',[]);
-            Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
-            NbDti=get_value(subt,'/BurstTiming/NbDti',1);
-            Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit
-            if ~isempty(Dti) 
-                Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times
-                Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals  Dti
-            end
-            if ~isempty(Dtj)
-                Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dti vector NbDti times
-                Dtj=[0 Dtj];
-%                 Time_val'
-%                 ones(1,numel(Dtj))
-%                 ones(numel(Time_val'),1)
-%                 cumsum(Dtj)
-                Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj
-            end
-            % reading Dtk
-            Dtk=get_value(subt,'/BurstTiming/Dtk',[]);
-            NbDtk=get_value(subt,'/BurstTiming/NbDtk',1)
-            if isempty(Dtk)
-                s.Time=[s.Time;Time_val];
-            else
-                for kblock=1:NbDtk+1
-                    Time_val=Time_val+(kblock-1)*Dtk;
-                    s.Time=[s.Time;Time_val];
-                end
-            end
-        end
-    end
-    if size(s.Time,1)==1
-        s.Time=(s.Time)'; %change vector into column
-    end
-end
-
-%read calibration
-uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');
-if ~isempty(uid_GeometryCalib)
-    if length(uid_GeometryCalib)>1
-        error=['More than one GeometryCalib in ' filecivxml];
-        return
-    end
-    subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib
-    cont=get(subt,1,'contents');
-    if ~isempty(cont)
-        uid_pixcmx=find(subt,'/GeometryCalib/Pxcmx');
-        uid_pixcmy=find(subt,'/GeometryCalib/Pxcmy');
-        if ~isempty(uid_pixcmx) & ~isempty(uid_pixcmy)%NON UTILISE 
-           pixcmx=str2num(get(subt,children(subt,uid_pixcmx),'value'));
-            if isempty(pixcmx),pixcmx=1;end; %default
-            pixcmy=str2num(get(subt,children(subt,uid_pixcmy),'value'));
-            if isempty(pixcmy),pixcmy=1;end; %default
-            tsai.Pxcmx=pixcmx;
-            tsai.Pxcmy=pixcmy;
-        end
-        %default values:
-        tsai.f=1;
-        tsai.dpx=1;
-        tsai.dpy=1;
-        tsai.sx=1;
-        tsai.Cx=0;
-        tsai.Cy=0;
-        tsai.Tz=1;
-        tsai.Tx=0;
-        tsai.Ty=0;
-        tsai.R=[1 0 0; 0 1 0; 0 0 0];
-        tsai.kappa1=0;
-        uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');
-        if ~isempty(uid_CoordUnit) 
-            tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');
-        end
-        uid_focal=find(subt,'/GeometryCalib/focal');
-        uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');
-        uid_sx=find(subt,'/GeometryCalib/sx');
-        uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');
-        uid_kappa1=find(subt,'/GeometryCalib/kappa1');
-        uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');
-        uid_R=find(subt,'/GeometryCalib/R');
-        if ~isempty(uid_focal) & ~isempty(uid_dpx_dpy) & ~isempty(uid_Cx_Cy)
-            tsai.f=str2num(get(subt,children(subt,uid_focal),'value'));
-            dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));
-            tsai.dpx=dpx_dpy(1);
-            tsai.dpy=dpx_dpy(2);
-            if ~isempty(uid_sx)
-               tsai.sx=str2num(get(subt,children(subt,uid_sx),'value')); 
-            end
-            Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));
-            tsai.Cx=Cx_Cy(1);
-            tsai.Cy=Cx_Cy(2);
-        end
-        if ~isempty(uid_Tx_Ty_Tz) 
-            Tx_Ty_T_char=get(subt,children(subt,uid_Tx_Ty_Tz),'value');
-            Tx_Ty_Tz=str2num(Tx_Ty_T_char);
-            tsai.Tx=Tx_Ty_Tz(1);
-            tsai.Ty=Tx_Ty_Tz(2);
-            tsai.Tz=Tx_Ty_Tz(3);
-        end
-        if ~isempty(uid_R)
-            RR=get(subt,children(subt,uid_R),'value');
-            if length(RR)==3
-                tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];
-            end
-        end
-        if ~isempty(uid_kappa1)     
-            tsai.kappa1=str2num(get(subt,children(subt,uid_kappa1),'value'));
-        end
-        %look for laser plane definitions   
-        uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');
-        uid_Pos=find(subt,'/GeometryCalib/PlanePos');
-        if ~isempty(uid_Angle) 
-            tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));
-        end
-        if ~isempty(uid_Pos)
-            for j=1:length(uid_Pos)
-                tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));
-            end
-        end
-        s.GeometryCalib=tsai;
-    end
-end   
-
-%--------------------------------------------------
-%  read an xml element
-function val=get_value(t,label,default)
-%--------------------------------------------------
-val=default;
-uid=find(t,label);%find the element iud(s)
-if ~isempty(uid)
-   uid_child=children(t,uid);
-   if ~isempty(uid_child)
-       data=get(t,uid_child,'type');
-       if iscell(data)
-           for icell=1:numel(data)
-               val_read=str2num(get(t,uid_child(icell),'value'));
-               if ~isempty(val_read)
-                   val(icell)=val_read;
-               end
-           end
-           val=val';
-       else
-           val_read=str2num(get(t,uid_child,'value'));
-           if ~isempty(val_read)
-               val=val_read;
-           end
-       end
-   end
-end
Index: unk/src/interp2_uvmat.m
===================================================================
--- /trunk/src/interp2_uvmat.m	(revision 7)
+++ 	(revision )
@@ -1,25 +1,0 @@
-% A matrix (npy,npx) to interpolate
-%XIMA: matrix of non-integer x index values (npY,npX)
-%YIMA: matrix of non-integer y index values (npY,npX), (with the same size as XIMA)
-function A_out=interp2_uvmat(A,XIMA,YIMA)
-npx=size(A,2);
-npy=size(A,1);
-npX=size(XIMA,2);
-npY=size(XIMA,1)
-XIMA=reshape(XIMA,1,npX*npY)+0.5;%indices corresponding to XIMA, reshaped in a matlab vector
-YIMA=reshape(YIMA,1,npX*npY)+0.5;%indices corresponding to XIMA, reshaped in a matlab vector
-X_delta=XIMA-floor(XIMA);%distance to the closest integer value
-XIMA=floor(XIMA);%integer x index on the image
-Y_delta=YIMA-floor(YIMA);%distance to the closest integer value
-YIMA=floor(YIMA);%integer x index on the image        
-flagin=(XIMA>=1 & XIMA<=npx-1 & YIMA >=1 & YIMA<=npy-1);%flagin=1 inside the original image
-ind_in=find(flagin);%list of indices of XIndex for valid values of image indices (inside the original image) 
-ind_out=find(~flagin);      
-vec_A=double(reshape(A(:,:,1),1,npx*npy));%reshape the original image as a Matlab image vector
-ICOMB=((XIMA-1)*npy+(npy+1-YIMA));%determine the indices in the image Matlab vector corresponding to XIMA and YIMA
-ICOMB=ICOMB(flagin);%selection of the valid indices
-X_delta=X_delta(ind_in);
-Y_delta=Y_delta(ind_in);
-A_out(ind_in)=(1-Y_delta).*(1-X_delta).*vec_A(ICOMB)+Y_delta.*(1-X_delta).*vec_A(ICOMB-1)+X_delta.*(1-Y_delta).*vec_A(ICOMB+npy)+X_delta.*Y_delta.*vec_A(ICOMB+npy-1);
-A_out(ind_out)=zeros(size(ind_out));
-A_out=reshape(A_out,npY,npX);%interpolated image 
Index: unk/src/keyboard_callback.m
===================================================================
--- /trunk/src/keyboard_callback.m	(revision 7)
+++ 	(revision )
@@ -1,51 +1,0 @@
-%'keyboard_callback:' function activated when a key is pressed on the keyboard
-%-----------------------------------
-function keyboard_callback(hObject,eventdata,handleshaxes)
-xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
-cur_axes=get(gcbf,'CurrentAxes');
-if ~isempty(cur_axes)
-    xlimit=get(cur_axes,'XLim');
-    ylimit=get(cur_axes,'Ylim');
-    dx=(xlimit(2)-xlimit(1))/10;
-    dy=(ylimit(2)-ylimit(1))/10;
-   
-    if isequal(xx,29)%move arrow right
-        xlimit=xlimit+dx;
-    elseif isequal(xx,28)%move arrow left
-        xlimit=xlimit-dx;
-    elseif isequal(xx,30)%move arrow up
-        ylimit=ylimit+dy;
-    elseif isequal(xx,31)%move arrow down
-        ylimit=ylimit-dy;
-    end
-    set(cur_axes,'XLim',xlimit)
-    set(cur_axes,'YLim',ylimit)
-end
-if ismember(xx,[8 127]) %if the delete or suppr key is pressed, delete the current object 
-    currentobject=gco;
-    huvmat=findobj(allchild(0),'Name','uvmat');
-%     UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
-    hlist_object=findobj(huvmat,'Tag','list_object');
-    ObjIndex=get(hlist_object,'Value');
-    if ObjIndex>1
-        delete_object(ObjIndex)
-    end
-    if ishandle(currentobject)
-        tag=get(currentobject,'Tag');%tag of the current selected object
-        if isequal(tag,'proj_object')
-            delete_object(currentobject)
-        end
-    end
-elseif isequal(xx,112)%  key 'p'
-    uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
-elseif isequal(xx,109)%  key 'm'
-    uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
-end
-
-AxeData=get(cur_axes,'UserData');
-if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
-    hparentrect=AxeData.ParentRect;
-    rect([1 2])=[xlimit(1) ylimit(1)];
-    rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
-    set(hparentrect,'Position',rect)
-end
Index: unk/src/mouse_down.m
===================================================================
--- /trunk/src/mouse_down.m	(revision 7)
+++ 	(revision )
@@ -1,343 +1,0 @@
-%'mouse_down': function activated when the mouse button is pressed on a figure (callback for 'WindowButtonDownFcn'
-%-------------------------------------------------------------- 
-% xy=mouse_down(hObject,eventdata) 
-% activated by the command:
-% set(hObject,'WindowButtonDownFcn',{'mouse_down'}), 
-% where hObject is the handle of the figure
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function xy=mouse_down(hObject,eventdata)
-testzoom=0;%default
-MouseAction='none'; %default
-huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle which controls theoption of  mouse action
-if ~isempty(huvmat)
-    hhuvmat=guidata(huvmat);%handles of elements in uvmat
-    UvData=get(huvmat,'UserData');
-    testzoom=get(hhuvmat.zoom,'Value');% get the mouse action from the uvmat GUI: options:
-    if isfield(UvData,'MouseAction')
-        MouseAction=UvData.MouseAction;% get the mouse action from the uvmat GUI: options:
-    end
-end
-test_create=~testzoom && (isequal(MouseAction,'create_object') || isequal(MouseAction,'create_mask'));
-%test_cal=get(handles.cal,'Value');
-test_cal=isequal(MouseAction,'calib');
-handles_coord=findobj(huvmat,'Tag','menu_coord');
-menu_coord=get(handles_coord,'String');
-coord_choice=get(handles_coord,'Value');
-coord_type=menu_coord{coord_choice};
-test_edit=isequal(MouseAction,'edit_object');
-test_edit_vect=isequal(MouseAction,'edit_vect');
-xdisplay=[];%default
-ydisplay=[];%default
-haxes=[];
-AxeData=[];%default
-
-%edit an existing point or line if found
-hcurrentobject=gco;% current object handle (selected by the mouse)
-hcurrentfig=gcbo;% current figure handle
-tag_obj=get(gco,'Tag');
-xy=[];%default
-xy_fig=get(hcurrentfig,'CurrentPoint');% current point of the current figure (gcbo)
-hchild=get(hcurrentfig,'Children');%handles of all objects in the current figure
-% loop on all the objects in the current figure (selected by the last mouse click) 
-for ichild=1:length(hchild)
-    obj_pos=get(hchild(ichild),'Position');%position of the object
-    if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4);
-        htype=get(hchild(ichild),'Type');%type of object child of the current figure
-        %if the mouse is over an axis, look at the data
-        if isequal(htype,'axes')
-            haxes=hchild(ichild);
-            xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
-            AxeData=get(haxes,'UserData');% data attached to the axis
-            AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
-            if ~isequal(tag_obj,'proj_object') & ~test_create
-                x_mouse=xy(1,1);%default
-                y_mouse=xy(1,2);%default
-                u_mouse=[];
-                v_mouse=[];
-                w_mouse=[];
-                A_mouse=[];
-                c_text=[];
-                f_text=[];
-                ff_text=[];     
-                ivec=[];   
-                if isfield(AxeData,'X') & isfield(AxeData,'Y') & isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
-                    flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/4) & AxeData.X>(xy(1,1)-AxeData.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
-                      (AxeData.Y<(xy(1,2)+AxeData.Mesh/4) & AxeData.Y>(xy(1,2)-AxeData.Mesh/4));%f
-                    ivec=find(flag_vec);% search the selected vector index ivec
-                    if length(ivec)>0
-                        ivec=ivec(1);%choice the first selected vector if several are selected                        
-                    end
-                end
-            end
-        elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
-           %FAIRE UNE OPTION D'AIDE AVEC BOUTON SOURIS DROIT (ALT)??
-        end
-    end
-end
-test2D=0;
-if isfield(AxeData,'NbDim')
-    if isequal(AxeData.NbDim,2)
-        test2D=1;
-    end
-end
-if ~test2D     %desable  object creation and vector editing if NbDim different from 2
-    test_create=0;
-    test_edit_vect=0;
-end
-%delete the current zoom rectangle
-if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)
-    delete(AxeData.CurrentRectZoom)
-    AxeData.CurrentRectZoom=[];
-end    
-
-if testzoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var')
-     AxeData.Drawing='zoom'; %initiate drawing mode
-     AxeData.CurrentObject=[];%unselect objects
-elseif ~isempty(huvmat)
-    %selection of an existing projection object
-    if  test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))
-        if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
-            userdata=get(hcurrentobject,'UserData');
-            if ishandle(userdata)%the selected line depends on a parent line
-                AxeData.CurrentObject=userdata;% the parent object becomes the current one
-            else
-                AxeData.CurrentObject=hcurrentobject;% the selected object becomes the current one
-            end
-            ObjectData=get(AxeData.CurrentObject,'UserData');
-            if test_edit & isfield(ObjectData,'IndexObj')
-                hother=findobj('Tag','proj_object','Type','line');%find all the proj objects
-                set(hother,'Color','b');%reset all the proj objects in 'blue' by default
-                set(hother,'Selected','off')
-                hother=findobj('Tag','proj_object','Type','rectangle');
-                set(hother,'EdgeColor','b');
-                set(hother,'Selected','off');
-                hother=findobj('Tag','proj_object','Type','image');
-                for iobj=1:length(hother)
-                       Acolor=get(hother(iobj),'CData');
-                       Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
-                       set(hother(iobj),'CData',Acolor);
-                end
-                hother=findobj('Tag','DeformPoint');
-                set(hother,'Color','b');
-                set(hother,'Selected','off')    
-                if isequal(get(AxeData.CurrentObject,'Type'),'line')
-                    set(AxeData.CurrentObject,'Color','m'); %set the selected object to magenta color
-                elseif isequal(get(AxeData.CurrentObject,'Type'),'rectangle')
-                     set(AxeData.CurrentObject,'EdgeColor','m'); %set the selected object to magenta color
-                end
-                if isfield(ObjectData,'SubObject')& ishandle(ObjectData.SubObject)
-                    for iobj=1:length(ObjectData.SubObject)
-                        hsub=ObjectData.SubObject(iobj);
-                        if isequal(get(hsub,'Type'),'rectangle')
-                            set(hsub,'EdgeColor','m'); %set the selected object to magenta color
-                        elseif isequal(get(hsub,'Type'),'image')
-                           Acolor=get(hsub,'CData');
-                           Acolor(:,:,1)=Acolor(:,:,3);
-                           set(hsub,'CData',Acolor);
-                        else
-                            set(hsub,'Color','m')
-                        end
-                    end
-                end
-                if isequal(tag_obj,'DeformPoint')
-                     set(hcurrentobject,'Color','m'); %set the selected DeformPoint to magenta color
-                end
-                IndexObj=ObjectData.IndexObj;
-                hlist_object=findobj(huvmat,'Tag','list_object');
-                set(hlist_object,'Value',IndexObj);
-                testdeform=0;
-                set(gcbo,'Pointer','circle'); 
-                AxeData.Drawing='deform';
-                if isequal(tag_obj,'DeformPoint')       
-                   if isfield(ObjectData,'DeformPoint')
-                       set(hcurrentobject,'Selected','on')
-                       for ipt=1:length(ObjectData.DeformPoint)
-                           if isequal(ObjectData.DeformPoint(ipt),hcurrentobject)
-                                AxeData.CurrentIndex=ipt;
-                                testdeform=1;
-                           end
-                       end
-                   end
-                end
-                if testdeform==0
-                    AxeData.Drawing='translate';
-                    set(AxeData.CurrentObject,'Selected','on')
-                    set(gcbo,'Pointer','fleur');
-                end
-            end
-        end
-    end
-    %  create new projection  object
-    if  test_create && ~isempty(xy) && ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
-            ObjectData=read_set_object(UvData.sethandles); 
-            ObjectData.Coord=[]; %reset previous object coordinates
-            ObjectData.Coord(1,1)=xy(1,1);
-            ObjectData.Coord(1,2)=xy(1,2);
-            ObjectData.Coord(1,3)=0;
-            if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
-                 ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
-            end
-            AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject
-            if isfield(UvData,'Object')
-                IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface
-            else
-                IndexObj=2;
-            end  
-            UvData.Object{IndexObj}=ObjectData;
-            UvData.Object{IndexObj}.HandlesDisplay(1)=AxeData.CurrentObject;
-            set(huvmat,'UserData',UvData)
-            list_str=get(hhuvmat.list_object,'String');
-            list_str{IndexObj}=[num2str(IndexObj) '-' set_title(ObjectData.Style,ObjectData.ProjMode)];
-            if ~isequal(list_str{end},'...')
-                 list_str{end+1}='...';
-            end
-            set(hhuvmat.list_object,'String',list_str)
-            set(hhuvmat.list_object,'Value',IndexObj)
-            PlotData=get(AxeData.CurrentObject,'UserData');
-            PlotData.IndexObj=IndexObj;
-            set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph
-            AxeData.Drawing='create';
-    end
-
-    % create calibration points if the GUI geometry_calib is opened
-    if test_cal & ~isempty(xy)
-        h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
-        hh_geometry_calib=guidata(h_geometry_calib);
-        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
-        h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
-        if isequal(get(h_edit_append,'Value'),1) 
-            if ~isequal(coord_type,'')
-                set(handles_coord,'Value',1)
-                coord_type='';
-                set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off'
-                set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
-                uvmat('run0_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
-            end
-%             if isequal(coord_type,'px')|isequal(coord_type,'');%px cordinates
-                strline=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
-%             else %phys cordinates
-%                 strline=[ num2str(xy(1,1),4) '    |    '  num2str(xy(1,2),4) '    |    0      |    '  '    |    ' ];
-%             end
-            Coord=get(h_ListCoord,'String');
-            val=get(h_ListCoord,'Value');
-            if isequal(Coord,{''})
-                val=0;
-            end
-            if length(Coord)>val
-                Coord(val+2:length(Coord)+1)=Coord(val+1:length(Coord));% push the list forward beyond the current point
-            end
-            Coord{val+1}=strline;
-            set(h_ListCoord,'String',Coord)
-            set(h_ListCoord,'Value',val+1)
-            geometry_calib('ListCoord_Callback',hObject,eventdata,hh_geometry_calib)
-            data=read_geometry_calib(Coord);
-            if isequal(coord_type,'px')|isequal(coord_type,'');%px cordinates
-                XCoord=data.Coord(:,4);
-                YCoord=data.Coord(:,5);
-            else %phys cordinates
-                XCoord=data.Coord(:,1);
-                YCoord=data.Coord(:,2);
-            end
-            hh=findobj('Tag','calib_points')           
-            if isempty(hh)
-                line(XCoord,YCoord,'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
-            else
-                set(hh,'XData',XCoord)
-                set(hh,'YData',YCoord)
-            end
-            hhh=findobj('Tag','calib_marker');
-            if ~isempty(hhh)
-                set(hhh,'XData',xy(1,1))
-                set(hhh,'YData',xy(1,2))
-            else
-                line(xy(1,1),xy(1,2),'Color','m','Tag','calib_marker','LineStyle','.','Marker','o','MarkerSize',20);
-            end
-            %uistack(h_geometry_calib,'top')
-        end
-    end
-
-    % edit vectors
-    if test_edit_vect & ~isempty(ivec) 
-    %     FF_100=FF-100*double(uint(abs(FF)/100); %value of FF without units and dizaines
-        if ~isfield(AxeData,'FF')
-            AxeData.FF=zeros(size(AxeData.X));
-        end
-        if isequal(AxeData.FF(ivec),0)
-
-            AxeData.FF(ivec)=100; %mark vector #ivec as false
-
-        else
-            AxeData.FF(ivec)=0;
-        end
-        set(haxes,'UserData',AxeData)
-        update_plot
-    end   
-end
-set(haxes,'UserData',AxeData);
-
-%------------------------------------------------------
-function update_plot
-%--------------------------------------------
-huvmat=gcbf;
-UvData=get(gcbf,'UserData');
-%determine the axes of action of the set_edit interface
-% list_axes=get(handles.MenuAxes,'String');% list menu fields
-% index_axes=get(handles.MenuAxes,'Value');% selected string index
-% current_axes= list_axes{index_axes(1)} % selected string
-% eval(['haxes=UvData.' current_axes '.Axes']);
-% if isempty(haxes)|~ishandle(haxes)| ~isequal(get(haxes,'Type'),'axes')
-     haxes= findobj(huvmat,'Tag','axes3'); %main plotting axes as default
-%      set(handles.MenuAxes,'Value',1)
-% end
-AxeData=get(haxes,'UserData');
-%For vector field representation
-%NEW
-PlotHandles.VecScale=findobj(huvmat,'Tag','VecScale');
-PlotHandles.AutoVec=findobj(huvmat,'Tag','AutoVec');
-PlotHandles.checkyellow=findobj(huvmat,'Tag','checkyellow');
-PlotHandles.checkblack=findobj(huvmat,'Tag','checkblack');
-PlotHandles.col_vec=findobj(huvmat,'Tag','col_vec');
-PlotHandles.colcode1=findobj(huvmat,'Tag','colcode1');
-PlotHandles.colcode2=findobj(huvmat,'Tag','colcode2');
-PlotHandles.vec_col_bar=findobj(huvmat,'Tag','vec_col_bar');
-PlotHandles.slider1=findobj(huvmat,'Tag','slider1');
-PlotHandles.slider2=findobj(huvmat,'Tag','slider2');
-PlotHandles.max_vec=findobj(huvmat,'Tag','max_vec');
-PlotHandles.min_vec=findobj(huvmat,'Tag','min_vec');
-PlotHandles.AutoVecColor=findobj(huvmat,'Tag','AutoVecColor');
-PlotHandles.decimate4=findobj(huvmat,'Tag','decimate4');
-
-%vectors
-Vectors.VecScale=str2num(get(PlotHandles.VecScale,'String'));
-Vectors.AutoVec=get(PlotHandles.AutoVec,'Value');%automatic vector length
-Vectors.checkyellow=get(PlotHandles.checkyellow,'Value');
-Vectors.checkblack=get(PlotHandles.checkblack,'Value');
-Vectors.decimate4=get(PlotHandles.decimate4,'Value');% =1; for reducing the nbre of vectors
-menu_col=get(PlotHandles.col_vec,'String');
-menu_val=get(PlotHandles.col_vec,'Value');
-Vectors.CName=menu_col{menu_val}; %'ima_cor','black','white',...
-Vectors.colcode1=str2num(get(PlotHandles.colcode1,'String'));% first threshold for rgb, first value for'continuous' 
-Vectors.colcode2=str2num(get(PlotHandles.colcode2,'String'));% second threshold for rgb, last value (saturation) for 'continuous' 
-Vectors.option=get(PlotHandles.vec_col_bar,'Value'); % =1 (64 colors), =0 (3 colors)
-Vectors.min=get(PlotHandles.slider1,'Min');
-Vectors.max=get(PlotHandles.slider1,'Max');
-Vectors.auto=get(PlotHandles.AutoVecColor,'Value');% =1; thresholds scaling relative to min and max, =0 fixed thresholds
-PlotParam.Vectors=Vectors;
-
-[PlotType,ScalOut]= plot_field(AxeData,haxes,PlotParam,1);
Index: unk/src/mouse_motion.m
===================================================================
--- /trunk/src/mouse_motion.m	(revision 7)
+++ 	(revision )
@@ -1,289 +1,0 @@
-%'mouse_motion': permanently called by mouse motion over a figure (Callback for 'WindowButtonMotionFcn' of the figure)
-%-----------------------------------------------------------------------
-%
-% function mouse_motion(hObject,eventdata,handles)
-% activated by the command:
-% set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})
-% where hObject is the handle of the figure
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function mouse_motion(hObject,eventdata,handles)
-if ~exist('handles','var')
-    return
-end
-if ~isfield(handles, 'mouse_coord')
-    return
-end
-if ~ishandle(handles.mouse_coord)
-    return
-end
-proj_coord=get(handles.mouse_coord,'String');
-choice=get(handles.mouse_coord,'Value');
-if ~isempty(proj_coord); proj_coord=proj_coord{choice};else;proj_coord=[];end;
-test_create=0;%default
-test_edit=0;%default
-if isfield(handles,'VOLUME') % mouse_motion not applied to the uvmat figure, no object creation
-    test_create=get(handles.create,'Value');   
-end
-test_edit=isfield(handles,'edit') & get(handles.edit,'Value');% edit test for mouse shap: an arrow
-test_zoom=isfield(handles,'zoom')& get(handles.zoom,'Value');% edit test for mouse shap: an arrow 
-
-%find the current axe 'haxes' and display the current mouse position or uicontrol tag
-text_displ_1='';
-text_displ_2='';
-text_displ_3='';
-text_displ_4='';
-
-haxes=[];
-AxeData=[];%default
-mouse=[];
-
-pointershape='arrow';% default pointer is an arrow 
-
-xy_fig=get(gcbo,'CurrentPoint');% current point of the current figure (gcbo)
-hchild=get(gcbo,'Children');%handles of all objects in the current figure
-currentfig=gcbo;%store gcbo as variable currentfig
-% loop on all the objects in the current figure (selected by the last mouse click) 
-for ichild=1:length(hchild)
-    obj_pos=get(hchild(ichild),'Position');%position of the object
-    if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4);
-        htype=get(hchild(ichild),'Type');%type of the crrent child
-        %if the mouse is over an axis, look at the data
-        if isequal(htype,'axes')
-            haxes=hchild(ichild);
-            xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
-            mouse.X=xy(1,1);
-            mouse.Y=xy(1,2);
-            u_mouse=[];
-            v_mouse=[];
-            w_mouse=[];
-            A_mouse=[];
-            c_text=[];
-            f_text=[];
-            ff_text=[];     
-            ivec=[];
-            AxeData=get(haxes,'UserData');% data attached to the axis
-             if ~test_edit && ~test_zoom
-                 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
-%                % pointershape='crosshair';%set pointer with cross shape (default over axis)
-             end
-            if isfield(AxeData,'X') && isfield(AxeData,'Y') && isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
-                if ~isempty(AxeData.Mesh)
-                    flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/3) & AxeData.X>(xy(1,1)-AxeData.Mesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse
-                          (AxeData.Y<(xy(1,2)+AxeData.Mesh/3) & AxeData.Y>(xy(1,2)-AxeData.Mesh/3));%f
-                    ivec=find(flag_vec);% search the selected vector index ivec
-                    if length(ivec)>0 
-                        if ~test_create
-                            pointershape='arrow'; %mouse indicates  the detection of a vector
-                        end
-                        ivec=ivec(1);%choice the first selected vector if several are selected
-                        mouse.X=AxeData.X(ivec);
-                        mouse.Y=AxeData.Y(ivec);
-                        u_mouse=AxeData.U(ivec);%displacement
-                        v_mouse=AxeData.V(ivec);
-                        w_mouse=0; %default
-                        if isfield(AxeData,'W')&length(AxeData.W)>=ivec
-                            w_text=[',  w=' num2str(AxeData.W(ivec),3)];
-                        else
-                            w_text='';
-                        end
-                        if ~isfield(AxeData,'CName')
-                            AxeData.CName='C';%REVOIR
-                        end
-                        c_text=[', ' AxeData.CName '=' num2str(AxeData.C(ivec),3)];
-                        if isfield(AxeData,'F')&length(AxeData.F)>=ivec
-                            f_text=[',  f=' num2str(AxeData.F(ivec),3)];
-                        else
-                            f_text='';
-                        end
-                        if isfield(AxeData,'FF')&length(AxeData.FF)>=ivec
-                            ff_text=[',  ff=' num2str(AxeData.FF(ivec),3)];
-                        else
-                            ff_text='';
-                        end
-                    end
-                end
-            end
-            if isfield(AxeData,'Z')
-                mouse.Z=AxeData.Z; %generaliser au cas avec angle
-            end
-            if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
-                mouse.Z=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
-            end
-            testscal= isfield(AxeData,'A')& isfield(AxeData,'AX')& isfield(AxeData,'AY');%test the existence of an image (or scalar represented by an image)
-               if testscal
-                   testscal=~isempty(AxeData.A)&~isempty(AxeData.AX)& ~isempty(AxeData.AY);
-               end
-            if testscal%test the existence of an image (or scalar represented by an image)
-                nxy=size(AxeData.A);
-                MaxAY=max(AxeData.AY(1),AxeData.AY(end));
-                MinAY=min(AxeData.AY(1),AxeData.AY(end));
-                if (xy(1,1)>AxeData.AX(1))&(xy(1,1)<AxeData.AX(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY)
-                    indx0=1+round((nxy(2)-1)*(xy(1,1)-AxeData.AX(1))/(AxeData.AX(end)-AxeData.AX(1)));% index x of pixel
-                    indy0=1+round((nxy(1)-1)*(xy(1,2)-AxeData.AY(1))/(AxeData.AY(end)-AxeData.AY(1)));% index y of pixel
-                    if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1)
-                        A_mouse=AxeData.A(indy0,indx0,:);
-                    end
-                end
-            end
-            %coordinate transform if proj_coord differs from menu_coord 
-            if isfield(AxeData,'CoordType')
-                  mouse.CoordType=AxeData.CoordType;
-            end
-            if isfield(AxeData,'CoordUnit')
-                  mouse.CoordUnit=AxeData.CoordUnit;
-            end
-            if isfield(mouse,'CoordType') &~isequal(mouse.CoordType,proj_coord)
-                huvmat=findobj(allchild(0),'Tag','uvmat');%find the uvmat interface handle
-                UvData=get(huvmat,'UserData'); %coord transformed stored in the uvmat interface, updated by file input
-                if isfield(AxeData,'CoordType')
-                    mouse.CoordType=AxeData.CoordType;
-                end
-                if isfield(AxeData,'dt')
-                    mouse.dt=AxeData.dt;
-                end
-%                 if ~isempty(z_mouse)
-%                     mouse.Z=z_mouse;
-%                 end
-                if length(ivec)>0 %& isfield(AxeData,'dt')                    
-                      mouse.U=u_mouse; 
-                      mouse.V=v_mouse;
-                end
-                mouse=feval(proj_coord,mouse,UvData);%apply transform proj_coord to the position
-                if length(ivec)>0%& isfield(AxeData,'dt')
-                     u_mouse=mouse.U;
-                     v_mouse=mouse.V;
-                end
-            end  
-            if isfield(mouse,'CoordType') 
-                if isequal(mouse.CoordType,'px')
-                    mouse.CoordUnit='px';
-                end
-            else
-                mouse.CoordUnit='';%default      
-            end      
-            text_displ_1=['x=' num2str(mouse.X,4) ',y=' num2str(mouse.Y,4)];
-            if isfield(mouse,'Z')&~isempty(mouse.Z)
-                text_displ_1=[text_displ_1 ',z=' num2str(mouse.Z,3)];
-            end
-            if isfield(mouse,'CoordUnit')
-                 text_displ_1=[text_displ_1 ' ' mouse.CoordUnit];
-            end
-            if ~isempty(ivec)
-                text_displ_4=['vec#=' num2str(ivec)];
-            end
-            if ~isempty(u_mouse)
-                text_displ_3=['u=' num2str(u_mouse,3) ',v=' num2str(v_mouse,3) w_text ];
-                if  isfield(mouse,'CoordUnit')
-                    if isequal(mouse.CoordUnit,'px')
-                        text_displ_3=[text_displ_3 '  ' mouse.CoordUnit];
-                    elseif isfield(AxeData,'TimeUnit') 
-                        text_displ_3=[text_displ_3 '  ' mouse.CoordUnit '/' AxeData.TimeUnit];
-                    end
-                end
-                text_displ_4=[text_displ_4 c_text f_text ff_text];
-            end
-           
-            if ~isempty(A_mouse)
-                text_displ_2=['A=' num2str(double(A_mouse)) ',i='  num2str(indx0) ',j=' num2str(indy0)];
-            end
-        elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
-            text_displ_1=get(hchild(ichild),'Tag');
-        end
-    end
-end
-set(handles.text_display_1,'String',text_displ_1);
-set(handles.text_display_2,'String',text_displ_2);
-set(handles.text_display_3,'String',text_displ_3);
-set(handles.text_display_4,'String',text_displ_4);
-
-%%%%%%%%%%%%%%%%%
-%create or modify an object
-if isfield(AxeData,'CurrentObject') & ishandle(AxeData.CurrentObject) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off')
-    PlotData=get(AxeData.CurrentObject,'UserData');
-    huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
-    if ~isempty(huvmat)
-        UvData=get(huvmat,'UserData');
-        if ~isfield(PlotData,'IndexObj')
-             return
-        end
-        ObjectData=UvData.Object{PlotData.IndexObj};
-        XYData=AxeData.CurrentOrigin;
-        if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
-           if isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|isequal(ObjectData.Style,'polygon')|isequal(ObjectData.Style,'points')
-              xy(1,3)=0;
-              ObjectData.Coord=[ObjectData.Coord ;xy(1,:)];
-             % ObjectData.Coord(end,:)=xy(1,:);
-           elseif isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'ellipse')|isequal(ObjectData.Style,'volume')
-              ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
-              ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
-              ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
-              ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
-           elseif isequal(ObjectData.Style,'plane') %case of 'plane'
-                DX=(xy(1,1)-ObjectData.Coord(1,1));
-                DY=(xy(1,2)-ObjectData.Coord(1,2));
-                ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
-                if isfield(ObjectData,'RangeX')
-                    XMax=sqrt(DX*DX+DY*DY);
-                    if XMax>max(ObjectData.RangeX)
-                        ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
-                    end
-                end
-           end
-            plot_object(ObjectData,[],AxeData.CurrentObject,'m');
-            pointershape='crosshair';
-        elseif  isequal(AxeData.Drawing,'translate')
-            DX=xy(1,1)-XYData(1);%translation from initial position
-            DY=xy(1,2)-XYData(2);
-            ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
-            ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
-            plot_object(ObjectData,[],AxeData.CurrentObject,'m');
-            pointershape='fleur';
-        elseif  isequal(AxeData.Drawing,'deform')
-            ind_move=AxeData.CurrentIndex;
-            ObjectData.Coord(ind_move,1)=xy(1,1);
-            ObjectData.Coord(ind_move,2)=xy(1,2);
-            plot_object(ObjectData,[],AxeData.CurrentObject,'m');
-            pointershape='circle';
-        end
-    end
-end    
-%%%%%%%%%%%%%
-%draw a rectangle if no object creation is selected
-if ~isempty(haxes) & isfield(AxeData,'Drawing')& isequal(AxeData.Drawing,'zoom')& isfield(AxeData,'CurrentOrigin')...
-        & isequal(get(gcf,'SelectionType'),'normal')% 
-   xy_rect=AxeData.CurrentOrigin;
-   if ~isempty(xy_rect) 
-        rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate
-        rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate
-        rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width
-        rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height
-        if rect(3)>0 & rect(4)>0
-            if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom)
-                set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position
-            else
-                AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');
-                set(haxes,'UserData',AxeData)
-            end
-        end
-   end
-end
-if test_zoom
-    pointershape='arrow';
-end
-set(currentfig,'Pointer',pointershape);
Index: unk/src/mouse_up.m
===================================================================
--- /trunk/src/mouse_up.m	(revision 7)
+++ 	(revision )
@@ -1,321 +1,0 @@
-%'mouse_up': function  activated when the mouse button is released
-%----------------------------------------------------------------
-% function mouse_up(ggg,eventdata,handles)
-% activated by the command:
-% set(hObject,'WindowButtonUpFcn',{'mouse_up'}), 
-% where hObject is the handle of the figure
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function mouse_up(ggg,eventdata,handles)
-MouseAction='none'; %default
-zoomstate=0;%default
-if ~exist('handles','var')
-   handles=get(gcbo,'UserData');
-end
-huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
-if ~isempty(huvmat)
-    hhuvmat=guidata(huvmat);
-    UvData=get(huvmat,'UserData');
-    if isfield(UvData,'MouseAction')
-        MouseAction=UvData.MouseAction;% set the mouse action (edit, create objects...)
-    end
-    zoomstate=get(hhuvmat.zoom,'Value');
-end
-if isequal(MouseAction,'calib') && ~zoomstate
-    return
-end
-currentfig=gcbo;
-AxeData=get(gca,'UserData');
-currentaxes=gca; %store the current axes handle
-test_drawing=0;%default
-
-%finalize the fabrication or the translation/deformation of an object and plot the corresponding projected field
-if ~isempty(huvmat) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off') & isfield(AxeData,'CurrentObject')...
-           & ishandle(AxeData.CurrentObject)
-    xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
-    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object  
-    IndexObj=PlotData.IndexObj;
-    ObjectData=UvData.Object{IndexObj};    
-    if isequal(AxeData.Drawing,'translate')
-        XYData=AxeData.CurrentOrigin;
-        DX=xy(1,1)-XYData(1);%translation from initial position
-        DY=xy(1,2)-XYData(2);
-        ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
-        ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
-    elseif isequal(AxeData.Drawing,'deform')
-        ind_move=AxeData.CurrentIndex;
-        ObjectData.Coord(ind_move,1)=xy(1,1);
-        ObjectData.Coord(ind_move,2)=xy(1,2);
-    else   %creating object
-        if isequal(ObjectData.Style,'line')||isequal(ObjectData.Style,'polyline')||...
-                isequal(ObjectData.Style,'polygon')||isequal(ObjectData.Style,'points')
-            if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==3
-              xy(1,3)=AxeData.ObjectCoord(1,3); % z coordinate of the mouse: to generalise ...
-            else
-                 xy(1,3)=0; % z coordinate set to 0 by default
-            end
-            if ~isequal(ObjectData.Coord,xy(1,:))
-                ObjectData.Coord=[ObjectData.Coord ;xy(1,:)];% append the coordiantes marked by the mouse to the eobject
-            end
-        elseif isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'ellipse')||isequal(ObjectData.Style,'volume')
-            XYData=AxeData.CurrentOrigin;
-            ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
-            ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
-            ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
-            ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
-        elseif isequal(ObjectData.Style,'plane') %case of 'plane'
-            DX=(xy(1,1)-ObjectData.Coord(1,1));
-            DY=(xy(1,2)-ObjectData.Coord(1,2));
-            ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
-            if isfield(ObjectData,'RangeX')
-                XMax=sqrt(DX*DX+DY*DY);
-                if XMax>max(ObjectData.RangeX)
-                    ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
-                end
-            end
-        end
-    end
-    %set(AxeData.CurrentObject,'UserData',ObjectData); %update the object properties
-    if isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'ellipse')
-        NbDefPoint=1;  
-    elseif isequal(ObjectData.Style,'line')|| isequal(ObjectData.Style,'plane');
-        NbDefPoint=2; 
-    else
-         NbDefPoint=3;
-    end
-    
-    %show object coordinates in the GUI set_object
-    h_set_object=findobj(allchild(0),'Name','set_object');
-    h_XObject=findobj(h_set_object,'Tag','XObject');
-    h_YObject=findobj(h_set_object,'Tag','YObject');
-    h_ZObject=findobj(h_set_object,'Tag','ZObject');
-    set(h_XObject,'String',num2str(ObjectData.Coord(:,1),4)); 
-    set(h_YObject,'String',num2str(ObjectData.Coord(:,2),4)); 
-    set(h_ZObject,'String',num2str(ObjectData.Coord(:,3),4));
-    if NbDefPoint<=2 || isequal(get(currentfig,'SelectionType'),'alt') ||...
-              isequal(AxeData.Drawing,'translate') || isequal(AxeData.Drawing,'deform');%stop drawing
-        AxeData.CurrentOrigin=[]; %suppress the current origin
-       if isequal(ObjectData.Style,'line') && size(ObjectData.Coord,1)<=1
-           AxeData.Drawing='off';
-           set(currentaxes,'UserData',AxeData);
-            return % line needs at leqst two points
-       end
-       if  ~isempty(ObjectData)
-             testmask=0;
-             hmask=findobj(huvmat,'Tag','makemask');
-             if ~isempty(hmask)
-                testmask=get(hmask,'Value');
-             end
-             if testmask
-                 PlotHandles=[];%do not project data on the object during mask creation
-             else
-                 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
-             end
-            AxeData.hset_object=set_object(ObjectData,PlotHandles);% call the set_object interface ,*
-            UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,PlotHandles); 
-            %ObjectData=update_obj(UvData,IndexObj,ObjectData,PlotHandles); 
-            if  isfield(UvData.Object{IndexObj},'PlotParam')
-                write_plot_param(PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object
-            end              
-            set(hhuvmat.create,'Value',0);% set to 'off' the button for object creation
-            set(hhuvmat.create,'BackgroundColor',[0 1 0]);% paint the creation button in green
-            set(hhuvmat.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
-            set(hhuvmat.edit,'Value',1);%
-            set(hhuvmat.edit,'Enable','on');%
-            set(hhuvmat.MenuEdit,'Enable','on');%
-            set(hhuvmat.MenuEdit,'Enable','on');%
-            set(hhuvmat.MenuObject,'Enable','on');%
-            UvData.MouseAction='edit_object'; % set the edit button to 'on'
-        end
-    else
-       AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the new current origin
-       test_drawing=1;%allow continuation of drawing object
-       UvData.Object{IndexObj}=ObjectData;
-    end
-    hother=findobj('Tag','deformpoint');%find all the deformpoints
-    set(hother,'Color','b');%reset all the deformpoints in 'blue' 
-else
-    test_drawing=0;
-end
-
-%creation of a new zoom plot
-test_replot=0;
-if isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
-%         FigData=get(currentfig,'UserData');
-        hparentfig=currentfig;
-        %open or update a new zoom figure if a rectangle has been drawn
-        if ishandle(currentaxes);
-            if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)
-                PosRect=get(AxeData.CurrentRectZoom,'Position');
-                if isfield(AxeData,'CurrentVec') & ishandle(AxeData.CurrentVec)
-                    delete(AxeData.CurrentVec)
-                end
-                %update the axes UvData.Plane2 if it exists, else create it
-%                 if isfield (UvData,'Plane2') & ishandle(UvData.Plane2.Fig)%if the second plan plotting axis already exists
-%                     hfig2=UvData.Plane2.Fig;
-%                     if isequal(gcf,hfig2)%if we are already on the secondary figure
-%                         test_replot=1;
-%                     else
-%                         figure(hfig2)%set hfig2 as the current figure
-%                         clf; %erase axes
-%                     end
-%                 else
-                    hfig2=figure;%create new figure
-                    set(hfig2,'name','zoom')
-                    set(hfig2,'Units','normalized')
-                    set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
-%                     UvData.Plane2.Fig=hfig2; 
-                    map=colormap(currentaxes);
-                    colormap(map);%transmit the current colormap to the zoom fig
-                    get(handles.RootFile,'String')
-%                 end
-                set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
-                if test_replot==0
-                    set(hfig2,'Unit','normalized')
-                    set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function
-                    set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function
-                    set(hfig2,'WindowButtonDownFcn',{@mouse_down})%set mouse click action function
-                    set(hfig2,'WindowButtonUpFcn',{@mouse_up,handles})  
-                    set(hfig2,'DeleteFcn',{@close_fig,AxeData.CurrentRectZoom,'zoom'})
-                    set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig
-                    AxeData.ZoomAxes=copyobj(currentaxes,hfig2); %copy the current graph axes to the zoom figure 
-                    figure(hfig2)
-                    set(AxeData.ZoomAxes,'Position',[0.1300    0.1100    0.7750    0.8150])% standard axes position on a figure
-                    hcol=findobj(hparentfig,'Tag','Colorbar'); %look for colorbar axes
-                    if ~isempty(hcol)             
-                        hcol_new=colorbar;
-                        YTick=get(hcol,'YTick');
-                        YTicklabel=get(hcol,'Yticklabel');  
-                        colbarlim=get(hcol,'YLim'); 
-                        newcolbarlim=get(hcol_new,'YLim');
-                        scale_bar=(newcolbarlim(2)-newcolbarlim(1))/(colbarlim(2)-colbarlim(1));                
-                        YTick_rescaled=newcolbarlim(1)+scale_bar*(YTick-colbarlim(1));
-                        set(hcol_new,'YTick',YTick_rescaled);
-                        set(hcol_new,'Yticklabel',YTicklabel);
-                    end
-                end
-                if ishandle(AxeData.ZoomAxes)
-                    hnew_rect=findobj(AxeData.ZoomAxes,'Tag','rect_zoom');
-                    if ~isempty(hnew_rect)
-                        delete(hnew_rect);
-                        ChildAxeData=get(AxeData.ZoomAxes,'UserData');
-                        ChildAxeData.CurrentRectZoom=[]; % no rect zoom in the new window
-                        ChildAxeData.Drawing='off';
-                        ChildAxeData.ParentRect=AxeData.CurrentRectZoom;%set the rectangle as a 'parent' associated to the new axes
-                        set(AxeData.ZoomAxes,'UserData',ChildAxeData);%update the AxeData of the new axes
-                       % UvData.TopFig=hfig2;%put the new fig to the top of the stack for uvmat
-        %                 set(huvmat,'UserData',UvData)
-                        set(AxeData.ZoomAxes,'Xlim',[PosRect(1) PosRect(1)+PosRect(3)])
-                        set(AxeData.ZoomAxes,'Ylim',[PosRect(2) PosRect(2)+PosRect(4)])
-                    end
-                end
-            end
-        end
-end
-%zoom in if no new figure is created
-if zoomstate
-     if  isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
-        %zoom(2)% zoom in by a factor of 2
-        alpha=0.5; %zoom factor (zoom in by a factor 2)
-        xlim=get(currentaxes,'XLim');
-        xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2;
-        xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2;
-        set(currentaxes,'XLim',xlim_new)
-        ylim=get(currentaxes,'YLim'); 
-        ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2;
-        ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2;
-        set(currentaxes,'YLim',ylim_new)
-        if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
-            hparentrect=AxeData.ParentRect;
-            xlim=get(currentaxes,'XLim');
-            ylim=get(currentaxes,'YLim');
-            rect([1 2])=[xlim(1) ylim(1)];
-            rect([3 4])=[xlim(2)-xlim(1) ylim(2)-ylim(1)];
-            set(hparentrect,'Position',rect)
-        end
-
-     elseif isequal(get(currentfig,'SelectionType'),'alt'); %if right button has been pressed
-            %zoom(0.5)% zoom out by a factor of 2
-            alpha=2; %zoom factor (zoom out by a factor 2)
-            xlim=get(currentaxes,'XLim');
-            xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2;
-            xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2;
-            ylim=get(currentaxes,'YLim');
-            ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2;
-            ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2;
-            set(currentaxes,'XLim',xlim_new)
-            set(currentaxes,'YLim',ylim_new)
-            %test whther zoom out is operating (to inactivate AxedAta
-            if ~isfield(AxeData,'CurrentXLim')| ~isequal(xlim,AxeData.CurrentXLim)
-                AxeData.CurrentXLim=xlim;%
-            end
-            if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
-                hparentrect=AxeData.ParentRect;
-                xlim=get(currentaxes,'XLim');
-                ylim=get(currentaxes,'YLim');
-                rect([1 2])=[xlim(1) ylim(1)];
-                rect([3 4])=[xlim(2)-xlim(1) ylim(2)-ylim(1)];
-                set(hparentrect,'Position',rect)
-            end
-      end
-end
-
-%display the data of the current object selected with the mouse right click
-if isequal(get(currentfig,'SelectionType'),'alt') && ~zoomstate && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
-    hother=findobj('Tag','proj_object');%find all the proj objects
-    nbselect=0;
-    %test the existence of selected objects:
-    for iproj=1:length(hother);
-        iselect=isequal(get(hother(iproj),'Selected'),'on');%reset all the proj objects in 'blue' by default
-        nbselect=nbselect+iselect;
-    end
-    hother=findobj('Tag','proj_object','Type','line');%find all the proj objects
-    set(hother,'Color','b');%reset all the proj objects in 'blue' by default
-    set(hother,'Selected','off')
-    hother=findobj('Tag','proj_object','Type','rectangle');
-    set(hother,'EdgeColor','b');
-    set(hother,'Selected','off')
-    hother=findobj('Tag','proj_object','Type','patch');
-    set(hother,'FaceColor','b');   
-    if isequal(get(gco,'Type'),'image')
-        currentobj=get(gco,'parent');%parent axes of the image
-    else 
-        currentobj=gco;%default
-    end
-    if ((nbselect==0) && isequal(get(currentobj,'Type'),'axes')) || isequal(currentobj,huvmat)
-        global CurData
-        CurData=get(currentobj,'UserData');
-        %plot_text(CurData)
-        %get_field([],CurData);
-        evalin('base','global CurData')%make CurData global in the workspace
-        objtype=get(currentobj,'Type');
-        display(['UserData of ' objtype ':'])
-        evalin('base','CurData') %display CurData in the workspace
-        commandwindow
-    end
-end
-if test_drawing==0
-        AxeData.Drawing='off';%stop current drawing action
-end
-set(currentaxes,'UserData',AxeData);
-if ~isempty(huvmat)
-    set(huvmat,'UserData',UvData);
-end
-
-    
-
Index: unk/src/name2display.m
===================================================================
--- /trunk/src/name2display.m	(revision 7)
+++ 	(revision )
@@ -1,205 +1,0 @@
-%'name2display': extracts the root name and field numbers from an input filename 
-%--------------------------------------------------------------------
-%[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
-%
-%OUTPUT:
-%filebasesub: filename without appendix
-%field_count: string for the first number i
-%str2: string for the second number i (only for .nc files)
-%str_a: string for the first number j
-%str_b:string for the second number j (only for .nc files)
-%ext: file extension
-%nom_type: char chain characterizing the file nomenclature: with values
-%   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
-%   nom_type='*':constant name for a file representing a series (e.g. avi movie)
-%   nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
-%   nom_type='#', series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
-%   nom_type='_i_j': matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
-%   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc') 
-%   nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
-%   nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
-%   nom_type='#a','#A", with a numerical index and an index letter(e.g.'aa045b.png') (lower or upper case)
-%   nom_type='raw_SMD', same as '#' but with no extension ext='', OBSOLETE
-%   nom_type='#_ab', from pairs of '#' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by '_i_j1-j2')
-%subdir: name of the subdirectory for netcdf files
-%
-%INPUT:
-%fileinput: complete name of the file, including path
-
-function [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
-% siz=length(fileinput);
-% indcur=siz;
-% default values:
-% test_=0;
-field_count='';%character string
-str2='';
-str_a='';
-str_b='';
-% ext='';
-nom_type='';
-subdir='';
-        %select file extension
-[RootPath,RootFile,ext]=fileparts(fileinput);
-indcur=length(RootFile);% nbre of characters in fileraw
-
-        %recognize the name form
-filerawascii=double(RootFile);%ascci code
-val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
-indsel=find(val);% character indices of non numerical characters
-filelit=RootFile(indsel);% fileraw name with numbers removed
-nbchar=length(indsel);
-if nbchar<4% put '*' before the name (remove at the end)
-   prefilelit(1:4-nbchar)='*';%insert 3_nbchar '*' in the file name
-   filelit=[prefilelit filelit];
-   indsel=[1:4-nbchar indsel+4-nbchar];
-   RootFile=[prefilelit RootFile];
-   indcur=indcur+4-nbchar;
-end
-separ3=indsel(end);% index of last non numerical character in fileraw
-separ2=indsel(end-1);% index of previous non numerical character
-separ1=indsel(end-2);
-separ0=indsel(end-3);
-num1='';num2='';num3='';
-if separ1>=separ0+1,num0=RootFile(separ0+1:separ1-1);end
-if separ2>=separ1+1,num1=RootFile(separ1+1:separ2-1);end
-if separ3>=separ2+1,num2=RootFile(separ2+1:separ3-1);end
-if indcur>=separ3+1,num3=RootFile(separ3+1:indcur);end
-last_str=RootFile(indcur);%last character in fileraw
-last=double(last_str);%corresponding ascii code
-penult=double(RootFile(indcur-1));%ascii code of the penultimate character
-testsub=0; %default 
-if strcmpi(ext,'.avi')
-     nom_type='*';
-      %case of old image nomenclature
-elseif (strcmp(ext,'.png') || strcmp(ext,'')) &&  penult >= 48 && penult <= 57 && (last < 48 || last > 57)
-    % if the penultimate character is a number and the last a letter
-    % search the appendix a,b,c,
-    str_a=last_str; %put appendix a,b,c....
-    indcur=indcur-1;
-    if strcmp(ext,'.png'), nom_type='#a'; end
-    if strcmp(ext,''), nom_type='raw_SMD'; end      
-    num=1;count=0; % extract the numerical appendix
-    while num==1;
-        filascii=double(RootFile(indcur));
-        if (48>filascii)||(filascii>57); % select the non-numerical characters
-            num=0; 
-        else
-            indcur=indcur-1; count=count+1;
-        end
-    end
-    if count~=0             
-            field_count=RootFile(indcur+1:indcur+count);% set the selected field number
-    end
-elseif  penult >= 48 && penult <= 57  && (last <= 66 && last >= 65)% PCO camera Toulouse, end with A or B (NEW)
-    % if the penultimate character is a number and the last a letter
-    % search the appendix a,b,c,
-    str_a=last_str; %put appendix a,b,c....
-    indcur=indcur-1;
-    nom_type='#A';   
-    num=1;count=0; % extract the numerical appendix
-    while num==1;
-        filascii=double(RootFile(indcur));
-        if (48>filascii)||(filascii>57); % select the non-numerical characters
-            num=0; 
-        else
-            indcur=indcur-1; count=count+1;
-        end
-    end
-    if count~=0             
-            field_count=RootFile(indcur+1:indcur+count);% set the selected field number
-    end   
-    indcur=indcur-1;
-elseif strcmp(filelit(end-2:end),'-_-_')%new  nomenclature appendix num1-num2_num_a-num_b
-    field_count=num0;
-    str2=num1;
-    str_a=num2;
-    str_b=num3;
-    nom_type='_i1-i2_j1-j2';
-    testsub=1;
-    indcur=separ0-1;
-elseif strcmp(filelit(end-2:end),'_-_')%new  nomenclature appendix num1-num2_num_a
-    field_count=num1;
-    str2=num2;
-    str_a=num3;
-    nom_type='_i1-i2_j';
-    testsub=1;
-    indcur=separ1-1;
-elseif strcmp(filelit(end-2:end),'__-')%new  nomenclature appendix num1_num2-num2 
-    indcur=separ1-1;
-    field_count=num1;
-    str_a=num2;
-    str_b=num3;
-    nom_type='_i_j1-j2';
-    testsub=1;
-elseif strcmp(filelit(end-1:end),'_-')
-    indcur=separ2-1;
-    field_count=num2;
-    str2=num3;
-    str_a='';
-    nom_type='_i1-i2';
-    testsub=1;
-elseif strcmp(filelit(end-1:end),'__')
-    indcur=separ2-1;
-    field_count=num2;
-    str2='';
-    str_a=num3;
-    nom_type='_i_j';
-elseif strcmp(filelit(end),'_')
-    indcur=separ3-1;
-%     field_count=num3;
-    str2='';
-    str_a='';
-    %detect zeros before the number
-%     count=0; % extract the numerical appendix
-    if strcmp('0',RootFile(separ3+1)); % select the non-numerical characters
-        nom_type=['_%0' num2str(length(RootFile(separ3+1:end))) 'd'];
-    else
-        nom_type='_i';
-    end  
-    field_count=RootFile(separ3+1:end);% set the selected field number'%03d' 
-elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d
-    last=RootFile(indcur-1:indcur);
-    if isequal(length(last),2) && double(last(1)) >= 97 && double(last(1)) <= 122 ...% = 1 for letters
-            && double(last(2)) >= 97 && double(last(2)) <= 122
-          str_a=last(1);%put appendix a,b,c, ou d
-          str_b=last(2);%put appendix a,b,c, ou d
-%           indcur=indcur-3;
-          separ0=indsel(end-3);
-        num0=RootFile(separ0+1:separ1-1);
-        field_count=num0;
-        indcur=separ0;
-        nom_type='#_ab';
-        testsub=1;
-    end
-%search for other names with counter
-else
-    if length(ext)>1     
-            num=1;count=0; % extract the numerical appendix
-            while num==1;
-                filascii=double(RootFile(indcur));
-                if (48>filascii)||(filascii>57); % select the non-numerical characters
-                    num=0; 
-                else
-                    indcur=indcur-1; count=count+1;
-                end
-            end
-            if count~=0   
-                field_count=RootFile(indcur+1:indcur+count);% set the selected field number'%03d'
-                if isequal(field_count(1),'0')
-                    nbfigures=length(field_count);
-                    nom_type=['%0' num2str(nbfigures) 'd'];
-                else
-                    nom_type='#';
-                end
-            end
-    end
-end
-            %select the root name in the file_input window
-RootFile=RootFile(1:indcur);
-if nbchar<4% put '*' before the name (remove at the end)
-   RootFile(1:4-nbchar)=[];
-end
-if testsub
-    [RootPath,subdir,extdir]=fileparts(RootPath);
-    subdir=[subdir extdir];
-end
Index: unk/src/name_generator.m
===================================================================
--- /trunk/src/name_generator.m	(revision 7)
+++ 	(revision )
@@ -1,284 +1,0 @@
-%'name_generator': creates a file name from a root name and indices. 
-%---------------------------------------------------------------------
-% [filename,idetect,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=...
-            % name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir);
-%---------------------------------------------------------------------           
-% This function detects the existence the constructed file name and it can
-% find indices according to file existence if they are not specified
-%%rmq: this function is related to the reverse functions display2name and name2diplay 
-%---------------------------------------------------------------------
-% OUTPUT:
-%filename: string representing the file name (including path)
-%idetect: =1 if the file is detected, 0 otherwise
-%num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out: index numbers and subdirectory detected 
-             %for free input (= to the corresponding input indices when comp_input=1)
-%---------------------------------------------------------------------
-% INPUT:
-% 'filebase': the root name, 
-% 'num_i1: first labelling index i 
-% 'num_j1', first labelling index j
-% 'ext': file name extension (e.g. '.png' or '.nc')
-% 'nom_type': string defining the kind of nomenclature used:
-     %nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
-     %nom_type='*': the same  file [filebase ext] contains successive fields (ex avi movies)
-     %nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
-     %nom_type='#' series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
-     %nom_type='_i_j' matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
-     %nom_type='_i1-i2' from pairs from a single index (e.g. 'aa_45-47.nc') 
-     %nom_type='_i_j1-j2'pairs of j indices (e.g. 'aa_45_2-3.nc')
-     %nom_type='_i1-i2_j' pairs of i indices (e.g. 'aa_45-46_2.nc')
-     %nom_type='#a','#A' with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j')
-     %nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif'
-     %nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif'
-     %nom_type='raw_SMD', same as '#a' but with no extension ext='', OBSOLETE
-     %nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
-     %nom_type='%3dab' from pairs of '%3da' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
-% A REVOIR: 'comp_input'=1 for writting =0 for reading ,  'comp_input'(for nom_type involving index pairs (e.g. netc))
-     %comp_input=1: the index pair is imposed, 
-     %comp_input=0: the index pair is automatically searched, choosing the most recent  file in case of multiple choice
-% 'num_i2': second index i (for nom_type involving index pairs (e.g. netc))
-% 'num_j2': second index j (for nom_type involving index pairs (e.g. netc))
-% 'subdir': (used for nom_type=netc...) string representing the name of the subdirectory 'subdir' containing file. 
-     %subdir='': no subdirectory, 
-     %subdir='?', the file is first searched with no subdirectory, then in the most recently modified subdirectory if not detected.
-
-% A FAIRE: si comp_inpu=0, si _i_j n'existe pas, chercher _i, 
-function [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=...
-           name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir);
-sizf=size(filebase);
-if (~ischar(filebase)||~isequal(sizf(1),1)),filebase='';end
-if ~ischar(ext),ext='';end
-% filename=[filebase ext];%default
-idetect=0;
-if ~exist('num_i1','var') || isequal(num_i1,[]) 
-    num_i1=1; %default
-end
-if ~exist('num_j1','var') || isequal(num_j1,[]) 
-    num_j1=1; %default
-end
-if ~exist('num_i2','var') || isequal(num_i2,[]) 
-    num_i2=num_i1; %default
-end
-if ~exist('subdir','var')|| isempty(subdir) 
-    subdir='' ; %default
-end
-%detection of mask or mean: filebase of the form [root '_' xxx 'm$$$'] with xxx a number and $$$ three characters
-% if length(filebase)>4 & filebase(end-3)=='m';
-%     basedouble=double(filebase);
-%     val=(48>basedouble)|(basedouble>57);% select the non-numerical characters
-%     i=length(filebase)-4;
-%     while val(i)==0 & i>0
-%         i=i-1;
-%     end
-%     nbslice=str2num(filebase(i+1:end-4));
-%     if ~isequal(nbslice,[]) 
-%         num_i1=mod(num_i1-1,nbslice)+1; %take the rest in the division
-%         if isequal(nom_type,'png_old')|isequal(nom_type,'#a')
-%             num_j1=1;% mask name must end by 'a'
-%         end
-%     end
-% end
-test_pairs=isequal(nom_type,'netc_old')| isequal(nom_type,'netc_2D') | isequal(nom_type,'netc_3D')| isequal(nom_type,'_i1-i2_j1-j2')| ...
-  isequal(nom_type,'netc_series')| isequal(nom_type,'#_ab')| isequal(nom_type,'_i_j1-j2')| isequal(nom_type,'_i1-i2_j')| isequal(nom_type,'_i1-i2');
-test_2D= isequal(nom_type,'netc_old') |isequal(nom_type,'netc_2D')|isequal(nom_type,'#_ab') |isequal(nom_type,'_i_j1-j2');
-test_3D=isequal(nom_type,'netc_3D') |isequal(nom_type,'netc_series')| isequal(nom_type,'_i1-i2_j')| isequal(nom_type,'_i1-i2');
-if isequal(nom_type,'series_i')| isequal(nom_type,'_i');
-        filename=[filebase '_' num2str(num_i1) ext];
- %       idetect=(exist(filename,'file')==2); 
-elseif length(nom_type)==5 && isequal(nom_type(1:3),'_%0')&& isequal(nom_type(5),'d');
-        filename=[filebase '_' num2str(num_i1,nom_type(2:5)) ext];
- %       idetect=(exist(filename,'file')==2); 
-elseif isequal(nom_type,'series_i_j')| isequal(nom_type,'_i_j')
-        filename=[filebase '_' num2str(num_i1) '_' num2str(num_j1) ext];
- %       idetect=(exist(filename,'file')==2);
-elseif isequal(nom_type,'png_old')| isequal(nom_type,'#a')| isequal(nom_type,'#A')
-        filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type) ext];
-   %     idetect=(exist(filename,'file')==2);
-elseif  length(nom_type)>=5 & isequal(nom_type(2:3),'%0') & isequal(nom_type(5),'d')  %isequal(nom_type,'_%04dA') %camera PCO Toulouse
-        filename=[filebase nom_type(1) num2str(num_i1,nom_type(2:4)) num2stra(num_j1,nom_type) ext];
- %       idetect=(exist(filename,'file')==2);         
-elseif isequal(nom_type,'raw_SMD') %suffix a, b, c without extension
-        filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type)];
-%        idetect=(exist(filename,'file')==2);
-elseif isequal(nom_type,'ima_num')| isequal(nom_type,'#')
-        filename=[filebase num2str(num_i1) ext];
-%        idetect=(exist(filename,'file')==2);
-elseif length(nom_type)>=4 & isequal(nom_type(1:2),'%0') & isequal(nom_type(end),'d')
-            filename=[filebase num2str(num_i1,nom_type) ext]; %test number with a 0 before
-%            idetect=(exist(filename,'file')==2);
-
-%case of derived file indexing (e.g. netcdf files)
-elseif test_pairs
-    if (~exist('num_j2','var')| isequal(num_j2,[])) & test_2D
-          num_j2=num_j1+1; %default if num_j2 undefined
-    end
-    if (~exist('num_i2','var')| isequal(num_i2,[])) & test_3D
-          num_i2=num_i1+1; %default if num_i2 undefined
-    end
-    filebasesub=filebase;
-    % get the root name filebasesub for the netcdf files
-    if  ~isequal(subdir,'') && ~isequal(subdir,'?') 
-            [Path,Name]=fileparts(filebase);
-            filebasesub=fullfile(Path,subdir,Name);
-    end
-     %inexistant pair if num_i2=0 or num_j2=0
-    if isequal(num_i2,0)
-        filename=[filebasesub '*-*_' num2str(num_i1) ext];
-        return
-    end
-    if isequal(num_j2,0)
-        filename=[filebasesub '_' num2str(num_i1) '_*-*' ext];
-        return
-    end
-    % case of an imposed image pair (comp_input=1)
-    if  (exist('comp_input','var') & isequal(comp_input,1)) 
-            if isequal(nom_type,'netc_old')|isequal(nom_type,'#_ab')
-                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
-                    filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) ext];
-                else
-                    filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) num2stra(num_j2,nom_type) ext];
-                end
-            elseif isequal(nom_type,'netc_2D')|isequal(nom_type,'_i_j1-j2')
-                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
-                    filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) ext];
-                else
-                    filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) '-' num2str(num_j2) ext];
-                end
-            elseif isequal(nom_type,'netc_3D') || isequal(nom_type,'_i1-i2_j')
-                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
-                      filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) ext];
-                else
-                    filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) '_' num2str(num_j1) ext];
-                end
-            elseif isequal(nom_type,'netc_series') || isequal(nom_type,'_i1-i2')
-                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
-                     filename=[filebasesub '_' num2str(num_i1) ext];
-                else
-                    filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) ext];
-                end
-            elseif isequal(nom_type,'_i1-i2_j1-j2')
-                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
-                    app1= [num2str(num_i1)];
-                else
-                    app1= [num2str(num_i1) '-' num2str(num_i2)];
-                end
-                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
-                    app2= [num2str(num_j1)];
-                else
-                    app2= [num2str(num_j1) '-' num2str(num_j2)];
-                end     
-                filename=[filebasesub '_' app1 '_' app2 ext];
-            end
-            idetect=1;
-           % idetect=(exist(filename,'file')==2);
-     % case of an image pair to determine (comp_input=0)
-    else
-            [filename,num_i1,num_j1,num_i2,num_j2,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type);
-    end
-    
-     %look for sub-directories containing netcdf files
-    if idetect==0 && isequal(subdir,'?')
-        [pathfile,name]=fileparts(filebase);
-        direct=dir(pathfile);%directory containing filebase
-        datedir=[];%default
-        idir=0;
-        indir=find(cell2mat({direct.isdir}));% find indices of subdirectories
-        direct=direct(indir([3:end]));% keep only the subdirectories,eliminating the two first terms '.' and '..'
-        lengthdir=length(direct);
-        if lengthdir==0
-            subdir='';% no subdirectory found
-        else
-            for idir=1:lengthdir
-                date_str=direct(idir).date;%string of the date of last modification
-                datedir(idir)=0;%default
-                char_code=double(date_str);% code of the date characters
-                special_char=(char_code>127); %non standard Ascii character (e.g. date in french)
-                if isempty(find(special_char))% standard Ascii character 
-                    datedir(idir)=datenum(date_str);
-                end                            
-%                 datedir(idir)=datenum(direct(idir).date); %absolute date of last directory modification
-            end
-            [mostrec,indrec]=max(datedir);% most recently modified subdir chosen by default
-            subdir=direct(indrec).name; %chosen directory
-        end
-        filebasesub=fullfile(pathfile,subdir,name);
-        %if the image pair is imposed
-        if (exist('comp_input','var') & isequal(comp_input,1)) 
-            if isequal(nom_type,'netc_old')|isequal(nom_type,'#_ab')
-                filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) num2stra(num_j2,nom_type) ext];
-            elseif isequal(nom_type,'netc_2D')|isequal(nom_type,'_i1_j1-j2')
-                filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) '-' num2str(num_i2) ext];
-            elseif isequal(nom_type,'netc_3D')|isequal(nom_type,'_i1-i2_j')
-                filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) '_' num2str(num_j1) ext];
-            elseif isequal(nom_type,'netc_series')|isequal(nom_type,'_i1-i2')
-                filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) ext];
-            end
-            idetect=(exist(filename,'file')==2);
-        else
-            [filename,num_i1,num_j1,num_i2,num_j2,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type);             
-        end
-    end
-% elseif isequal(nom_type,'none')|isequal(nom_type,'')|isequal(nom_type,'*')
-else
-    filebasesub=filebase;
-    if ~isequal(subdir,'') && ~isequal(subdir,'?') 
-            [Path,Name]=fileparts(filebase);
-            filebasesub=fullfile(Path,subdir,Name);
-    end
-    filename=[filebasesub ext];
-    idetect=(exist(filename,'file')==2);  
-end
-num_i1_out=num_i1;
-num_j1_out=num_j1;
-if exist('num_i2','var'), num_i2_out=num_i2; else, num_i2_out=[]; end;
-if exist('num_j2','var'), num_j2_out=num_j2; else, num_j2_out=[]; end;
-if ~isequal(subdir,'?'), subdir_out=subdir; else, subdir_out='';end;
-
-%---------------------------------------------------------------
-% search the appropriate image pair (netcdf file) corresponding to a given
-% image number
-%-------------------------------------------------------------------
-function [filename,num_i1,num_j1,num_i2,num_j2,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type)
-% for nom_type=netc_2D or netc_old, it searches all the pairs corresponding
-% to num_i1, and chooses the most recent file.
-%for nom_type=netc_3D or netc_series, it searches all the pairs (num_i1
-%num_i2), with num_i1 as the first  index, and chooses the most recent file.
-
-filename=[];num_j2=[];idetect=0;%default values
-if isequal(nom_type,'netc_old')|isequal(nom_type,'#_ab')
-    dirpair=dir([filebasesub num2str(num_i1,'%03d') '_*.nc']);
-elseif isequal(nom_type,'netc_2D')|isequal(nom_type,'_i_j1-j2')
-    dirpair=dir([filebasesub '_' num2str(num_i1) '_*-*.nc']);
-elseif isequal(nom_type,'netc_3D')|isequal(nom_type,'_i1-i2_j')
-    dirpair=dir([filebasesub '_' num2str(num_i1) '-*_' num2str(num_j1) '.nc']);
-elseif isequal(nom_type,'netc_series')|isequal(nom_type,'_i1-i2')
-    dirpair=dir([filebasesub '_' num2str(num_i1) '-*.nc']);
-    if isempty(dirpair)
-        dirpair=dir([filebasesub '_*-' num2str(num_i2) '.nc']);
-    end
-end
-nbpair=length(dirpair);
-if nbpair >= 1 %choose the most recent file if several are found
-    idetect=1; %detected pair
-    for ipair=1:nbpair
-         date_str=dirpair(ipair).date;%string of the date of last modification
-         datepair(ipair)=0;%default
-         char_code=double(date_str);% code of the date characters
-         special_char=(char_code>127); %non standard Ascii character (e.g. date in french)
-         if isempty(find(special_char))% standard Ascii character 
-             datepair(ipair)=datenum(date_str);
-         end    
-      %  datepair(ipair)=datenum(dirpair(ipair).date);
-    end
-    [choice,indpair]=max(datepair);
-%     [filebase,field_count,str2,str_a,str_b,ext,nom_type]=name2display(dirpair(indpair).name);
-    [pathname,file,field_count,str2,str_a,str_b,ext,nom_type]=name2display(dirpair(indpair).name);
-    num_i1=str2num(field_count);
-    num_i2=str2num(str2);
-    num_j1=stra2num(str_a);
-    num_j2=stra2num(str_b);
-     pathname=fileparts(filebasesub);% CORRIGE LE 6 JUIN (ETAIT DESACTIVE)
-    filename=fullfile(pathname,dirpair(indpair).name);
-end
-
-
Index: unk/src/nc2struct.m
===================================================================
--- /trunk/src/nc2struct.m	(revision 7)
+++ 	(revision )
@@ -1,269 +1,0 @@
-%'nc2struct': transform a netcdf file in a corresponding matlab structure
-% it reads all the global attributes and all variables, or a selected list.
-% The corresponding dimensions and variable attributes are then extracted
-%%%%%% TODO: add the possibility to read only attributes, see  nc2struct_toolbox %%%
-%----------------------------------------------------------------------
-% function [Data,var_detect,ichoice]=nc2struct(nc,ListVarName)
-%
-% OUTPUT:
-%  Data: structure containing all the information of the netcdf file (or netcdf object)
-%           with fields:
-%    .ListGlobalAttribute: cell listing the names of the global attributes
-%        .Att_1,Att_2... : values of the global attributes
-%            .ListDimName: cell listing the names of the array dimensions
-%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
-%            .ListVarName: cell listing the names of the variables
-%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
-%            .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName
-%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
-%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
-%  var_detect: vector with same length as ListVarName, with 1 for each detected variable and 0 else.
-%  ichoice: = line 
-%
-%INPUT:
-%     nc:      name of a netcdf file (char string) or netcdf object   
-% ListVarName: optional list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} ) 
-%         if ListVarName=[] or {}, no variables is read (only global attributes and lists of dimensions, variables and attriburtes)
-%         if ListVarName is absent, or = '*', ALL the variables are read. 
-%        if ListVarName is a cell array with n lines, the set of variables
-%                        will be sought by order of priority in the list, while output names will be set by the first line
-% 
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-   
-function [Data,var_detect,ichoice]=nc2struct(nc,varargin)
-List=varargin;
-if nargin==0
-    List{1}='*';
-end
-% if ~exist('ListVarName','var')
-%     ListVarName='*';
-% end
-hhh=which('netcdf.open');% look for built-in matlab netcdf library
-
-if ~isequal(hhh,'')
-    %default output
-    Data=[];
-    var_detect=[];
-    ichoice=[];%default
-    %open the netcdf file for reading
-    if ischar(nc) 
-        if exist(nc,'file')
-            nc=netcdf.open(nc,'NC_NOWRITE');
-            testfile=1;
-        else
-           Data.Txt=['ERROR:file ' nc ' does not exist'];
-           return
-        end
-    else
-        testfile=0;
-    end
-    % short reading of global attributes
-    if isequal(List{1},'ListGlobalAttribute')
-        for ilist=2:numel(List)
-            valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),List{ilist});
-            eval(['Data.' List{ilist} '=valuestr;'])
-        end
-        netcdf.close(nc)
-       return
-    end
-
-    % reading of variables, including attributes
-    ListVarName=List{1};  
-    [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, attributes
-    
-    %  -------- read global attributes (constants)-----------
-    att_key={};%default
-    iatt_g=0;
-    Data.ListGlobalAttribute={};%default
-    for iatt=1:ngatts
-        keystr= netcdf.inqAttName(nc,netcdf.getConstant('NC_GLOBAL'),iatt-1);
-        indstr1=regexp(keystr,'\\');%detect '\\'
-        indstr2=regexp(keystr,'\.');%detect '\.'
-        if isempty(indstr1) && isempty(indstr2)
-           valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),keystr);
-           if ischar(valuestr) && length(valuestr)<200
-                iatt_g=iatt_g+1;
-                indstr1=regexp(keystr,'\\');%detect '\\'
-                indstr2=regexp(keystr,'\.');%detect '\.'
-                if isempty(indstr1) && isempty(indstr2)
-                    eval(['Data.' keystr '=''' valuestr ''';'])
-                    att_key{iatt_g}=keystr;
-                end
-            elseif isempty(valuestr)
-                iatt_g=iatt_g+1;
-                eval(['Data.' keystr '=[];'])
-                att_key{iatt_g}=keystr;
-            elseif isnumeric(valuestr)
-                iatt_g=iatt_g+1;
-                eval(['Data.' keystr '=valuestr;'])
-                att_key{iatt_g}=keystr;
-            end
-        end
-    end
-    Data.ListGlobalAttribute=att_key;
-
-    %  -------- read dimensions -----------
-    dim_name={};
-    dim_value=[];
-    for idim=1:ndims%length(dim_read);
-        [dim_name{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);
-    end
-    if ~isempty(dim_name) && ~isempty(dim_value)
-        Data.ListDimName=dim_name;
-        Data.DimValue=dim_value;
-%         DimIndices=[1:ndims]; %index of the dimension in the netcdf file
-        dim_used=zeros(1,ndims);%initialize test of used dimensions
-    end
- 
-    %  -------- read variables -----------
-    var_read={}; %default
-    dimids={};
-    nbatt=[];
-    for ivar=1:nvars
-        [var_read{ivar},xtype,dimids{ivar},nbatt(ivar)] = netcdf.inqVar(nc,ivar-1); 
-    end  
-    var_index=1:nvars; %default set of variable indices in the netcdf file
-    testmulti=0;
-    OutputList=[];
-    %select input variables, if requested by the input ListVarName
-    if ~(isequal(ListVarName,'*')||isempty(ListVarName))
-        sizvar=size(ListVarName);
-        testmulti=(sizvar(1)>1);
-        var_index=zeros(1,sizvar(2));%default
-        if testmulti
-            OutputList=ListVarName(1,:);
-            testend=0;
-            for iline=1:sizvar(1)
-                if testend
-                    break
-                end
-          %      var_index=zeros(size(ListVarName));%default
-                for ivar=1:sizvar(2)
-                    if ~isempty(ListVarName{iline,ivar})
-                         for ilist=1:nvars
-                            if isequal(var_read{ilist},ListVarName{iline,ivar})
-                                var_index(ivar)=ilist;
-     %                          var_detect(ivar)=1;
-                            break
-                            end
-                         end
-                         if ivar==1
-                            if var_index(ivar)==0
-                                break%go to next line if the first nc variable is not found
-                            else
-                                testend=1; %this line will be read
-                                ichoice=iline-1; %selectedline number in the list of input names of variables
-                            end
-                         end
-                    end
-                end
-            end
-        else   %single list of input variables
-            for ivar=1:sizvar(2)
-                for ilist=1:nvars
-                    if isequal(var_read{ilist},ListVarName{ivar})
-                        var_index(ivar)=ilist;
-                        var_detect(ivar)=1;
-                        break
-                    end
-                end
-            end
-        end
-        list_index=find(var_index);
-        if ~isempty(list_index)
-            if testmulti
-                OutputList=OutputList(list_index);
-            end
-            var_index=var_index(list_index);
-            var_detect=(var_index~=0);
-            var_read=var_read(var_index);         
-        end
-    end
-    
-    
-    %select variable attributes and associate dimensions
-%     var_dim_index=[]; %default
-    Data.ListVarName={};%default
-    VarDimIndex={};%default
-    for ivar=1:length(var_read)
-        if testmulti
-            Data.ListVarName{ivar}=OutputList{ivar};%new name given by ListVarName(1,:)
-        else
-            Data.ListVarName{ivar}=var_read{ivar};%name of the variable
-        end
-        var_dim=dimids{var_index(ivar)}+1; %dimension indices used by the variable
-        dim_used(var_dim)=ones(size(var_dim));
-        VarDimIndex{ivar}=var_dim;
-
-        %variable attributes
-        if ivar==1
-            Data.VarAttribute={};%initialisation of the list of variable attributes
-        end
-        %variable attributes
-        for iatt=1:nbatt(var_index(ivar))
-            attname = netcdf.inqAttName(nc,var_index(ivar)-1,iatt-1);
-            valuestr= netcdf.getAtt(nc,var_index(ivar)-1,attname);
-            if ischar(valuestr)
-                eval(['Data.VarAttribute{ivar}.' attname '=''' valuestr ''';'])
-            elseif isempty(valuestr)
-                eval(['Data.VarAttribute{ivar}.' attname '=[];'])
-            elseif isnumeric(valuestr)
-                eval(['Data.VarAttribute{ivar}.' attname '=valuestr;'])
-            end
-        end
-    end
-
-    %select the used dimensions
-    if isempty(var_read) 
-        if isfield(Data,'ListDimName') && isfield(Data,'DimValue')
-        Data=rmfield(Data,'ListDimName');
-        Data=rmfield(Data,'DimValue');
-        end
-    else
-%         list_dim=1:ndims;
-        dim_index=find(dim_used);
-%         list_dim=list_dim(dim_index);
-        old2new=cumsum(dim_used); 
-        Data.ListDimName=Data.ListDimName(dim_index);
-        Data.DimValue=Data.DimValue(dim_index);
-    end
-    for ivar=1:length(var_read)
-        Data.VarDimIndex{ivar}=old2new(VarDimIndex{ivar});% ENLEVER Data.VarDimIndex ulterieurement
-        Data.VarDimName{ivar}=Data.ListDimName(Data.VarDimIndex{ivar});
-    end
-    %variable values
-    if  ~isempty(ListVarName)
-        for ivar=1:length(Data.ListVarName)
-            VarName=Data.ListVarName{ivar};
-            indstr=regexp(VarName,'-');%detect '-'
-            if ~isempty(indstr)
-                VarName(indstr)=[];
-            end
-            eval(['Data.' VarName '=netcdf.getVar(nc,var_index(ivar)-1);'])%read the variable data
-            eval(['siz=size(Data.' VarName ');'])
-            if numel(siz)<=2
-            eval(['Data.' VarName '=Data.' VarName ''';'])%read the variable data
-            end
-        end
-    end
-    %  -------- close fle-----------
-    if testfile==1
-        netcdf.close(nc) 
-    end
-else
-    [Data,var_detect,ichoice]=nc2struct_toolbox(nc,varargin);
-end
Index: unk/src/nc2struct_toolbox.m
===================================================================
--- /trunk/src/nc2struct_toolbox.m	(revision 7)
+++ 	(revision )
@@ -1,260 +1,0 @@
-%'nc2struct_toolbox': transform a netcdf file in a corresponding matlab structure, USE OLD NETCDF LIBRARY
-%----------------------------------------------------------------------
-% function [Data,var_detect,ichoice]=nc2struct_toolbox(nc,ListField)
-%
-% OUTPUT:
-%  Data: structure containing all the information of the netcdf file (or netcdf object)
-%           with fields:
-%    .ListGlobalAttribute: cell listing the names of the global attributes
-%        .Att_1,Att_2... : values of the global attributes
-%            .ListDimName: cell listing the names of the array dimensions
-%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
-%            .ListVarName: cell listing the names of the variables
-%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
-%            .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName
-%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
-%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
-%  var_detect: vector with same length as ListVarName, with 1 for each detected variable and 0 else.
-%  ichoice: = line 
-%
-%INPUT:
-%     nc:      name of a netcdf file (char string) or netcdf object   
-% ListField: optional list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} ) 
-%         if ListField is absent or ='*', ALL the attributes and variables are read.  %      
-%        if  ListField='ListGlobalAttribute', followed by the arguments 'name1', name2'..., only thes global attributes will be read (short option)
-%        if  ListField=[] or{}, no variables is read (only global attributes and lists of vdimensions, variables and attriburtes)
-%        if ListField is a cell array with n lines, the set of variables
-%                        will be sought by order of priority in the list, while output names will be set by the first line
-% 
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function [Data,var_detect,ichoice]=nc2struct_toolbox(nc,varargin)
-
-List=varargin{1};
-%default output
-Data=[];
-var_detect=[];
-ichoice=[];%default
-
-%open the netcdf file for reading
-if ischar(nc)
-    if exist(nc,'file') % rmq: time for exist search = 0.5 ms CPU
-        nc=netcdf(nc,'nowrite'); % rmq: time needed for opening = 2 ms CPU
-        testfile=1;
-    else
-       Data.Txt=['ERROR:file ' nc ' does not exist'];
-       return
-    end
-else
-    testfile=0;
-end
-
-% short reading of global attributes
-if ~isempty(List) && isequal(List{1},'ListGlobalAttribute')
-    for ilist=2:numel(List)
-        att_str=List{ilist};
-        eval(['Data.' att_str '=nc.' att_str '(:);'])
-    end
-    close(nc) 
-        %total time from beginning : 15 ms for a single attribute
-   return
-end
-
-% reading of variables, including attributes
-if isempty(List)
-   ListVarName='*';
-else
-if isempty(List{1})
-    ListVarName='*';
-else
-    ListVarName=List{1};  
-end
-end
-%  -------- read global attributes -----------              
-att_read=att(nc);%cell of 'global attributes' (nc objects), CPU time 30 ms   
-att_key={};%default
-iatt_g=0;
-for iatt=1:length(att_read)
-    aa=att_read{iatt};
-    keystr=name(aa);
-    indstr1=regexp(keystr,'\\');%replace dots'
-    indstr2=regexp(keystr,'\.');%replace dots'
-    if ~isequal(keystr,'title') % PROBLEM WITH civx files do not read 'title' 
-        if  isempty(indstr1) && isempty(indstr2) % 
-           eval(['valuestr=nc.' keystr '(:);'])
-            if ischar(valuestr) && length(valuestr)<200
-                iatt_g=iatt_g+1;
-                indstr1=regexp(keystr,'\\');%replace dots'
-                indstr2=regexp(keystr,'\.');%replace dots'
-                if isempty(indstr1) && isempty(indstr2)
-                    eval(['Data.' keystr '=''' valuestr ''';'])
-                    att_key{iatt_g}=keystr;
-                end
-            elseif isempty(valuestr)
-                iatt_g=iatt_g+1;
-                eval(['Data.' keystr '=[];'])
-                att_key{iatt_g}=keystr;
-            elseif isnumeric(valuestr)
-                iatt_g=iatt_g+1;
-                eval(['Data.' keystr '=valuestr;'])
-                att_key{iatt_g}=keystr;
-            end
-        end
-    end
-end
-Data.ListGlobalAttribute=att_key;
-nbattr=length(att_key);
-neworder=[nbattr+1 (1:nbattr)];
-Data=orderfields(Data,neworder);
-
-%  -------- read dimensions -----------
-dim_read=dim(nc);%cell of variable dimension names (nc objects): CPU time 0.0013
-dim_name={};
-dim_value=[];
-for idim=1:length(dim_read);
-    aa=dim_read{idim};
-    if ~isempty(aa)
-    dim_name{idim}=name(aa);
-    dim_value(idim)=length(aa);
-    end
-end
-if ~isempty(dim_name) && ~isempty(dim_value)
-    Data.ListDimName=dim_name;
-    Data.DimValue=dim_value;
-    used=zeros(1,length(dim_value));%initialize test of used dimensions
-end
-
-%  -------- read variables -----------
-var_read={}; %default
-testmulti=0;
-OutputList=[];
-if isequal(ListVarName,'*')%|| isempty(ListVarName)
-     var_read=var(nc);%cell of all variables
-elseif ~isempty(ListVarName)
-    sizvar=size(ListVarName);
-    testmulti=(sizvar(1)>1);
-    if testmulti
-        OutputList=ListVarName(1,:);
-        testend=0;
-        for iline=1:sizvar(1)
-            if testend
-                break
-            end
-            for ivar=1:sizvar(2)
-                var_read{ivar}=[];%default
-                var_detect(ivar)=0;%default
-                VarName=ListVarName{iline,ivar};
-                if ~isempty(VarName)
-                     var_read{ivar}=nc{VarName};%select the input variable names
-                     if ivar==1
-                        if isempty (var_read{ivar})
-                            break%go to next line if the first nc variable is not found
-                        else
-                            testend=1; %this line will be read
-                            ichoice=iline-1; %selectedline number in the list of input names of variables
-                            var_detect(ivar)=1;
-                        end
-                     else
-                          var_detect(ivar)=~isempty (var_read{ivar});
-                     end
-                end
-            end
-        end
-        if ~isempty(find(var_detect,1))
-            OutputList=OutputList(find(var_detect));  
-        end
-    else   %single list of input variables
-        var_detect=ones(size(ListVarName));
-        for ivar=1:sizvar(2)
-            var_read{ivar}=nc{ListVarName{ivar}};%select the input variable names
-            var_detect(ivar)=~isempty(var_read{ivar});
-        end
-    end
-    var_read=var_read(find(var_detect));
-end
-
-% var_dim_index=[]; %default
-Data.ListVarName={};%default
-for ivar=1:length(var_read)
-    vv=var_read{ivar};
-    Data.ListVarName{ivar}=name(vv);%name of the variable
-    if testmulti
-        Data.ListVarName{ivar}=OutputList{ivar};
-    else
-        Data.ListVarName{ivar}=name(vv);%name of the variable
-    end
-    var_dim=dim(vv);%dimension netcdf object of the variable
-    for ivardim=1:length(var_dim)
-        var_dim_name=name(var_dim{ivardim});%name of the dimension
-        for idim=1:length(dim_name)% find the index of the current dimension in the list of dimensions
-            if isequal(dim_name{idim},var_dim_name)
-                Data.VarDimIndex{ivar}(ivardim)=idim;
-                used(idim)=1;
-                break
-            end
-        end
-    end 
-    Data.VarDimName{ivar}={};
-    %variable attributes
-    Data.VarAttribute{ivar}=[];%initialisation of the list of variable attributes
-    %variable attributes
-    att_read=att(vv);
-    for iatt=1:length(att_read)
-        aa=att_read{iatt};
-        eval(['valuestr=vv.' name(aa) '(:);'])
-        if ischar(valuestr)
-            eval(['Data.VarAttribute{ivar}.' name(aa) '=''' valuestr ''';'])
-        elseif isempty(valuestr)
-            eval(['Data.VarAttribute{ivar}.' name(aa) '=[];'])
-        elseif isnumeric(valuestr)
-            eval(['Data.VarAttribute{ivar}.' name(aa) '=valuestr;'])
-        end
-    end
-end
-
-%select the used dimensions
-if isempty(var_read) 
-    if isfield(Data,'ListDimName') && isfield(Data,'DimValue')
-    Data=rmfield(Data,'ListDimName');
-    Data=rmfield(Data,'DimValue');
-    end
-else
-    old_dim_index=find(used); %dimension indices which are used by the selected variables
-    old2new=cumsum(used); 
-    Data.ListDimName=Data.ListDimName(old_dim_index);
-    Data.DimValue=Data.DimValue(old_dim_index);
-end
-for ivar=1:length(var_read)
-    Data.VarDimIndex{ivar}=(old2new(Data.VarDimIndex{ivar}));
-    Data.VarDimName{ivar}=(Data.ListDimName(Data.VarDimIndex{ivar}));
-end
-%variable values
-
-if  ~isempty(ListVarName)
-    for ivar=1:length(Data.ListVarName)
-        vv=var_read{ivar};
-        vdata=vv(:);%data array of the field variable
-        eval(['Data.' Data.ListVarName{ivar} '=vdata;'])%read the variable data
-    end
-end
-%  -------- close fle-----------
-if testfile==1
-    close(nc) 
-end
-
-%total time from beginning : 150 ms for a full civ2 field, 65 ms for four fields
-
Index: unk/src/nomtype2pair.m
===================================================================
--- /trunk/src/nomtype2pair.m	(revision 7)
+++ 	(revision )
@@ -1,70 +1,0 @@
-%'nomtype2pair': creates nomencalture for index pairs. 
-%---------------------------------------------------------------------
-% [nom_type_nc]=nomtype2pair(nom_type);
-%---------------------------------------------------------------------           
-% This function detects the existence the constructed file name and it can
-% find indices according to file existence if they are not specified
-%%rmq: this function is related to the reverse functions display2name and name2diplay 
-%---------------------------------------------------------------------
-% OUTPUT:
-%nom_type_nc
-
-%---------------------------------------------------------------------
-% INPUT:
-% 'nom_type': string defining the kind of nomenclature used:
-     %nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
-     %nom_type='*': the same  file [filebase ext] contains successive fields (ex avi movies)
-     %nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
-     %nom_type='#' series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
-     %nom_type='_i_j' matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
-     %nom_type='_i1-i2' from pairs from a single index (e.g. 'aa_45-47.nc') 
-     %nom_type='_i_j1-j2'pairs of j indices (e.g. 'aa_45_2-3.nc')
-     %nom_type='_i1-i2_j' pairs of i indices (e.g. 'aa_45-46_2.nc')
-     %nom_type='#a','#A', with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j')
-     %nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif'
-     %nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif'
-     %nom_type='raw_SMD', same as '#a' but with no extension ext='', OBSOLETE
-     %nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
-     %nom_type='%3dab' from pairs of '%3da' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
-% Dti: ~=0 if i index pairs are used
-% Dtj: ~=0 if i index pairs are used
-
-function [nom_type_pair]=nomtype2pair(nom_type,Dti,Dtj);
-
-%determine nom_type_nc:
-nom_type_nc=[];%default
-switch nom_type
-    case {'_i_j'}
-        if Dtj>0 || Dtj<0
-            nom_type_pair='_i_j1-j2';
-            if Dti>0 || Dti<0
-                nom_type_pair='_i1-i2_j1-j2';
-            end
-            elseif Dti>0 || Dti<0
-            nom_type_pair='_i1-i21_j';   
-        else
-             nom_type_pair='_i_j';
-        end
-    case {'_i1-i2_j'}
-        if Dtj>0 || Dtj<0
-           nom_type_pair='_i1-i2_j1-j2';
-        else
-            nom_type_pair='_i1-i2_j';
-        end
-    case {'i_j1-j2'}
-        if Dti>0 || Dti<0
-           nom_type_pair='_i1-i2_j1-j2';
-        else
-            nom_type_pair='_i1-i2_j';
-        end
-    case {'i1-i2_j1-j2'}
-         nom_type_pair='_i1-i2_j1-j2';
-    case '#a'
-        if Dtj>0 || Dtj<0
-            nom_type_pair='#_ab';
-        end
-    otherwise
-        if Dti>0 || Dti<0
-           nom_type_pair='_i1-i2'; 
-        end
-end
Index: unk/src/num2stra.m
===================================================================
--- /trunk/src/num2stra.m	(revision 7)
+++ 	(revision )
@@ -1,41 +1,0 @@
-%'num2stra': transform number to the corresponding character string depending on the nomenclature
-%--------------------------------------------
-% function str=num2stra(num,nom_type)
-%
-% OUTPUT: 
-% str: character string
-%
-% INPUT:
-% num: input number (file index)
-% nom_type: nomencalture type (see fct name_generator)
-%
-% see also: stra2num, name_generator, name2display
-
-function str=num2stra(num,nom_type,index);
-if ~exist('index','var')
-    index=2; %index 1 or 2 of the file indices
-end
-switch index
-    case 1
-        if length(nom_type)>=4 && isequal(nom_type(1:2),'%0') && isequal(nom_type(4),'d') 
-           str=num2str(num,nom_type(1:4)); 
-        else
-           str=num2str(num); 
-        end
-    case 2
-        if isempty(nom_type)
-            nom_type='none';
-        end
-        if isequal(nom_type,'png_old') || isequal(nom_type,'netc_old') || isequal(nom_type,'raw_SMD')||...
-            isequal(nom_type(end),'a')||isequal(nom_type(end),'b')
-            str=char(96+num);
-        elseif isequal(nom_type(end),'A')|isequal(nom_type(end),'B')
-            str=char(64+num);
-        elseif isequal(nom_type,'series_i')|isequal(nom_type,'netc_series')...
-                |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none')...
-                isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')
-            str='';
-        else
-            str=num2str(num);
-        end
-end
Index: unk/src/parseXML.m
===================================================================
--- /trunk/src/parseXML.m	(revision 7)
+++ 	(revision )
@@ -1,70 +1,0 @@
-% PARSEXML Convert XML file to a MATLAB structure. (from matlab help)
-function theStruct = parseXML(filename)
-
-try
-   tree = xmlread(filename);
-catch
-   error('Failed to read XML file %s.',filename);
-end
-
-% Recurse over child nodes. This could run into problems 
-% with very deeply nested trees.
-try
-   theStruct = parseChildNodes(tree);
-catch
-   error('Unable to parse XML file %s.');
-end
-
-
-% ----- Subfunction PARSECHILDNODES -----
-function children = parseChildNodes(theNode)
-% Recurse over node children.
-children = [];
-if theNode.hasChildNodes
-   childNodes = theNode.getChildNodes;
-   numChildNodes = childNodes.getLength;
-   allocCell = cell(1, numChildNodes);
-
-   children = struct(             ...
-      'Name', allocCell, 'Attributes', allocCell,    ...
-      'Data', allocCell, 'Children', allocCell);
-
-    for count = 1:numChildNodes
-        theChild = childNodes.item(count-1);
-        children(count) = makeStructFromNode(theChild);
-    end
-end
-
-% ----- Subfunction MAKESTRUCTFROMNODE -----
-function nodeStruct = makeStructFromNode(theNode)
-% Create structure of node info.
-
-nodeStruct = struct(                        ...
-   'Name', char(theNode.getNodeName),       ...
-   'Attributes', parseAttributes(theNode),  ...
-   'Data', '',                              ...
-   'Children', parseChildNodes(theNode));
-
-if any(strcmp(methods(theNode), 'getData'))
-   nodeStruct.Data = char(theNode.getData); 
-else
-   nodeStruct.Data = '';
-end
-
-% ----- Subfunction PARSEATTRIBUTES -----
-function attributes = parseAttributes(theNode)
-% Create attributes structure.
-
-attributes = [];
-if theNode.hasAttributes
-   theAttributes = theNode.getAttributes;
-   numAttributes = theAttributes.getLength;
-   allocCell = cell(1, numAttributes);
-   attributes = struct('Name', allocCell, 'Value', allocCell);
-
-   for count = 1:numAttributes
-      attrib = theAttributes.item(count-1);
-      attributes(count).Name = char(attrib.getName);
-      attributes(count).Value = char(attrib.getValue);
-   end
-end
Index: unk/src/peaklock.m
===================================================================
--- /trunk/src/peaklock.m	(revision 7)
+++ 	(revision )
@@ -1,197 +1,0 @@
-%'peaklock': determines peacklocking errors from velocity histograms.
-%-------------------------------------------------------
-%first smooth the input histogram 'histu' in such a way that the integral over
-%n-n+1 is preserved, then deduce the peaklocking 'error' function of the pixcel displacement 'x'.
-%
-% [histinter,x,error]=peaklock(nbb,minim,maxim,histu)
-%OUTPUT:
-%histinter: smoothed interpolated histogram
-% x: vector of displacement values.
-% error: vector of estimated errors corresponding to x
-%INPUT:
-%histu=vector representing the values of histogram  of measured velocity ;
-%minim, maxim: extremal values of the measured velocity (absica for histu)
-%nbb: number of bins inside each integer interval for the histograms
-%SUBROUTINES INCLUDED:
-%spline4.m% spline interpolation at 4th order
-%splinhist.m: give spline coeff cc for a smooth histo (call spline4)
-%histsmooth.m(x,cc): calculate the smooth histo for any value x
-%histder.m(x,cc): calculate the derivative of the smooth histo
-function [histinter,x,error]=peaklock(nbb,minim,maxim,histu)
-
-nint=maxim-minim+1
-xfin=[minim-0.5+1/(2*nbb):(1/nbb):maxim+0.5-(1/(2*nbb))];
-histo=(reshape(histu,nbb,nint));%extract values with x between integer -1/2 integer +1/2
-Integ=sum(histo)/nbb; %integral of the pdf on each integer bin
-[histinter,cc]=splinhist(Integ,minim,nbb);
-histx=reshape(histinter,nbb,nint);
-xint=[minim:1:maxim];
-x=zeros(nbb,nint);
-%determination of the displacement x(j,:)
-%j=1
-delx=histo(1,:)./histsmooth(-0.5*ones(1,nint),cc)/nbb;
-%del(1,:)=delx;
-x(1,:)=-0.5+delx-(delx.*delx/2).*histder(-0.5*ones(1,nint),cc);
-%histx(1,:)=histsmooth(x(j-1,:),cc);
-for j=2:nbb
-    delx=histo(j,:)./histsmooth(x(j-1,:),cc)/nbb;
-    %delx=delx.*(delx<3*ones(1,nint)/nbb)+3*ones(1,nint)/nbb.*~(delx <3*ones(1,nint)/nbb)
-    x(j,:)=x(j-1,:)+delx-(delx.*delx/2).*histder(x(j-1,:),cc);
-end
-%reshape
-xint=ones(nbb,1)*xint;
-x=x+xint;
-x=reshape(x,1,nbb*nint);
-error=xfin+1/(2*nbb)-x;
-
-%-------------------------------------------------------
-% --- determine the spline coefficients cc for the interpolated histogram.
-%-------------------------------------------------
-function [histsmooth,cc]= splinhist(Integ,mini,nbb)
-% provides a smooth histogramm histmooth, which remains always positive,
-% and is such that its sum over each integer bin [i-1/2 i+1/2] is equal to
-% Integ(i). The function determines histmooth as the exponential of a 4th
-% order spline function and adjust the cefficients by a Newton method to
-% fit the integral conditions Integ
-% histmooth is determined at the abscissa
-% xfin=[mini-0.5+1/(2*n):(1/n):maxi+0.5-(1/(2*n))] (maxi=mini+size(aa)-1)
-%cc(1-5,i) provides the spline coefficients
-
-% order 0
-siz=size(Integ);
-nint=siz(2);
-izero=find(Integ==0); %indices of zero elements
-inonzero=find(Integ);
-Integ(izero)=min(Integ(inonzero));
-aa=log(Integ);%initial guess for a coeff
-spli=spline4(aa,mini,nbb);  %appel à la fonction spline4
-histsmooth=exp(spli);
-
-S=(sum(reshape(histsmooth,nbb,nint)))/nbb;% integral of the fit histsmooth on ]i-1/2 i+1/2[
-epsilon=max(abs(Integ-S));
-iter=0;
-while epsilon > 0.000001 & iter<10
-ident=eye(nint);
-dSda=ones(nint);
-for j=1:nint% determination of the jacobian matrix dSda
-dhistda=spline4(ident(j,:),mini,nbb);
-expdhistda=dhistda.*histsmooth;
-dSda(j,:)=(sum(reshape(expdhistda,nbb,nint)))/nbb;
-end
-aa=aa+(Integ-S)*inv(dSda);%new estimate of coefficients aa by linear interpolation
-[spli,bb]=spline4(aa,mini,nbb);% new fit histsmooth
-histsmooth=exp(spli);
-S=(sum(reshape(histsmooth,nbb,nint)))/nbb;% integral of the fit histsmooth on ]i-1/2 i+1/2[
-epsilon=max(abs(Integ-S));
-iter=iter+1;
-end
-if iter==10, errordlg('splinhist did not converge after 10 iterations'),end
-cc(1,:)=aa;
-cc(2,:)=bb(1,:);
-cc(3,:)=bb(2,:);
-cc(4,:)=bb(3,:);
-cc(5,:)=bb(4,:);
-
-%-------------------------------------------------------
-% --- determine the 4th order spline coefficients from the function values aa.
-%-------------------------------------------------
-function [histsmooth,bb]= spline4(aa,mini,n)
-% spline interpolation at 4th order
-%aa=vector of values of a function at integer abscissa, starting at mini
-%n=number of subdivisions for the interpolated function
-% histmooth =interpolated values at absissa
-% xfin=[mini-0.5+1/(2*n):(1/n):maxi+0.5-(1/(2*n))] (maxi=mini+size(aa)-1)
-%bb=[b(i);c(i);d(i); e(i)] matrix of spline coeff
-L1=[1/2 1/4 1/8 1/16;1 1 3/4 1/2;0 2 3 3;0 0 6 12];
-L2=[-1/2 1/4 -1/8 1/16;1 -1 3/4 -1/2;0 2 -3 3;0 0 6 -12];
-M=inv(L2)*L1;
-[V,D]=eig(M);
-F=-inv(V)*inv(L2)*[1 ;0 ;0;0];
-a1rev=[1 -1/D(1,1)];
-b1rev=[F(1)/D(1,1)];
-a2rev=[1 -1/D(2,2)];
-b2rev=[F(2)/D(2,2)];
-a3=[1 -D(3,3)];
-b3=[F(3)];
-a4=[1 -D(4,4)];
-b4=[F(4)];
-
-%data
-% n=10;% résolution de la pdf: nbre de points par unite de u
-% mini=-10.0;%general mini=uint16(min(values)-1 CHOOSE maxi-mini+1 EVEN
-% maxi=9.0; % general maxi=uint16(max(values))+1
-%nint=double(maxi-mini+1); % nombre d'intervals entiers EVEN!
-siz=size(aa);
-nint=siz(2);
-maxi=mini+nint-1;
-npdf=nint*n;% nbre total d'intervals à introduire dans la pdf: hist(u,npdf)
-%simulation de pdf
-xfin=[mini-0.5+1/(2*n):(1/n):maxi+0.5-(1/(2*n))];% valeurs d'interpolation: we take n values in each integer interval
-%histolin=exp(-(xfin-1).*(xfin-1)).*(2+cos(10*(xfin-1)));% simulation d'une pdf
-%histo=log(histolin);
-%histo=sin(2*pi*xfin);
-%histextract=(reshape(histo,n,nint));
-%aa=sum(histextract)/n %integral of the pdf on each integer bin
-IP=[0 diff(aa)];
-Irev=zeros(size(aa));
-for i=1:nint
-    Irev(i)=aa(end-i+1);
-end
-IPrev=[0 diff(Irev)];
-
-%get the spline coelfficients a_d, using filter on the eigen vectors A,B,C
-Arev=filter(b1rev,a1rev,IPrev);
-Brev=filter(b2rev,a2rev,IPrev);
-C=filter(b3,a3,IP);
-D=filter(b4,a4,IP);
-A=zeros(size(Arev));
-B=zeros(size(Brev));
-for i=1:nint
-    A(i)=Arev(end-i+1);
-    B(i)=Brev(end-i+1);
-end
-%Matr=V*[A;B;C;D];
-bb=V*[A;B;C;D];
-%b=Matr(1,:);
-%c=Matr(2,:);
-%d=Matr(3,:);
-%e=Matr(4,:);
-%a=aa;
-
-%calculate the interpolation using the spline coefficients a-d
-%xextract=(reshape(xfin,n,nint));% 
-chi=xfin+1/(2*n)-min(xfin)-double(int16(xfin+(1/(2*n))-min(xfin)))-0.5;% decimal part
-chi2=chi.*chi;
-chi3=chi2.*chi;
-chi4=chi3.*chi;
-avec=reshape(ones(n,1)*aa,1,n*nint);
-bvec=reshape(ones(n,1)*bb(1,:),1,n*nint);
-cvec=reshape(ones(n,1)*bb(2,:),1,n*nint);
-dvec=reshape(ones(n,1)*bb(3,:),1,n*nint);
-evec=reshape(ones(n,1)*bb(4,:),1,n*nint);
-histsmooth=avec+bvec.*chi+cvec.*chi2+dvec.*chi3+evec.*chi4;
-
-%-------------------------------------------------------
-% --- determine the interpolated histogram at points chi from the spline ceff cc.
-%-------------------------------------------------
-function histx= histsmooth(chi,cc)
-% provides the value of the interpolated histogram at values chi=x-i
-%(difference with the mnearest integer)
-% cc(5,size(chi)) is the set of spline coefficients obtained by splinhist
-chi2=chi.*chi;
-chi3=chi2.*chi;
-chi4=chi3.*chi;
-histx=exp(cc(1,:)+cc(2,:).*chi+cc(3,:).*chi2+cc(4,:).*chi3+cc(5,:).*chi4);
-
-%-------------------------------------------------------
-% --- determine the derivative p'/p of the interpolated histogram at points chi from the spline ceff cc.
-%-------------------------------------------------
-function histder= histder(chi,cc)
-% provides the logarithmique derivative p'/p of the interpolated histogram
-%at values chi=x-i
-%(difference with the nearest integer)
-% cc(5,size(chi)) is the set of spline coefficients obtained by splinhist
-chi2=chi.*chi;
-chi3=chi2.*chi;
-chi4=chi3.*chi;
-histder=cc(2,:)+2*cc(3,:).*chi+3*cc(4,:).*chi2+4*cc(5,:).*chi3;
Index: unk/src/phys.m
===================================================================
--- /trunk/src/phys.m	(revision 7)
+++ 	(revision )
@@ -1,232 +1,0 @@
-%'phys': transforms image (px) to real world (phys) coordinates using geometric calibration parameters
-% OUTPUT: 
-% DataOut:   structure representing the modified field
-% DataOut_1: structure representing the second modified field
-
-%INPUT:
-% Data:  structure of input data 
-%       with fields .A (image or scalar matrix), AX, AY
-%       .X,.Y,.U,.V, .DjUi
-%       .ZIndex: index of plane in multilevel case 
-% Data.CoordType='phys' or 'px', The function ACTS ONLY IF .CoordType='px'
-% Calib: structure containing calibration parameters or a subtree Calib.GeometryCalib =calibration data (tsai parameters)
-
-function [DataOut,DataOut_1]=phys(varargin)
-% A FAIRE: 1- verifier si DataIn est une 'field structure'(.ListVarName'):
-% chercher ListVarAttribute, for each field (cell of variables):
-%   .CoordType: 'phys' or 'px'   (default==phys, no transform)
-%   .scale_factor: =dt (to transform displacement into velocity) default=1
-%   .covariance: 'scalar', 'coord', 'D_i': covariant (like velocity), 'D^i': contravariant (like gradient), 'D^jD_i' (like strain tensor)
-%   (default='coord' if .Role='coord_x,_y..., 
-%            'D_i' if '.Role='vector_x,...',
-%              'scalar', else (thenno change except scale factor)
-Calib{1}=[];
-if nargin==2||nargin==4 % nargin =nbre of input variables
-    Data=varargin{1};
-    DataOut=Data;%default
-    DataOut_1=[];%default
-    CalibData=varargin{2};
-    if isfield(CalibData,'GeometryCalib')
-        Calib{1}=CalibData.GeometryCalib;
-    end
-    Calib{2}=Calib{1};
-else
-    DataOut.Txt='wrong input: need two or four structures';
-end
-test_1=0;
-if nargin==4
-    test_1=1;
-    Data_1=varargin{3};
-    DataOut_1=Data_1;%default
-    CalibData_1=varargin{4};
-    if isfield(CalibData_1,'GeometryCalib')
-        Calib{2}=CalibData_1.GeometryCalib;
-    end
-end
-iscalar=0;
-if  ~isempty(Calib{1})
-    DataOut=phys_1(Data,Calib{1});
-    %case of images or scalar: in case of two input fields, we need to project the transform of on the same regular grid
-    if isfield(Data,'A') && isfield(Data,'AX') && ~isempty(Data.AX) && isfield(Data,'AY')&&...
-                                           ~isempty(Data.AY) && length(Data.A)>1
-        iscalar=1;
-        A{1}=Data.A;
-    end
-end
-%transform of X,Y coordinates for vector fields
-if isfield(Data,'ZIndex')&&~isempty(Data.ZIndex)
-    ZIndex=Data.ZIndex;
-else
-    ZIndex=0;
-end
-if test_1
-    DataOut_1=phys_1(Data_1,Calib{2});
-    if isfield(Data_1,'A')&&isfield(Data_1,'AX')&&~isempty(Data_1.AX) && isfield(Data_1,'AY')&&...
-                                       ~isempty(Data_1.AY)&&length(Data_1.A)>1
-          iscalar=iscalar+1;
-          Calib{iscalar}=Calib{2};
-          A{iscalar}=Data_1.A;
-          if isfield(Data_1,'ZIndex') && ~isequal(Data_1.ZIndex,ZIndex)
-              DataOut.Txt='inconsistent plane indexes in the two input fields';
-          end
-          if iscalar==1% case for which only the second field is a scalar
-               [A,AX,AY]=phys_Ima(A,Calib,ZIndex);
-               DataOut_1.A=A{1};
-               DataOut_1.AX=AX; 
-               DataOut_1.AY=AY;
-               return
-          end
-    end
-end
-if iscalar~=0
-    [A,AX,AY]=phys_Ima(A,Calib,ZIndex);%TODO : introduire interp2_uvmat ds phys_ima
-    DataOut.A=A{1};
-    DataOut.AX=AX; 
-    DataOut.AY=AY;
-    if iscalar==2
-        DataOut_1.A=A{2};
-        DataOut_1.AX=AX; 
-        DataOut_1.AY=AY;
-    end
-end
-
-%------------------------------------------------
-function DataOut=phys_1(Data,Calib)
-% for icell=1:length(Data)
-
-DataOut=Data;%default
-DataOut.CoordType='phys'; %put flag for physical coordinates
-% The transform ACTS ONLY IF .CoordType='px'and Calib defined
-if isfield(Data,'CoordType')&& isequal(Data.CoordType,'px')&& ~isempty(Calib)
-    if isfield(Calib,'CoordUnit')
-        DataOut.CoordUnit=Calib.CoordUnit;
-    else
-        DataOut.CoordUnit='cm'; %default
-%     elseif isfield(DataOut,'CoordUnit')
-%         DataOut=rmfield(DataOut,'CoordUnit');
-    end
-    DataOut.TimeUnit='s';
-    %transform of X,Y coordinates for vector fields
-    if isfield(Data,'ZIndex') && ~isempty(Data.ZIndex)
-        Z=Data.ZIndex;
-    else
-        Z=0;
-    end
-    if isfield(Data,'X') &&isfield(Data,'Y')&&~isempty(Data.X) && ~isempty(Data.Y)
-        [DataOut.X,DataOut.Y,DataOut.Z]=phys_XYZ(Calib,Data.X,Data.Y,Z); 
-        if isfield(Data,'U')&&isfield(Data,'V')&&~isempty(Data.U) && ~isempty(Data.V)&& isfield(Data,'dt') 
-            if ~isempty(Data.dt)
-            [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z);
-            [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z);
-            DataOut.U=(XOut_2-XOut_1)/Data.dt;
-            DataOut.V=(YOut_2-YOut_1)/Data.dt;
-            end
-        end
-    end
-    %transform of an image or scalar: done in phys_ima
-      
-    %transform of spatial derivatives
-    if isfield(Data,'X') && ~isempty(Data.X) && isfield(Data,'DjUi') && ~isempty(Data.DjUi)...
-          && isfield(Data,'dt')    
-        if ~isempty(Data.dt)
-            % estimate the Jacobian matrix DXpx/DXphys 
-            for ip=1:length(Data.X) 
-                [Xp1,Yp1]=phys_XYZ(Calib,Data.X(ip)+0.5,Data.Y(ip),Z);
-                [Xm1,Ym1]=phys_XYZ(Calib,Data.X(ip)-0.5,Data.Y(ip),Z);
-                [Xp2,Yp2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)+0.5,Z);
-                [Xm2,Ym2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)-0.5,Z); 
-            %Jacobian matrix DXpphys/DXpx
-               DjXi(1,1)=(Xp1-Xm1);
-               DjXi(2,1)=(Yp1-Ym1);
-               DjXi(1,2)=(Xp2-Xm2);
-               DjXi(2,2)=(Yp2-Ym2);
-               DjUi(:,:)=Data.DjUi(ip,:,:);
-               DjUi=(DjXi*DjUi')/DjXi;% =J-1*M*J , curvature effects (derivatives of J) neglected
-               DataOut.DjUi(ip,:,:)=DjUi';
-            end
-            DataOut.DjUi =  DataOut.DjUi/Data.dt;   %     min(Data.DjUi(:,1,1))=DUDX                          
-        end
-    end
-end
-
-
-%%%%%%%%%%%%%%%%%%%%
-function [A_out,Rangx,Rangy]=phys_Ima(A,CalibIn,ZIndex)
-xcorner=[];
-ycorner=[];
-npx=[];
-npy=[];
-for icell=1:length(A)
-    siz=size(A{icell});
-    npx=[npx siz(2)];
-    npy=[npy siz(1)];
-    Calib=CalibIn{icell};
-    xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordiantes of corners
-    yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
-    [xcorner_new,ycorner_new]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates
-    xcorner=[xcorner xcorner_new];
-    ycorner=[ycorner ycorner_new];
-end
-Rangx(1)=min(xcorner);
-Rangx(2)=max(xcorner);
-Rangy(2)=min(ycorner);
-Rangy(1)=max(ycorner);
-test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy)); 
-npx=max(npx);
-npy=max(npy);
-x=linspace(Rangx(1),Rangx(2),npx);
-y=linspace(Rangy(1),Rangy(2),npy);
-[X,Y]=meshgrid(x,y);%grid in physical coordiantes
-vec_B=[];
-A_out={};
-for icell=1:length(A) 
-    Calib=CalibIn{icell};
-    if (isfield(Calib,'R') && ~isequal(Calib.R(2,1),0) && ~isequal(Calib.R(1,2),0)) ||...
-        ((isfield(Calib,'kappa1')&& ~isequal(Calib.kappa1,0))) || test_multi || ~isequal(Calib,CalibIn{1})
-        zphys=0; %default
-        if isfield(Calib,'SliceCoord') %.Z= index of plane
-           SliceCoord=Calib.SliceCoord(ZIndex,:);
-           zphys=SliceCoord(3); %to generalize for non-parallel planes
-        end
-        [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,zphys);%corresponding image indices for each point in the real space grid
-        XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line'
-        YIMA=reshape(round(YIMA),1,npx*npy);
-        flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
-        testuint8=isa(A{icell},'uint8');
-        testuint16=isa(A{icell},'uint16');
-        if numel(siz)==2 %(B/W images)
-            vec_A=reshape(A{icell},1,npx*npy);%put the original image in line
-            ind_in=find(flagin);
-            ind_out=find(~flagin);
-            ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
-            ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
-            vec_B(ind_in)=vec_A(ICOMB);
-            vec_B(ind_out)=zeros(size(ind_out));
-            A_out{icell}=reshape(vec_B,npy,npx);%new image in real coordinates
-        elseif numel(siz)==3     
-            for icolor=1:siz(3)
-                vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line
-                ind_in=find(flagin);
-                ind_out=find(~flagin);
-                ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
-                ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
-                vec_B(ind_in)=vec_A(ICOMB);
-                vec_B(ind_out)=zeros(size(ind_out));
-                A_out{icell}(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates
-            end
-        end
-        if testuint8
-            A_out{icell}=uint8(A_out{icell});
-        end
-        if testuint16
-            A_out{icell}=uint16(A_out{icell});
-        end
-    else%
-        
-        A_out{icell}=A{icell};%no transform
-        Rangx=[0.5 npx-0.5];%image coordiantes of corners
-        Rangy=[npy-0.5 0.5];
-        [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],[ZIndex ZIndex]);%case of translations without rotation and quadratic deformation
-        [xx,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,[ZIndex ZIndex]);
-    end
-end
Index: unk/src/phys_XYZ.m
===================================================================
--- /trunk/src/phys_XYZ.m	(revision 7)
+++ 	(revision )
@@ -1,54 +1,0 @@
-%'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters
-% function [Xphys,Yphys]=phys_XYZ(Calib,X,Y,Z)
-%
-%OUTPUT:
-%
-%INPUT:
-%Z: index of plane
-function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)
-if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'SliceCoord')&length(Calib.SliceCoord)>=Z
-    Zindex=Z;
-    Zphys=Calib.SliceCoord(Zindex,3);%GENERALISER AUX CAS AVEC ANGLE
-else
-%     if exist('Z','var')
-%         Zphys=Z;
-%     else
-        Zphys=0;
-%     end
-end
-if ~exist('X','var')||~exist('Y','var')
-    Xphys=[];
-    Yphys=[];%default
-    return
-end
-Xphys=X;%default
-Yphys=Y;
-%image transform
-if isfield(Calib,'R')
-    R=(Calib.R)';
-    Dx=R(5)*R(7)-R(4)*R(8);
-    Dy=R(1)*R(8)-R(2)*R(7);
-    D0=Calib.f*(R(2)*R(4)-R(1)*R(5));
-    Z11=R(6)*R(8)-R(5)*R(9);
-    Z12=R(2)*R(9)-R(3)*R(8);  
-    Z21=R(4)*R(9)-R(6)*R(7);
-    Z22=R(3)*R(7)-R(1)*R(9);
-    Zx0=R(3)*R(5)-R(2)*R(6);
-    Zy0=R(1)*R(6)-R(3)*R(4);
-    A11=R(8)*Calib.Ty-R(5)*Calib.Tz+Z11*Zphys;
-    A12=R(2)*Calib.Tz-R(8)*Calib.Tx+Z12*Zphys;
-    A21=-R(7)*Calib.Ty+R(4)*Calib.Tz+Z21*Zphys;
-    A22=-R(1)*Calib.Tz+R(7)*Calib.Tx+Z11*Zphys;
-    X0=Calib.f*(R(5)*Calib.Tx-R(2)*Calib.Ty+Zx0*Zphys);
-    Y0=Calib.f*(-R(4)*Calib.Tx+R(1)*Calib.Ty+Zy0*Zphys);
-        %px to camera:
-    Xd=(Calib.dpx/Calib.sx)*(X-Calib.Cx); % sensor coordinates
-    Yd=Calib.dpy*(Y-Calib.Cy);
-    dist_fact=1+Calib.kappa1*(Xd.*Xd+Yd.*Yd); %distortion factor
-    Xu=dist_fact.*Xd;%undistorted sensor coordinates
-    Yu=dist_fact.*Yd;
-    denom=Dx*Xu+Dy*Yu+D0;
-    % denom2=denom.*denom;
-    Xphys=(A11.*Xu+A12.*Yu+X0)./denom;%world coordinates
-    Yphys=(A21.*Xu+A22.*Yu+Y0)./denom;
-end
Index: unk/src/phys_polar.m
===================================================================
--- /trunk/src/phys_polar.m	(revision 7)
+++ 	(revision )
@@ -1,226 +1,0 @@
-%transform image coordinates (px) to physical coordinates
-% then transform to polar coordinates: 
-%[DataOut,DataOut_1]=phys_polar(varargin)
-%
-% OUTPUT: 
-% DataOut: structure of modified data field: .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components
-% DataOut_1:  second data field (if two fields are in input)
-%
-%INPUT:
-% Data:  structure of input data (like UvData)
-% CalibData= structure containing the field .GeometryCalib with calibration parameters
-% Data_1:  second input field (not mandatory)
-% CalibData_1= calibration parameters for the second field
-
-function [DataOut,DataOut_1]=phys_polar(varargin)
-Calib{1}=[];
-if nargin==2||nargin==4
-    Data=varargin{1};
-    DataOut=Data;%default
-    DataOut_1=[];%default
-    CalibData=varargin{2};
-    if isfield(CalibData,'GeometryCalib')
-        Calib{1}=CalibData.GeometryCalib;
-    end
-    Calib{2}=Calib{1};
-else
-    DataOut.Txt='wrong input: need two or four structures';
-end
-test_1=0;
-if nargin==4
-    test_1=1;
-    Data_1=varargin{3};
-    DataOut_1=Data_1;%default
-    CalibData_1=varargin{4};
-    if isfield(CalibData_1,'GeometryCalib')
-        Calib{2}=CalibData_1.GeometryCalib;
-    end
-end
-
-%parameters for polar coordinates (taken from the calibration data of the first field)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-origin_xy=[0 0];%center for the polar coordinates in the original x,y coordinates
-if isfield(Calib{1},'PolarCentre') && isnumeric(Calib{1}.PolarCentre)
-    if isequal(length(Calib{1}.PolarCentre),2);
-        origin_xy= Calib{1}.PolarCentre;
-    end
-end
-radius_offset=0;%reference radius used to offset the radial coordinate r 
-angle_offset=0; %reference angle used as new origin of the polar angle (= axis Ox by default)
-if isfield(Calib{1},'PolarReferenceRadius') && isnumeric(Calib{1}.PolarReferenceRadius)
-    radius_offset=Calib{1}.PolarReferenceRadius;
-end
-if radius_offset > 0
-    angle_scale=radius_offset; %the azimuth is rescale in terms of the length along the reference radius
-else
-    angle_scale=180/pi; %polar angle in degrees 
-end
-if isfield(Calib{1},'PolarReferenceAngle') && isnumeric(Calib{1}.PolarReferenceAngle)
-    angle_offset=Calib{1}.PolarReferenceAngle; %offset angle (in unit of the final angle, degrees or arc length along the reference radius))
-end
-% new x coordinate = radius-radius_offset;
-% new y coordinate = theta*angle_scale-angle_offset
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-iscalar=0;
-if  ~isempty(Calib{1})
-    DataOut=phys_1(Data,Calib{1},origin_xy,radius_offset,angle_offset,angle_scale);
-    %case of images or scalar
-    if isfield(Data,'A')&isfield(Data,'AX')&~isempty(Data.AX) & isfield(Data,'AY')&...
-                                           ~isempty(Data.AY)&length(Data.A)>1
-        iscalar=1;
-        A{1}=Data.A;
-    end
-    %transform of X,Y coordinates for vector fields
-    if isfield(Data,'ZIndex')&~isempty(Data.ZIndex)
-        ZIndex=Data.ZIndex;
-    else
-        ZIndex=0;
-    end
-end
-
-if test_1
-    DataOut_1=phys_1(Data_1,Calib{2},origin_xy,radius_offset,angle_offset,angle_scale);
-    if isfield(Data_1,'A')&isfield(Data_1,'AX')&~isempty(Data_1.AX) & isfield(Data_1,'AY')&...
-                                       ~isempty(Data_1.AY)&length(Data_1.A)>1
-          iscalar=iscalar+1;
-          Calib{iscalar}=Calib{2};
-          A{iscalar}=Data_1.A;
-          if isfield(Data_1,'ZIndex')&~isequal(Data_1.ZIndex,ZIndex)
-              DataOut.Txt='inconsistent plane indexes in the two input fields';
-          end
-          if iscalar==1% case for which only the second field is a scalar
-               [A,AX,AY]=phys_Ima(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);
-               DataOut_1.A=A{1};
-               DataOut_1.AX=AX; 
-               DataOut_1.AY=AY;
-               return
-          end
-    end
-end
-if iscalar~=0
-    [A,AX,AY]=phys_Ima(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);%
-    DataOut.A=A{1};
-    DataOut.AX=AX; 
-    DataOut.AY=AY;
-    if iscalar==2
-        DataOut_1.A=A{2};
-        DataOut_1.AX=AX; 
-        DataOut_1.AY=AY;
-    end
-end
-
-%------------------------------------------------
-function DataOut=phys_1(Data,Calib,origin_xy,radius_offset,angle_offset,angle_scale)
-
-DataOut=Data;
-DataOut.CoordType='phys'; %put flag for physical coordinates
-if isfield(Calib,'CoordUnit')
-    DataOut.CoordUnit=Calib.CoordUnit;
-else
-    DataOut.CoordUnit='cm'; %default
-end
-DataOut.TimeUnit='s';
-%perform a geometry transform if Calib contains a field .GeometryCalib 
-if isfield(Data,'CoordType') && isequal(Data.CoordType,'px') && ~isempty(Calib)
-    if isfield(Data,'CoordUnit')
-         DataOut=rmfield(DataOut,'CoordUnit');
-    end
-    %transform of X,Y coordinates for vector fields
-    if isfield(Data,'ZIndex')&~isempty(Data.ZIndex)
-        Z=Data.ZIndex;
-    else
-        Z=0;
-    end
-    if isfield(Data,'X') &isfield(Data,'Y')&~isempty(Data.X) & ~isempty(Data.Y)
-        [DataOut.X,DataOut.Y,DataOut.Z]=phys_XYZ(Calib,Data.X,Data.Y,Z); %transform from pixels to physical
-        DataOut.X=DataOut.X-origin_xy(1);%origin of coordinates at the tank center
-        DataOut.Y=DataOut.Y-origin_xy(2);%origin of coordinates at the tank center
-        [theta,DataOut.X] = cart2pol(DataOut.X,DataOut.Y);%theta  and X are the polar coordinates angle and radius
-          %shift and renormalize the polar coordinates
-        DataOut.X=DataOut.X-radius_offset;%
-        DataOut.Y=theta*angle_scale-angle_offset;% normalized angle: distance along reference radius
-        %transform velocity field if exists
-        if isfield(Data,'U')&isfield(Data,'V')&~isempty(Data.U) & ~isempty(Data.V)& isfield(Data,'dt') 
-            if ~isempty(Data.dt)
-            [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z);
-            [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z);
-            UX=(XOut_2-XOut_1)/Data.dt;
-            VY=(YOut_2-YOut_1)/Data.dt;      
-            %transform u,v into polar coordiantes
-            DataOut.U=UX.*cos(theta)+VY.*sin(theta);%radial velocity
-            DataOut.V=(-UX.*sin(theta)+VY.*cos(theta));%./(DataOut.X)%+radius_ref);%angular velocity calculated 
-            %shift and renormalize the angular velocity
-            end
-        end
-    end
-end
-
- 
-%%%%%%%%%%%%%%%%%%%%
-function [A_out,Rangx,Rangy]=phys_Ima(A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)
-xcorner=[];
-ycorner=[];
-npx=[];
-npy=[];
-
-for icell=1:length(A)
-    siz=size(A{icell});
-    npx=[npx siz(2)];
-    npy=[npy siz(1)];
-    zphys=0; %default
-    if isfield(CalibIn{icell},'SliceCoord') %.Z= index of plane
-       SliceCoord=CalibIn{icell}.SliceCoord(ZIndex,:);
-       zphys=SliceCoord(3); %to generalize for non-parallel planes
-    end
-    xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordiantes of corners
-    yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
-    [xcorner_new,ycorner_new]=phys_XYZ(CalibIn{icell},xima,yima,ZIndex);%corresponding physical coordinates
-    %transform the corner coordinates into polar ones    
-    xcorner_new=xcorner_new-origin_xy(1);%shift to the origin of the polar coordinates 
-    ycorner_new=ycorner_new-origin_xy(2);%shift to the origin of the polar coordinates       
-    [theta,xcorner_new] = cart2pol(xcorner_new,ycorner_new);%theta  and X are the polar coordinates angle and radius
-    if (max(theta)-min(theta))>pi   %if the polar origin is inside the image
-        xcorner_new=[0 max(xcorner_new)];
-        theta=[-pi pi];
-    end
-          %shift and renormalize the polar coordinates
-    xcorner_new=xcorner_new-radius_offset;%
-    ycorner_new=theta*angle_scale-angle_offset;% normalized angle: distance along reference radius
-    xcorner=[xcorner xcorner_new];
-    ycorner=[ycorner ycorner_new];
-end
-Rangx(1)=min(xcorner);
-Rangx(2)=max(xcorner);
-Rangy(2)=min(ycorner);
-Rangy(1)=max(ycorner);
-% test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy)); 
-npx=max(npx);
-npy=max(npy);
-x=linspace(Rangx(1),Rangx(2),npx);
-y=linspace(Rangy(1),Rangy(2),npy);
-[X,Y]=meshgrid(x,y);%grid in physical coordinates
-%transform X, Y in cartesian
-X=X+radius_offset;%
-Y=(Y+angle_offset)/angle_scale;% normalized angle: distance along reference radius
-[X,Y] = pol2cart(Y,X);
-X=X+origin_xy(1);%shift to the origin of the polar coordinates 
-Y=Y+origin_xy(2);%shift to the origin of the polar coordinates 
-for icell=1:length(A) 
-    [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,zphys);%corresponding image indices for each point in the real space grid
-    XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line'
-    YIMA=reshape(round(YIMA),1,npx*npy);
-    flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
-    vec_A=reshape(A{icell}(:,:,1),1,npx*npy);%put the original image in line
-    ind_in=find(flagin);
-    ind_out=find(~flagin);
-    ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
-    ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
-    vec_B(ind_in)=vec_A(ICOMB);
-    vec_B(ind_out)=zeros(size(ind_out));
-    A_out{icell}=reshape(vec_B,npy,npx);%new image in real coordinates
-end
-%Rangx=Rangx-radius_offset;
-
-
Index: unk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 7)
+++ 	(revision )
@@ -1,1160 +1,0 @@
-%'plot_field': plot any field with the structure defined in the uvmat package
-%------------------------------------------------------------------------
-%
-%  This function is used by uvmat to plot fields. It automatically chooses the representation 
-% appropriate to the input field structure: 
-%     2D vector fields are represented by arrows, 2D scalar fiedlds by grey scale images or contour plots, 1D fields are represented by usual plot with (abscissa, ordinate).
-%  The input field structure is first tested by check_field_structure.m,
-%  then split into blocks of related variables  by find_field_indices.m.
-%  The dimensionality of each block is obtained  by this fuction
-%  considering the presence of variables with the attribute .Role='coord_x'
-%  and/or coord_y and/or coord_z (case of unstructured coordinates), or
-%  dimension variables (case of matrices). 
-%
-% function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,KeepLim,PosColorbar)
-%
-% OUPUT:
-% PlotType: type of plot: 'text','line'(curve plot),'plane':2D view,'volume'
-% PlotParamOut: structure, representing the updated  plotting parameters, in case of automatic scaling
-% haxes: handle of the plotting axis, when a new figure is created.
-%
-%INPUT
-%    Data:   structure describing the field to plot 
-%         (optional) .ListGlobalAttribute: cell listing the names of the global attributes
-%                    .Att_1,Att_2... : values of the global attributes
-%         (requested)  .ListVarName: list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} ) 
-%         (requested)  .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)
-%                      .VarAttribute: cell of attributes for each element of .ListVarName (cell array of structures of the form VarAtt.key=value)
-%         (requested) .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
-%  
-%            Variable attribute .Role :
-%    The only variable attribute used for plotting purpose is .Role which can take
-%    the values
-        %       Role = 'scalar':  (default) represents a scalar field
-        %            = 'coord_x', 'coord_y',  'coord_z': represents a separate set of
-        %                        unstructured coordinate x, y  or z
-        %            = 'vector': represents a vector field whose number of components
-        %                is given by the last dimension (called 'nb_dim')
-        %            = 'vector_x', 'vector_y', 'vector_z'  :represents the x, y or z  component of a vector  
-        %            = 'warnflag' : provides a warning flag about the quality of data in a 'Field', default=0, no warning
-        %            = 'errorflag': provides an error flag marking false data,
-        %                   default=0, no error. Different non zero values can represent different criteria of elimination.
-
-
-%         additional elements characterizing the projection object (should not be necessary)--
-%            Data.Style : style of projection object
-%            Data.XObject,.YObject: set of coordinates defining the object position;
-%            Data.ProjMode=type of projection ;
-%            Data.ProjAngle=angle of projection;
-%            Data.DX,.DY,.DZ=increments;
-%            Data.MaxY,MinY: min and max Y
-
-%   haxes: handle of the plotting axes to update with the new plot. If this input is absent or not a valid axes handle, a new figure is created.
-%
-%   PlotParam: parameters for plotting, as read on the uvmat interface (by function 'read_plot_param.m')
-%            --scalars--
-%    .Scalar.MaxA: upper bound (saturation color) for the scalar representation, max(field) by default
-%    .Scalar.MinA: lower bound (saturation) for the scalar representation, min(field) by default
-%    .Scalar.AutoScal: =1 (default) lower and upper bounds of the scalar representation set to the min and max of the field
-%               =0 lower and upper bound imposed by .AMax and .MinA
-%    .Scalar.BW= 1 black and white representation imposed, =0 by default.
-%    .Scalar.Contours= 1: represent scalars by contour plots (Matlab function 'contour'); =0 by default
-%    .IncrA : contour interval
-%            -- vectors--
-%    .Vectors.VecScale: scale for the vector representation
-%    .Vectors.AutoVec: =0 (default) automatic length for vector representation, =1: length set by .VecScale
-%    .Vectors.HideFalse= 0 (default) false vectors represented in magenta, =1: false vectors not represented;
-%    .Vectors.HideWarning= 0 (default) vectors marked by warnflag~=0 marked in black, 1: no warning representation;
-%    .Vectors.decimate4 = 0 (default) all vectors reprtesented, =1: half of  the vectors represented along each coordinate
-%         -- vector color--
-%    .Vectors.ColorCode= 'black','white': imposed color  (default ='blue')
-%                        'rgb', : three colors red, blue, green depending
-%                        on thresholds .colcode1 and .colcode2 on the input  scalar value (C)
-%                        'brg': like rgb but reversed color order (blue, green, red)
-%                        '64 colors': continuous color from blue to red (multijet)
-%    .Vectors.colcode1 : first threshold for rgb, first value for'continuous' 
-%    .Vectors.colcode2 : second threshold for rgb, last value (saturation) for 'continuous' 
-%    .Vectors.FixedCbounds;  =0 (default): the bounds on C representation are min and max, =1: they are fixed by .Minc and .MaxC
-%    .Vectors.MinC = imposed minimum of the scalar field used for vector color;
-%    .Vectors.MaxC = imposed maximum of the scalar field used for vector color;
-%
-% KeepLim:=0 (default) adjust axes limit to the X,Y data, =1: preserves the previous axes limits
-% PosColorbar: if not empty, display a colorbar for B&W images
-%               imposed position of the colorbar (ex [0.821 0.471 0.019 0.445])
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,KeepLim,PosColorbar)
-%default output
-if ~exist('PlotParam','var'),PlotParam=[];end;
-if ~exist('KeepLim','var'),KeepLim=0;end;
-if ~exist('PosColorbar','var'),PosColorbar=[];end;
-PlotType='text'; %default
-PlotParamOut=PlotParam;%default
-
-% check input structure
-[Data,errormsg]=check_field_structure(Data);
-
-if ~isempty(errormsg)
-    msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg])
-    display(['input of plot_field/check_field_structure:: ' errormsg])
-    return
-end
-
-testnewfig=1;%test to create a new figure (default)
-testzoomaxes=0;%test for the existence of a zoom secondary figure attached to the plotting axes
-if exist('haxes','var')
-    if ishandle(haxes)
-        if isequal(get(haxes,'Type'),'axes')
-%             hfig=get(haxes,'Parent');
-            axes(haxes)
-            testnewfig=0;
-            AxeData=get(haxes,'UserData');
-            if isfield(AxeData,'ZoomAxes')&& ishandle(AxeData.ZoomAxes)
-                if isequal(get(AxeData.ZoomAxes,'Type'),'axes') 
-                    testzoomaxes=1;
-                    zoomaxes=AxeData.ZoomAxes;
-                end
-            end
-        end
-    end
-end
-if testnewfig% create a new figure and axes if the plotting axes does not exist
-    hfig=figure;
-    if isfield(Data,'IndexObj')&isfield(Data,'Style')&isfield(Data,'ProjMode')
-        figname=[num2str(Data.IndexObj) '-' set_title(Data.Style,Data.ProjMode)];
-        set(hfig,'Name',figname)
-    end
-    testhandle=0;
-    if isfield(PlotParam,'text_display_1')& ishandle(PlotParam.text_display_1)
-        set(hfig,'UserData',PlotParam)
-        testhandle=1;
-    end
-    set(hfig,'Units','normalized')
-    set(hfig,'WindowButtonDownFcn','mouse_down')
-    %set(hfig,'WindowButtonMotionFcn',{'mouse_motion',PlotParam})%set mouse action function
-    set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action function
-    set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse action function
-    haxes=axes;
-    set(haxes,'position',[0.13,0.2,0.775,0.73])
-end
-if isfield(PlotParam,'text_display_1')& ishandle(PlotParam.text_display_1)
-    PlotParam=read_plot_param(PlotParam);   
-end
-if testnewfig
-  PlotParam.NextPlot='add'; %parameter for plot_profile and plot_hist
-end
-if isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1) 
-    set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
-end
-
-% check the cells of fields :
-testnbdim=1;
-[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
-
-if ~isempty(errormsg)
-    msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg])
-    display(['input of plot_field: ' errormsg])
-    return
-end
-if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot 
-    [Data.NbDim,imax]=max(NbDim);
-end
-if isequal(Data.NbDim,0) % TODO: chech whether this function is still used, replace by plot_profile ?
-%     if isfield(Data,'Style') & isequal(Data.Style,'points')
-        AxeData=plot_text(Data,haxes);
-        PlotType='text';
-%     else
-%         [AxeData,haxes]=plot_hist(Data,haxes,PlotParam);
-%     end
-elseif isequal(Data.NbDim,1)
-    [AxeData,haxes]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);% 
-    if testzoomaxes
-        [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam);
-        AxeData.ZoomAxes=zoomaxes;
-    end
-    PlotType='line';
-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,KeepLim,PosColorbar);
-    if testzoomaxes
-        [AxeData,zoomaxes,PlotParamOut]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
-        AxeData.ZoomAxes=zoomaxes;
-    end
-elseif isequal(Data.NbDim,3)
-    msgbox_uvmat('ERROR','volume plot not implemented yet')
-    return
-    %plot_volume(haxes,Data,PlotParam)% A FAIRE
-    %PlotType='volume';
-else
-    testnbdim=0;
-end
-
-%display (or delete) error message
-htext=findobj(haxes,'Tag','hTxt');
-if isfield(Data,'Txt')
-    if isempty(htext)
-        Xlim=get(haxes,'XLim');
-        Ylim=get(haxes,'YLim');
-        htext=text(Xlim(1),(Ylim(1)+Ylim(2))/2,Data.Txt,'Tag','hTxt','Color','r');
-        set(htext,'Interpreter','none')
-    else
-        set(htext,'String',Data.Txt)
-    end
-elseif ~isempty(htext)
-    delete(htext)
-end
-
-% set graph aspect ratio
-
-
-set(haxes,'UserData',AxeData)
-%set(haxes,'Tag','uvmat'); 
-
- 
-% %-------------------------------------------
-% function [AxeData,haxes]=plot_hist(Data,haxes,PlotParam)% TODO: chech whether this function is still used, replace by plot_profile ?
-% %------------------------------------------
-% AxeData=get(haxes,'UserData'); %defau
-% hfig=get(haxes,'parent');
-% if ~isfield(Data,'ListVarName')
-%     return
-% end
-% ColorOrder=[1 0 0;0 0.5 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
-% set(haxes,'ColorOrder',ColorOrder)
-% if isfield(PlotParam,'NextPlot')
-%     set(haxes,'NextPlot',PlotParam.NextPlot)
-% end
-% charplot='''-''';
-% iplot=0;
-% legend_str={};
-% label_str='';
-% textmean={};
-% plotstr='plot(';
-% for ilist=1:length(Data.ListVarName)
-%     VarName=Data.ListVarName{ilist}; 
-%     eval(['[' VarName 'hist,' VarName 'val]=hist(double(Data.' VarName '),100);']);%coordinate variable set as c
-%     plotstr=[plotstr VarName 'val,' VarName 'hist,' charplot ','];
-%     eval(['nbcomponent2=size(Data.' VarName ',2);']);
-%     eval(['nbcomponent1=size(Data.' VarName ',1);']);
-%     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
-%         for ic=1:min(nbcomponent1,nbcomponent2)
-%             legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components 
-%                                                                % labeled by their index (e.g. color component)
-%         end
-%     end
-%     label_str=[label_str ' ' VarName]; 
-% end
-% if ~isequal(plotstr,'plot(')
-%     plotstr(end)=')';
-%     eval(plotstr)
-%     hlegend=findobj(hfig,'Tag','legend');%find existing legend on the plot
-%     if ~isempty(hlegend)
-%         legend_old=get(hlegend,'String');
-%         if isequal(size(legend_old,1),size(legend_str,1))
-%              legend_str=[legend_old legend_str];
-%         end
-%     end
-%     legend(legend_str)
-%     xlabel(label_str)
-%     ylabel('nb values')
-%      grid on
-%     title_str='';
-%     if isfield(Data,'filename')
-%        [Path, title_str, ext]=fileparts(Data.filename);
-%        title_str=[title_str ext];
-%     end
-%     if isfield(Data,'Action')
-%         if ~isequal(title_str,'')
-%             title_str=[title_str ', '];
-%         end
-%         title_str=[title_str Data.Action];
-%     end
-%     htitle=title(title_str);
-%     set(htitle,'Interpreter','none')% desable tex interpreter
-%     hlist=findobj(gcf,'Style','listbox');
-%     if isempty(hlist)
-%             uicontrol('Style','popupmenu','Position',[20 20 200 20],'String',textmean);
-%     else
-%             set(hlist(1),'String',textmean)
-%     end
-% end
-% AxeData=Data;
-
-
-%----------------------------------------------------------
-function [AxeData,haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
-%-----------------------------------------------------------
-axes(haxes)
-hfig=get(haxes,'parent');
-AxeData=data;
-ColorOrder=[1 0 0;0 0.5 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
-set(haxes,'ColorOrder',ColorOrder)
-if isfield(PlotParam,'NextPlot')
-    set(haxes,'NextPlot',PlotParam.NextPlot)
-end
-legend_str={};
-
-%initiates string of the plot command
-plotstr='plot(';
-textmean={};
-abscissa_name='';
-coord_x_index=[];
-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;
-    else
-        coord_x_index_cell=VarType{icell}.coord(1);
-        if isequal(coord_x_index_cell,0)
-            continue  % the cell has no abscissa, skip it
-        end
-        if ~isempty(coord_x_index)&&~isequal(coord_x_index_cell,coord_x_index)
-            continue %all the selected variables must have the same first dimension
-        else
-            coord_x_index=coord_x_index_cell;
-        end
-    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 ')'];
-    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;
-    end
-    if ~isempty(VarType{icell}.warnflag')
-            testplot(VarType{icell}.warnflag)=0;
-    end
-    if ~isempty(VarType{icell}.discrete')
-         charplot_0='''+''';
-    else
-          charplot_0='''-''';
-    end
-%     if testcoordvar==0
-%         coord_x{icell}=[1:data.DimValue(DimIndices(1))];%abscissa by default if no coordinate variable
-%        % charplot_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
-    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 ','];
-            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
-if ~isequal(plotstr,'plot(')
-    plotstr(end)=')';
-                %execute plot (instruction  plotstr)
-    eval(plotstr)
-                %%%%%
-    grid on
-    hxlabel=xlabel(xtitle);
-    set(hxlabel,'Interpreter','none')% desable tex interpreter
-    if length(legend_str)>=1
-        hylabel=ylabel(legend_str{end});
-        set(hylabel,'Interpreter','none')% desable tex interpreter
-    end
-    if ~isempty(legend_str)
-        hlegend=findobj(hfig,'Tag','legend');
-        if isempty(hlegend)
-            hlegend=legend(legend_str);
-            txt=ver;
-            Release=txt(1).Release;
-            relnumb=str2num(Release(3:4));
-            if relnumb >= 14
-                set(hlegend,'Interpreter','none')% desable tex interpreter
-            end
-        else
-            legend_old=get(hlegend,'String');
-            if isequal(size(legend_old,1),size(legend_str,1))&~isequal(legend_old,legend_str)
-                set(hlegend,'String',[legend_old legend_str]);
-            end
-        end 
-    end
-    title_str='';
-    if isfield(data,'filename')
-       [Path, title_str, ext]=fileparts(data.filename);
-       title_str=[title_str ext];
-    end
-    if isfield(data,'Action')
-        if ~isequal(title_str,'')
-            title_str=[title_str ', '];
-        end
-        title_str=[title_str data.Action];
-    end
-    htitle=title(title_str);
-    txt=ver;
-    Release=txt(1).Release;
-    relnumb=str2num(Release(3:4));
-    if relnumb >= 14
-        set(htitle,'Interpreter','none')% desable tex interpreter
-    end
-    % A REPRENDRE Mean
-%         hlist=findobj(gcf,'Style','listbox','Tag','liststat');
-%         if isempty(hlist)
-%             'text'
-%             textmean
-%             set(gca,'position',[0.13,0.2,0.775,0.73])
-%             uicontrol('Style','popupmenu','Position',[20 20 200 20],'String',textmean,'Tag','liststat');
-%         else
-%             set(hlist(1),'String',textmean)
-%         end
-end
-
-
-%---------------------------------------
-% plot_plane
-%----------------------------------------
-function [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,KeepLim,PosColorbar)
-
-%default plotting parameters
-PlotType='plane';%default
-if ~exist('PlotParam','var')
-    PlotParam=[];
-end
-if ~isfield(PlotParam,'Scalar')
-    PlotParam.Scalar=[];
-end
-if ~isfield(PlotParam,'Vectors')
-    PlotParam.Vectors=[];
-end
-PlotParamOut=PlotParam;%default
-
-%plotting axes
-hfig=get(haxes,'parent');
-hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
-hima=findobj(haxes,'Tag','ima');% search existing image in the current axes
-AxeData=get(haxes,'UserData'); %default
-if ~isstruct(AxeData)% AxeData must be a structure
-    AxeData=[];
-end
-AxeData.NbDim=2;
-if isfield(Data,'ObjectCoord')
-    AxeData.ObjectCoord=Data.ObjectCoord;
-end
-
-test_ima=0; %default: test for image or map plot
-test_vec=0; %default: test for vector plots
-test_black=0;
-test_false=0;
-test_C=0;
-XName='';
-x_units='';
-YName='';
-y_units='';
-for icell=1:length(CellVarIndex) % length(CellVarIndex) =1 or 2 (from the calling function)
-%     VarIndex=CellVarIndex{icell};
-    VarType=VarTypeCell{icell};
-    ivar_X=VarType.coord_x; % defines (unique) index for the variable representing unstructured x coordinate (default =[])
-    ivar_Y=VarType.coord_y; % defines (unique)index for the variable representing unstructured y coordinate (default =[])
-    ivar_U=VarType.vector_x; % defines (unique) index for the variable representing x vector component (default =[])
-    ivar_V=VarType.vector_y; % defines (unique) index for the variable representing y vector component (default =[])
-    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')
-        return
-    end
-    ivar_F=VarType.warnflag; %defines index (unique) for warning flag variable
-    ivar_FF=VarType.errorflag; %defines index (unique) for error flag variable
-    ind_coord=find(VarType.coord);
-    if numel(ind_coord)==2
-        VarType.coord=VarType.coord(ind_coord);
-    end
-    idim_Y=[];  
-    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')
-            return
-        else
-            test_vec=1;
-            eval(['vec_U=Data.' Data.ListVarName{ivar_U} ';']) 
-            eval(['vec_V=Data.' Data.ListVarName{ivar_V} ';']) 
-            if ~isempty(ivar_X) && ~isempty(ivar_Y)% 2D field (with unstructured coordinates or structured ones (then ivar_X and ivar_Y empty)     
-                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
-                eval(['y=Data.' Data.ListVarName{VarType.coord(1)} ';']) 
-                eval(['x=Data.' Data.ListVarName{VarType.coord(2)} ';'])
-                if numel(y)==2 % y defined by first and last values on aregular mesh
-                    y=linspace(y(1),y(2),size(vec_U,1));
-                end
-                if numel(x)==2 % y defined by first and last values on aregular mesh
-                    x=linspace(x(1),x(2),size(vec_U,2));
-                end
-                [vec_X,vec_Y]=meshgrid(x,y);  
-            else
-                msgbox_uvmat('ERROR','error in plot_field: invalid coordinate definition for vector field')
-                return
-            end
-            if ~isempty(ivar_C)
-                 eval(['vec_C=Data.' Data.ListVarName{ivar_C} ';']) ;
-                 vec_C=reshape(vec_C,1,numel(vec_C));
-                 test_C=1;
-            end
-            if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1)) 
-                if test_vec 
-                    eval(['vec_F=Data.' Data.ListVarName{ivar_F} ';']) % warning flags for  dubious vectors
-                    if  ~(isfield(PlotParam.Vectors,'HideWarning') && isequal(PlotParam.Vectors.HideWarning,1)) 
-                        test_black=1;
-                    end
-                end
-            end
-            if ~isempty(ivar_FF) %&& ~test_false
-                if test_vec% TODO: deal with FF for structured coordinates
-                    eval(['vec_FF=Data.' Data.ListVarName{ivar_FF} ';']) % flags for false vectors
-                end
-            end
-        end
-    elseif ~isempty(ivar_C) %scalar or image
-        if test_ima
-             msgbox_uvmat('ERROR','attempt to plot two scalar fields or images')
-            return
-        end
-        eval(['A=squeeze(Data.' Data.ListVarName{ivar_C} ');']) ;% scalar represented as color image
-        test_ima=1;
-        if ~isempty(ivar_X) && ~isempty(ivar_Y)% 2D field (with unstructured coordinates or structured ones (then ivar_X and ivar_Y empty) 
-            XName=Data.ListVarName{ivar_X};
-            YName=Data.ListVarName{ivar_Y};
-            eval(['AX=Data.' XName ';']) 
-            eval(['AY=Data.' YName ';'])
-            [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256');  % interpolate on a grid  
-            if isfield(Data,'VarAttribute')
-                if numel(Data.VarAttribute)>=ivar_X & isfield(Data.VarAttribute{ivar_X},'units')
-                    x_units=['(' Data.VarAttribute{ivar_X}.units ')'];
-                end
-                if numel(Data.VarAttribute)>=ivar_Y & isfield(Data.VarAttribute{ivar_Y},'units')
-                    y_units=['(' Data.VarAttribute{ivar_Y}.units ')'];
-                end
-            end        
-        elseif numel(VarType.coord)==2 %structured coordinates
-            XName=Data.ListVarName{VarType.coord(2)};
-            YName=Data.ListVarName{VarType.coord(1)};
-            eval(['AY=Data.' Data.ListVarName{VarType.coord(1)} ';']) 
-            eval(['AX=Data.' Data.ListVarName{VarType.coord(2)} ';'])
-            test_interp_X=0; %default, regularly meshed X coordinate
-            test_interp_Y=0; %default, regularly meshed Y coordinate
-            if isfield(Data,'VarAttribute')
-                if numel(Data.VarAttribute)>=VarType.coord(2) & isfield(Data.VarAttribute{VarType.coord(2)},'units')
-                    x_units=['(' Data.VarAttribute{VarType.coord(2)}.units ')'];
-                end
-                if numel(Data.VarAttribute)>=VarType.coord(1) & isfield(Data.VarAttribute{VarType.coord(1)},'units')
-                    y_units=['(' Data.VarAttribute{VarType.coord(1)}.units ')'];
-                end
-            end  
-            if numel(AY)>2
-                DAY=diff(AY);
-                DAY_min=min(DAY);
-                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)} ];
-                      return
-                end 
-                test_interp_Y=(DAY_max-DAY_min)> 0.0001*abs(DAY_max);
-            end
-            if numel(AX)>2
-                DAX=diff(AX);
-                DAX_min=min(DAX);
-                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)} ];
-                      return
-                end 
-                test_interp_X=(DAX_max-DAX_min)> 0.0001*abs(DAX_max);
-            end  
-            if test_interp_Y          
-                npxy(1)=max([256 floor((AY(end)-AY(1))/DAY_min) floor((AY(end)-AY(1))/DAY_max)]);
-                yI=linspace(AY(1),AY(end),npxy(1));
-                if ~test_interp_X
-                    xI=linspace(AX(1),AX(end),size(A,2));%default 
-                    AX=xI;
-                end
-            end
-            if test_interp_X  
-                npxy(1)=max([256 floor((AX(end)-AX(1))/DAX_min) floor((AX(end)-AX(1))/DAX_max)]);
-                xI=linspace(AX(1),AX(end),npxy(2));   
-                if ~test_interp_Y
-                   yI=linspace(AY(1),AY(end),size(A,1)); 
-                   AY=yI;
-                end
-            end
-            if test_interp_X || test_interp_Y               
-                [AX2D,AY2D]=meshgrid(AX,AY);
-                A=interp2(AX2D,AY2D,double(A),xI,yI');
-            end
-            AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation 
-            AY=[AY(1) AY(end)];
-        else
-            msgbox_uvmat('ERROR','error in plot_field: invalid coordinate definition ')
-            return
-        end
-          x_label=[Data.ListVarName{ivar_X} '(' x_units ')'];
-    end       
-%     if isfield(Data,'VarAttribute')
-%         VarAttribute=Data.VarAttribute;
-%     end    
-end 
-
-%%%%%%%%%%%%%%%%%%%%%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
-
-if ~isfield(PlotParam.Scalar,'Contours')
-    PlotParam.Scalar.Contours=0; %default
-end
-PlotParamOut=PlotParam; %default
-if test_ima
-    % distinguish B/W and color images
-    np=size(A);%size of image
-    siz=size(np);
-    %set the color map
-    if siz(2)==2 %for black and white images
-        if ~isfield(PlotParam.Scalar,'AutoScal')
-            PlotParam.Scalar.AutoScal=0;%default
-        end
-        if ~isfield(PlotParam.Scalar,'MinA')
-            PlotParam.Scalar.MinA=[];%default
-        end
-        if ~isfield(PlotParam.Scalar,'MaxA')
-            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
-            MinA=double(min(min(A)));
-        else
-            MinA=PlotParam.Scalar.MinA;  
-        end; 
-        if isequal(PlotParam.Scalar.AutoScal,0)|isempty(PlotParam.Scalar.MaxA)|~isa(PlotParam.Scalar.MaxA,'double') %correct if there is no numerical data in edit box
-            MaxA=double(max(max(A)));
-        else
-            MaxA=PlotParam.Scalar.MaxA;  
-        end; 
-        PlotParamOut.Scalar.MinA=MinA;
-        PlotParamOut.Scalar.MaxA=MaxA;
-        axes(haxes)
-        if isequal(PlotParam.Scalar.Contours,1)
-            if ~isempty(hima) & ishandle(hima)
-                delete(hima)
-            end
-            if ~isfield(PlotParam.Scalar,'IncrA')
-                PlotParam.Scalar.IncrA=[];
-            end
-            if isempty(PlotParam.Scalar.IncrA)% | PlotParam.Scalar.AutoScal==0
-                cont=colbartick(MinA,MaxA);
-                intercont=cont(2)-cont(1);%default
-                PlotParamOut.Scalar.IncrA=intercont;
-            else
-               intercont=PlotParam.Scalar.IncrA;
-            end
-            B=A;            
-            abscontmin=intercont*floor(MinA/intercont);
-            abscontmax=intercont*ceil(MaxA/intercont);
-            contmin=intercont*floor(min(min(B))/intercont);
-            contmax=intercont*ceil(max(max(B))/intercont);
-            cont_pos_plus=[0:intercont:contmax];
-            cont_pos_min=[double(contmin):intercont:-intercont];
-            cont_pos=[cont_pos_min cont_pos_plus];
-            sizpx=(AX(end)-AX(1))/(np(2)-1);
-            sizpy=(AY(1)-AY(end))/(np(1)-1);
-            x_cont=[AX(1):sizpx:AX(end)]; % pixel x coordinates for image display 
-            y_cont=[AY(1):-sizpy:AY(end)]; % pixel x coordinates for image display
-            txt=ver;%version of Matlab
-            Release=txt(1).Release;
-            relnumb=str2num(Release(3:4));
-            if relnumb >= 14
-                    vec=linspace(0,1,(abscontmax-abscontmin)/intercont);%define a greyscale colormap with steps intercont
-                map=[vec' vec' vec'];
-                colormap(map);
-                [var,hcontour]=contour(x_cont,y_cont,B,cont_pos);        
-                set(hcontour,'Fill','on')
-                set(hcontour,'LineStyle','none')
-                hold on
-            end
-            [var_p,hcontour_p]=contour(x_cont,y_cont,B,cont_pos_plus,'k-');
-            hold on
-            [var_m,hcontour_m]=contour(x_cont,y_cont,B,cont_pos_min,':');
-            set(hcontour_m,'LineColor',[1 1 1])
-            hold off
-            caxis([abscontmin abscontmax]) 
-            colormap(map);
-        end
-        if ~isequal(PlotParam.Scalar.Contours,1)       
-            % rescale the grey levels with min and max, put a grey scale colorbar
-            if (isfield(PlotParam.Scalar,'BW')& (isequal(PlotParam.Scalar.BW,1))|isa(A,'uint8')| isa(A,'uint16'))%images
-                B=A;
-                vec=linspace(0,1,255);%define a linear greyscale colormap
-                map=[vec' vec' vec'];
-                colormap(map);  %grey scale color map 
-            else
-                B=A;
-                colormap('default'); % standard faulse colors for div, vort , scalar fields 
-            end
-        end
-    elseif siz(2)==3 %color images
-        axes(haxes)
-        B=uint8(A); 
-        MinA=0;
-        MaxA=255;
-    end
-    if ~isequal(PlotParam.Scalar.Contours,1)
-        %interpolate to increase resolution
-        test_interp=1;
-        if max(np) <= 64 
-            npxy=8*np;% increase the resolution 8 times
-        elseif max(np) <= 128 
-            npxy=4*np;% increase the resolution 4 times
-        elseif max(np) <= 256 
-            npxy=2*np;% increase the resolution 2 times
-        else
-            npxy=np;
-            test_interp=0; % no interpolation done
-        end
-        if test_interp==1%if we interpolate              
-            x=linspace(AX(1),AX(2),np(2));
-            y=linspace(AY(1),AY(2),np(1));
-            [X,Y]=meshgrid(x,y);
-            xi=linspace(AX(1),AX(2),npxy(2));
-            yi=linspace(AY(1),AY(2),npxy(1));
-            B = interp2(X,Y,double(B),xi,yi');
-        end        
-        if isempty(hima)
-            tag=get(haxes,'Tag');
-            hima=imagesc(AX,AY,B,[MinA MaxA]);
-            set(hima,'Tag','ima','HitTest','off')
-            set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!)       
-        else
-            set(hima,'CData',B);
-            if MinA<MaxA
-                caxis([MinA MaxA])
-            else
-                caxis([MinA MinA+1])
-            end
-            set(hima,'XData',AX);
-            set(hima,'YData',AY);
-        end
-    end
-    if ~isstruct(AxeData)
-        AxeData=[];
-    end
-    AxeData.A=A;
-    AxeData.AX=[AX(1) AX(end)];
-    AxeData.AY=[AY(1) AY(end)];
-    test_ima=1;
-    %display the colorbar code for B/W images if Poscolorbar not empty
-    if siz(2)==2 & exist('PosColorbar','var')& ~isempty(PosColorbar)
-        if isempty(hcol)|~ishandle(hcol)
-             hcol=colorbar;%create new colorbar
-        end
-        if length(PosColorbar)==4
-                 set(hcol,'Position',PosColorbar)           
-        end 
-        YTick=0;%default
-        if MaxA>MinA
-            if isequal(PlotParam.Scalar.Contours,1)
-                colbarlim=get(hcol,'YLim');
-                scale_bar=(colbarlim(2)-colbarlim(1))/(abscontmax-abscontmin);                
-                YTick=cont_pos(2:end-1);
-                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
-                hi=get(hcol,'children');
-                if iscell(hi)%multiple images in colorbar
-                    hi=hi{1};
-                end
-                set(hi,'YData',[MinA MaxA])
-                set(hi,'CData',[1:256]')
-                set(hcol,'YLim',[MinA MaxA])
-                YTick=colbartick(MinA,MaxA);
-                set(hcol,'YTick',YTick)                
-            else
-                hi=get(hcol,'children');
-                if iscell(hi)%multiple images in colorbar
-                    hi=hi{1};
-                end
-                set(hi,'YData',[MinA MaxA])
-                set(hi,'CData',[1:64]')
-                YTick=colbartick(MinA,MaxA); 
-                set(hcol,'YLim',[MinA MaxA])
-                set(hcol,'YTick',YTick)
-            end
-            set(hcol,'Yticklabel',num2str(YTick'));
-        end
-    elseif ishandle(hcol)
-        delete(hcol); %erase existing colorbar if not needed 
-    end
-else%no scalar plot
-    if ~isempty(hima) && ishandle(hima) 
-        delete(hima)
-    end
-    if ~isempty(hcol)&& ishandle(hcol)
-       delete(hcol)
-    end
-    AxeData.A=[];
-    AxeData.AX=[];
-    AxeData.AY=[];
-    PlotParamOut=rmfield(PlotParamOut,'Scalar');
-end
-
-%%%%%%%%%%%%%%%%%%%%%   vector plot %%%%%%%%%%%%%%%%%%%%%%%%%%
-if test_vec
-   %vector scale representation
-    if size(vec_U,1)==numel(vec_Y) && size(vec_U,2)==numel(vec_X); % x, y  coordinate variables
-        [vec_X,vec_Y]=meshgrid(vec_X,vec_Y);
-    end   
-    vec_X=reshape(vec_X,1,numel(vec_X));%reshape in matlab vectors
-    vec_Y=reshape(vec_Y,1,numel(vec_Y));
-    vec_U=reshape(vec_U,1,numel(vec_U));
-    vec_V=reshape(vec_V,1,numel(vec_V));
-    MinMaxX=max(vec_X)-min(vec_X);
-    MinMaxY=max(vec_Y)-min(vec_Y);
-    AxeData.Mesh=sqrt((MinMaxX*MinMaxY)/length(vec_X));
-    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=[];
-        if test_false %remove false vectors
-            indsel=find(AxeData.FF==0);%indsel =indices of good vectors
-        else     
-            indsel=[1:numel(vec_X)];%
-        end
-        if isempty(vec_U)
-            scale=1;
-        else
-            if isempty(indsel)
-                MaxU=max(abs(vec_U));
-                MaxV=max(abs(vec_V));
-            else
-                MaxU=max(abs(vec_U(indsel)));
-                MaxV=max(abs(vec_V(indsel)));
-            end
-            scale=MinMaxX/(max(MaxU,MaxV)*50);
-            PlotParam.Vectors.VecScale=scale;%update the 'scale' display
-        end
-    else
-        scale=PlotParam.Vectors.VecScale;  %impose the length of vector representation
-    end;
-    
-    %record vectors on the plotting axes
-    if test_C==0
-        vec_C=ones(1,numel(vec_X));
-    end
-    AxeData.X=vec_X';
-    AxeData.Y=vec_Y';
-    AxeData.U=vec_U';
-    AxeData.V=vec_V';
-    AxeData.C=vec_C';
-    if isempty(ivar_F)
-        AxeData.F=[];
-    else
-        AxeData.F=vec_F';
-    end
-    if isempty(ivar_FF)
-        AxeData.FF=[];
-    else
-        AxeData.FF=vec_FF';
-    end
-%     if isfield(Data,'W')
-%         AxeData.W=Data.W;
-%     end
-    
-    %decimate by a factor 2 in vector mesh(4 in nbre of vectors)
-    if isfield(PlotParam.Vectors,'decimate4')&isequal(PlotParam.Vectors.decimate4,1)
-        diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
-        dy_thresh=max(abs(diffy))/2; 
-        ind_jump=find(abs(diffy) > dy_thresh); %indices with diff(vec_Y)> max/2, detect change of line
-        ind_sel=[1:ind_jump(1)];%select the first line
-        for i=2:2:length(ind_jump)-1
-            ind_sel=[ind_sel [ind_jump(i)+1:ind_jump(i+1)]];% select the odd lines
-        end
-        nb_sel=length(ind_sel);
-        ind_sel=ind_sel([1:2:nb_sel]);% take half the points on a line
-        vec_X=vec_X(ind_sel);
-        vec_Y=vec_Y(ind_sel);
-        vec_U=vec_U(ind_sel);
-        vec_V=vec_V(ind_sel);
-        vec_C=vec_C(ind_sel);
-        if ~isempty(ivar_F)
-           vec_F=vec_F(ind_sel);
-        end
-        if ~isempty(ivar_FF)
-           vec_FF=vec_FF(ind_sel);
-        end
-    end
-    
-    %get main level color code
-    [colorlist,col_vec,PlotParamOut.Vectors]=set_col_vec(PlotParam.Vectors,vec_C);
-    % take flags into account: add flag colors to the list of colors
-    sizlist=size(colorlist);
-    nbcolor=sizlist(1);
-    if test_black 
-       nbcolor=nbcolor+1;
-       colorlist(nbcolor,:)=[0 0 0]; %add black to the list of colors
-       if ~isempty(ivar_FF)
-            ind_flag=find(vec_F~=1 & vec_FF==0);  %flag warning but not false
-       else
-            ind_flag=find(vec_F~=1);
-       end
-       col_vec(ind_flag)=nbcolor;    
-    end
-    nbcolor=nbcolor+1;
-    if ~isempty(ivar_FF)
-        ind_flag=find(vec_FF~=0);
-        if isfield(PlotParam.Vectors,'HideFalse') && PlotParam.Vectors.HideFalse==1
-            colorlist(nbcolor,:)=[NaN NaN NaN];% no plot of false vectors
-        else
-            colorlist(nbcolor,:)=[1 0 1];% magenta color
-        end
-        col_vec(ind_flag)=nbcolor;
-    end
-    %plot vectors:
-    quiresetn(haxes,vec_X,vec_Y,vec_U,vec_V,scale,colorlist,col_vec);   
-else
-    hvec=findobj(haxes,'Tag','vel');
-    if ~isempty(hvec)
-        delete(hvec);
-    end
-    AxeData.X=[];
-    AxeData.Y=[];
-    AxeData.U=[];
-    AxeData.V=[];
-    AxeData.C=[];
-    AxeData.W=[];
-    AxeData.F=[];
-     AxeData.FF=[];
-    AxeData.Mesh=[];
-    PlotParamOut=rmfield(PlotParamOut,'Vectors');
-end
-if isfield(Data,'Z')
-    AxeData.Z=Data.Z;% A REVOIR
-end
-listfields={'AY','AX','A','X','Y','U','V','C','W','F','FF'};
-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=[];
-nbvar=0;
-AxeData.ListVarName={};
-AxeData.VarDimName={};
-AxeData.VarAttribute={};
-for ilist=1:numel(listfields)
-    eval(['testvar=isfield(AxeData,listfields{ilist}) && ~isempty(AxeData.' listfields{ilist} ');'])
-    if testvar
-        nbvar=nbvar+1;
-        AxeData.ListVarName{nbvar}=listfields{ilist};
-        AxeData.VarDimName{nbvar}=listdim{ilist};
-        AxeData.VarAttribute{nbvar}.Role=Role{ilist};
-    end
-end
-
-% adjust the size of the plot to include the whole field, except if KeepLim=1
-if ~(exist('KeepLim','var') && isequal(KeepLim,1))  %adjust the graph limits*
-        test_lim=0;
-        if test_vec
-            Xlim=[min(vec_X) max(vec_X)];
-            Ylim=[min(vec_Y) max(vec_Y)];
-            test_lim=1;
-            if test_ima%both background image and vectors coexist, take the wider bound
-                Xlim(1)=min(AX(1),Xlim(1));
-                Xlim(2)=max(AX(end),Xlim(2));
-                Ylim(1)=min(AY(end),Ylim(1));
-                Ylim(2)=max(AY(1),Ylim(2));
-            end
-        elseif test_ima %only image plot
-            Xlim(1)=min(AX(1),AX(end));
-            Xlim(2)=max(AX(1),AX(end));
-            Ylim(1)=min(AY(1),AY(end));
-            Ylim(2)=max(AY(1),AY(end));
-            test_lim=1;
-        end 
-        if test_lim
-            set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates
-            set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
-        end
-end
-if ~(isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1))
-     set(haxes,'DataAspectRatio',[1 1 1])
-end
-set(haxes,'YDir','normal') 
-set(get(haxes,'XLabel'),'String',[XName x_units]);
-set(get(haxes,'YLabel'),'String',[YName y_units]);
-%---------------------------------------------
-%function for plotting vectors
-%------------------------------------------------
-%INPUT:
-% haxes: handles of the plotting axes
-%x,y,u,v: vectors coordinates and vector components to plot, arrays withb the same dimension
-% scale: scaling factor for vector length representation
-%colorlist(icolor,:): list of vector colors, dim (nbcolor,3), depending on color #i
-%col_vec: matlab vector setting the color number #i for each velocity vector
-function quiresetn(haxes,x,y,u,v,scale,colorlist,col_vec)
-
-%define arrows
-theta=0.5 ;%angle arrow
-alpha=0.3 ;%length arrow
-rot=alpha*[cos(theta) -sin(theta); sin(theta) cos(theta)]';
-%find the existing lines
-%h=findobj(gca,'Type','Line');% search existing lines in the current axes
-h=findobj(haxes,'Tag','vel');% search existing lines in the current axes
-sizh=size(h);
-set(h,'EraseMode','xor');
-set(haxes,'NextPlot','replacechildren');
-%htext=findobj('Tag','scalevec');
-      
-%drawnow
-%create lines (if no lines) or modify them
-if ~isequal(size(col_vec),size(x))
-    col_vec=ones(size(x));% case of error in col_vec input
-end
-sizlist=size(colorlist);
-ncolor=sizlist(1);
-
-for icolor=1:ncolor
-    %determine the line positions for each color icolor 
-    ind=find(col_vec==icolor);
-    xc=x(ind);
-    yc=y(ind);
-    uc=u(ind)*scale;
-    vc=v(ind)*scale;
-    n=size(xc);
-    xN=NaN*ones(size(xc));
-    matx=[xc(:) xc(:)+uc(:) xN(:)]';
-    matx=reshape(matx,1,3*n(2));
-    maty=[yc(:) yc(:)+vc(:) xN(:)]';
-    maty=reshape(maty,1,3*n(2));
-    
-    %determine arrow heads
-    arrowplus=rot*[uc;vc];
-    arrowmoins=rot'*[uc;vc];
-    x1=xc+uc-arrowplus(1,:);
-    x2=xc+uc;
-    x3=xc+uc-arrowmoins(1,:);
-    y1=yc+vc-arrowplus(2,:);
-    y2=yc+vc;
-    y3=yc+vc-arrowmoins(2,:);
-    matxar=[x1(:) x2(:) x3(:) xN(:)]';
-    matxar=reshape(matxar,1,4*n(2));
-    matyar=[y1(:) y2(:) y3(:) xN(:)]';
-    matyar=reshape(matyar,1,4*n(2));
-    %draw the line or modify the existing ones
-    isn=isnan(colorlist(icolor,:));%test if color NaN
-    if 2*icolor > sizh(1) %if icolor exceeds the number of existing ones
-        axes(haxes)
-        if ~isn(1) %if the vectors are visible color not nan
-            if n(2)>0
-                hold on
-                line(matx,maty,'Color',colorlist(icolor,:),'Tag','vel');% plot new lines
-                line(matxar,matyar,'Color',colorlist(icolor,:),'Tag','vel');% plot arrows
-            end
-        end
-    else
-        if isn(1) 
-            delete(h(2*icolor-1))
-            delete(h(2*icolor))
-        else
-            set(h(2*icolor-1),'Xdata',matx,'Ydata',maty);
-            set(h(2*icolor-1),'Color',colorlist(icolor,:));
-            set(h(2*icolor-1),'EraseMode','xor');
-            set(h(2*icolor),'Xdata',matxar,'Ydata',matyar);
-            set(h(2*icolor),'Color',colorlist(icolor,:));
-            set(h(2*icolor),'EraseMode','xor');
-        end
-     end
-end
-if sizh(1) > 2*ncolor
-    for icolor=ncolor+1 : sizh(1)/2%delete additional objects
-        delete(h(2*icolor-1))
-        delete(h(2*icolor))
-    end
-end
-
-%---------------------------------------
-%determine tick positions for colorbar
-%------------------------------------
-function YTick=colbartick(MinA,MaxA)
-%determine tick positions with "simple" values between MinA and MaxA
-YTick=0;%default
-maxabs=max([abs(MinA) abs(MaxA)]);
-if maxabs>0 
-ord=10^(floor(log10(maxabs)));%order of magnitude
-div=1;
-siz2=1;
-while siz2<2
-%     values=[-9:div:9];
-    values=-10:div:10;
-    ind=find((ord*values-MaxA)<0 & (ord*values-MinA)>0);%indices of 'values' such that MinA<ord*values<MaxA
-    siz=size(ind);
-    if siz(2)<4%if there are less than 4 selected values (4 levels)
-        values=[-9:0.5*div:9];
-        ind=find((ord*values-MaxA)<0 & (ord*values-MinA)>0);
-    end
-    siz2=size(ind,2);
-%     siz2=siz(2)
-    div=div/10;
-end
-YTick=ord*values(ind);
-end
Index: unk/src/plot_object.m
===================================================================
--- /trunk/src/plot_object.m	(revision 7)
+++ 	(revision )
@@ -1,408 +1,0 @@
-%'plot_object': draws a projection object (points, line, plane...)
-%-------------------------------------------------------------------
-% function [ObjectData_out,hh]=plot_object(ObjectData,hplot,col)
-%
-%OUTPUT
-%             hh: handles of the graphic object (core part)
-%
-%INPUT:
-%
-% ObjectDataIn: structure representing the object properties:
-%        .Style : style of projection object
-%        .Coord: set of coordinates defining the object position;
-%        .ProjMode=type of projection ;
-%       .ProjAngle=angle of projection;
-%       .DX,.DY,.DZ=increments;
-%       .YMax,YMin: min and max Y
-% ProjObject: projection object corresponding to the current plot (e. g. plane) 
-% hplot: handle of the object plot to modify or if it is an axis, the axis
-%            where the object must be plotted, or if it is a figure the plotting figure 
-% col: color of the plot, e;g; 'm', 'b' ..;
-
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function [hh]=plot_object(ObjectDataIn,ProjObject,hplot,col)
-hh=[];%default output
-if isequal(ProjObject,ObjectDataIn)% object representation does not appear in its own projection plot
-    return
-end
-if ~isfield(ProjObject,'Style') 
-    ObjectData=ObjectDataIn;
-elseif isequal(ProjObject.Style,'plane')
-    ObjectData=ObjectDataIn;% TODO: modify take into account rotation of axis
-else
-    return % no object representation yet available
-end
-if ~isfield(ObjectData,'Style')|isempty(ObjectData.Style)|~ischar(ObjectData.Style)
-    warndlg_uvmat('undefined ObjectData.Style in plot_object.m','ERROR')
-    return
-end
-if ~isfield(ObjectData,'Style')|isempty(ObjectData.Style)|~ischar(ObjectData.Style)
-    warndlg_uvmat('undefined ObjectData.Style in plot_object.m','ERROR')
-    return
-end
-XMin=0;%default
-XMax=0;
-YMin=0;
-YMax=0;
-ZMin=0;
-ZMax=0;
-
-%determine the plotting axes (with handle 'haxes')
-test_newobj=1;
-if ishandle(hplot)
-    if isequal(get(hplot,'Tag'),'proj_object')  
-        test_newobj=0;
-        haxes=get(hplot,'parent');
-    elseif isequal(get(hplot,'Type'),'axes')
-        axes(hplot)
-        haxes=hplot;
-    elseif isequal(get(hplot,'Type'),'figure')
-        figure(hplot);%set the input figure as the current one
-        haxes=findobj(hplot,'Type','axes');%look for axes in the figure
-        haxes=haxes(1);
-        axes(haxes); %set the first found axis as the current one
-    else
-        figure; %create new figure
-        hplot=axes;%create new axes
-        haxes=hplot;
-    end
-else
-    figure; %create new figure
-    hplot=axes;%create new axes
-    haxes=hplot;
-end
-
-%default input parameters
-if ~isfield(ObjectData,'ProjMode')|isempty(ObjectData.ProjMode)
-     ObjectData.ProjMode='projection';%default
-end
-if ~isfield(ObjectData,'Coord')|isempty(ObjectData.Coord)
-     ObjectData.Coord=[0 0 0];%default
-end
-if ~isfield(ObjectData,'Phi')|isempty(ObjectData.Phi)
-     ObjectData.Phi=0;%default
-end
-if ~isfield(ObjectData,'Range')
-    ObjectData.Range(1,1)=0; %edfault
-end
-if size(ObjectData.Range,2)>=2
-    YMax=ObjectData.Range(1,2);%default
-end
-if size(ObjectData.Range,2)>=2 & size(ObjectData.Range,1)>=2
-    YMin=ObjectData.Range(2,2);
-else
-    YMin=0;
-end
-XMax=ObjectData.Range(1,1);
-if size(ObjectData.Range,1)>=2 
-    XMin=ObjectData.Range(2,1);
-end
-if isfield(ObjectData,'RangeX')
-   XMax=max(ObjectData.RangeX);
-   XMin=min(ObjectData.RangeX);
-end
-if isfield(ObjectData,'RangeY')
-   YMax=max(ObjectData.RangeY);
-   YMin=min(ObjectData.RangeY);
-end
-if isfield(ObjectData,'RangeZ')
-   ZMax=max(ObjectData.RangeZ);
-   ZMin=min(ObjectData.RangeZ);
-end
-if isequal(ObjectData.Style,'points')&isequal(ObjectData.ProjMode,'projection')
-    YMax=max(XMax,YMax);
-    YMax=max(YMax,ZMax);
-elseif isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'ellipse')|isequal(ObjectData.Style,'volume')
-    if  isequal(YMax,0)
-        ylim=get(haxes,'YLim');
-        YMax=(ylim(2)-ylim(1))/100;
-    end
-    if isequal(XMax,0)
-        XMax=YMax;%default
-    end
-elseif isequal(ObjectData.Style,'plane')
-   if  isequal(XMax,0)
-        xlim=get(haxes,'XLim');
-        XMax=xlim(2);
-   end
-   if  isequal(YMax,0)
-        ylim=get(haxes,'YLim');
-        YMax=ylim(2);
-   end
-end
-sizcoord=size(ObjectData.Coord);
-
-%determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot
-test_line= isequal(ObjectData.Style,'points')|isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|...
-    isequal(ObjectData.Style,'polygon')| isequal(ObjectData.Style,'plane')| isequal(ObjectData.Style,'volume');
-test_patch=isequal(ObjectData.ProjMode,'inside')||isequal(ObjectData.ProjMode,'outside')||isequal(ObjectData.Style,'volume')...
-    ||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside');
-if test_line
-    xline=ObjectData.Coord(:,1);
-    yline=ObjectData.Coord(:,2);
-    if isequal(ObjectData.Style,'polygon')
-        xline=[xline; ObjectData.Coord(1,1)];%closing the line
-        yline=[yline; ObjectData.Coord(1,2)];
-    elseif isequal(ObjectData.Style,'plane')| isequal(ObjectData.Style,'volume') 
-        phi=ObjectData.Phi*pi/180;%angle in radians
-        Xend_x=xline(1)+XMax*cos(phi);
-        Xend_y=yline(1)+XMax*sin(phi);
-        Xbeg_x=xline(1)+XMin*cos(phi);
-        Xbeg_y=yline(1)+XMin*sin(phi);
-        Yend_x=xline(1)-YMax*sin(phi);
-        Yend_y=yline(1)+YMax*cos(phi);
-        Ybeg_x=xline(1)-YMin*sin(phi);
-        Ybeg_y=yline(1)+YMin*cos(phi);
-        xline=[Xbeg_x Xend_x NaN Ybeg_x Yend_x];
-        yline=[Xbeg_y Xend_y NaN Ybeg_y Yend_y];
-    end
-    SubLineStyle='none';%default
-    if isfield(ObjectData,'ProjMode')
-        if isequal(ObjectData.ProjMode,'projection')
-            SubLineStyle='--'; %range of projection marked by dash
-            if isfield (ObjectData,'DX')
-               rmfield(ObjectData,'DX');
-            end
-            if isfield (ObjectData,'DY')
-               rmfield(ObjectData,'DY');
-            end
-        elseif isequal(ObjectData.ProjMode,'filter')
-            SubLineStyle=':';%range of projection not visible
-        end
-    end 
-    if isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|isequal(ObjectData.Style,'polygon')
-        if length(xline)<2
-            theta=0;
-        else
-            theta=angle(diff(xline)+i*diff(yline));
-            theta(length(xline))=theta(length(xline)-1);
-        end
-        xsup(1)=xline(1)+YMax*sin(theta(1));
-        xinf(1)=xline(1)-YMax*sin(theta(1));
-        ysup(1)=yline(1)-YMax*cos(theta(1));
-        yinf(1)=yline(1)+YMax*cos(theta(1));
-        for ip=2:length(xline)
-            xsup(ip)=xline(ip)+YMax*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
-            xinf(ip)=xline(ip)-YMax*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
-            ysup(ip)=yline(ip)-YMax*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
-            yinf(ip)=yline(ip)+YMax*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
-        end
-    end
-end
-
-%shading image
-if test_patch
-    npMx=512;
-    npMy=512;  
-    flag=zeros(npMy,npMx);
-    if isequal(ObjectData.Style,'ellipse')
-        XimaMin=ObjectData.Coord(1,1)-XMax;
-        XimaMax=ObjectData.Coord(1,1)+XMax;
-        YimaMin=ObjectData.Coord(1,2)-YMax;
-        YimaMax=ObjectData.Coord(1,2)+YMax; 
-        xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];%create an image around the ellipse
-        ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
-        scale_x=2*1.4*XMax/npMx;
-        scale_y=2*1.4*YMax/npMy;
-        xi=[0.5:npMx-0.5]*scale_x+xlim(1);
-        yi=[0.5:npMy-0.5]*scale_y+ylim(1);
-        [Xi,Yi]=meshgrid(xi,yi);
-        X2Max=XMax*XMax;
-        Y2Max=YMax*YMax;
-        distX=(Xi-ObjectData.Coord(1,1));
-        distY=(Yi-ObjectData.Coord(1,2));
-        flag=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;
-    elseif isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'volume')
-        XimaMin=ObjectData.Coord(1,1)-XMax;
-        XimaMax=ObjectData.Coord(1,1)+XMax;
-        YimaMin=ObjectData.Coord(1,2)-YMax;
-        YimaMax=ObjectData.Coord(1,2)+YMax; 
-        xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];%create an image around the ellipse
-        ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
-        scale_x=2*1.4*XMax/npMx;
-        scale_y=2*1.4*YMax/npMy;
-        xi=[0.5:npMx-0.5]*scale_x+xlim(1);
-        yi=[0.5:npMy-0.5]*scale_y+ylim(1);
-        [Xi,Yi]=meshgrid(xi,yi);
-        distX=abs(Xi-ObjectData.Coord(1,1));
-        distY=abs(Yi-ObjectData.Coord(1,2));
-        flag=distX<XMax & distY< YMax;
-    elseif isequal(ObjectData.Style,'polygon')
-        XimaMin=min(ObjectData.Coord(:,1));
-        XimaMax=max(ObjectData.Coord(:,1));
-        YimaMin=min(ObjectData.Coord(:,2));
-        YimaMax=max(ObjectData.Coord(:,2)); 
-        xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];
-        ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
-        [Xlim,Ylim]=meshgrid(linspace(xlim(1),xlim(2),npMx),linspace(ylim(1),ylim(2),npMy));
-        %flag=roipoly(xlim,ylim,flag,ObjectData.Coord(:,1),ObjectData.Coord(:,2));%=1 inside the polygon, 0 outsid
-        flag=inpolygon(Xlim,Ylim,ObjectData.Coord(:,1),ObjectData.Coord(:,2));%=1 inside the polygon, 0 outsid
-    end 
-    if isequal(ObjectData.ProjMode,'outside')||isequal(ObjectData.ProjMode,'mask_outside')
-        flag=~flag;
-    end
-    imflag=zeros(npMx,npMy,3);
-    imflag(:,:,3)=flag; % blue color
-    if isequal(col,'m')
-         imflag(:,:,1)=flag; % magenta color
-    end
-    dx=(xlim(2)-xlim(1))/npMx;
-    dy=(ylim(2)-ylim(1))/npMy;
-end
-
-PlotData=[];%default
-%MODIFY AN EXISTING OBJECT PLOT
-if test_newobj==0;
-    hh=hplot;
-    PlotData=get(hplot,'UserData');            
-    if test_line
-        set(hplot,'XData',xline)
-        set(hplot,'YData',yline)
-    %modify subobjects
-        if isfield(PlotData,'SubObject') 
-           if length(PlotData.SubObject)==2 && ~isequal(ObjectData.Style,'points')&& ~isequal(ObjectData.Style,'plane');
-                set(PlotData.SubObject(1),'XData',xinf);
-                set(PlotData.SubObject(1),'YData',yinf);
-                set(PlotData.SubObject(2),'XData',xsup);
-                set(PlotData.SubObject(2),'YData',ysup);
-           elseif isequal(ObjectData.Style,'points')&& ~isequal(YMax,0)
-               for ipt=1:min(length(PlotData.SubObject),size(ObjectData.Coord,1))
-                    set(PlotData.SubObject(ipt),'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax])
-               end
-               %complement missing points
-               if size(ObjectData.Coord,1)>length(PlotData.SubObject)
-                   for ipt=length(PlotData.SubObject)+1:size(ObjectData.Coord,1)
-                     PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
-                  'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
-                  'LineStyle',SubLineStyle,'Tag','proj_object');
-                   end
-               end                                         
-           end
-        end
-        if isfield(PlotData,'DeformPoint')
-           for ipt=1:length(PlotData.DeformPoint)
-               if ishandle(PlotData.DeformPoint(ipt))
-                   if length(xline)>=ipt &   length(yline)>=ipt    
-                        set(PlotData.DeformPoint(ipt),'XData',xline(ipt),'YData',yline(ipt));
-                    end
-               end
-           end
-           if length(xline)>length(PlotData.DeformPoint)
-               for ipt=length(PlotData.DeformPoint)+1:length(xline)
-                    PlotData.DeformPoint(ipt)=line(xline(ipt),yline(ipt),'Color',col,'LineStyle','.','Tag','DeformPoint',...
-                        'SelectionHighlight','off','UserData',hplot);
-               end
-               set(hplot,'UserData',PlotData)
-           end
-        end
-    elseif isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'ellipse')
-        set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax])          
-    end
-    if test_patch 
-        for iobj=1:length(PlotData.SubObject)
-            objtype=get(PlotData.SubObject(iobj),'Type');
-            if isequal(objtype,'image')
-                set(PlotData.SubObject(iobj),'CData',imflag,'AlphaData',(flag)*0.2)
-                set(PlotData.SubObject(iobj),'XData',[xlim(1)+dx/2 xlim(2)-dx/2])
-                set(PlotData.SubObject(iobj),'YData',[ylim(1)+dy/2 ylim(2)-dy/2])
-            end
-        end
-    end
-end
-
-%create the object
-if test_newobj
-    axes(haxes)
-    hother=findobj('Tag','proj_object');%find all the proj objects
-    for iobj=1:length(hother)
-        if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
-            set(hother(iobj),'EdgeColor','b')
-            if isequal(get(hother(iobj),'FaceColor'),'m')
-                set(hother(iobj),'FaceColor','b')
-            end
-        elseif isequal(get(hother(iobj),'Type'),'image')
-               Acolor=get(hother(iobj),'CData');
-               Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
-               set(hother(iobj),'CData',Acolor);
-        else
-             set(hother(iobj),'Color','b')
-        end
-        set(hother(iobj),'Selected','off')
-    end
-    hother=findobj('Tag','DeformPoint');
-    set(hother,'Color','b');
-    set(hother,'Selected','off')  
-    if isequal(ObjectData.Style,'points')
-        hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color',col,'LineStyle','.','Marker','+');
-        for ipt=1:length(xline)
-              PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
-                  col,'LineStyle','.','SelectionHighlight','off','UserData',hh,'Tag','DeformPoint');
-              %create circle around each point
-              if ~isequal(YMax,0)
-                 PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
-                  'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
-                  'LineStyle',SubLineStyle,'Tag','proj_object');
-              end
-        end
-    elseif  isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|...        
-          isequal(ObjectData.Style,'polygon') |isequal(ObjectData.Style,'plane')|isequal(ObjectData.Style,'volume')%  (isequal(ObjectData.Style,'polygon') & ~test_patch) |isequal(ObjectData.Style,'plane')
-        hh=line(xline,yline,'Color',col);
-        if ~isequal(ObjectData.Style,'plane')& ~isequal(ObjectData.Style,'volume')
-            for ipt=1:sizcoord(1)
-                PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
-                      col,'LineStyle','none','Marker','.','Tag','DeformPoint','SelectionHighlight','off','UserData',hh);
-            end
-            PlotData.SubObject(1)=line(xinf,yinf,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');%draw sub-lines
-            PlotData.SubObject(2)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
-        end
-    
-    elseif isequal(ObjectData.Style,'rectangle')
-        hh=rectangle('Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col);   
-    elseif isequal(ObjectData.Style,'ellipse')
-        hh=rectangle('Curvature',[1 1],'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col);
-    else
-        warndlg_uvmat('unknown ObjectData.Style in plot_object.m','ERROR')
-        return
-    end
-    set(hh,'Tag','proj_object')
-    %set(hh,'UserData',ObjectData)%
-%         hh=hplot;
-%     set(hh,'DeleteFcn',@deletefcn)
-%     if isequal(ObjectData.ProjMode,'inside')
-%          if isequal(ObjectData.Style,'ellipse')|isequal(ObjectData.Style,'rectangle')
-%             set(hh,'FaceColor',col)
-%             set(hh,'EdgeColor',col)
-%          end
-%     end
-    if test_patch
-        hold on
-        hhh=image([xlim(1)+dx/2 xlim(2)-dx/2],[ylim(1)+dy/2 ylim(2)-dy/2],imflag,'Tag','proj_object','HitTest','off');
-        set(hhh,'AlphaData',(flag)*0.2)
-        PlotData.SubObject=hhh;    
-    end
-    if isfield(PlotData,'SubObject')
-        set(PlotData.SubObject,'UserData',hh)%record the parent handles in the SubObjects
-    end
-    if isfield(PlotData,'DeformPoint')
-        for ipt=1:sizcoord(1)
-            set(PlotData.DeformPoint(ipt),'UserData',hh);%record the parent handles in the SubObjects
-        end
-        set(PlotData.DeformPoint,'UserData',hh)%record the parent handles in the SubObjects
-    end
-end
-set(hh,'UserData',PlotData)
Index: unk/src/plot_text.m
===================================================================
--- /trunk/src/plot_text.m	(revision 7)
+++ 	(revision )
@@ -1,86 +1,0 @@
-%'plot_text': function for displaying the content of a Matlab structure in a figure
-%------------------------------------------------------------------------
-% function hdisplay=plot_text(FieldData,hdisplay_in)
-%
-% OUTPUT:
-% hdisplay: handle of the display edit box
-%
-%  INPUT: 
-% FieldData: input Matlab structure
-% hdisplay_in: handles of the display box, if it is not defined create a new figure
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function hdisplay=plot_text(FieldData,hdisplay_in)
-
-if exist('hdisplay_in','var') & ishandle(hdisplay_in) & isequal(get(hdisplay_in,'Type'),'uicontrol')
-    hdisplay=hdisplay_in;
-else
-    figure;%create new figure
-    hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced');
-end
-    
-ff=fields(FieldData);%list of field names
-vv=struct2cell(FieldData);%list of field values
-
-for icell=1:length(vv)
-    Tabcell{icell,1}=ff{icell};
-    ss=vv{icell};
-    sizss=size(ss);
-    if isnumeric(ss)
-        if sizss(1)<=1 & length(ss)<5
-            displ{icell}=num2str(ss);
-        else
-            displ{icell}=[class(ss) ', size ' num2str(size(ss))];
-        end
-    elseif ischar(ss)
-        displ{icell}=ss;
-    elseif iscell(ss)
-        sizcell=size(ss);
-        if sizcell(1)==1 & length(sizcell)==2 %line cell
-           ssline='{''';
-           for icolumn=1:sizcell(2)
-               if isnumeric(ss{icolumn})
-                   if size(ss{icolumn},1)<=1 & length(ss{icolumn})<5
-                      sscolumn=num2str(ss{icolumn});%line vector
-                   else
-                      sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))];
-                   end
-               elseif ischar(ss{icolumn})
-                   sscolumn=ss{icolumn};
-               else
-                   sscolumn=class(ss{icolumn});
-               end
-               if icolumn==1
-                   ssline=[ssline sscolumn];
-               else
-                   ssline=[ssline ''',''' sscolumn];
-               end
-           end
-           displ{icell}=[ssline '''}'];
-        else
-           displ{icell}=[class(ss) ', size ' num2str(sizcell)];
-        end
-    else
-        displ{icell}=class(ss);
-    end
-    Tabcell{icell,2}=displ{icell};
-end 
-Tabchar=cell2tab(Tabcell,': '); 
-set(hdisplay,'String', Tabchar)
-
-
Index: /trunk/src/private/ListDir.m
===================================================================
--- /trunk/src/private/ListDir.m	(revision 8)
+++ /trunk/src/private/ListDir.m	(revision 8)
@@ -0,0 +1,98 @@
+%'ListDir': scan the structure of the directory tree (for dataview.m)
+%------------------------------------------------------------------------
+function [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices_in,ListRecords_in)
+
+ListRecords={};
+ListDevices={};
+ListXml={};
+irecord_tot=0;
+idevice_tot=0;
+ixml_tot=0;
+for iexp=1:length(ListExperiments) 
+    List.Experiment{iexp}.name=ListExperiments{iexp};
+    hdir=dir(fullfile(CurrentPath,ListExperiments{iexp}));
+    idevice=0;
+    for isub=1:length(hdir)% scan the sub-directories  of the current experiment       
+        if hdir(isub).isdir
+            name=hdir(isub).name;%name of the current device
+            if ~isequal(name(1),'.')% subdirectory of the current experiment
+                [testnew,testselect]=test_select(name,ListDevices,ListDevices_in);
+                if testselect
+                    idevice=idevice+1;
+                    List.Experiment{iexp}.Device{idevice}.name=name;             
+                    if testnew
+                         idevice_tot=idevice_tot+1;
+                         ListDevices{idevice_tot}=name;
+                    end
+                    CurrentDevice=fullfile(CurrentPath,ListExperiments{iexp},name);
+                    hsubxml=dir(fullfile(CurrentDevice,'*.xml'));%look at xml files in the subdirectory of the current device
+                    if isempty(hsubxml) % the subdirectory of the current device contains directories 'Record'' 
+                        hsubdir=dir(fullfile(CurrentPath,ListExperiments{iexp},name));%list what is inside the directory 'Device'   
+                        irecord=0;
+                        for isubsub=1:length(hsubdir)% subdirectories of the current device
+                            if hsubdir(isubsub).isdir                       
+                                RecordName=hsubdir(isubsub).name;  
+                                if ~isequal(RecordName(1),'.')
+                                    [testnew,testselect]=test_select(RecordName,ListRecords,ListRecords_in);
+                                    if testselect
+                                        if testnew
+                                            irecord_tot=irecord_tot+1;
+                                            ListRecords{irecord_tot}=RecordName;
+                                        end
+                                        irecord=irecord+1;
+                                        List.Experiment{iexp}.Device{idevice}.Record{irecord}.name=RecordName;
+                                        hsubsubxml=dir(fullfile(CurrentDevice,RecordName,'*.xml'));%
+                                        for ixml=1:length(hsubsubxml)
+                                            XmlName=hsubsubxml(ixml).name;
+                                            List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}=XmlName;
+                                            testnew=test_select(XmlName,ListXml,{});
+                                            if testnew
+                                                ixml_tot=ixml_tot+1;
+                                                ListXml{ixml_tot}=XmlName;
+                                            end
+                                        end 
+                                    end              
+                                end
+                            end
+                        end
+                    else
+                        for ixml=1:length(hsubxml)
+                            XmlName=hsubxml(ixml).name;
+                            List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}=XmlName;
+                            testnew=test_select(XmlName,ListXml,{});
+                            if testnew
+                                ixml_tot=ixml_tot+1;
+                                ListXml{ixml_tot}=XmlName;
+                            end
+                        end
+                    end
+                end
+            end
+        end
+    end
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function [testnew,testselect]=test_select(name,ListDevices,ListDevices_in)
+if ~isempty(ListDevices_in)
+    testnew=0;
+    testselect=0;
+    for ilist=1:length(ListDevices_in)
+        if isequal(name,ListDevices_in{ilist})
+            testnew=1;
+            testselect=1; 
+            break
+        end
+    end
+else
+    testnew=1; 
+    testselect=1;
+end
+if testnew
+    for ilist=1:length(ListDevices)
+         if isequal(name,ListDevices{ilist})
+              testnew=0;
+              break
+         end
+    end
+end
Index: /trunk/src/private/RUN_FIX.m
===================================================================
--- /trunk/src/private/RUN_FIX.m	(revision 8)
+++ /trunk/src/private/RUN_FIX.m	(revision 8)
@@ -0,0 +1,145 @@
+%'RUN_FIX': function for fixing velocity fields:
+%-----------------------------------------------
+% RUN_FIX(filename,field,flagindex,thresh_vecC,thresh_vel,iter,flag_mask,maskname,fileref,fieldref)
+%
+%filename: name of the netcdf file (used as input and output)
+%field: structure specifying the field to fix (field.vel_type='civ1' or 'civ2')
+%flagindex: flag specifying which values of vec_f are removed: 
+        % if flagindex(1)=1: vec_f=-2 vectors are removed
+        % if flagindex(2)=1: vec_f=3 vectors are removed
+        % if flagindex(3)=1: vec_f=2 vectors are removed (if iter=1) or vec_f=4 vectors are removed (if iter=2)
+%iter=1 for civ1 fields and iter=2 for civ2 fields
+%thresh_vecC: threshold in the image correlation vec_C
+%flag_mask: =1 mask used to remove vectors (0 else)
+%maskname: name of the mask image file for fix
+%thresh_vel: threshold on velocity, or on the difference with the reference file fileref if exists
+%inf_sup=1: remove values smaller than threshold thresh_vel, =2, larger than threshold
+%fileref: .nc file name for a reference velocity (='': refrence 0 used)
+%fieldref: 'civ1','filter1'...feld used in fileref
+
+function error=RUN_FIX(filename,field,flagindex,iter,thresh_vecC,flag_mask,maskname,thresh_vel,inf_sup,fileref,fieldref)
+error=[]; %default
+vel_type{1}=field.vel_type;
+Field=read_civxdata(filename,[],field.vel_type);
+if isfield(Field,'Txt')
+    error=Field.Txt; %error in reading
+    return
+end
+
+if ~isfield(Field,'X') || ~isfield(Field,'Y') || ~isfield(Field,'U') || ~isfield(Field,'V')
+    error=['input file ' filename ' does not contain vectors in RUN_FIX.m']; %bad input file
+    return
+end
+if ~isfield(Field,'C')
+    Field.C=ones(size(Field.X));%correlation=1 by default
+end
+if ~isfield(Field,'F')
+    Field.F=ones(size(Field.X));%warning flag=1 by default
+end
+if ~isfield(Field,'FF')
+    Field.FF=zeros(size(Field.X));%fixflag=0 by default
+end
+
+vec_f_unit=abs(Field.F)-10*double(uint16(abs(Field.F)/10)); %unityterm of vec_F in abs value
+vec_f_sign=sign(Field.F).*vec_f_unit;% gives the unity digit of vec_f with correct sign
+flag1=(flagindex(1)==1)&(vec_f_sign==-2);%removed vectors vec_f=-2
+flag2=(flagindex(2)==1)&(vec_f_sign==3);%removed vectors vec_f=3
+if iter==1
+        flag3=(flagindex(3)==1)&(vec_f_sign==2); % Hart vectors
+elseif iter==2
+        flag3=(flagindex(3)==1)&(vec_f_sign==4); % 
+end
+flag4=(Field.C < thresh_vecC)&(flag1~=1)&(flag2~=1)&(flag3~=1); % =1 for low vec_C vectors not previously removed
+
+% criterium on velocity values
+delta_u=Field.U;%default without ref file
+delta_v=Field.V;
+if exist('fileref','var') && ~isempty(fileref)
+    if ~exist(fileref,'file')
+        error='reference file not found in RUN_FIX.m';
+        display(error);
+        return
+    end
+    FieldRef=read_civxdata(fileref,[],fieldref);   
+    if isfield(FieldRef,'FF')
+        index_true=find(FieldRef.FF==0);
+        FieldRef.X=FieldRef.X(index_true);
+        FieldRef.Y=FieldRef.Y(index_true);
+        FieldRef.U=FieldRef.U(index_true);
+        FieldRef.V=FieldRef.V(index_true);
+    end
+    if ~isfield(FieldRef,'X') || ~isfield(FieldRef,'Y') || ~isfield(FieldRef,'U') || ~isfield(FieldRef,'V')
+        error='reference file is not a velocity field in RUN_FIX.m '; %bad input file
+        return
+    end
+    if length(FieldRef.X)<=1
+        errordlg('reference field with one vector or less in RUN_FIX.m')
+        return
+    end
+    vec_U_ref=griddata_uvmat(FieldRef.X,FieldRef.Y,FieldRef.U,Field.X,Field.Y);  %interpolate vectors in the ref field
+    vec_V_ref=griddata_uvmat(FieldRef.X,FieldRef.Y,FieldRef.V,Field.X,Field.Y);  %interpolate vectors in the ref field to the positions  of the main field     
+    delta_u=Field.U-vec_U_ref;%take the difference with the interpolated ref field
+    delta_v=Field.V-vec_V_ref;
+end
+
+thresh_vel_x=thresh_vel; 
+thresh_vel_y=thresh_vel; 
+if isequal(inf_sup,1)
+    flag5=abs(delta_u)<thresh_vel_x & abs(delta_v)<thresh_vel_y &(flag1~=1)&(flag2~=1)&(flag3~=1)&(flag4~=1);
+elseif isequal(inf_sup,2)
+    flag5=(abs(delta_u)>thresh_vel_x | abs(delta_v)>thresh_vel_y) &(flag1~=1)&(flag2~=1)&(flag3~=1)&(flag4~=1);
+end
+
+            % flag7 introduce a grey mask, matrix M
+if isequal (flag_mask,1)
+   M=imread(maskname);
+   nxy=size(M);
+   M=reshape(M,1,nxy(1)*nxy(2));
+   rangx0=[0.5 nxy(2)-0.5];
+   rangy0=[0.5 nxy(1)-0.5];
+   vec_x1=Field.X-Field.U/2;%beginning points
+   vec_x2=Field.X+Field.U/2;%end points of vectors
+   vec_y1=Field.Y-Field.V/2;%beginning points
+   vec_y2=Field.Y+Field.V/2;%end points of vectors
+   indx=1+round((nxy(2)-1)*(vec_x1-rangx0(1))/(rangx0(2)-rangx0(1)));% image index x at abcissa vec_x
+   indy=1+round((nxy(1)-1)*(vec_y1-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y   
+   test_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside
+   indx=indx.*test_in+(1-test_in); %replace indx by 1 out of the mask range
+   indy=indy.*test_in+(1-test_in); %replace indy by 1 out of the mask range
+   ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector
+   Mvalues=M(ICOMB);
+   flag7b=((20 < Mvalues) & (Mvalues < 200))| ~test_in';
+   indx=1+round((nxy(2)-1)*(vec_x2-rangx0(1))/(rangx0(2)-rangx0(1)));% image index x at abcissa Field.X
+   indy=1+round((nxy(1)-1)*(vec_y2-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y
+   test_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside
+   indx=indx.*test_in+(1-test_in); %replace indx by 1 out of the mask range
+   indy=indy.*test_in+(1-test_in); %replace indy by 1 out of the mask range
+   ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector
+   Mvalues=M(ICOMB);
+   flag7e=((Mvalues > 20) & (Mvalues < 200))| ~test_in';
+   flag7=(flag7b|flag7e)';
+else
+   flag7=0;
+end   
+flagmagenta=flag1|flag2|flag3|flag4|flag5|flag7;
+
+%write fix flags
+[errorread,message]=fileattrib(filename);
+
+if ~isempty(message) && ~isequal(message.UserWrite,1)
+     msgbox_uvmat('ERROR',['no writting access to ' filename ' (RUN_FIX.m)']);
+    return
+end
+nc=netcdf(filename,'write'); %open netcdf file for writing
+result=redef(nc);
+if isempty(result), errordlg('##Bad redef operation.'),end  
+if iter==1
+    nc.fix=1;
+elseif iter==2
+    nc.fix2=1;
+end
+%theDim=nc(field.nb) ;% get the number of velocity vectors
+nc{field.fixflag}=ncfloat(field.nb);
+fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag
+nc{field.fixflag}(:)=fixflag_unit+10*flagmagenta;
+close(nc);
Index: /trunk/src/private/RUN_STLIN.m
===================================================================
--- /trunk/src/private/RUN_STLIN.m	(revision 8)
+++ /trunk/src/private/RUN_STLIN.m	(revision 8)
@@ -0,0 +1,202 @@
+%'RUN_STLIN': combine velocity fields for stereo PIV
+% file_A,file_B: input velocity files
+%vel_type: string ='civ1' or 'civ2'
+function RUN_STLIN(file_A,file_B,vel_type,file_st,nx_patch,ny_patch,thresh_patch,fileAxml,fileBxml)
+                
+ [XmlDataA,error]=imadoc2struct(fileAxml); 
+ [XmlDataB,error]=imadoc2struct(fileBxml);
+ npxA=[]; npyA=[]; pxB=[]; npyB=[];
+ if isfield(XmlDataA,'Camera') && isfield(XmlDataB,'Camera')
+      if isfield(XmlDataA.Camera,'ImageSize')&& isfield(XmlDataB.Camera,'ImageSize')
+          ImageSizeA=XmlDataA.Camera.ImageSize;
+          ImageSizeB=XmlDataB.Camera.ImageSize;
+          if ~isempty(ImageSizeA)&& ~isempty(ImageSizeB)
+               xindex=findstr(ImageSizeA,'x');
+               if length(xindex)>=2
+                    npxA=str2num(ImageSizeA(1:xindex(1)-1));
+                    npyA=str2num(ImageSizeA(xindex(1)+1:xindex(2)-1));
+               end
+               xindex=findstr(ImageSizeB,'x');
+               if length(xindex)>=2
+                    npxB=str2num(ImageSizeB(1:xindex(1)-1));
+                    npyB=str2num(ImageSizeB(xindex(1)+1:xindex(2)-1));
+               end
+          end
+     end
+ end
+ if isempty(npxA) ||isempty(npxB)
+     warndlg_uvmat('The size of image A needs to be defined in the xml file ImaDoc','ERROR')
+     return
+ elseif isempty(npxB) || isempty(npyB)
+      warndlg_uvmat('The size of image B needs to be defined in the xml file ImaDoc','ERROR')
+     return
+ end
+ if isfield(XmlDataA,'GeometryCalib')
+     tsaiA=XmlDataA.GeometryCalib;
+ else
+     warndlg_uvmat('no geometric calibration available for image A','ERROR')
+     return
+ end
+ if isfield(XmlDataB,'GeometryCalib')
+     tsaiB=XmlDataB.GeometryCalib;
+ else
+     warndlg_uvmat('no geometric calibration available for image B','ERROR')
+     return
+ end
+ 
+ %corners of each image in real coordinates:
+ cornerA(:,1)=[0 0 npxA npxA]';%x positions
+ cornerA(:,2)=[0 npyA 0 npyA]';%y positions
+ cornerB(:,1)=[0 0 npxB npxB]';%x positions
+ cornerB(:,2)=[0 npyB 0 npyB]';%y positions
+[xyA(:,1),xyA(:,2)]=phys_XYZ(tsaiA,cornerA(:,1),cornerA(:,2));
+[xyB(:,1),xyB(:,2)]=phys_XYZ(tsaiB,cornerB(:,1),cornerB(:,2));
+ max_x=max(max(xyA(:,1)),max(xyB(:,1)));%maximum on the 4 corners of the the images
+ min_x=min(min(xyA(:,1)),min(xyB(:,1)));%minimum on the 4 corners of the the images
+ max_y=max(max(xyA(:,2)),max(xyB(:,2)));
+ min_y=min(min(xyA(:,2)),min(xyB(:,2)));
+ array_realx=[min_x:(max_x-min_x)/(nx_patch-1):max_x];
+ array_realy=[min_y:(max_y-min_y)/(ny_patch-1):max_y];
+ [grid_realx,grid_realy]=meshgrid(array_realx,array_realy);
+ grid_real(:,1)=reshape(grid_realx,nx_patch*ny_patch,1);
+ grid_real(:,2)=reshape(grid_realy,nx_patch*ny_patch,1);
+ grid_real(:,3)=zeros(nx_patch*ny_patch,1);
+[grid_imaA(:,1),grid_imaA(:,2)]=px_XYZ(tsaiA,grid_real(:,1),grid_real(:,2));
+[grid_imaB(:,1),grid_imaB(:,2)]=px_XYZ(tsaiB,grid_real(:,1),grid_real(:,2));
+
+ flagA=grid_imaA(:,1)>0 & grid_imaA(:,1)<npxA & grid_imaA(:,2)>0 & grid_imaA(:,2)<npyA;
+ flagB=grid_imaB(:,1)>0 & grid_imaB(:,1)<npxB & grid_imaB(:,2)>0 & grid_imaB(:,2)<npyB;
+ ind_good=find(flagA==1&flagB==1);
+ XimaA=grid_imaA(ind_good,1);
+ YimaA=grid_imaA(ind_good,2);
+ XimaB=grid_imaB(ind_good,1);
+ YimaB=grid_imaB(ind_good,2);
+ grid_real_x=grid_real(ind_good,1);
+ grid_real_y=grid_real(ind_good,2);
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %read the velocity fields
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% 
+% [dt,time1,pixcmx,pixcmy,vec_X,vec_Y,vec_Z,vec_U,vec_V,vec_W,vec_C,vec_F,fixflag,vel_type_out,error,nb_coord,nb_dim]...
+%     =read_vel({filecell_ncA},{vel_type});
+%read field A
+[Field,VelTypeOut]=read_civxdata(file_A,[],vel_type);
+%interpolate on XimaA
+Field.X=Field.X(find(Field.FF==0));
+Field.Y=Field.Y(find(Field.FF==0));
+Field.U=Field.U(find(Field.FF==0));
+Field.V=Field.V(find(Field.FF==0));
+dXa= griddata_uvmat(Field.X,Field.Y,Field.U,XimaA,YimaA);
+dYa= griddata_uvmat(Field.X,Field.Y,Field.V,XimaA,YimaA);
+dt=Field.dt;
+time=Field.Time;
+
+%read field B
+% [dt,time2,pixcmx,pixcmy,vec_X,vec_Y,vec_Z,vec_U,vec_V,vec_W,vec_C,vec_F,fixflag,vel_type_out,error,nb_coord,nb_dim]...
+%     =read_vel({file_B},{vel_type});
+[Field,VelTypeOut]=read_civxdata(file_B,FieldNames,vel_type);
+if ~isequal(Field.dt,dt)
+    warndlg_uvmat('different time intervals for the two velocity fields ','ERROR')
+     return
+end
+if ~isequal(Field.Time,time)
+    warndlg_uvmat('different times for the two velocity fields ','ERROR')
+     return
+end
+%interpolate on XimaB
+Field.X=Field.X(find(Field.FF==0));
+Field.Y=Field.Y(find(Field.FF==0));
+Field.U=Field.U(find(Field.FF==0));
+Field.V=Field.V(find(Field.FF==0));
+dXb=griddata_uvmat(Field.X,Field.Y,Field.U,XimaB,YimaB);
+dYb=griddata_uvmat(Field.X,Field.Y,Field.V,XimaB,YimaB);
+%eliminate Not-a-Number 
+ind_Nan=find(and(~isnan(dXa),~isnan(dXb)));
+dXa=dXa(ind_Nan);
+dYa=dYa(ind_Nan);
+dXb=dXb(ind_Nan);
+dYb=dYb(ind_Nan); 
+grid_phys1(:,1)=grid_real_x(ind_Nan);
+grid_phys1(:,2)=grid_real_y(ind_Nan);
+ 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+%compute the coefficients
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+[A11,A12,A13,A21,A22,A23]=pxcm_tsai(tsaiA,grid_phys1);
+[B11,B12,B13,B21,B22,B23]=pxcm_tsai(tsaiB,grid_phys1);
+
+C1=A11.*A22-A12.*A21;
+C2=A13.*A22-A12.*A23;
+C3=A13.*A21-A11.*A23;
+D1=B11.*B22-B12.*B21;
+D2=B13.*B22-B12.*B23;
+D3=B13.*B21-B11.*B23;
+A1=(A22.*D1.*(C1.*D3-C3.*D1)+A21.*D1.*(C2.*D1-C1.*D2));
+A2=(A12.*D1.*(C3.*D1-C1.*D3)+A11.*D1.*(C1.*D2-C2.*D1));
+B1=(B22.*C1.*(C3.*D1-C1.*D3)+B21.*C1.*(C1.*D2-C2.*D1));
+B2=(B12.*C1.*(C1.*D3-C3.*D1)+B11.*C1.*(C2.*D1-C1.*D2));
+Lambda=(A1.*dXa+A2.*dYa+B1.*dXb+B2.*dYb)./(A1.*A1+A2.*A2+B1.*B1+B2.*B2);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%Projection for compatible displacements
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Ua=dXa-Lambda.*A1;
+Va=dYa-Lambda.*A2;
+Ub=dXb-Lambda.*B1;
+Vb=dYb-Lambda.*B2;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%Calculations of displacements and error
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+U=(A22.*D2.*Ua-A12.*D2.*Va-B22.*C2.*Ub+B12.*C2.*Vb)./(C1.*D2-C2.*D1);
+V=(A21.*D3.*Ua-A11.*D3.*Va-B21.*C3.*Ub+B11.*C3.*Vb)./(C3.*D1-C1.*D3);
+W=(A22.*D1.*Ua-A12.*D1.*Va-B22.*C1.*Ub+B12.*C1.*Vb)./(C2.*D1-C1.*D2);
+W1=(-A21.*D1.*Ua+A11.*D1.*Va+B21.*C1.*Ub-B11.*C1.*Vb)./(C1.*D3-C3.*D1);
+
+error=sqrt((A1.*dXa+A2.*dYa+B1.*dXb+B2.*dYb).*(A1.*dXa+A2.*dYa+B1.*dXb+B2.*dYb)./(A1.*A1+A2.*A2+B1.*B1+B2.*B2));
+
+ind_error=(find(error<thresh_patch));
+U=U(ind_error);
+V=V(ind_error);
+W=W(ind_error);%correction for water interface
+error=error(ind_error);
+
+%create nc grid file
+Result.ListGlobalAttribute={'nb_coord','nb_dim','constant_pixcm','absolut_time_T0','hart','dt','civ'};
+Result.nb_coord=3;%grid file, no velocity
+Result.nb_dim=2;
+Result.constant_pixcm=0;%no linear correspondance with images
+Result.absolut_time_T0=time;%absolute time of the field
+Result.hart=0;
+Result.dt=dt;%time interval for image correlation (put  by default)
+% cte.title='grid';
+Result.civ=0;%not a civ file (no direct correspondance with an image)
+Result.ListDimName={'nb_vectors'}
+Result.DimValue=length(U);
+Result.ListVarName={'vec_X';'vec_Y';'vec_U';'vec_V';'vec_W';'vec_E'};
+Result.VarDimIndex: {[1]  [1]  [1]  [1]  [1]  [1]}
+Result.vec_X= grid_phys1(ind_error,1);
+Result.vec_Y= grid_phys1(ind_error,2);
+Result.vec_U=U/dt;
+Result.vec_V=V/dt;
+Result.vec_W=W/dt;
+Result.vec_E=error; 
+% error=write_netcdf(file_st,cte,fieldlabels,grid_phys);
+error=struct2nc(file_st,Result);
+display([file_st ' written'])
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /trunk/src/private/calc_field.m
===================================================================
--- /trunk/src/private/calc_field.m	(revision 8)
+++ /trunk/src/private/calc_field.m	(revision 8)
@@ -0,0 +1,312 @@
+%'calc_field': defines fields (velocity, vort, div...) from civx data and calculate them  
+%---------------------------------------------------------------------
+
+%
+% OUTPUT: 
+% Scal: matlab vector representing the scalar values (length nbvec defined by var_read)  
+            % if no input , Scal=list of programmed scalar names (to put in menus)
+            % if only the sclar name is put as input, vec_A=type of scalar, which can be:
+%                   'vel': scalar calculated solely from velocity components
+%                   'der': needs spatial derivatives     
+%                   'var': the scalar name directly corresponds to a field name in the netcdf files
+% error: error flag
+            % error = 0; OK
+            % error = 1; the prescribed scalar cannot be read or calculated from available fields
+% INPUT:
+% ScalName: string representing the name of the scalar
+% DataIn: structure representing the field, as defined in check_field_srtructure.m
+
+% FUNCTION related
+% varname_generator.m: determines the field names to read in the netcdf file, depending on the scalar
+
+function [DataOut,errormsg]=calc_field(FieldName,DataIn)
+
+%list of defined scalars to display in menus (in addition to 'ima_cor').
+% a type is associated to each scalar: 
+%              'discrete': related to the individual velocity vectors, not interpolated by patch
+%              'vel': calculated from velocity components, continuous field (interpolated with velocity)              
+%              'der': needs spatial derivatives     
+%              'var': the scalar name corresponds to a field name in the netcdf files
+% a specific variable name for civ1 and civ2 fields are also associated, if
+% '' the scalar is calculated from other fields, as explicited below
+%list_scal={title, type, civ1 var name,civ2 var name}
+list_field={'velocity';...%image correlation corresponding to a vel vector
+            'ima_cor';...%image correlation corresponding to a vel vector
+           'norm_vel';...%norm of the velocity
+           'vort';...%vorticity
+           'div';...%divergence
+           'strain';...%rate of strain
+           'u';... %u velocity component
+           'v';... %v velocity component
+           'w';... %w velocity component
+           'w_normal';... %w velocity component normal to the plane
+          'error'}; %error associated to a vector (for stereo or patch)
+errormsg=[]; %default error message
+if ~exist('FieldName','var') 
+    DataOut=list_field;% gives the list of possible fields in the absence of input
+else
+    if ~exist('DataIn','var')
+        DataIn=[];
+    end
+    if ischar(FieldName)
+        FieldName={FieldName};
+    end
+    if isfield(DataIn,'Z')&& isequal(size(DataIn.Z),size(DataIn.X))
+        nbcoord=3;
+    else
+        nbcoord=2;
+    end    
+    DataOut=DataIn; %reporduce global attribute
+    ListVarName={};
+    ValueList={};
+    RoleList={};
+    units_cell={};
+    for ilist=1:length(FieldName)  
+        [VarName,Value,Role,units]=feval(FieldName{ilist},DataIn);%calculate field with appropriate function named FieldName{ilist}
+        ListVarName=[ListVarName VarName];
+        ValueList=[ValueList Value];
+        RoleList=[RoleList Role];
+        units_cell=[units_cell units];
+    end   
+       %erase previous data (except coordinates)
+    for ivar=nbcoord+1:length(DataOut.ListVarName)
+        VarName=DataOut.ListVarName{ivar};
+        DataOut=rmfield(DataOut,VarName);
+    end  
+    DataOut.ListVarName=DataOut.ListVarName(1:nbcoord);
+    if isfield(DataOut,'VarDimName')
+        DataOut.VarDimName=DataOut.VarDimName(1:nbcoord);
+    else
+        errormsg='element .VarDimName missing in input data';
+        return
+    end
+    DataOut.VarAttribute=DataOut.VarAttribute(1:nbcoord);
+    %append new data
+    DataOut.ListVarName=[DataOut.ListVarName ListVarName];
+    for ivar=1:length(ListVarName)
+        DataOut.VarDimName{nbcoord+ivar}=DataOut.VarDimName{1};      
+        DataOut.VarAttribute{nbcoord+ivar}.Role=RoleList{ivar};  
+        DataOut.VarAttribute{nbcoord+ivar}.units=units_cell{ivar};
+        eval(['DataOut.' ListVarName{ivar} '=ValueList{ivar};'])
+    end
+end
+
+%%%%%%%%%%%%% velocity fieldn%%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units_cell]=velocity(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units_cell={};
+if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
+    units=[DataIn.CoordUnit '/' DataIn.TimeUnit];
+else
+    units='pixel';
+end
+if isfield(DataIn,'U')
+    VarName=[VarName {'U'}];
+    ValCell=[ValCell {DataIn.U}];
+    Role=[Role {'vector_x'}];
+    units_cell=[units_cell {units}];
+end
+if isfield(DataIn,'V')
+    VarName=[VarName {'V'}];
+    ValCell=[ValCell {DataIn.V}];
+    Role=[Role {'vector_y'}];  
+    units_cell=[units_cell {units}];
+end
+if isfield(DataIn,'W')
+    VarName=[VarName {'W'}];
+    ValCell=[ValCell {DataIn.W}];
+    Role=[Role {'vector_z'}];
+    units_cell=[units_cell {units}];
+end
+if isfield(DataIn,'F')
+    VarName=[VarName {'F'}];
+    ValCell=[ValCell {DataIn.F}];
+    Role=[Role {'warnflag'}];
+    units_cell=[units_cell {[]}];
+end
+if isfield(DataIn,'FF')
+    VarName=[VarName,{'FF'}];
+    ValCell=[ValCell {DataIn.FF}];
+    Role=[Role {'errorflag'}];
+    units_cell=[units_cell {[]}];
+end
+
+%%%%%%%%%%%%% ima cor%%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=ima_cor(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'C')
+    VarName{1}='C';
+    ValCell{1}=DataIn.C;
+    Role={'ancillary'};
+    units={[]};
+end
+
+%%%%%%%%%%%%% norm_vec %%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=norm_vel(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'U') && isfield(DataIn,'V')
+    VarName{1}='norm_vel';
+     ValCell{1}=DataIn.U.*DataIn.U+ DataIn.V.*DataIn.V;
+     if isfield(DataIn,'W') && isequal(size(DataIn.W),size(DataIn.U))
+         ValCell{1}=ValCell{1}+DataIn.W.*DataIn.W;
+     end
+     ValCell{1}=sqrt(ValCell{1});
+     Role{1}='scalar';
+     if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
+        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
+     else
+        units={'pixel'};
+     end
+end  
+
+
+
+%%%%%%%%%%%%% vorticity%%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=vort(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'DjUi')
+    VarName{1}='vort';
+    ValCell{1}=DataIn.DjUi(:,1,2)-DataIn.DjUi(:,2,1);  %vorticity
+    siz=size(ValCell{1});
+    ValCell{1}=reshape(ValCell{1},siz(1),1);
+    Role{1}='scalar';
+    if isfield(DataIn,'TimeUnit')
+        units={[DataIn.TimeUnit '-1']};
+    else
+        units={[]};
+    end
+end  
+
+%%%%%%%%%%%%% divergence%%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=div(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'DjUi')
+    VarName{1}='div';
+    ValCell{1}=DataIn.DjUi(:,1,1)+DataIn.DjUi(:,2,2); %DUDX+DVDY
+    siz=size(ValCell{1});
+    ValCell{1}=reshape(ValCell{1},siz(1),1);
+    Role{1}='scalar';
+    if isfield(DataIn,'TimeUnit')
+        units={[DataIn.TimeUnit '-1']};
+    else
+        units={[]};
+    end
+end  
+
+%%%%%%%%%%%%% strain %%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=strain(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'DjUi')
+   VarName{1}='strain'; 
+   ValCell{1}=DataIn.DjUi(:,1,2)+DataIn.DjUi(:,2,1);%DVDX+DUDY
+   siz=size(ValCell{1});    
+   ValCell{1}=reshape(ValCell{1},siz(1),1); 
+   if isfield(DataIn,'TimeUnit')
+        units={[DataIn.TimeUnit '-1']};
+   else
+        units={[]};
+   end
+end  
+
+%%%%%%%%%%%%% u %%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=u(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'U')
+    VarName{1}='U';
+    ValCell{1}=DataIn.U;
+    Role{1}='scalar';
+    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
+        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
+    else
+        units={'pixel'};
+    end
+end
+
+%%%%%%%%%%%%% v %%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=v(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'V')
+    VarName{1}='V';
+    ValCell{1}=DataIn.V;
+    Role{1}='scalar';
+    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
+        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
+    else
+        units={'pixel'};
+    end
+end
+
+%%%%%%%%%%%%% w %%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=w(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'W')
+    VarName{1}='W';
+    ValCell{1}=DataIn.W;
+    Role{1}='scalar';%will remain unchanged by projection
+    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
+        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
+    else
+        units={'pixel'};
+    end
+end
+
+%%%%%%%%%%%%% w_normal %%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=w_normal(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'W')
+    VarName{1}='W';
+    ValCell{1}=DataIn.W;
+    Role{1}='vector_z';%will behave like a vector component  by projection 
+    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
+        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
+    else
+        units={'pixel'};
+    end
+end
+
+%%%%%%%%%%%%% error %%%%%%%%%%%%%%%%%%%%
+function [VarName,ValCell,Role,units]=error(DataIn)
+VarName={};
+ValCell={};
+Role={};
+units={};
+if isfield(DataIn,'E')
+    VarName{1}='E';
+    ValCell{1}=DataIn.E;
+    Role{1}='ancillary'; %TODO CHECK units in actual fields
+    if isfield(DataIn,'CoordUnit') && isfield(DataIn,'TimeUnit')
+        units={[DataIn.CoordUnit '/' DataIn.TimeUnit]};
+    else
+        units={'pixel'};
+    end
+end
+
Index: /trunk/src/private/cell2tab.m
===================================================================
--- /trunk/src/private/cell2tab.m	(revision 8)
+++ /trunk/src/private/cell2tab.m	(revision 8)
@@ -0,0 +1,33 @@
+%'cell2tab': transform a Matlab cell in a character array suitable for display in a table
+% INPUT:
+% Tabcell: (nx,ny) cell table, for nx lines
+% separator: character used for separating displayed columns
+function Tabchar=cell2tab(Tabcell,separator) 
+Tabchar={};%default
+[nx,ny]=size(Tabcell);
+%determine width withcolumn(jtab) of each column
+for jtab=1:ny 
+    widthcolumn(jtab)=0;%default
+    for itab=1:nx% read line
+        if widthcolumn(jtab)<length(Tabcell{itab,jtab})
+            widthcolumn(jtab)=length(Tabcell{itab,jtab});
+        end
+    end
+end
+%justify table
+for itab=1:nx    
+    charchain=[];         
+    for jtab=1:ny% read line
+        textlu=Tabcell{itab,jtab};
+        if widthcolumn(jtab)>length(textlu)
+            blankstr=char(32*ones(1,widthcolumn(jtab)-length(textlu)));
+            textlu=[textlu blankstr];
+        end
+        if ~isempty(charchain)
+            textlu=[separator textlu];
+        end
+        charchain=[charchain textlu];
+    end
+    %Tabchar(itab)={charchain};
+    Tabchar(itab,1)={charchain};
+end
Index: /trunk/src/private/check_field_structure.m
===================================================================
--- /trunk/src/private/check_field_structure.m	(revision 8)
+++ /trunk/src/private/check_field_structure.m	(revision 8)
@@ -0,0 +1,151 @@
+%'check_field_structure': check the validity of the field struture representation consitant with the netcdf format
+%----------------------------------------------------------------------
+% function [DataOut,errormsg]=check_field_structure(Data)
+%
+% OUTPUT:
+%  Data: structure reproducing the input structure Data, with the additional elements:
+%           with fields:
+%
+%            .ListDimName: cell listing the names of the array dimensions
+%             .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
+%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
+%            .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName
+% errormsg: error message which is not empty when the input structure does not have the right form
+%
+%INPUT:
+% Data:   structure containing 
+%         (optional) .ListGlobalAttribute: cell listing the names of the global attributes
+%                    .Att_1,Att_2... : values of the global attributes
+%         (requested)  .ListVarName: list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} ) 
+%         (requested)  .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)                         
+%         (requested) .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
+
+
+function [DataOut,errormsg]=check_field_structure(Data)
+DataOut=[]; %default
+errormsg=[];
+if ~isstruct(Data)
+    errormsg='input field is not a structure';
+    return
+end
+if isfield(Data,'ListVarName') && iscell(Data.ListVarName)
+    nbfield=numel(Data.ListVarName); 
+else
+    errormsg='input field does not contain the list of variables .ListVarNames';
+    return
+end
+%check dimension names
+% definition by VarDimIndex (obsolete)
+% if ~isfield(Data,'VarDimName') && isfield(Data,'VarDimIndex') && isfield(Data,'ListDimName')%old convention
+%     for ivar=1:nbfield
+%         DimCell=Data.VarDimIndex{ivar};
+%         if isnumeric(DimCell)
+%             if DimCell <= numel(Data.ListDimName)
+%                 Data.VarDimName{ivar}=Data.ListDimName(DimCell);
+%             else                      
+%                 errormsg='dimension names not defined';
+%                 return 
+%             end
+%         else 
+%             errormsg='unrecognized format for .VarDimIndex';
+%         end
+%     end
+% end
+if ~(isfield(Data,'VarDimName') && iscell(Data.VarDimName))
+    errormsg='input field does not contain the list of dimensions .VarDimName';
+    return
+end
+if isfield(Data,'DimValue')
+    Data=rmfield(Data,'DimValue');
+end
+if isfield(Data,'VarDimName') && iscell(Data.VarDimName)
+    nbdim=0;
+    if numel(Data.VarDimName)==nbfield
+        for ivar=1:nbfield
+            VarName=Data.ListVarName{ivar};
+            if ~isfield(Data,VarName)
+                errormsg=['the listed variable ' VarName ' is not found'];
+                return
+            else             
+                eval(['sizvar=size(Data.' VarName ');'])% sizvar = dimension of variable
+                DimCell=Data.VarDimName{ivar};
+                if ischar(DimCell)
+                    DimCell={DimCell};
+                elseif ~iscell(DimCell)
+                    errormsg=['wrong format for .VarDimName{' num2str(ivar) ' (must be the cell of dimension names of the variable ' VarName];
+                    return
+                end
+                nbcoord=numel(sizvar);
+                if numel(DimCell)==0
+                    errormsg=['empty declared dimension .VarDimName{' num2str(ivar) '} for ' VarName];
+                    return
+                elseif numel(DimCell)==1% one dimension declared
+                    if nbcoord==2 
+                        if sizvar(1)==1 
+                            nbcoord=1;
+                            sizvar(1)=sizvar(2);
+                        elseif sizvar(2)==1
+                            nbcoord=1;
+                        else
+                            errormsg=['1 dimension declared in .VarDimName{' num2str(ivar) '} inconsistent with the nbre of dimensions =2 of the variable ' VarName];
+                            return
+                        end
+                    else
+                          errormsg=['1 dimension declared in .VarDimName{' num2str(ivar) '} inconsistent with the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName];
+                          return      
+                    end  
+                else
+                    if numel(DimCell)>nbcoord
+                        DimCell=DimCell(end-nbcoord+1:end);%first singleton diemnsions omitted, 
+                    elseif nbcoord > numel(DimCell)
+                        errormsg=['nbre of declared dimensions in .VarDimName{' num2str(ivar) '} smaller than the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName];
+                        return
+                    end
+                end
+                DimIndex=[];
+                for idim=1:nbcoord %loop on the coordinates of variable #ivar   
+                    DimName=DimCell{idim};
+                    testprev=0;
+                    for iprev=1:nbdim %check previously listed dimension names
+                        if strcmp(Data.ListDimName{iprev},DimName)
+                           if ~isequal(Data.DimValue(iprev),sizvar(idim))
+                               if isequal(Data.DimValue(iprev),0)  % the dimension has been already detected as a range [min max]
+                                   Data.DimValue(idim)=sizvar(idim); %update with actual value 
+                               elseif sizvar(idim)==2 && strcmp(DimName,VarName)
+                                    %case of a regularly spaced coordinate defined by the first and last values: dimension will be determined later                          
+                               else
+                                   errormsg=['dimension declaration inconsistent with the size =[' num2str(sizvar) '] for ' VarName];
+                                   return 
+                               end
+                           end
+                           DimIndex=[DimIndex iprev];
+                           testprev=1;
+                           break
+                        end
+                    end
+                    if ~testprev % a new dimension is appended to the list
+                        nbdim=nbdim+1;
+                        if sizvar(idim)==2 && strcmp(DimName,VarName)
+                            Data.DimValue(nbdim)=0; %to be updated for a later variable
+%                             Data.VarType{ivar}='range';
+                        else
+                            Data.DimValue(nbdim)=sizvar(idim);
+                        end
+                        Data.ListDimName{nbdim}=DimName;
+                        DimIndex=[DimIndex nbdim];
+                    end
+                end
+                Data.VarDimIndex{ivar}=DimIndex;
+            end
+        end                               
+    else
+        errormsg=' .ListVarNames and .VarDimName have different lengths';
+        return
+    end
+else
+    errormsg='input field does not contain the cell of dimension names .VarDimName for variables';
+    return
+end
+DataOut=Data;
+    
+   
Index: /trunk/src/private/check_functions.m
===================================================================
--- /trunk/src/private/check_functions.m	(revision 8)
+++ /trunk/src/private/check_functions.m	(revision 8)
@@ -0,0 +1,117 @@
+%'check_functions': check the path and modification date for all the
+%  function in the toolbox UVMAT. Called at the opening of uvmat.fig
+%----------------------------------------------------------------------
+% function [errormsg,date_str]=check_functions
+%
+% OUTPUT:
+% errormsg: error message listing functions whose paths are not in the directory of uvmat.m
+% date_str: date of the most recent modification of a file in the toolbox
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function [errormsg,date_str]=check_functions
+errormsg={};%default
+list_fct={'calc_field';...% defines fields (velocity, vort, div...) from civx data and calculate them  
+          'cell2tab';... %transform a Matlab cell in a character array suitable for display in a table
+          'check_functions';...  
+          'civ';...   %function associated with the interface 'civ.fig' for PIV and spline interpolation
+          'civ.fig';...
+          'civ_3D';... function associated with the interface 'civ_3D.fig' for PIV in volume (in progress) 
+          'civ_3D.fig';...
+          'close_fig';...% function  activated when a figure is closed
+          'copyfields';...%copy fields between two matlab structures
+          'delete_object';...%delete a projection object, defined by its index in the Uvmat list or by its graphic handle
+          'editxml';...%display and edit xml files using a xls schema
+          'editxml.fig';...%interface for editxml
+          'find_field_indices';...% group the variables of a nc-formated Matlab structure into 'fields' with common dimensions
+          'geometry_calib';...%performs geometric calibration from a set of reference points
+          'geometry_calib.fig';...%interface for geometry_calib
+          'get_field';...% choose and plot a field from a Netcdf file
+          'get_field.fig';...%interface for get_field
+          'get_plot_handles';... %provides handles of elements setting the plotting parameters in the uvmat interface
+          'griddata_uvmat';...%make 2D linear interpolation using griddata, with input appropriate for both Matlab 6.5 and 7
+          'hist_update';...%  update of a current global histogram by inclusion of a new field  
+          'imadoc2struct';...%convert the image documentation file ImaDoc into a Matlab structure
+          'keyboard_callback';... % function activated when a key is pressed on the keyboard 
+          'ListDir';... scan the structure of the directory tree (for dataview.m)
+          'mouse_down';% function activated when the mouse button is pressed on a figure (callback for 'WindowButtonDownFcn')
+          'mouse_motion';...% permanently called by mouse motion over a figure (callback for 'WindowButtonMotionFcn')
+          'mouse_up';... % function to be activated when the mouse button is released (callback for 'WindowButtonUpFcn')
+          'msgbox_uvmat';... associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls
+          'msgbox_uvmat.fig';...
+          'name2display';...% extracts the root name and field numbers from an input filename 
+          'name_generator';...%creates a file name from a root name and indices. 
+          'nc2struct';...% transform a netcdf file in a corresponding matlab structure
+          'peaklock';...%
+          'phys';...% transforms fields from image (px) to real world (phys) coordinates using geometric calibration parameters
+          'phys_polar';... transform image coordinates (px) to physical ploar coordinates
+          'phys_XYZ';...%transforms image (px) to real world (phys) coordinates using geometric calibration parameters
+          'px';...% transform fields from physical to px coordinates using geometrical calibration parameters
+          'px_XYZ';...% ransform physical to px coordinates using geometrical calibration parameters
+          'plot_field';...%displays a vector field and/or scalar or images
+          'plot_object';...%draws a projection object (points, line, plane...)
+          'proj_field';...%project a field on a projection object (plane, line,...)
+          'read_civxdata';...reads civx data from netcdf files
+          'read_imatext';...%read .civ files (obsolete, but can be adapted to other text documentation files)
+           'read_plot_param';... %read the plotting option parameters on the uvmat interface
+           'read_set_object';...%read the data on the set_object interface
+           'read_xls';...%read excel files containing the list of the experiments
+           'reinit';...% suppress the personal parameter file 'uvmat_perso.mat' 
+           'RUN_FIX';...% fix velocity fields
+           'RUN_STLIN';...% combine 2 displacement fields for stereo PIV
+           'series';...% master function for analysis field series, with interface 'series.fig'
+           'series.fig';...% interface for 'series'
+           'set_col_vec';...
+           'set_grid';...% creates a grid for PIV
+           'set_grid.fig';...% interface for set_grid
+           'set_object.m';...%  edit a projection object
+           'set_object.fig';...% interface for set_object
+           'sub_field';...% combine the two input fields, 
+           'struct2nc';...% %write fields in netcdf files
+           'uvmat';...% master function for file scanning and visualisation of 2D fields
+           'uvmat.fig';...  %interface for uvmat  
+           'update_obj';... update the object representation graph and its projection field, record it in the uvmat interface
+           'update_waitbar';... update the waitbar display, used for ACTION functions in the GUI 'series'
+           'warndlg_uvmat';...% display messages (error, warning, confirmation) , OBSOLETE, use msgbox_uvmat 
+            'write_plot_param'};%update plotting parameters after plot 
+ dir_fct=which('uvmat');% path to uvmat
+[pathuvmat,name,ext]=fileparts(dir_fct);
+icount=0;
+% loop on the list of functions in the uvmat package
+ for i=1:length(list_fct)
+    dir_fct=which(list_fct{i});% path to fct
+    if isempty(dir_fct)
+        icount=icount+1;
+        errormsg{icount}=[list_fct{i} ' not found'];% test for function not found
+    else
+       [pth,name,ext]=fileparts(dir_fct);
+       if ~isequal(pathuvmat,pth)
+           icount=icount+1;
+           errormsg{icount}=[dir_fct ' overrides the package UVMAT'];% bad path for the function
+       end
+       datfile=dir(dir_fct);
+       date_str=datfile.date;%string of the date of last modification
+       datnum(i)=0;%default
+       char_code=double(date_str);% code of the date characters
+       special_char=(char_code>127); %non standard Ascii character (e.g. date in french)
+       if isempty(find(special_char))% standard Ascii character 
+          datnum(i)=datenum(date_str);
+       end
+   end
+end
+errormsg=errormsg';
+date_str=datestr(max(datnum));
Index: /trunk/src/private/close_fig.m
===================================================================
--- /trunk/src/private/close_fig.m	(revision 8)
+++ /trunk/src/private/close_fig.m	(revision 8)
@@ -0,0 +1,12 @@
+%'close_fig': function  activated when a figure is closed
+%----------------------------------------------------------------
+% function close_fig(ggg,eventdata,hparent,type)
+% activated by the command:
+%set(hObject,'DeleteFcn',{@close_fig,hparent,type})
+% where hObject is the handle of the figure
+%
+
+function close_fig(ggg,eventdata,hparent,type)
+if isequal(type,'zoom')
+    delete(hparent)  % delete the rectangle showing the zoom graph in the parent fig
+end
Index: /trunk/src/private/copyfields.m
===================================================================
--- /trunk/src/private/copyfields.m	(revision 8)
+++ /trunk/src/private/copyfields.m	(revision 8)
@@ -0,0 +1,22 @@
+%'copyfields' copy fields between two matlab structures
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% OUPUT:
+% NewData: resulting structure
+%
+%INPUT:
+% listfields: cell arrays representing the list of field names to be copied
+% SourceData: structure containing the source data to copy in NewData
+% OldData: (optional) preexisting data structure.
+
+function NewData=copyfields(listfields,SourceData,OldData)
+if ~exist('OldData','var')
+    OldData=[];
+end
+NewData=OldData;%default
+for ifield=1:length(listfields)
+    if isfield(SourceData,listfields{ifield}) & ~isempty(eval(['SourceData.' listfields{ifield}]))
+        eval(['NewData.' listfields{ifield} '=SourceData.' listfields{ifield} ';']); 
+    elseif isfield(OldData,listfields{ifield})
+        NewData=rmfield(NewData,listfields{ifield});
+    end
+end
Index: /trunk/src/private/datenum_uvmat.m
===================================================================
--- /trunk/src/private/datenum_uvmat.m	(revision 8)
+++ /trunk/src/private/datenum_uvmat.m	(revision 8)
@@ -0,0 +1,602 @@
+%'datenum_uvmat': like the Matlab function datenum.m but gives empty output instead of stopping for input error
+%--------------------------------------------------------------------------
+function n = datenum_uvmat(arg1,arg2,arg3,h,min,s)
+%DATENUM Serial date number.
+%	N = DATENUM(V) converts one or more date vectors V into serial date 
+%	numbers N. Input V can be an M-by-6 or M-by-3 matrix containing M full 
+%	or partial date vectors respectively.  DATENUM returns a column vector
+%	of M date numbers.
+%
+%	A date vector contains six elements, specifying year, month, day, hour, 
+%	minute, and second. A partial date vector has three elements, specifying 
+%	year, month, and day.  Each element of V must be a positive double 
+%	precision number.  A serial date number of 1 corresponds to Jan-1-0000.  
+%	The year 0000 is merely a reference point and is not intended to be 
+%	interpreted as a real year.
+%
+%	N = DATENUM(S,F) converts one or more date strings S to serial date 
+%	numbers N using format string F. S can be a character array where each
+%	row corresponds to one date string, or one dimensional cell array of 
+%	strings.  DATENUM returns a column vector of M date numbers, where M is 
+%	the number of strings in S. 
+%
+%	All of the date strings in S must have the same format F, which must be
+%	composed of date format symbols according to Table 2 in DATESTR help.
+%	Formats with 'Q' are not accepted by DATENUM.  
+%
+%	Certain formats may not contain enough information to compute a date
+%	number.  In those cases, hours, minutes, and seconds default to 0, days
+%	default to 1, months default to January, and years default to the
+%	current year. Date strings with two character years are interpreted to
+%	be within the 100 years centered around the current year.
+%
+%	N = DATENUM(S,F,P) or N = DATENUM(S,P,F) uses the specified format F
+%	and the pivot year P to determine the date number N, given the date
+%	string S.  The pivot year is the starting year of the 100-year range in 
+%	which a two-character year resides.  The default pivot year is the 
+%	current year minus 50 years.
+%
+%	N = DATENUM(Y,MO,D) and N = DATENUM([Y,MO,D]) return the serial date
+%	numbers for corresponding elements of the Y,MO,D (year,month,day)
+%	arrays. Y, MO, and D must be arrays of the same size (or any can be a
+%	scalar).
+%
+%	N = DATENUM(Y,MO,D,H,MI,S) and N = DATENUM([Y,MO,D,H,MI,S]) return the
+%	serial date numbers for corresponding elements of the Y,MO,D,H,MI,S
+%	(year,month,day,hour,minute,second) arrays.  The six arguments must be
+%	arrays of the same size (or any can be a scalar).
+%
+%	N = DATENUM(S) converts the string or date vector (as defined by 
+%	DATEVEC) S into a serial date number.  If S is a string, it must be in 
+%	one of the date formats 0,1,2,6,13,14,15,16,23 as defined by DATESTR.
+%	This calling syntax is provided for backward compatibility, and is
+%	significantly slower than the syntax which specifies the format string.
+%	If the format is known, the N = DATENUM(S,F) syntax should be used.
+%
+%	N = DATENUM(S,P) converts the date string S, using pivot year P. If the 
+%	format is known, the N = DATENUM(S,F,P) or N = DATENUM(S,P,F) syntax 
+%	should be used.
+%
+%	Note:  The vectorized calling syntax can offer significant performance
+%	improvement for large arrays.
+%
+%	Examples:
+%		n = datenum('19-May-2000') returns n = 730625. 
+%		n = datenum(2001,12,19) returns n = 731204. 
+%		n = datenum(2001,12,19,18,0,0) returns n = 731204.75. 
+%		n = datenum('19.05.2000','dd.mm.yyyy') returns n = 730625.
+%
+%	See also NOW, DATESTR, DATEVEC, DATETICK.
+
+%   Copyright 1984-2004 The MathWorks, Inc.
+%   $Revision: 1.24.4.7 $  $Date: 2004/10/27 23:53:57 $
+
+if (nargin<1) || (nargin>6)
+    error('MATLAB:datenumr:Nargin',nargchk(1,6,nargin));
+end
+
+% parse input arguments
+isdatestr = ~isnumeric(arg1);
+isdateformat = false;
+if nargin == 2
+    isdateformat = ischar(arg2);
+elseif nargin == 3
+    isdateformat = [ischar(arg2),ischar(arg3)];
+end
+% try to convert date string or date vector to a date number
+try
+    switch nargin
+        case 1 
+            if isdatestr
+                n = datenummx(datevec(arg1));
+            elseif (size(arg1,2)==3) || (size(arg1,2)==6)
+                n = datenummx(arg1);
+            else
+                n = arg1;
+            end
+        case 2
+            if isdateformat
+                if ischar(arg1)
+					arg1 = cellstr(arg1);
+				end
+                n = dtstr2dtnummx(arg1,cnv2icudf(arg2));
+            else
+                n = datenummx(datevec(arg1,arg2));
+            end
+        case 3
+			if any(isdateformat)
+				if isdateformat(1) 
+					format = arg2;
+					pivot = arg3;
+				elseif isdateformat(2)
+					format = arg3;
+					pivot = arg2;
+				end
+				if ischar(arg1)
+					arg1 = cellstr(arg1);
+				end
+				icu_dtformat = cnv2icudf(format);
+				showyr =  strfind(icu_dtformat,'y'); 
+				if ~isempty(showyr)
+					wrtYr =  numel(showyr);
+					checkYr = diff(showyr);
+					if any(checkYr~=1)
+						error('MATLAB:datenum:YearFormat','Unrecognized year format');
+					end
+					switch wrtYr
+						case 4,
+							icu_dtformat = strrep(icu_dtformat,'yyyy','yy');
+						case 3,
+							icu_dtformat = strrep(icu_dtformat,'yyy','yy');
+					end
+				end
+				n = dtstr2dtnummx(arg1,icu_dtformat,pivot);
+			else
+                n = datenummx(arg1,arg2,arg3);
+			end
+        case 6, n = datenummx(arg1,arg2,arg3,h,min,s);
+        otherwise, error('MATLAB:datenum:Nargin',...
+                         'Incorrect number of arguments');
+    end
+catch
+    err = lasterror;
+    err.message = sprintf('DATENUM failed.\n%s',err.message);
+    
+    if (nargin == 1 && ~isdatestr)
+        err.identifier = 'MATLAB:datenum:ConvertDateNumber';
+    elseif (nargin == 1 && isdatestr) || (isdatestr && any(isdateformat))
+        err.identifier = 'MATLAB:datenum:ConvertDateString';
+    elseif (nargin > 1) && ~isdatestr && ~any(isdateformat)
+        err.identifier = 'MATLAB:datenum:ConvertDateVector';
+    end
+ 
+    rethrow(err);
+end
+end
+
+function [y,mo,d,h,mi,s] = datevec(t,varargin)
+%DATEVEC Date components.
+%	V = DATEVEC(N) converts one or more date numbers N to date vectors V. N
+%	can be a scalar, vector, or multidimensional array of positive date
+%	numbers. DATEVEC returns an M-by-6 matrix containing M date vectors,
+%	where M is the total number of date numbers in N.
+%
+%	V = DATEVEC(S,F) converts one or more date strings S to date vectors
+%	V using format string F to interpret the date strings in S. S can be a
+%	cell array of strings or a character array where each row corresponds
+%	to one date string. All of the date strings in S must have the same
+%	format which must be composed of date format symbols according to 
+%	Table 2 in DATESTR help. Formats with 'Q' are not accepted by DATEVEC. 
+%	DATEVEC returns an M-by-6 matrix of date vectors, where M is the number 
+%	of date strings in S.
+%
+%	Certain formats may not contain enough information to compute a date
+%	vector.  In those cases, hours, minutes, and seconds default to 0, days
+%	default to 1, months default to January, and years default to the
+%	current year. Date strings with two character years are interpreted to
+%	be within the 100 years centered around the current year.
+%
+%	V = DATEVEC(S,F,P) or V = DATEVEC(S,P,F) converts the date string S to
+%	a date vector V, using the pivot year P and the date format F.  The 
+%	pivot year is the starting year of the 100-year range in which a 
+%	two-character year resides.  The default pivot year is the current year 
+%	minus 50 years.
+%
+%	[Y,MO,D,H,MI,S] = DATEVEC(...) takes any of the two syntaxes shown
+%	above and returns the components of the date vector as individual
+%	variables.  
+%
+%	V = DATEVEC(S) converts date string S to date vector V. S must be in 
+%	one of the date formats 0,1,2,6,13,14,15,16,23 as defined by DATESTR.  
+%	This calling syntax is provided for backward compatibility, and is
+%	significantly slower than the syntax which specifies the format string.
+%	If the format is known, the V = DATEVEC(S,F) syntax should be used.
+%
+%	V = DAVEVEC(S,P) converts the date string S using pivot year P.
+%	If the format is known, the V = DATEVEC(S,F,P) or V = DATEVEC(S,P,F) 
+%	syntax should be used.
+%
+%	Note 1:  If more than one input argument is used, the first argument 
+%	must be a date string or array of date strings.
+%
+%	Note 2:  The vectorized calling syntax can offer significant performance
+%	improvement for large arrays.
+%
+%	Examples
+%		d = '12/24/1984';
+%		t = 725000.00;
+%		c = datevec(d) or c = datevec(t) produce c = [1984 12 24 0 0 0].
+%		[y,m,d,h,mi,s] = datevec(d) returns y=1984, m=12, d=24, h=0, mi=0, s=0.
+%		c = datevec('5/6/03') produces c = [2003 5 6 0 0 0] until 2054.
+%		c = datevec('5/6/03',1900) produces c = [1903 5 6 0 0 0].
+%		c = datevec('19.05.2000','dd.mm.yyyy') produces c = [2000 5 19 0 0 0].
+%
+%	See also DATENUM, DATESTR, CLOCK, DATETICK. 
+
+%	Copyright 1984-2004 The MathWorks, Inc. 
+%	$Revision: 1.28.4.11 $  $Date: 2004/10/27 23:53:59 $
+
+if (nargin<1) || (nargin>3)
+%     error('MATLAB:datevec:Nargin',nargchk(1,3,nargin));
+    return
+end
+
+% parse input arguments
+isdatestr = ~isnumeric(t);
+isdateformat = false;
+if ~isdatestr && nargin > 1
+    warning('MATLAB:datevec:Inputs', ...
+        'Unless the first input argument is a date string, all subsequent\narguments will be ignored.');
+elseif nargin > 1
+    isdateformat = cellfun('isclass',varargin,'char');
+    if (nargin == 3)
+        if ~isdateformat(1)
+            pivotyear = varargin{1};
+        elseif ~isdateformat(2)
+            pivotyear = varargin{2};
+        elseif isdateformat(1) && isdateformat(2)
+%             error('MATLAB:datevec:DateFormat',...
+%                 'You specified two date format strings.\nThere can only be one.');
+           return
+        end 
+    elseif (nargin == 2) && ~isdateformat
+        pivotyear = varargin{1};
+    end
+end
+
+if isdatestr && isempty(t)
+    if nargout <= 1
+        y = zeros(0,6);
+	else
+		[y,mo,d,h,mi,s] = deal(zeros(0,0));
+    end;
+	warning('MATLAB:datevec:EmptyDate',...
+		'Usage of DATEVEC with empty date strings is not supported.\nResults may change in future versions.');
+    return;
+end
+
+% branch to appropriate date string parser
+if  isdatestr
+    % a date format string was specified
+    % map date format to ICU date format tokens
+    if ischar(t)
+        % convert to cellstring.
+        t = cellstr(t);
+    end
+    icu_dtformat = {};
+    if ~any(isdateformat)
+        format = getformat(t);
+        if ~isempty(format)
+            icu_dtformat = cnv2icudf(format);
+        end
+    else
+        icu_dtformat = cnv2icudf(varargin{isdateformat});
+    end
+    if ~isempty(icu_dtformat) 
+        % call ICU MEX function to parse date string to date vector
+        try
+            if nargin < 2 || (nargin == 2 && any(isdateformat))
+                y = dtstr2dtvecmx(t,icu_dtformat);
+            else
+				showyr =  findstr(icu_dtformat,'y'); 
+				if ~isempty(showyr)
+					wrtYr =  numel(showyr);
+					if showyr(end) - showyr(1) >= wrtYr
+% 						error('MATLAB:datevec:YearFormat','Unrecognized year format');
+                        return
+					end
+					switch wrtYr
+						case 4,
+							icu_dtformat = strrep(icu_dtformat,'yyyy','yy');
+						case 3,
+							icu_dtformat = strrep(icu_dtformat,'yyy','yy');
+					end
+				end
+                y = dtstr2dtvecmx(t,icu_dtformat,pivotyear);
+            end
+            if nargout > 1
+                mo = y(:,2);
+                d  = y(:,3);
+                h  = y(:,4);
+                mi = y(:,5);
+                s  = y(:,6);
+                y  = y(:,1);
+            end
+        catch
+            err = lasterror;
+            err.identifier = 'MATLAB:datevec:dtstr2dtvecmx';
+            err.message = sprintf(['DATEVEC failed, calling DTSTR2DTVECMX.\n'... 
+                    '%s'],err.message);
+            rethrow(err);
+        end 
+    else
+        %last resort!!!
+       if ischar(t)
+          m = size(t,1);
+       else
+          m = length(t);
+       end
+       y = zeros(m,6);
+       t = lower(t);
+%        ampmtokens = lower(getampmtokensmx);
+        amtok = 'am'; %ampmtokens{1};
+       amtok0 = 'am';
+        pmtok = 'pm';%ampmtokens{2};
+       pmtok0 = 'pm';
+       M={'jan';'feb';'mar';'apr';'may';'jun';'jul';'aug';'sept';'oct';'nov';'dec'};
+       M0=M;
+%        M = lower(getmonthnames);
+%        M0 = lower(getmonthnames(0)); % fall-back list of English short month names.
+       try
+           for i = 1:m
+               % Convert date input to date vector
+               % Initially, the six fields are all unknown.
+               c(1,1:6) = NaN;
+               pm = -1; % means am or pm is not in datestr
+               if ischar(t)
+                   str = t(i,:);
+               else
+                   str = t{i};
+               end
+               d = [' ' str ' '];
+
+               % Replace 'a ' or 'am', 'p ' or 'pm' with ': '.
+               p = max(find(d == amtok(1) | d == pmtok(1) | ...
+                            d == amtok0(1)| d == pmtok0(1)));
+               if ~isempty(p)
+                   if (d(p+1) == amtok(2) | ...
+                       d(p+1) == amtok0(2)| isspace(d(p+1))) & ...
+                       d(p-1) ~= lower('e')
+                       pm = (d(p) == pmtok(1) | d(p) == pmtok0(1));
+                       if d(p-1) == ' '
+                           d(p-1:p+1) = ':  ';
+                       else
+                           d(p:p+1) = ': ';
+                       end
+                   end
+               end
+
+               % Any remaining letters must be in the month field
+               p = find(isletter(d));
+
+               % Test length of string to catch a bogus date string.
+               % Get index of month in list of months of year
+               % replace with spaces, month name in date string.
+               % If native month name lookup fails, fall back on 
+               % list of English month names.
+               if ~isempty(p) && numel(d)>4
+                   k = min(p);
+                   if d(k+3) == '.', d(k+3) = ' '; end
+                   monthidx = ~cellfun('isempty',strfind(M,d(k:k+2)));
+                   if ~any(monthidx)
+                       monthidx = ~cellfun('isempty',strfind(M0,d(k:k+2)));
+                       if ~any(monthidx)
+%                            error('MATLAB:datevec:MonthOfYear',...
+%                                'Failed to lookup month of year.');
+                          return
+                       end
+                   end
+                   c(2) = find(monthidx);
+                   d(p) = char(' '*ones(size(p)));
+               end
+
+               % Find all nonnumbers.
+               p = find((d < '0' | d > '9') & (d ~= '.'));
+
+               % Pick off and classify numeric fields, one by one.
+               % Colons delinate hour, minutes and seconds.
+
+               k = 1;
+               while k < length(p)
+                   if d(p(k)) ~= ' ' && d(p(k)+1) == '-'
+                       f = str2double(d(p(k)+1:p(k+2)-1));
+                       k = k+1;
+                   else
+                       f = str2double(d(p(k)+1:p(k+1)-1));
+                   end
+                   if ~isnan(f)
+                       if d(p(k))==':' || d(p(k+1))==':'
+                           if isnan(c(4))
+                               c(4) = f;             % hour
+                               % Add 12 if pm specified and hour isn't 12
+                               if pm == 1 && f ~= 12 
+                                   c(4) = f+12;
+                               elseif pm == 0 && f == 12
+                                   c(4) = 0;
+                               end
+                           elseif isnan(c(5))
+                               c(5) = f;             % minutes
+                           elseif isnan(c(6)) 
+                               c(6) = f;             % seconds
+                           else
+%                                error('MATLAB:datevec:NumberOfTimeFields',...
+%                                    'Too many time fields in %s', str);
+                                return
+                           end
+                       elseif isnan(c(2))
+                           if f > 12
+%                                error('MATLAB:datevec:IllegalDateField',...
+%                                    '%s is too large to be a month.',num2str(f));
+                                return
+                           end
+                           c(2) = f;                % month
+                       elseif isnan(c(3))
+                           c(3) = f;                % date
+                       elseif isnan(c(1))
+                           if (f >= 0) & (p(k+1)-p(k) == 3) % two char year
+                               if nargin < 2
+                                   clk = clock;
+                                   pivotyear = clk(1)-50;  %(current year-50 years)
+                               end
+                               % Moving 100 year window centered around current year
+                               c(1) = pivotyear+rem(f+100-rem(pivotyear,100),100);
+                           else
+                               c(1) = f;             % year
+                           end
+                       else
+%                            error('MATLAB:datevec:NumberOfDateFields',...
+%                                'Too many date fields in %s', str);
+                            return
+                       end
+                   end
+                   k = k+1;
+               end
+
+               if sum(isnan(c)) >= 5
+%                    error('MATLAB:datevec:ParseDateString',...
+%                        'Cannot parse date %s', str);
+                    return
+               end
+              % If any field has not been specified
+               if isnan(c(1)), clk = clock; c(1) = clk(1); end
+               if isnan(c(2)), c(2) = 1; end;
+               if isnan(c(3)), c(3) = 1; end;
+               if isnan(c(4)), c(4) = 0; end;               
+               if isnan(c(5)), c(5) = 0; end;                   
+               if isnan(c(6)), c(6) = 0; end;
+
+               % Normalize components to correct ranges.
+               y(i,:) = datevecmx(datenummx(c));
+           end
+       catch
+           err = lasterror;
+           err.message = sprintf('Failed to parse date string.\n%s',...
+                                 err.message);
+           rethrow(err);
+       end 
+       if nargout > 1
+           mo = y(:,2);
+           d  = y(:,3);
+           h  = y(:,4);
+           mi = y(:,5);
+           s  = y(:,6);
+           y  = y(:,1);
+       end
+    end
+elseif nargout <= 1
+   % date number was specified 
+   y = datevecmx(t);
+elseif nargout == 3
+    % date number was specified and first three date fields for output
+   [y,mo,d] = datevecmx(t);
+else
+   % date number was specified and all six date fields for output
+   [y,mo,d,h,mi,s] = datevecmx(t);
+end
+end
+%--------------------------------------------------------------------------
+%--
+function [format] = getformat(str)
+  format = '';
+  formatstr = cell(11,1);
+  formatstr(1) = {'dd-mmm-yyyy HH:MM:SS'};
+  formatstr(2) = {'dd-mmm-yyyy'};
+  formatstr(3) = {'mm/dd/yy'};
+  formatstr(4) = {'mm/dd'};
+  formatstr(5) = {'HH:MM:SS'};
+  formatstr(6) = {'HH:MM:SS PM'};
+  formatstr(7) = {'HH:MM'};
+  formatstr(8) = {'HH:MM PM'};
+  formatstr(9) = {'mm/dd/yyyy'};
+  formatstr(10) = {'dd-mmm-yyyy HH:MM'};  %used by finance
+  formatstr(11) = {'dd-mmm-yy'};  %used by finance
+  
+  AlphaFormats = [1 1 0 0 0 1 0 1 0 1 1];
+  %[1 2 6 8 10 11];
+  SlashFormats = [ 0 0 1 1 0 0 0 0 1 0 0];
+  %[3 4 9];
+  TwoSlashFormats = [ 0 0 1 0 0 0 0 0 1 0 0];
+  %[3 9];
+  DashFormats = [ 1 1 0 0 0 0 0 0 0 1 1];
+  %[1 2 10 11];
+  ColonFormats = [1 0 0 0 1 1 1 1 0 1 0];
+  %[1 5 6 7 8 10];
+  TwoColonFormats = [1 0 0 0 1 1 0 0 0 0 0];
+  %[1 5 6];
+  SpaceFormats = [1 0 0 0 0 1 0 1 0 1 0];
+  %[1 6 8 10];
+  
+  bMask = [ 1 1 1 1 1 1 1 1 1 1 1];
+  
+  if length(str) > 1
+      str = str(1,1);
+  end
+  str = strtrim(char(str));
+  slashes = strfind(str, '/');
+  if ~isempty(slashes)
+	  bMask = bMask & SlashFormats;
+	  if (length(slashes) > 0 && slashes(1) == 2)
+		  if (length(slashes) > 1 && slashes(2) == 4)
+			  str = ['0' str(1:slashes(1)) '0' str(slashes(1)+1:end)];
+		  else
+			  str = ['0' str];
+		  end
+	  elseif (length(slashes) > 1 && slashes(2) - slashes(1) == 2)
+		  str = [str(1:slashes(1)) '0' str(slashes(1)+1:end)];
+	  end
+	  if length(slashes) > 1
+		  bMask = bMask & TwoSlashFormats;
+	  else
+		  bMask = bMask & ~TwoSlashFormats;
+	  end
+  else
+	  bMask = bMask & ~SlashFormats;
+  end
+  
+  dashes = strfind(str,'-');
+  if ~isempty(dashes)
+	  bMask = bMask & DashFormats;
+	  if (length(dashes) > 0 && dashes(1) == 2)
+		str = ['0' str];
+	  end
+  else
+	  bMask = bMask & ~DashFormats;	  
+  end
+  
+  colons = strfind(str,':');
+  if ~isempty(colons)
+	  bMask = bMask & ColonFormats;
+	  if (length(colons) > 0) && (colons(1) == 2) && (length(str) - colons(end) > 3)
+		str = ['0' str];
+	  end
+	  if length(colons) > 1
+		  bMask = bMask & TwoColonFormats;
+	  else
+		  bMask = bMask & ~TwoColonFormats;
+	  end	  
+  else
+	  bMask = bMask & ~ColonFormats;
+  end      
+  
+  spaces = strfind(str,' ');
+  if ~isempty(spaces)
+	  bMask = bMask & SpaceFormats;
+  else
+	  bMask = bMask & ~SpaceFormats;
+  end
+  
+  for i = 1:11
+	  if bMask(i)
+		  try
+			  str1 = dateformverify(str,char(formatstr(i)));
+			if (strcmpi(str, strtrim(str1)) == 1)
+				format = char(formatstr(i));
+				break;
+			end
+		  catch
+			   lasterr('');
+		  end
+		  if AlphaFormats(i)
+			  try
+				str1 = dateformverify(str,char(formatstr(i)),'local');
+				if (strcmpi(str, strtrim(str1)) == 1)
+					format = char(formatstr(i));
+					break;
+				end
+			  catch
+				lasterr('');
+			  end       
+		  end
+	  end
+  end
+ end 
Index: /trunk/src/private/delete_object.m
===================================================================
--- /trunk/src/private/delete_object.m	(revision 8)
+++ /trunk/src/private/delete_object.m	(revision 8)
@@ -0,0 +1,73 @@
+%'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
+%
+%INPUT:
+% hObject: object index (if integer) or handle of the graphic object. If
+% hObject is a subobject, the parent object is detected and deleted. 
+
+function delete_object(hObject)
+
+huvmat=findobj('Name','uvmat');%handles of the uvmat interface
+UvData=get(huvmat,'UserData');
+hlist_object=findobj(huvmat,'Tag','list_object');%handles of the object liçst in the uvmat interface
+list_str=get(hlist_object,'String');%objet list
+ObjectData=[];%default
+hdisplay=[];
+if isequal(floor(hObject),hObject) %case of an index
+    if  ~isempty(UvData) & isfield(UvData, 'Object') & length(UvData.Object)>=hObject 
+        if isfield(UvData.Object{hObject},'HandlesDisplay') 
+            hdisplay=UvData.Object{hObject}.HandlesDisplay;
+            for iview=1:length(hdisplay)
+                if ishandle(hdisplay(iview)) & ~isequal(hdisplay(iview),0)
+                    ObjectData=get(hdisplay(iview),'UserData');
+                    if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
+                        delete(ObjectData.SubObject);
+                    end
+                    if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
+                        delete(ObjectData.DeformPoint);
+                    end
+                    delete(hdisplay(iview))
+                end
+                ishandle(hdisplay(iview))
+            end
+        end   
+        for iobj=hObject+1:length(UvData.Object)
+            hdisplay=UvData.Object{iobj}.HandlesDisplay;
+            for iview=1:length(hdisplay)
+                if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
+                    PlotData=get(hdisplay(iview),'UserData');
+                    PlotData.IndexObj=iobj-1;
+                    set(hdisplay(iview),'UserData',PlotData);
+                end
+            end
+        end
+        UvData.Object(hObject)=[];  
+        list_str(hObject)=[];
+    end
+elseif ishandle(hObject)%object handle
+    userdata=get(hObject,'UserData');
+    if ishandle(userdata)%the selected line depends on a parent line
+        hdisplay=userdata;% the parent object becomes the current one
+    else
+        hdisplay=hObject;% the selected object becomes the current one
+    end
+    PlotData=get(hdisplay,'UserData');
+    if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
+            delete(PlotData.SubObject);
+    end
+    if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
+           delete(PlotData.DeformPoint);
+    end
+    delete(hdisplay);
+    if isfield(PlotData,'IndexObj')
+        IndexObj=PlotData.IndexObj;
+        if  isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj
+            if isfield(UvData,'Object')& length(UvData.Object) > IndexObj
+               UvData.Object(IndexObj)=[];
+            end
+            list_str(IndexObj)=[];
+        end
+    end
+end
+set(huvmat,'UserData',UvData);
+set(hlist_object,'String',list_str)
+set(hlist_object,'Value',length(list_str))
Index: /trunk/src/private/find_field_indices.m
===================================================================
--- /trunk/src/private/find_field_indices.m	(revision 8)
+++ /trunk/src/private/find_field_indices.m	(revision 8)
@@ -0,0 +1,181 @@
+%'find_file_indices': test field structure for input in proj_field and plot_field
+%group the variables  into 'fields' with common dimensions
+%----------------------------------------------------------------------
+% function [DimVarIndex,CellVarIndex,NbDim,VarType]=find_field_indices(Data)
+%
+%OUTPUT:
+% CellVaxIndex: cell whose elements are arrays of indices in the list data.ListVarName  
+%              CellvarIndex{i} represents a set of variables with the same dimensions
+% NbDim: array with the length of CellVarIndex, giving its  space dimension
+% VarType: cell array of structures with fields
+%      .coord_x, y, z: indices (in .ListVarname) of variables representing  unstructured coordinates x, y, z 
+%      .vector_x,_y,_z: indices of variables giving the vector components x, y, z
+%      .warnflag: index of warnflag
+%      .errorflag: index of error flag
+%      .ancillary: indices of ancillary variables
+%      .image   : B/W image, (behaves like scalar)
+%      .color : color image, the last index, which is not a coordinate variable, represent the 3 color components rgb
+%      .discrete: like scalar, but set of data points without continuity, represented as dots in a usual plot, instead of continuous lines otherwise
+%      .scalar: scalar field (default)
+
+%   
+%INPUT:
+% Data: structure representing fields, output of check_field_structure
+%            .ListDimName: cell listing the names of the array dimensions
+%            .ListVarName: cell listing the names of the variables
+%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
+%
+% HELP: 
+% to get the dimensions of arrays common to the field #icell
+%         VarIndex=CellVarIndex{icell}; % list of variable indices
+%         DimIndex=Data.VarDimIndex{VarIndex(1)} % list of dimensions for each variable in the cell #icell
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data)
+CellVarIndex={};
+NbDim=[];
+VarType=[];
+errormsg=[];
+nbvar=numel(Data.ListVarName);%number of field variables
+icell=0;
+ivardim=0;
+VarDimIndex=[];
+VarDimName={};
+
+if ~isfield(Data,'VarDimName')
+    errormsg='missing .VarDimName';
+    return
+end
+
+%loop on the list of variables
+for ivar=1:nbvar
+    DimCell=Data.VarDimName{ivar}; %dimensions associated with the variable #ivar
+    if ischar(DimCell)
+        DimCell={DimCell};
+        Data.VarDimName{ivar}={Data.VarDimName{ivar}};%transform char chain into cell
+    end
+    testnewcell=1;
+    for icell_prev=1:numel(CellVarIndex)%detect whether the dimensions of ivar fit with an existing cell
+        PrevVarIndex=CellVarIndex{icell_prev};
+        PrevDimName=Data.VarDimName{PrevVarIndex(1)};
+        if isequal(PrevDimName,DimCell)
+            CellVarIndex{icell_prev}=[CellVarIndex{icell_prev} ivar];% add variable index #ivar to the cell #icell_prev
+            testnewcell=0; %existing cell detected
+            break
+        end
+    end
+    if testnewcell
+        icell=icell+1;
+        CellVarIndex{icell}=ivar;%put the current variabl index in the new cell 
+    end
+    
+    %look for dimension variables
+    if numel(DimCell)==1% if the variable has a single dimension 
+        Role='';
+        if isfield(Data,'VarAttribute') && length(Data.VarAttribute)>=ivar && isfield(Data.VarAttribute{ivar},'Role')
+            Role=Data.VarAttribute{ivar}.Role;
+        end
+        if strcmp(DimCell{1},Data.ListVarName{ivar}) || strcmp(Role,'dimvar')
+            ivardim=ivardim+1;
+            VarDimIndex(ivardim)=ivar;%index of the variable
+            VarDimName{ivardim}=DimCell{1};%name of the dimension
+        end
+    end
+end
+
+% find the spatial dimensions and vector components 
+ListRole={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','warnflag','errorflag',...
+    'ancillary','image','color','discrete','scalar'};
+for icell=1:length(CellVarIndex)
+    for ilist=1:numel(ListRole)
+        eval(['ivar_' ListRole{ilist} '=[];'])
+    end
+    VarIndex=CellVarIndex{icell};%set of variable indices with the same dim 
+    DimCell=Data.VarDimName{VarIndex(1)};% list of dimensions for each variable in the cell #icell
+    if isfield(Data,'VarAttribute');
+        VarAttribute=Data.VarAttribute;
+    else
+        VarAttribute={};
+    end
+    test_2D=0;
+    for ivar=VarIndex
+        if length(VarAttribute)>=ivar
+            if isfield(VarAttribute{ivar},'Role') 
+                role=VarAttribute{ivar}.Role;
+                switch role
+                    case ListRole
+                        eval(['ivar_' role '=[ivar_' role ' ivar];']) 
+                    otherwise
+                       ivar_scalar=[ivar_scalar ivar];%variables are consiered as 'scalar' by default (in the absence of attribute 'Role')
+                end
+            else
+              ivar_scalar=[ivar_scalar ivar];% variable considered as scalar in the absence of Role attribute  
+            end
+            if isfield(VarAttribute{ivar},'Coord_2')
+                test_2D=1; %obsolete convention
+            end
+        else
+            ivar_scalar=[ivar_scalar ivar];%variables are consiered as 'scalar' by default (in the absence of attribute 'Role')
+        end
+    end
+    for ilist=1:numel(ListRole)
+        eval(['VarType{icell}.' ListRole{ilist} '=ivar_' ListRole{ilist} ';'])
+    end    
+    if numel(ivar_coord_x)>1 || numel(ivar_coord_y)>1 || numel(ivar_coord_z)>1
+        errormsg='multiply defined coordinates  in the same cell';
+        return
+    end
+    if numel(ivar_vector_x)>1 || numel(ivar_vector_y)>1 || numel(ivar_vector_z)>1
+        errormsg='multiply defined vector components in the same cell';
+        return
+    end  
+    if numel(ivar_errorflag)>1
+        errormsg='multiply defined error flag in the same cell';
+        return
+    end
+    if numel(ivar_warnflag)>1
+        errormsg='multiply defined warning flag in the same cell';
+        return
+    end
+    NbDim(icell)=0;% nbre of space dimensions 
+    if ~isempty(ivar_coord_z)
+        NbDim(icell)=3;
+    elseif ~isempty(ivar_coord_y)
+        NbDim(icell)=2;
+    elseif ~isempty(ivar_coord_x)
+        NbDim(icell)=1;
+    end
+           
+    % look at coordinates variables  
+    coord=zeros(1,numel(DimCell));%default
+    if NbDim(icell)==0 && ~isempty(VarDimName)% no unstructured coordinate found 
+        for idim=1:numel(DimCell)   %loop on the dimensions of the variables in cell #icell
+            for ivardim=1:numel(VarDimName)
+                if strcmp(VarDimName{ivardim},DimCell{idim})
+                    coord(idim)=VarDimIndex(ivardim);
+                    break
+                end
+            end
+        end
+        NbDim(icell)=numel(find(coord));  
+    end  
+    VarType{icell}.coord=coord; 
+    if NbDim(icell)==0 && test_2D %look at attributes Coord_1, coord_2 (obsolete convention)
+        NbDim(icell)=2;
+    end
+end
Index: /trunk/src/private/get_plot_handles.m
===================================================================
--- /trunk/src/private/get_plot_handles.m	(revision 8)
+++ /trunk/src/private/get_plot_handles.m	(revision 8)
@@ -0,0 +1,73 @@
+%'get_plot_handles': list the  handles of elements setting the plotting parameters in the uvmat interface
+%--------------------------------------------------------
+%function [PlotHandles]=get_plot_handles(handles)
+%
+% OUTPUT:
+% PlotHandles: structure containing the  used to set plotting parameters
+% INPUT:
+% handles: structure of the handles of the graphic elements in the uvmat interface
+%            -- TODO: needs to be replaced by a cell listing the element tags --
+
+function PlotHandles=get_plot_handles(handles)
+PlotHandles.auto_xy=handles.auto_xy;
+%For scalar field representation
+PlotHandles.MaxA=handles.MaxA;
+PlotHandles.MinA=handles.MinA;
+PlotHandles.AutoScal=handles.AutoScal;
+PlotHandles.BW=handles.BW;
+PlotHandles.Contours=handles.Contours;
+PlotHandles.IncrA=handles.IncrA;
+PlotHandles.SCALAR_title=handles.SCALAR_title;
+PlotHandles.min_title=handles.min_title;
+PlotHandles.max_title=handles.max_title;
+PlotHandles.frame_scal=handles.frame_scal;
+PlotHandles.npx=handles.npx;
+PlotHandles.npy=handles.npy;
+PlotHandles.npx_title=handles.npx_title;
+PlotHandles.npy_title=handles.npy_title;
+
+%For vector field representation
+PlotHandles.frame_vect=handles.frame_vect;
+PlotHandles.VECT_title=handles.VECT_title;
+PlotHandles.VecScale=handles.VecScale;
+PlotHandles.AutoVec=handles.AutoVec;
+PlotHandles.HideFalse=handles.HideFalse;
+PlotHandles.HideWarning=handles.HideWarning;
+PlotHandles.record=handles.record;
+PlotHandles.col_vec=handles.col_vec;
+PlotHandles.Color_title=handles.Color_title;
+PlotHandles.color_code=handles.color_code;
+PlotHandles.colcode1=handles.colcode1;
+PlotHandles.colcode2=handles.colcode2;
+PlotHandles.vec_col_bar=handles.vec_col_bar;
+PlotHandles.slider1=handles.slider1;
+PlotHandles.slider2=handles.slider2;
+PlotHandles.max_vec=handles.max_vec;
+PlotHandles.min_vec=handles.min_vec;
+PlotHandles.scale_title=handles.scale_title;
+PlotHandles.AutoVecColor=handles.AutoVecColor;
+PlotHandles.decimate4=handles.decimate4;
+PlotHandles.min_C_title=handles.min_C_title;
+PlotHandles.max_C_title=handles.max_C_title;
+PlotHandles.MenuVectors=handles.MenuVectors;
+PlotHandles.MenuEditVectors=handles.MenuEditVectors;
+PlotHandles.edit_vect=handles.edit_vect;
+%menu for the choice of the current plotting axes
+%PlotHandles.MenuAxes=handles.MenuAxes;
+
+%handles for move_mouse
+PlotHandles.mouse_coord=handles.mouse_coord;
+% PlotHandles.POINTS=handles.POINTS;
+% PlotHandles.LINE=handles.LINE;
+% PlotHandles.PLANE=handles.PLANE;
+% PlotHandles.PATCH=handles.PATCH;
+PlotHandles.cal=handles.cal;
+%PlotHandles.makemask=handles.makemask;
+PlotHandles.edit=handles.edit;
+PlotHandles.text_display_1=handles.text_display_1;
+PlotHandles.text_display_2=handles.text_display_2;
+PlotHandles.text_display_3=handles.text_display_3;
+PlotHandles.text_display_4=handles.text_display_4;
+
+%handles for mouse_up
+PlotHandles.zoom=handles.zoom;
Index: /trunk/src/private/hist_update.m
===================================================================
--- /trunk/src/private/hist_update.m	(revision 8)
+++ /trunk/src/private/hist_update.m	(revision 8)
@@ -0,0 +1,54 @@
+%'hist_update': update of a current global histogram by inclusion of a new field
+%------------------------------------------------------------------------
+%[val,HIST]=hist_update(val,HIST,C,dC)
+%
+% OUTPUT:
+% val: vector of field values at which the histogram is determined (middle of bins)
+% HIST(:,icolor): nbre of occurence of the field value in the bins whose middle is given by val
+%           can be a column vector, same size as val, or a matrix with three columns, for color images
+%
+% INPUT:
+% val: existing field values from the current histogram, =[] if there is no current histogram
+% HIST(:,icolor): current histogram,  =[] if there is none
+%       can be a column vector (icolor=1), same size as val, or a matrix with three columns, for color images      
+% C(:,icolor): vector representing the current field values
+%       can be a column vector (icolor=1), or a matrix with three columns, for color images 
+% dC: width of the new bins extending val to account for the new field.
+
+function [val,HIST]=hist_update(val,HIST,C,dC)
+
+valplus=[];valminus=[];
+HISTplus=[];HISTminus=[];
+if isempty(HIST)
+    HIST=0;
+end
+siz=size(C);nbfields=siz(2);
+C=double(C);
+valmin=min(val); 
+valmax=max(val);
+Cmin=min(min(C)); Cmax=max(max(C));
+if isempty(val)%no current histogram
+    val=[Cmin-dC/2:dC:Cmax+dC/2];
+else %extending the current histogram beyond its maximum value
+    if Cmax>=valmax+dC/2;
+        valplus=[valmax+dC:dC:Cmax+dC/2];% we extend the values val
+        HISTplus=zeros(length(valplus),nbfields);% we put histogram to zero at these values
+    end
+    %extending the current histogram below its minimum value
+    if Cmin<=valmin-dC/2;
+        valminus=[valmin-dC:-dC:Cmin-dC/2];% we extend the values val
+        valminus=sort(valminus);% we reverse the order
+        HISTminus=zeros(length(valminus),nbfields);% we put histogram to zero at these values
+    end
+    val=[valminus val valplus];
+end
+HIST=[HISTminus;HIST;HISTplus];
+if nbfields==1
+    histC=(hist(C,val))';% initiate the global histogram 
+elseif nbfields==3
+    HIST1=(hist(C(:,1),val))';
+    HIST2=(hist(C(:,2),val))';
+    HIST3=(hist(C(:,3),val))';
+    histC=[HIST1 HIST2 HIST3];
+end
+HIST=HIST+histC;
Index: /trunk/src/private/imadoc2struct.m
===================================================================
--- /trunk/src/private/imadoc2struct.m	(revision 8)
+++ /trunk/src/private/imadoc2struct.m	(revision 8)
@@ -0,0 +1,250 @@
+%'imadoc2struct': reads the xml file for image documentation 
+%
+%function [s,errormsg]=imadoc2struct(ImaDoc) 
+%--------------------------------------------------------
+% OUTPUT:
+% s: structure representing ImaDoc
+%   s.Heading: information about the data hierarchical structure
+%   s.Time: matrix of times
+%   s.TimeUnit
+%  s.GeometryCalib: substructure containing the parameters for geometric calibration
+% errormsg: error message
+%
+% INPUT:
+% ImaDoc: full name of the xml input file with head key ImaDoc
+%function [s,error,Heading,nom_type_ima,ext_ima,abs_time,TimeUnit,mode,NbSlice]=imadoc2struct(ImaDoc) 
+function [s,errormsg]=imadoc2struct(ImaDoc) 
+
+errormsg=[];%default
+s.Heading=[];%default
+s.Time=[]; %default
+s.TimeUnit=[]; %default
+s.GeometryCalib=[];
+nom_type_ima=[];%default
+ext_ima=[];%default
+% abs_time=[];%initiation
+% GeometryCalib.CoordUnit='cm';%default
+mode=[]; %default
+NbSlice=1;%default
+npx=[];%default
+npy=[];%default
+% GeometryCalib.Pxcmx=1;
+% GeometryCalib.Pxcmy=1;
+% GeometryCalib=[];
+NbDtj=1;
+tsai=[];%default
+% if ~exist('testime','var')
+%     testime=1;%default
+
+if exist(ImaDoc,'file')~=2, errormsg=[ ImaDoc ' does not exist']; return;end;%input file does not exist
+try
+    t=xmltree(ImaDoc);
+catch
+    errormsg={[ImaDoc ' is not a valid xml file']; lasterr};
+    display(errormsg);
+    return
+end
+
+uid_root=find(t,'/ImaDoc');
+if isempty(uid_root), errormsg=[ImaDoc ' is not an image documentation file ImaDoc']; return; end;%not an ImaDoc .xml file
+
+%Heading
+uid_Heading=find(t,'/ImaDoc/Heading');
+if ~isempty(uid_Heading), 
+    uid_Campaign=find(t,'/ImaDoc/Heading/Campaign');
+    uid_Exp=find(t,'/ImaDoc/Heading/Experiment');
+    uid_Device=find(t,'/ImaDoc/Heading/Device');
+    uid_Record=find(t,'/ImaDoc/Heading/Record');
+    uid_FirstImage=find(t,'/ImaDoc/Heading/ImageName');
+    s.Heading.Campaign=get(t,children(t,uid_Campaign),'value');
+    s.Heading.Experiment=get(t,children(t,uid_Exp),'value');
+    s.Heading.Device=get(t,children(t,uid_Device),'value');
+    if ~isempty(uid_Record)
+        s.Heading.Record=get(t,children(t,uid_Record),'value');
+    end
+    s.Heading.ImageName=get(t,children(t,uid_FirstImage),'value');
+    FirstImage=s.Heading.ImageName;
+    if ~isempty(FirstImage)
+        [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type_ima]=name2display(FirstImage);
+    end
+end
+
+%Camera   
+uid_Camera=find(t,'/ImaDoc/Camera');
+if ~isempty(uid_Camera)
+    uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');
+    if ~isempty(uid_ImageSize);
+        ImageSize=get(t,children(t,uid_ImageSize),'value');
+        xindex=findstr(ImageSize,'x');
+        if length(xindex)>=2
+            npx=str2num(ImageSize(1:xindex(1)-1));
+            npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1));
+        end
+    end
+    uid_NbSlice=find(t,'/ImaDoc/Camera/NbSlice');
+    if ~isempty(uid_NbSlice)
+        NbSlice=str2num(get(t,children(t,uid_NbSlice),'value'));
+        if isempty(NbSlice),NbSlice=1;end; %default
+    end
+    uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');
+    if ~isempty(uid_TimeUnit)
+        s.TimeUnit=get(t,children(t,uid_TimeUnit),'value');
+    end
+    uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');
+    if ~isempty(uid_BurstTiming)
+        for k=1:length(uid_BurstTiming)
+            Dtj=[];%default
+            NbDtj=1;%default
+            subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming
+             % reading Dtk
+            Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1);
+            Dtj=get_value(subt,'/BurstTiming/Dtj',[]);
+            Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
+            NbDtj=get_value(subt,'/BurstTiming/NbDtj',1);
+            Dti=get_value(subt,'/BurstTiming/Dti',[]);
+            Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
+            NbDti=get_value(subt,'/BurstTiming/NbDti',1);
+            Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit
+            if ~isempty(Dti) 
+                Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times
+                Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals  Dti
+            end
+            if ~isempty(Dtj)
+                Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dti vector NbDti times
+                Dtj=[0 Dtj];
+%                 Time_val'
+%                 ones(1,numel(Dtj))
+%                 ones(numel(Time_val'),1)
+%                 cumsum(Dtj)
+                Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj
+            end
+            % reading Dtk
+            Dtk=get_value(subt,'/BurstTiming/Dtk',[]);
+            NbDtk=get_value(subt,'/BurstTiming/NbDtk',1)
+            if isempty(Dtk)
+                s.Time=[s.Time;Time_val];
+            else
+                for kblock=1:NbDtk+1
+                    Time_val=Time_val+(kblock-1)*Dtk;
+                    s.Time=[s.Time;Time_val];
+                end
+            end
+        end
+    end
+    if size(s.Time,1)==1
+        s.Time=(s.Time)'; %change vector into column
+    end
+end
+
+%read calibration
+uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');
+if ~isempty(uid_GeometryCalib)
+    if length(uid_GeometryCalib)>1
+        error=['More than one GeometryCalib in ' filecivxml];
+        return
+    end
+    subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib
+    cont=get(subt,1,'contents');
+    if ~isempty(cont)
+        uid_pixcmx=find(subt,'/GeometryCalib/Pxcmx');
+        uid_pixcmy=find(subt,'/GeometryCalib/Pxcmy');
+        if ~isempty(uid_pixcmx) & ~isempty(uid_pixcmy)%NON UTILISE 
+           pixcmx=str2num(get(subt,children(subt,uid_pixcmx),'value'));
+            if isempty(pixcmx),pixcmx=1;end; %default
+            pixcmy=str2num(get(subt,children(subt,uid_pixcmy),'value'));
+            if isempty(pixcmy),pixcmy=1;end; %default
+            tsai.Pxcmx=pixcmx;
+            tsai.Pxcmy=pixcmy;
+        end
+        %default values:
+        tsai.f=1;
+        tsai.dpx=1;
+        tsai.dpy=1;
+        tsai.sx=1;
+        tsai.Cx=0;
+        tsai.Cy=0;
+        tsai.Tz=1;
+        tsai.Tx=0;
+        tsai.Ty=0;
+        tsai.R=[1 0 0; 0 1 0; 0 0 0];
+        tsai.kappa1=0;
+        uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');
+        if ~isempty(uid_CoordUnit) 
+            tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');
+        end
+        uid_focal=find(subt,'/GeometryCalib/focal');
+        uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');
+        uid_sx=find(subt,'/GeometryCalib/sx');
+        uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');
+        uid_kappa1=find(subt,'/GeometryCalib/kappa1');
+        uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');
+        uid_R=find(subt,'/GeometryCalib/R');
+        if ~isempty(uid_focal) & ~isempty(uid_dpx_dpy) & ~isempty(uid_Cx_Cy)
+            tsai.f=str2num(get(subt,children(subt,uid_focal),'value'));
+            dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));
+            tsai.dpx=dpx_dpy(1);
+            tsai.dpy=dpx_dpy(2);
+            if ~isempty(uid_sx)
+               tsai.sx=str2num(get(subt,children(subt,uid_sx),'value')); 
+            end
+            Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));
+            tsai.Cx=Cx_Cy(1);
+            tsai.Cy=Cx_Cy(2);
+        end
+        if ~isempty(uid_Tx_Ty_Tz) 
+            Tx_Ty_T_char=get(subt,children(subt,uid_Tx_Ty_Tz),'value');
+            Tx_Ty_Tz=str2num(Tx_Ty_T_char);
+            tsai.Tx=Tx_Ty_Tz(1);
+            tsai.Ty=Tx_Ty_Tz(2);
+            tsai.Tz=Tx_Ty_Tz(3);
+        end
+        if ~isempty(uid_R)
+            RR=get(subt,children(subt,uid_R),'value');
+            if length(RR)==3
+                tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];
+            end
+        end
+        if ~isempty(uid_kappa1)     
+            tsai.kappa1=str2num(get(subt,children(subt,uid_kappa1),'value'));
+        end
+        %look for laser plane definitions   
+        uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');
+        uid_Pos=find(subt,'/GeometryCalib/PlanePos');
+        if ~isempty(uid_Angle) 
+            tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));
+        end
+        if ~isempty(uid_Pos)
+            for j=1:length(uid_Pos)
+                tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));
+            end
+        end
+        s.GeometryCalib=tsai;
+    end
+end   
+
+%--------------------------------------------------
+%  read an xml element
+function val=get_value(t,label,default)
+%--------------------------------------------------
+val=default;
+uid=find(t,label);%find the element iud(s)
+if ~isempty(uid)
+   uid_child=children(t,uid);
+   if ~isempty(uid_child)
+       data=get(t,uid_child,'type');
+       if iscell(data)
+           for icell=1:numel(data)
+               val_read=str2num(get(t,uid_child(icell),'value'));
+               if ~isempty(val_read)
+                   val(icell)=val_read;
+               end
+           end
+           val=val';
+       else
+           val_read=str2num(get(t,uid_child,'value'));
+           if ~isempty(val_read)
+               val=val_read;
+           end
+       end
+   end
+end
Index: /trunk/src/private/interp2_uvmat.m
===================================================================
--- /trunk/src/private/interp2_uvmat.m	(revision 8)
+++ /trunk/src/private/interp2_uvmat.m	(revision 8)
@@ -0,0 +1,25 @@
+% A matrix (npy,npx) to interpolate
+%XIMA: matrix of non-integer x index values (npY,npX)
+%YIMA: matrix of non-integer y index values (npY,npX), (with the same size as XIMA)
+function A_out=interp2_uvmat(A,XIMA,YIMA)
+npx=size(A,2);
+npy=size(A,1);
+npX=size(XIMA,2);
+npY=size(XIMA,1)
+XIMA=reshape(XIMA,1,npX*npY)+0.5;%indices corresponding to XIMA, reshaped in a matlab vector
+YIMA=reshape(YIMA,1,npX*npY)+0.5;%indices corresponding to XIMA, reshaped in a matlab vector
+X_delta=XIMA-floor(XIMA);%distance to the closest integer value
+XIMA=floor(XIMA);%integer x index on the image
+Y_delta=YIMA-floor(YIMA);%distance to the closest integer value
+YIMA=floor(YIMA);%integer x index on the image        
+flagin=(XIMA>=1 & XIMA<=npx-1 & YIMA >=1 & YIMA<=npy-1);%flagin=1 inside the original image
+ind_in=find(flagin);%list of indices of XIndex for valid values of image indices (inside the original image) 
+ind_out=find(~flagin);      
+vec_A=double(reshape(A(:,:,1),1,npx*npy));%reshape the original image as a Matlab image vector
+ICOMB=((XIMA-1)*npy+(npy+1-YIMA));%determine the indices in the image Matlab vector corresponding to XIMA and YIMA
+ICOMB=ICOMB(flagin);%selection of the valid indices
+X_delta=X_delta(ind_in);
+Y_delta=Y_delta(ind_in);
+A_out(ind_in)=(1-Y_delta).*(1-X_delta).*vec_A(ICOMB)+Y_delta.*(1-X_delta).*vec_A(ICOMB-1)+X_delta.*(1-Y_delta).*vec_A(ICOMB+npy)+X_delta.*Y_delta.*vec_A(ICOMB+npy-1);
+A_out(ind_out)=zeros(size(ind_out));
+A_out=reshape(A_out,npY,npX);%interpolated image 
Index: /trunk/src/private/keyboard_callback.m
===================================================================
--- /trunk/src/private/keyboard_callback.m	(revision 8)
+++ /trunk/src/private/keyboard_callback.m	(revision 8)
@@ -0,0 +1,51 @@
+%'keyboard_callback:' function activated when a key is pressed on the keyboard
+%-----------------------------------
+function keyboard_callback(hObject,eventdata,handleshaxes)
+xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
+cur_axes=get(gcbf,'CurrentAxes');
+if ~isempty(cur_axes)
+    xlimit=get(cur_axes,'XLim');
+    ylimit=get(cur_axes,'Ylim');
+    dx=(xlimit(2)-xlimit(1))/10;
+    dy=(ylimit(2)-ylimit(1))/10;
+   
+    if isequal(xx,29)%move arrow right
+        xlimit=xlimit+dx;
+    elseif isequal(xx,28)%move arrow left
+        xlimit=xlimit-dx;
+    elseif isequal(xx,30)%move arrow up
+        ylimit=ylimit+dy;
+    elseif isequal(xx,31)%move arrow down
+        ylimit=ylimit-dy;
+    end
+    set(cur_axes,'XLim',xlimit)
+    set(cur_axes,'YLim',ylimit)
+end
+if ismember(xx,[8 127]) %if the delete or suppr key is pressed, delete the current object 
+    currentobject=gco;
+    huvmat=findobj(allchild(0),'Name','uvmat');
+%     UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
+    hlist_object=findobj(huvmat,'Tag','list_object');
+    ObjIndex=get(hlist_object,'Value');
+    if ObjIndex>1
+        delete_object(ObjIndex)
+    end
+    if ishandle(currentobject)
+        tag=get(currentobject,'Tag');%tag of the current selected object
+        if isequal(tag,'proj_object')
+            delete_object(currentobject)
+        end
+    end
+elseif isequal(xx,112)%  key 'p'
+    uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
+elseif isequal(xx,109)%  key 'm'
+    uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
+end
+
+AxeData=get(cur_axes,'UserData');
+if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
+    hparentrect=AxeData.ParentRect;
+    rect([1 2])=[xlimit(1) ylimit(1)];
+    rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
+    set(hparentrect,'Position',rect)
+end
Index: /trunk/src/private/mouse_down.m
===================================================================
--- /trunk/src/private/mouse_down.m	(revision 8)
+++ /trunk/src/private/mouse_down.m	(revision 8)
@@ -0,0 +1,343 @@
+%'mouse_down': function activated when the mouse button is pressed on a figure (callback for 'WindowButtonDownFcn'
+%-------------------------------------------------------------- 
+% xy=mouse_down(hObject,eventdata) 
+% activated by the command:
+% set(hObject,'WindowButtonDownFcn',{'mouse_down'}), 
+% where hObject is the handle of the figure
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function xy=mouse_down(hObject,eventdata)
+testzoom=0;%default
+MouseAction='none'; %default
+huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle which controls theoption of  mouse action
+if ~isempty(huvmat)
+    hhuvmat=guidata(huvmat);%handles of elements in uvmat
+    UvData=get(huvmat,'UserData');
+    testzoom=get(hhuvmat.zoom,'Value');% get the mouse action from the uvmat GUI: options:
+    if isfield(UvData,'MouseAction')
+        MouseAction=UvData.MouseAction;% get the mouse action from the uvmat GUI: options:
+    end
+end
+test_create=~testzoom && (isequal(MouseAction,'create_object') || isequal(MouseAction,'create_mask'));
+%test_cal=get(handles.cal,'Value');
+test_cal=isequal(MouseAction,'calib');
+handles_coord=findobj(huvmat,'Tag','menu_coord');
+menu_coord=get(handles_coord,'String');
+coord_choice=get(handles_coord,'Value');
+coord_type=menu_coord{coord_choice};
+test_edit=isequal(MouseAction,'edit_object');
+test_edit_vect=isequal(MouseAction,'edit_vect');
+xdisplay=[];%default
+ydisplay=[];%default
+haxes=[];
+AxeData=[];%default
+
+%edit an existing point or line if found
+hcurrentobject=gco;% current object handle (selected by the mouse)
+hcurrentfig=gcbo;% current figure handle
+tag_obj=get(gco,'Tag');
+xy=[];%default
+xy_fig=get(hcurrentfig,'CurrentPoint');% current point of the current figure (gcbo)
+hchild=get(hcurrentfig,'Children');%handles of all objects in the current figure
+% loop on all the objects in the current figure (selected by the last mouse click) 
+for ichild=1:length(hchild)
+    obj_pos=get(hchild(ichild),'Position');%position of the object
+    if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4);
+        htype=get(hchild(ichild),'Type');%type of object child of the current figure
+        %if the mouse is over an axis, look at the data
+        if isequal(htype,'axes')
+            haxes=hchild(ichild);
+            xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+            AxeData=get(haxes,'UserData');% data attached to the axis
+            AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
+            if ~isequal(tag_obj,'proj_object') & ~test_create
+                x_mouse=xy(1,1);%default
+                y_mouse=xy(1,2);%default
+                u_mouse=[];
+                v_mouse=[];
+                w_mouse=[];
+                A_mouse=[];
+                c_text=[];
+                f_text=[];
+                ff_text=[];     
+                ivec=[];   
+                if isfield(AxeData,'X') & isfield(AxeData,'Y') & isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
+                    flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/4) & AxeData.X>(xy(1,1)-AxeData.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
+                      (AxeData.Y<(xy(1,2)+AxeData.Mesh/4) & AxeData.Y>(xy(1,2)-AxeData.Mesh/4));%f
+                    ivec=find(flag_vec);% search the selected vector index ivec
+                    if length(ivec)>0
+                        ivec=ivec(1);%choice the first selected vector if several are selected                        
+                    end
+                end
+            end
+        elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
+           %FAIRE UNE OPTION D'AIDE AVEC BOUTON SOURIS DROIT (ALT)??
+        end
+    end
+end
+test2D=0;
+if isfield(AxeData,'NbDim')
+    if isequal(AxeData.NbDim,2)
+        test2D=1;
+    end
+end
+if ~test2D     %desable  object creation and vector editing if NbDim different from 2
+    test_create=0;
+    test_edit_vect=0;
+end
+%delete the current zoom rectangle
+if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)
+    delete(AxeData.CurrentRectZoom)
+    AxeData.CurrentRectZoom=[];
+end    
+
+if testzoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var')
+     AxeData.Drawing='zoom'; %initiate drawing mode
+     AxeData.CurrentObject=[];%unselect objects
+elseif ~isempty(huvmat)
+    %selection of an existing projection object
+    if  test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))
+        if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
+            userdata=get(hcurrentobject,'UserData');
+            if ishandle(userdata)%the selected line depends on a parent line
+                AxeData.CurrentObject=userdata;% the parent object becomes the current one
+            else
+                AxeData.CurrentObject=hcurrentobject;% the selected object becomes the current one
+            end
+            ObjectData=get(AxeData.CurrentObject,'UserData');
+            if test_edit & isfield(ObjectData,'IndexObj')
+                hother=findobj('Tag','proj_object','Type','line');%find all the proj objects
+                set(hother,'Color','b');%reset all the proj objects in 'blue' by default
+                set(hother,'Selected','off')
+                hother=findobj('Tag','proj_object','Type','rectangle');
+                set(hother,'EdgeColor','b');
+                set(hother,'Selected','off');
+                hother=findobj('Tag','proj_object','Type','image');
+                for iobj=1:length(hother)
+                       Acolor=get(hother(iobj),'CData');
+                       Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
+                       set(hother(iobj),'CData',Acolor);
+                end
+                hother=findobj('Tag','DeformPoint');
+                set(hother,'Color','b');
+                set(hother,'Selected','off')    
+                if isequal(get(AxeData.CurrentObject,'Type'),'line')
+                    set(AxeData.CurrentObject,'Color','m'); %set the selected object to magenta color
+                elseif isequal(get(AxeData.CurrentObject,'Type'),'rectangle')
+                     set(AxeData.CurrentObject,'EdgeColor','m'); %set the selected object to magenta color
+                end
+                if isfield(ObjectData,'SubObject')& ishandle(ObjectData.SubObject)
+                    for iobj=1:length(ObjectData.SubObject)
+                        hsub=ObjectData.SubObject(iobj);
+                        if isequal(get(hsub,'Type'),'rectangle')
+                            set(hsub,'EdgeColor','m'); %set the selected object to magenta color
+                        elseif isequal(get(hsub,'Type'),'image')
+                           Acolor=get(hsub,'CData');
+                           Acolor(:,:,1)=Acolor(:,:,3);
+                           set(hsub,'CData',Acolor);
+                        else
+                            set(hsub,'Color','m')
+                        end
+                    end
+                end
+                if isequal(tag_obj,'DeformPoint')
+                     set(hcurrentobject,'Color','m'); %set the selected DeformPoint to magenta color
+                end
+                IndexObj=ObjectData.IndexObj;
+                hlist_object=findobj(huvmat,'Tag','list_object');
+                set(hlist_object,'Value',IndexObj);
+                testdeform=0;
+                set(gcbo,'Pointer','circle'); 
+                AxeData.Drawing='deform';
+                if isequal(tag_obj,'DeformPoint')       
+                   if isfield(ObjectData,'DeformPoint')
+                       set(hcurrentobject,'Selected','on')
+                       for ipt=1:length(ObjectData.DeformPoint)
+                           if isequal(ObjectData.DeformPoint(ipt),hcurrentobject)
+                                AxeData.CurrentIndex=ipt;
+                                testdeform=1;
+                           end
+                       end
+                   end
+                end
+                if testdeform==0
+                    AxeData.Drawing='translate';
+                    set(AxeData.CurrentObject,'Selected','on')
+                    set(gcbo,'Pointer','fleur');
+                end
+            end
+        end
+    end
+    %  create new projection  object
+    if  test_create && ~isempty(xy) && ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
+            ObjectData=read_set_object(UvData.sethandles); 
+            ObjectData.Coord=[]; %reset previous object coordinates
+            ObjectData.Coord(1,1)=xy(1,1);
+            ObjectData.Coord(1,2)=xy(1,2);
+            ObjectData.Coord(1,3)=0;
+            if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
+                 ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
+            end
+            AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject
+            if isfield(UvData,'Object')
+                IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface
+            else
+                IndexObj=2;
+            end  
+            UvData.Object{IndexObj}=ObjectData;
+            UvData.Object{IndexObj}.HandlesDisplay(1)=AxeData.CurrentObject;
+            set(huvmat,'UserData',UvData)
+            list_str=get(hhuvmat.list_object,'String');
+            list_str{IndexObj}=[num2str(IndexObj) '-' set_title(ObjectData.Style,ObjectData.ProjMode)];
+            if ~isequal(list_str{end},'...')
+                 list_str{end+1}='...';
+            end
+            set(hhuvmat.list_object,'String',list_str)
+            set(hhuvmat.list_object,'Value',IndexObj)
+            PlotData=get(AxeData.CurrentObject,'UserData');
+            PlotData.IndexObj=IndexObj;
+            set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph
+            AxeData.Drawing='create';
+    end
+
+    % create calibration points if the GUI geometry_calib is opened
+    if test_cal & ~isempty(xy)
+        h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
+        hh_geometry_calib=guidata(h_geometry_calib);
+        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
+        h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
+        if isequal(get(h_edit_append,'Value'),1) 
+            if ~isequal(coord_type,'')
+                set(handles_coord,'Value',1)
+                coord_type='';
+                set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off'
+                set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
+                uvmat('run0_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
+            end
+%             if isequal(coord_type,'px')|isequal(coord_type,'');%px cordinates
+                strline=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
+%             else %phys cordinates
+%                 strline=[ num2str(xy(1,1),4) '    |    '  num2str(xy(1,2),4) '    |    0      |    '  '    |    ' ];
+%             end
+            Coord=get(h_ListCoord,'String');
+            val=get(h_ListCoord,'Value');
+            if isequal(Coord,{''})
+                val=0;
+            end
+            if length(Coord)>val
+                Coord(val+2:length(Coord)+1)=Coord(val+1:length(Coord));% push the list forward beyond the current point
+            end
+            Coord{val+1}=strline;
+            set(h_ListCoord,'String',Coord)
+            set(h_ListCoord,'Value',val+1)
+            geometry_calib('ListCoord_Callback',hObject,eventdata,hh_geometry_calib)
+            data=read_geometry_calib(Coord);
+            if isequal(coord_type,'px')|isequal(coord_type,'');%px cordinates
+                XCoord=data.Coord(:,4);
+                YCoord=data.Coord(:,5);
+            else %phys cordinates
+                XCoord=data.Coord(:,1);
+                YCoord=data.Coord(:,2);
+            end
+            hh=findobj('Tag','calib_points')           
+            if isempty(hh)
+                line(XCoord,YCoord,'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
+            else
+                set(hh,'XData',XCoord)
+                set(hh,'YData',YCoord)
+            end
+            hhh=findobj('Tag','calib_marker');
+            if ~isempty(hhh)
+                set(hhh,'XData',xy(1,1))
+                set(hhh,'YData',xy(1,2))
+            else
+                line(xy(1,1),xy(1,2),'Color','m','Tag','calib_marker','LineStyle','.','Marker','o','MarkerSize',20);
+            end
+            %uistack(h_geometry_calib,'top')
+        end
+    end
+
+    % edit vectors
+    if test_edit_vect & ~isempty(ivec) 
+    %     FF_100=FF-100*double(uint(abs(FF)/100); %value of FF without units and dizaines
+        if ~isfield(AxeData,'FF')
+            AxeData.FF=zeros(size(AxeData.X));
+        end
+        if isequal(AxeData.FF(ivec),0)
+
+            AxeData.FF(ivec)=100; %mark vector #ivec as false
+
+        else
+            AxeData.FF(ivec)=0;
+        end
+        set(haxes,'UserData',AxeData)
+        update_plot
+    end   
+end
+set(haxes,'UserData',AxeData);
+
+%------------------------------------------------------
+function update_plot
+%--------------------------------------------
+huvmat=gcbf;
+UvData=get(gcbf,'UserData');
+%determine the axes of action of the set_edit interface
+% list_axes=get(handles.MenuAxes,'String');% list menu fields
+% index_axes=get(handles.MenuAxes,'Value');% selected string index
+% current_axes= list_axes{index_axes(1)} % selected string
+% eval(['haxes=UvData.' current_axes '.Axes']);
+% if isempty(haxes)|~ishandle(haxes)| ~isequal(get(haxes,'Type'),'axes')
+     haxes= findobj(huvmat,'Tag','axes3'); %main plotting axes as default
+%      set(handles.MenuAxes,'Value',1)
+% end
+AxeData=get(haxes,'UserData');
+%For vector field representation
+%NEW
+PlotHandles.VecScale=findobj(huvmat,'Tag','VecScale');
+PlotHandles.AutoVec=findobj(huvmat,'Tag','AutoVec');
+PlotHandles.checkyellow=findobj(huvmat,'Tag','checkyellow');
+PlotHandles.checkblack=findobj(huvmat,'Tag','checkblack');
+PlotHandles.col_vec=findobj(huvmat,'Tag','col_vec');
+PlotHandles.colcode1=findobj(huvmat,'Tag','colcode1');
+PlotHandles.colcode2=findobj(huvmat,'Tag','colcode2');
+PlotHandles.vec_col_bar=findobj(huvmat,'Tag','vec_col_bar');
+PlotHandles.slider1=findobj(huvmat,'Tag','slider1');
+PlotHandles.slider2=findobj(huvmat,'Tag','slider2');
+PlotHandles.max_vec=findobj(huvmat,'Tag','max_vec');
+PlotHandles.min_vec=findobj(huvmat,'Tag','min_vec');
+PlotHandles.AutoVecColor=findobj(huvmat,'Tag','AutoVecColor');
+PlotHandles.decimate4=findobj(huvmat,'Tag','decimate4');
+
+%vectors
+Vectors.VecScale=str2num(get(PlotHandles.VecScale,'String'));
+Vectors.AutoVec=get(PlotHandles.AutoVec,'Value');%automatic vector length
+Vectors.checkyellow=get(PlotHandles.checkyellow,'Value');
+Vectors.checkblack=get(PlotHandles.checkblack,'Value');
+Vectors.decimate4=get(PlotHandles.decimate4,'Value');% =1; for reducing the nbre of vectors
+menu_col=get(PlotHandles.col_vec,'String');
+menu_val=get(PlotHandles.col_vec,'Value');
+Vectors.CName=menu_col{menu_val}; %'ima_cor','black','white',...
+Vectors.colcode1=str2num(get(PlotHandles.colcode1,'String'));% first threshold for rgb, first value for'continuous' 
+Vectors.colcode2=str2num(get(PlotHandles.colcode2,'String'));% second threshold for rgb, last value (saturation) for 'continuous' 
+Vectors.option=get(PlotHandles.vec_col_bar,'Value'); % =1 (64 colors), =0 (3 colors)
+Vectors.min=get(PlotHandles.slider1,'Min');
+Vectors.max=get(PlotHandles.slider1,'Max');
+Vectors.auto=get(PlotHandles.AutoVecColor,'Value');% =1; thresholds scaling relative to min and max, =0 fixed thresholds
+PlotParam.Vectors=Vectors;
+
+[PlotType,ScalOut]= plot_field(AxeData,haxes,PlotParam,1);
Index: /trunk/src/private/mouse_motion.m
===================================================================
--- /trunk/src/private/mouse_motion.m	(revision 8)
+++ /trunk/src/private/mouse_motion.m	(revision 8)
@@ -0,0 +1,289 @@
+%'mouse_motion': permanently called by mouse motion over a figure (Callback for 'WindowButtonMotionFcn' of the figure)
+%-----------------------------------------------------------------------
+%
+% function mouse_motion(hObject,eventdata,handles)
+% activated by the command:
+% set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})
+% where hObject is the handle of the figure
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function mouse_motion(hObject,eventdata,handles)
+if ~exist('handles','var')
+    return
+end
+if ~isfield(handles, 'mouse_coord')
+    return
+end
+if ~ishandle(handles.mouse_coord)
+    return
+end
+proj_coord=get(handles.mouse_coord,'String');
+choice=get(handles.mouse_coord,'Value');
+if ~isempty(proj_coord); proj_coord=proj_coord{choice};else;proj_coord=[];end;
+test_create=0;%default
+test_edit=0;%default
+if isfield(handles,'VOLUME') % mouse_motion not applied to the uvmat figure, no object creation
+    test_create=get(handles.create,'Value');   
+end
+test_edit=isfield(handles,'edit') & get(handles.edit,'Value');% edit test for mouse shap: an arrow
+test_zoom=isfield(handles,'zoom')& get(handles.zoom,'Value');% edit test for mouse shap: an arrow 
+
+%find the current axe 'haxes' and display the current mouse position or uicontrol tag
+text_displ_1='';
+text_displ_2='';
+text_displ_3='';
+text_displ_4='';
+
+haxes=[];
+AxeData=[];%default
+mouse=[];
+
+pointershape='arrow';% default pointer is an arrow 
+
+xy_fig=get(gcbo,'CurrentPoint');% current point of the current figure (gcbo)
+hchild=get(gcbo,'Children');%handles of all objects in the current figure
+currentfig=gcbo;%store gcbo as variable currentfig
+% loop on all the objects in the current figure (selected by the last mouse click) 
+for ichild=1:length(hchild)
+    obj_pos=get(hchild(ichild),'Position');%position of the object
+    if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4);
+        htype=get(hchild(ichild),'Type');%type of the crrent child
+        %if the mouse is over an axis, look at the data
+        if isequal(htype,'axes')
+            haxes=hchild(ichild);
+            xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+            mouse.X=xy(1,1);
+            mouse.Y=xy(1,2);
+            u_mouse=[];
+            v_mouse=[];
+            w_mouse=[];
+            A_mouse=[];
+            c_text=[];
+            f_text=[];
+            ff_text=[];     
+            ivec=[];
+            AxeData=get(haxes,'UserData');% data attached to the axis
+             if ~test_edit && ~test_zoom
+                 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
+%                % pointershape='crosshair';%set pointer with cross shape (default over axis)
+             end
+            if isfield(AxeData,'X') && isfield(AxeData,'Y') && isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
+                if ~isempty(AxeData.Mesh)
+                    flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/3) & AxeData.X>(xy(1,1)-AxeData.Mesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse
+                          (AxeData.Y<(xy(1,2)+AxeData.Mesh/3) & AxeData.Y>(xy(1,2)-AxeData.Mesh/3));%f
+                    ivec=find(flag_vec);% search the selected vector index ivec
+                    if length(ivec)>0 
+                        if ~test_create
+                            pointershape='arrow'; %mouse indicates  the detection of a vector
+                        end
+                        ivec=ivec(1);%choice the first selected vector if several are selected
+                        mouse.X=AxeData.X(ivec);
+                        mouse.Y=AxeData.Y(ivec);
+                        u_mouse=AxeData.U(ivec);%displacement
+                        v_mouse=AxeData.V(ivec);
+                        w_mouse=0; %default
+                        if isfield(AxeData,'W')&length(AxeData.W)>=ivec
+                            w_text=[',  w=' num2str(AxeData.W(ivec),3)];
+                        else
+                            w_text='';
+                        end
+                        if ~isfield(AxeData,'CName')
+                            AxeData.CName='C';%REVOIR
+                        end
+                        c_text=[', ' AxeData.CName '=' num2str(AxeData.C(ivec),3)];
+                        if isfield(AxeData,'F')&length(AxeData.F)>=ivec
+                            f_text=[',  f=' num2str(AxeData.F(ivec),3)];
+                        else
+                            f_text='';
+                        end
+                        if isfield(AxeData,'FF')&length(AxeData.FF)>=ivec
+                            ff_text=[',  ff=' num2str(AxeData.FF(ivec),3)];
+                        else
+                            ff_text='';
+                        end
+                    end
+                end
+            end
+            if isfield(AxeData,'Z')
+                mouse.Z=AxeData.Z; %generaliser au cas avec angle
+            end
+            if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
+                mouse.Z=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
+            end
+            testscal= isfield(AxeData,'A')& isfield(AxeData,'AX')& isfield(AxeData,'AY');%test the existence of an image (or scalar represented by an image)
+               if testscal
+                   testscal=~isempty(AxeData.A)&~isempty(AxeData.AX)& ~isempty(AxeData.AY);
+               end
+            if testscal%test the existence of an image (or scalar represented by an image)
+                nxy=size(AxeData.A);
+                MaxAY=max(AxeData.AY(1),AxeData.AY(end));
+                MinAY=min(AxeData.AY(1),AxeData.AY(end));
+                if (xy(1,1)>AxeData.AX(1))&(xy(1,1)<AxeData.AX(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY)
+                    indx0=1+round((nxy(2)-1)*(xy(1,1)-AxeData.AX(1))/(AxeData.AX(end)-AxeData.AX(1)));% index x of pixel
+                    indy0=1+round((nxy(1)-1)*(xy(1,2)-AxeData.AY(1))/(AxeData.AY(end)-AxeData.AY(1)));% index y of pixel
+                    if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1)
+                        A_mouse=AxeData.A(indy0,indx0,:);
+                    end
+                end
+            end
+            %coordinate transform if proj_coord differs from menu_coord 
+            if isfield(AxeData,'CoordType')
+                  mouse.CoordType=AxeData.CoordType;
+            end
+            if isfield(AxeData,'CoordUnit')
+                  mouse.CoordUnit=AxeData.CoordUnit;
+            end
+            if isfield(mouse,'CoordType') &~isequal(mouse.CoordType,proj_coord)
+                huvmat=findobj(allchild(0),'Tag','uvmat');%find the uvmat interface handle
+                UvData=get(huvmat,'UserData'); %coord transformed stored in the uvmat interface, updated by file input
+                if isfield(AxeData,'CoordType')
+                    mouse.CoordType=AxeData.CoordType;
+                end
+                if isfield(AxeData,'dt')
+                    mouse.dt=AxeData.dt;
+                end
+%                 if ~isempty(z_mouse)
+%                     mouse.Z=z_mouse;
+%                 end
+                if length(ivec)>0 %& isfield(AxeData,'dt')                    
+                      mouse.U=u_mouse; 
+                      mouse.V=v_mouse;
+                end
+                mouse=feval(proj_coord,mouse,UvData);%apply transform proj_coord to the position
+                if length(ivec)>0%& isfield(AxeData,'dt')
+                     u_mouse=mouse.U;
+                     v_mouse=mouse.V;
+                end
+            end  
+            if isfield(mouse,'CoordType') 
+                if isequal(mouse.CoordType,'px')
+                    mouse.CoordUnit='px';
+                end
+            else
+                mouse.CoordUnit='';%default      
+            end      
+            text_displ_1=['x=' num2str(mouse.X,4) ',y=' num2str(mouse.Y,4)];
+            if isfield(mouse,'Z')&~isempty(mouse.Z)
+                text_displ_1=[text_displ_1 ',z=' num2str(mouse.Z,3)];
+            end
+            if isfield(mouse,'CoordUnit')
+                 text_displ_1=[text_displ_1 ' ' mouse.CoordUnit];
+            end
+            if ~isempty(ivec)
+                text_displ_4=['vec#=' num2str(ivec)];
+            end
+            if ~isempty(u_mouse)
+                text_displ_3=['u=' num2str(u_mouse,3) ',v=' num2str(v_mouse,3) w_text ];
+                if  isfield(mouse,'CoordUnit')
+                    if isequal(mouse.CoordUnit,'px')
+                        text_displ_3=[text_displ_3 '  ' mouse.CoordUnit];
+                    elseif isfield(AxeData,'TimeUnit') 
+                        text_displ_3=[text_displ_3 '  ' mouse.CoordUnit '/' AxeData.TimeUnit];
+                    end
+                end
+                text_displ_4=[text_displ_4 c_text f_text ff_text];
+            end
+           
+            if ~isempty(A_mouse)
+                text_displ_2=['A=' num2str(double(A_mouse)) ',i='  num2str(indx0) ',j=' num2str(indy0)];
+            end
+        elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
+            text_displ_1=get(hchild(ichild),'Tag');
+        end
+    end
+end
+set(handles.text_display_1,'String',text_displ_1);
+set(handles.text_display_2,'String',text_displ_2);
+set(handles.text_display_3,'String',text_displ_3);
+set(handles.text_display_4,'String',text_displ_4);
+
+%%%%%%%%%%%%%%%%%
+%create or modify an object
+if isfield(AxeData,'CurrentObject') & ishandle(AxeData.CurrentObject) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off')
+    PlotData=get(AxeData.CurrentObject,'UserData');
+    huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
+    if ~isempty(huvmat)
+        UvData=get(huvmat,'UserData');
+        if ~isfield(PlotData,'IndexObj')
+             return
+        end
+        ObjectData=UvData.Object{PlotData.IndexObj};
+        XYData=AxeData.CurrentOrigin;
+        if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
+           if isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|isequal(ObjectData.Style,'polygon')|isequal(ObjectData.Style,'points')
+              xy(1,3)=0;
+              ObjectData.Coord=[ObjectData.Coord ;xy(1,:)];
+             % ObjectData.Coord(end,:)=xy(1,:);
+           elseif isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'ellipse')|isequal(ObjectData.Style,'volume')
+              ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
+              ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
+              ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
+              ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
+           elseif isequal(ObjectData.Style,'plane') %case of 'plane'
+                DX=(xy(1,1)-ObjectData.Coord(1,1));
+                DY=(xy(1,2)-ObjectData.Coord(1,2));
+                ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
+                if isfield(ObjectData,'RangeX')
+                    XMax=sqrt(DX*DX+DY*DY);
+                    if XMax>max(ObjectData.RangeX)
+                        ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
+                    end
+                end
+           end
+            plot_object(ObjectData,[],AxeData.CurrentObject,'m');
+            pointershape='crosshair';
+        elseif  isequal(AxeData.Drawing,'translate')
+            DX=xy(1,1)-XYData(1);%translation from initial position
+            DY=xy(1,2)-XYData(2);
+            ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
+            ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
+            plot_object(ObjectData,[],AxeData.CurrentObject,'m');
+            pointershape='fleur';
+        elseif  isequal(AxeData.Drawing,'deform')
+            ind_move=AxeData.CurrentIndex;
+            ObjectData.Coord(ind_move,1)=xy(1,1);
+            ObjectData.Coord(ind_move,2)=xy(1,2);
+            plot_object(ObjectData,[],AxeData.CurrentObject,'m');
+            pointershape='circle';
+        end
+    end
+end    
+%%%%%%%%%%%%%
+%draw a rectangle if no object creation is selected
+if ~isempty(haxes) & isfield(AxeData,'Drawing')& isequal(AxeData.Drawing,'zoom')& isfield(AxeData,'CurrentOrigin')...
+        & isequal(get(gcf,'SelectionType'),'normal')% 
+   xy_rect=AxeData.CurrentOrigin;
+   if ~isempty(xy_rect) 
+        rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate
+        rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate
+        rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width
+        rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height
+        if rect(3)>0 & rect(4)>0
+            if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom)
+                set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position
+            else
+                AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');
+                set(haxes,'UserData',AxeData)
+            end
+        end
+   end
+end
+if test_zoom
+    pointershape='arrow';
+end
+set(currentfig,'Pointer',pointershape);
Index: /trunk/src/private/mouse_up.m
===================================================================
--- /trunk/src/private/mouse_up.m	(revision 8)
+++ /trunk/src/private/mouse_up.m	(revision 8)
@@ -0,0 +1,321 @@
+%'mouse_up': function  activated when the mouse button is released
+%----------------------------------------------------------------
+% function mouse_up(ggg,eventdata,handles)
+% activated by the command:
+% set(hObject,'WindowButtonUpFcn',{'mouse_up'}), 
+% where hObject is the handle of the figure
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function mouse_up(ggg,eventdata,handles)
+MouseAction='none'; %default
+zoomstate=0;%default
+if ~exist('handles','var')
+   handles=get(gcbo,'UserData');
+end
+huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
+if ~isempty(huvmat)
+    hhuvmat=guidata(huvmat);
+    UvData=get(huvmat,'UserData');
+    if isfield(UvData,'MouseAction')
+        MouseAction=UvData.MouseAction;% set the mouse action (edit, create objects...)
+    end
+    zoomstate=get(hhuvmat.zoom,'Value');
+end
+if isequal(MouseAction,'calib') && ~zoomstate
+    return
+end
+currentfig=gcbo;
+AxeData=get(gca,'UserData');
+currentaxes=gca; %store the current axes handle
+test_drawing=0;%default
+
+%finalize the fabrication or the translation/deformation of an object and plot the corresponding projected field
+if ~isempty(huvmat) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off') & isfield(AxeData,'CurrentObject')...
+           & ishandle(AxeData.CurrentObject)
+    xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object  
+    IndexObj=PlotData.IndexObj;
+    ObjectData=UvData.Object{IndexObj};    
+    if isequal(AxeData.Drawing,'translate')
+        XYData=AxeData.CurrentOrigin;
+        DX=xy(1,1)-XYData(1);%translation from initial position
+        DY=xy(1,2)-XYData(2);
+        ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
+        ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
+    elseif isequal(AxeData.Drawing,'deform')
+        ind_move=AxeData.CurrentIndex;
+        ObjectData.Coord(ind_move,1)=xy(1,1);
+        ObjectData.Coord(ind_move,2)=xy(1,2);
+    else   %creating object
+        if isequal(ObjectData.Style,'line')||isequal(ObjectData.Style,'polyline')||...
+                isequal(ObjectData.Style,'polygon')||isequal(ObjectData.Style,'points')
+            if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==3
+              xy(1,3)=AxeData.ObjectCoord(1,3); % z coordinate of the mouse: to generalise ...
+            else
+                 xy(1,3)=0; % z coordinate set to 0 by default
+            end
+            if ~isequal(ObjectData.Coord,xy(1,:))
+                ObjectData.Coord=[ObjectData.Coord ;xy(1,:)];% append the coordiantes marked by the mouse to the eobject
+            end
+        elseif isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'ellipse')||isequal(ObjectData.Style,'volume')
+            XYData=AxeData.CurrentOrigin;
+            ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
+            ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
+            ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
+            ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
+        elseif isequal(ObjectData.Style,'plane') %case of 'plane'
+            DX=(xy(1,1)-ObjectData.Coord(1,1));
+            DY=(xy(1,2)-ObjectData.Coord(1,2));
+            ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
+            if isfield(ObjectData,'RangeX')
+                XMax=sqrt(DX*DX+DY*DY);
+                if XMax>max(ObjectData.RangeX)
+                    ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
+                end
+            end
+        end
+    end
+    %set(AxeData.CurrentObject,'UserData',ObjectData); %update the object properties
+    if isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'ellipse')
+        NbDefPoint=1;  
+    elseif isequal(ObjectData.Style,'line')|| isequal(ObjectData.Style,'plane');
+        NbDefPoint=2; 
+    else
+         NbDefPoint=3;
+    end
+    
+    %show object coordinates in the GUI set_object
+    h_set_object=findobj(allchild(0),'Name','set_object');
+    h_XObject=findobj(h_set_object,'Tag','XObject');
+    h_YObject=findobj(h_set_object,'Tag','YObject');
+    h_ZObject=findobj(h_set_object,'Tag','ZObject');
+    set(h_XObject,'String',num2str(ObjectData.Coord(:,1),4)); 
+    set(h_YObject,'String',num2str(ObjectData.Coord(:,2),4)); 
+    set(h_ZObject,'String',num2str(ObjectData.Coord(:,3),4));
+    if NbDefPoint<=2 || isequal(get(currentfig,'SelectionType'),'alt') ||...
+              isequal(AxeData.Drawing,'translate') || isequal(AxeData.Drawing,'deform');%stop drawing
+        AxeData.CurrentOrigin=[]; %suppress the current origin
+       if isequal(ObjectData.Style,'line') && size(ObjectData.Coord,1)<=1
+           AxeData.Drawing='off';
+           set(currentaxes,'UserData',AxeData);
+            return % line needs at leqst two points
+       end
+       if  ~isempty(ObjectData)
+             testmask=0;
+             hmask=findobj(huvmat,'Tag','makemask');
+             if ~isempty(hmask)
+                testmask=get(hmask,'Value');
+             end
+             if testmask
+                 PlotHandles=[];%do not project data on the object during mask creation
+             else
+                 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
+             end
+            AxeData.hset_object=set_object(ObjectData,PlotHandles);% call the set_object interface ,*
+            UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,PlotHandles); 
+            %ObjectData=update_obj(UvData,IndexObj,ObjectData,PlotHandles); 
+            if  isfield(UvData.Object{IndexObj},'PlotParam')
+                write_plot_param(PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object
+            end              
+            set(hhuvmat.create,'Value',0);% set to 'off' the button for object creation
+            set(hhuvmat.create,'BackgroundColor',[0 1 0]);% paint the creation button in green
+            set(hhuvmat.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
+            set(hhuvmat.edit,'Value',1);%
+            set(hhuvmat.edit,'Enable','on');%
+            set(hhuvmat.MenuEdit,'Enable','on');%
+            set(hhuvmat.MenuEdit,'Enable','on');%
+            set(hhuvmat.MenuObject,'Enable','on');%
+            UvData.MouseAction='edit_object'; % set the edit button to 'on'
+        end
+    else
+       AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the new current origin
+       test_drawing=1;%allow continuation of drawing object
+       UvData.Object{IndexObj}=ObjectData;
+    end
+    hother=findobj('Tag','deformpoint');%find all the deformpoints
+    set(hother,'Color','b');%reset all the deformpoints in 'blue' 
+else
+    test_drawing=0;
+end
+
+%creation of a new zoom plot
+test_replot=0;
+if isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
+%         FigData=get(currentfig,'UserData');
+        hparentfig=currentfig;
+        %open or update a new zoom figure if a rectangle has been drawn
+        if ishandle(currentaxes);
+            if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)
+                PosRect=get(AxeData.CurrentRectZoom,'Position');
+                if isfield(AxeData,'CurrentVec') & ishandle(AxeData.CurrentVec)
+                    delete(AxeData.CurrentVec)
+                end
+                %update the axes UvData.Plane2 if it exists, else create it
+%                 if isfield (UvData,'Plane2') & ishandle(UvData.Plane2.Fig)%if the second plan plotting axis already exists
+%                     hfig2=UvData.Plane2.Fig;
+%                     if isequal(gcf,hfig2)%if we are already on the secondary figure
+%                         test_replot=1;
+%                     else
+%                         figure(hfig2)%set hfig2 as the current figure
+%                         clf; %erase axes
+%                     end
+%                 else
+                    hfig2=figure;%create new figure
+                    set(hfig2,'name','zoom')
+                    set(hfig2,'Units','normalized')
+                    set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
+%                     UvData.Plane2.Fig=hfig2; 
+                    map=colormap(currentaxes);
+                    colormap(map);%transmit the current colormap to the zoom fig
+                    get(handles.RootFile,'String')
+%                 end
+                set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
+                if test_replot==0
+                    set(hfig2,'Unit','normalized')
+                    set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function
+                    set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function
+                    set(hfig2,'WindowButtonDownFcn',{@mouse_down})%set mouse click action function
+                    set(hfig2,'WindowButtonUpFcn',{@mouse_up,handles})  
+                    set(hfig2,'DeleteFcn',{@close_fig,AxeData.CurrentRectZoom,'zoom'})
+                    set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig
+                    AxeData.ZoomAxes=copyobj(currentaxes,hfig2); %copy the current graph axes to the zoom figure 
+                    figure(hfig2)
+                    set(AxeData.ZoomAxes,'Position',[0.1300    0.1100    0.7750    0.8150])% standard axes position on a figure
+                    hcol=findobj(hparentfig,'Tag','Colorbar'); %look for colorbar axes
+                    if ~isempty(hcol)             
+                        hcol_new=colorbar;
+                        YTick=get(hcol,'YTick');
+                        YTicklabel=get(hcol,'Yticklabel');  
+                        colbarlim=get(hcol,'YLim'); 
+                        newcolbarlim=get(hcol_new,'YLim');
+                        scale_bar=(newcolbarlim(2)-newcolbarlim(1))/(colbarlim(2)-colbarlim(1));                
+                        YTick_rescaled=newcolbarlim(1)+scale_bar*(YTick-colbarlim(1));
+                        set(hcol_new,'YTick',YTick_rescaled);
+                        set(hcol_new,'Yticklabel',YTicklabel);
+                    end
+                end
+                if ishandle(AxeData.ZoomAxes)
+                    hnew_rect=findobj(AxeData.ZoomAxes,'Tag','rect_zoom');
+                    if ~isempty(hnew_rect)
+                        delete(hnew_rect);
+                        ChildAxeData=get(AxeData.ZoomAxes,'UserData');
+                        ChildAxeData.CurrentRectZoom=[]; % no rect zoom in the new window
+                        ChildAxeData.Drawing='off';
+                        ChildAxeData.ParentRect=AxeData.CurrentRectZoom;%set the rectangle as a 'parent' associated to the new axes
+                        set(AxeData.ZoomAxes,'UserData',ChildAxeData);%update the AxeData of the new axes
+                       % UvData.TopFig=hfig2;%put the new fig to the top of the stack for uvmat
+        %                 set(huvmat,'UserData',UvData)
+                        set(AxeData.ZoomAxes,'Xlim',[PosRect(1) PosRect(1)+PosRect(3)])
+                        set(AxeData.ZoomAxes,'Ylim',[PosRect(2) PosRect(2)+PosRect(4)])
+                    end
+                end
+            end
+        end
+end
+%zoom in if no new figure is created
+if zoomstate
+     if  isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
+        %zoom(2)% zoom in by a factor of 2
+        alpha=0.5; %zoom factor (zoom in by a factor 2)
+        xlim=get(currentaxes,'XLim');
+        xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2;
+        xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2;
+        set(currentaxes,'XLim',xlim_new)
+        ylim=get(currentaxes,'YLim'); 
+        ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2;
+        ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2;
+        set(currentaxes,'YLim',ylim_new)
+        if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
+            hparentrect=AxeData.ParentRect;
+            xlim=get(currentaxes,'XLim');
+            ylim=get(currentaxes,'YLim');
+            rect([1 2])=[xlim(1) ylim(1)];
+            rect([3 4])=[xlim(2)-xlim(1) ylim(2)-ylim(1)];
+            set(hparentrect,'Position',rect)
+        end
+
+     elseif isequal(get(currentfig,'SelectionType'),'alt'); %if right button has been pressed
+            %zoom(0.5)% zoom out by a factor of 2
+            alpha=2; %zoom factor (zoom out by a factor 2)
+            xlim=get(currentaxes,'XLim');
+            xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2;
+            xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2;
+            ylim=get(currentaxes,'YLim');
+            ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2;
+            ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2;
+            set(currentaxes,'XLim',xlim_new)
+            set(currentaxes,'YLim',ylim_new)
+            %test whther zoom out is operating (to inactivate AxedAta
+            if ~isfield(AxeData,'CurrentXLim')| ~isequal(xlim,AxeData.CurrentXLim)
+                AxeData.CurrentXLim=xlim;%
+            end
+            if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
+                hparentrect=AxeData.ParentRect;
+                xlim=get(currentaxes,'XLim');
+                ylim=get(currentaxes,'YLim');
+                rect([1 2])=[xlim(1) ylim(1)];
+                rect([3 4])=[xlim(2)-xlim(1) ylim(2)-ylim(1)];
+                set(hparentrect,'Position',rect)
+            end
+      end
+end
+
+%display the data of the current object selected with the mouse right click
+if isequal(get(currentfig,'SelectionType'),'alt') && ~zoomstate && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
+    hother=findobj('Tag','proj_object');%find all the proj objects
+    nbselect=0;
+    %test the existence of selected objects:
+    for iproj=1:length(hother);
+        iselect=isequal(get(hother(iproj),'Selected'),'on');%reset all the proj objects in 'blue' by default
+        nbselect=nbselect+iselect;
+    end
+    hother=findobj('Tag','proj_object','Type','line');%find all the proj objects
+    set(hother,'Color','b');%reset all the proj objects in 'blue' by default
+    set(hother,'Selected','off')
+    hother=findobj('Tag','proj_object','Type','rectangle');
+    set(hother,'EdgeColor','b');
+    set(hother,'Selected','off')
+    hother=findobj('Tag','proj_object','Type','patch');
+    set(hother,'FaceColor','b');   
+    if isequal(get(gco,'Type'),'image')
+        currentobj=get(gco,'parent');%parent axes of the image
+    else 
+        currentobj=gco;%default
+    end
+    if ((nbselect==0) && isequal(get(currentobj,'Type'),'axes')) || isequal(currentobj,huvmat)
+        global CurData
+        CurData=get(currentobj,'UserData');
+        %plot_text(CurData)
+        %get_field([],CurData);
+        evalin('base','global CurData')%make CurData global in the workspace
+        objtype=get(currentobj,'Type');
+        display(['UserData of ' objtype ':'])
+        evalin('base','CurData') %display CurData in the workspace
+        commandwindow
+    end
+end
+if test_drawing==0
+        AxeData.Drawing='off';%stop current drawing action
+end
+set(currentaxes,'UserData',AxeData);
+if ~isempty(huvmat)
+    set(huvmat,'UserData',UvData);
+end
+
+    
+
Index: /trunk/src/private/name2display.m
===================================================================
--- /trunk/src/private/name2display.m	(revision 8)
+++ /trunk/src/private/name2display.m	(revision 8)
@@ -0,0 +1,205 @@
+%'name2display': extracts the root name and field numbers from an input filename 
+%--------------------------------------------------------------------
+%[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
+%
+%OUTPUT:
+%filebasesub: filename without appendix
+%field_count: string for the first number i
+%str2: string for the second number i (only for .nc files)
+%str_a: string for the first number j
+%str_b:string for the second number j (only for .nc files)
+%ext: file extension
+%nom_type: char chain characterizing the file nomenclature: with values
+%   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
+%   nom_type='*':constant name for a file representing a series (e.g. avi movie)
+%   nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
+%   nom_type='#', series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
+%   nom_type='_i_j': matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
+%   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc') 
+%   nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
+%   nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
+%   nom_type='#a','#A", with a numerical index and an index letter(e.g.'aa045b.png') (lower or upper case)
+%   nom_type='raw_SMD', same as '#' but with no extension ext='', OBSOLETE
+%   nom_type='#_ab', from pairs of '#' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by '_i_j1-j2')
+%subdir: name of the subdirectory for netcdf files
+%
+%INPUT:
+%fileinput: complete name of the file, including path
+
+function [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
+% siz=length(fileinput);
+% indcur=siz;
+% default values:
+% test_=0;
+field_count='';%character string
+str2='';
+str_a='';
+str_b='';
+% ext='';
+nom_type='';
+subdir='';
+        %select file extension
+[RootPath,RootFile,ext]=fileparts(fileinput);
+indcur=length(RootFile);% nbre of characters in fileraw
+
+        %recognize the name form
+filerawascii=double(RootFile);%ascci code
+val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
+indsel=find(val);% character indices of non numerical characters
+filelit=RootFile(indsel);% fileraw name with numbers removed
+nbchar=length(indsel);
+if nbchar<4% put '*' before the name (remove at the end)
+   prefilelit(1:4-nbchar)='*';%insert 3_nbchar '*' in the file name
+   filelit=[prefilelit filelit];
+   indsel=[1:4-nbchar indsel+4-nbchar];
+   RootFile=[prefilelit RootFile];
+   indcur=indcur+4-nbchar;
+end
+separ3=indsel(end);% index of last non numerical character in fileraw
+separ2=indsel(end-1);% index of previous non numerical character
+separ1=indsel(end-2);
+separ0=indsel(end-3);
+num1='';num2='';num3='';
+if separ1>=separ0+1,num0=RootFile(separ0+1:separ1-1);end
+if separ2>=separ1+1,num1=RootFile(separ1+1:separ2-1);end
+if separ3>=separ2+1,num2=RootFile(separ2+1:separ3-1);end
+if indcur>=separ3+1,num3=RootFile(separ3+1:indcur);end
+last_str=RootFile(indcur);%last character in fileraw
+last=double(last_str);%corresponding ascii code
+penult=double(RootFile(indcur-1));%ascii code of the penultimate character
+testsub=0; %default 
+if strcmpi(ext,'.avi')
+     nom_type='*';
+      %case of old image nomenclature
+elseif (strcmp(ext,'.png') || strcmp(ext,'')) &&  penult >= 48 && penult <= 57 && (last < 48 || last > 57)
+    % if the penultimate character is a number and the last a letter
+    % search the appendix a,b,c,
+    str_a=last_str; %put appendix a,b,c....
+    indcur=indcur-1;
+    if strcmp(ext,'.png'), nom_type='#a'; end
+    if strcmp(ext,''), nom_type='raw_SMD'; end      
+    num=1;count=0; % extract the numerical appendix
+    while num==1;
+        filascii=double(RootFile(indcur));
+        if (48>filascii)||(filascii>57); % select the non-numerical characters
+            num=0; 
+        else
+            indcur=indcur-1; count=count+1;
+        end
+    end
+    if count~=0             
+            field_count=RootFile(indcur+1:indcur+count);% set the selected field number
+    end
+elseif  penult >= 48 && penult <= 57  && (last <= 66 && last >= 65)% PCO camera Toulouse, end with A or B (NEW)
+    % if the penultimate character is a number and the last a letter
+    % search the appendix a,b,c,
+    str_a=last_str; %put appendix a,b,c....
+    indcur=indcur-1;
+    nom_type='#A';   
+    num=1;count=0; % extract the numerical appendix
+    while num==1;
+        filascii=double(RootFile(indcur));
+        if (48>filascii)||(filascii>57); % select the non-numerical characters
+            num=0; 
+        else
+            indcur=indcur-1; count=count+1;
+        end
+    end
+    if count~=0             
+            field_count=RootFile(indcur+1:indcur+count);% set the selected field number
+    end   
+    indcur=indcur-1;
+elseif strcmp(filelit(end-2:end),'-_-_')%new  nomenclature appendix num1-num2_num_a-num_b
+    field_count=num0;
+    str2=num1;
+    str_a=num2;
+    str_b=num3;
+    nom_type='_i1-i2_j1-j2';
+    testsub=1;
+    indcur=separ0-1;
+elseif strcmp(filelit(end-2:end),'_-_')%new  nomenclature appendix num1-num2_num_a
+    field_count=num1;
+    str2=num2;
+    str_a=num3;
+    nom_type='_i1-i2_j';
+    testsub=1;
+    indcur=separ1-1;
+elseif strcmp(filelit(end-2:end),'__-')%new  nomenclature appendix num1_num2-num2 
+    indcur=separ1-1;
+    field_count=num1;
+    str_a=num2;
+    str_b=num3;
+    nom_type='_i_j1-j2';
+    testsub=1;
+elseif strcmp(filelit(end-1:end),'_-')
+    indcur=separ2-1;
+    field_count=num2;
+    str2=num3;
+    str_a='';
+    nom_type='_i1-i2';
+    testsub=1;
+elseif strcmp(filelit(end-1:end),'__')
+    indcur=separ2-1;
+    field_count=num2;
+    str2='';
+    str_a=num3;
+    nom_type='_i_j';
+elseif strcmp(filelit(end),'_')
+    indcur=separ3-1;
+%     field_count=num3;
+    str2='';
+    str_a='';
+    %detect zeros before the number
+%     count=0; % extract the numerical appendix
+    if strcmp('0',RootFile(separ3+1)); % select the non-numerical characters
+        nom_type=['_%0' num2str(length(RootFile(separ3+1:end))) 'd'];
+    else
+        nom_type='_i';
+    end  
+    field_count=RootFile(separ3+1:end);% set the selected field number'%03d' 
+elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d
+    last=RootFile(indcur-1:indcur);
+    if isequal(length(last),2) && double(last(1)) >= 97 && double(last(1)) <= 122 ...% = 1 for letters
+            && double(last(2)) >= 97 && double(last(2)) <= 122
+          str_a=last(1);%put appendix a,b,c, ou d
+          str_b=last(2);%put appendix a,b,c, ou d
+%           indcur=indcur-3;
+          separ0=indsel(end-3);
+        num0=RootFile(separ0+1:separ1-1);
+        field_count=num0;
+        indcur=separ0;
+        nom_type='#_ab';
+        testsub=1;
+    end
+%search for other names with counter
+else
+    if length(ext)>1     
+            num=1;count=0; % extract the numerical appendix
+            while num==1;
+                filascii=double(RootFile(indcur));
+                if (48>filascii)||(filascii>57); % select the non-numerical characters
+                    num=0; 
+                else
+                    indcur=indcur-1; count=count+1;
+                end
+            end
+            if count~=0   
+                field_count=RootFile(indcur+1:indcur+count);% set the selected field number'%03d'
+                if isequal(field_count(1),'0')
+                    nbfigures=length(field_count);
+                    nom_type=['%0' num2str(nbfigures) 'd'];
+                else
+                    nom_type='#';
+                end
+            end
+    end
+end
+            %select the root name in the file_input window
+RootFile=RootFile(1:indcur);
+if nbchar<4% put '*' before the name (remove at the end)
+   RootFile(1:4-nbchar)=[];
+end
+if testsub
+    [RootPath,subdir,extdir]=fileparts(RootPath);
+    subdir=[subdir extdir];
+end
Index: /trunk/src/private/name_generator.m
===================================================================
--- /trunk/src/private/name_generator.m	(revision 8)
+++ /trunk/src/private/name_generator.m	(revision 8)
@@ -0,0 +1,284 @@
+%'name_generator': creates a file name from a root name and indices. 
+%---------------------------------------------------------------------
+% [filename,idetect,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=...
+            % name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir);
+%---------------------------------------------------------------------           
+% This function detects the existence the constructed file name and it can
+% find indices according to file existence if they are not specified
+%%rmq: this function is related to the reverse functions display2name and name2diplay 
+%---------------------------------------------------------------------
+% OUTPUT:
+%filename: string representing the file name (including path)
+%idetect: =1 if the file is detected, 0 otherwise
+%num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out: index numbers and subdirectory detected 
+             %for free input (= to the corresponding input indices when comp_input=1)
+%---------------------------------------------------------------------
+% INPUT:
+% 'filebase': the root name, 
+% 'num_i1: first labelling index i 
+% 'num_j1', first labelling index j
+% 'ext': file name extension (e.g. '.png' or '.nc')
+% 'nom_type': string defining the kind of nomenclature used:
+     %nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
+     %nom_type='*': the same  file [filebase ext] contains successive fields (ex avi movies)
+     %nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
+     %nom_type='#' series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
+     %nom_type='_i_j' matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
+     %nom_type='_i1-i2' from pairs from a single index (e.g. 'aa_45-47.nc') 
+     %nom_type='_i_j1-j2'pairs of j indices (e.g. 'aa_45_2-3.nc')
+     %nom_type='_i1-i2_j' pairs of i indices (e.g. 'aa_45-46_2.nc')
+     %nom_type='#a','#A' with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j')
+     %nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif'
+     %nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif'
+     %nom_type='raw_SMD', same as '#a' but with no extension ext='', OBSOLETE
+     %nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
+     %nom_type='%3dab' from pairs of '%3da' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
+% A REVOIR: 'comp_input'=1 for writting =0 for reading ,  'comp_input'(for nom_type involving index pairs (e.g. netc))
+     %comp_input=1: the index pair is imposed, 
+     %comp_input=0: the index pair is automatically searched, choosing the most recent  file in case of multiple choice
+% 'num_i2': second index i (for nom_type involving index pairs (e.g. netc))
+% 'num_j2': second index j (for nom_type involving index pairs (e.g. netc))
+% 'subdir': (used for nom_type=netc...) string representing the name of the subdirectory 'subdir' containing file. 
+     %subdir='': no subdirectory, 
+     %subdir='?', the file is first searched with no subdirectory, then in the most recently modified subdirectory if not detected.
+
+% A FAIRE: si comp_inpu=0, si _i_j n'existe pas, chercher _i, 
+function [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=...
+           name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir);
+sizf=size(filebase);
+if (~ischar(filebase)||~isequal(sizf(1),1)),filebase='';end
+if ~ischar(ext),ext='';end
+% filename=[filebase ext];%default
+idetect=0;
+if ~exist('num_i1','var') || isequal(num_i1,[]) 
+    num_i1=1; %default
+end
+if ~exist('num_j1','var') || isequal(num_j1,[]) 
+    num_j1=1; %default
+end
+if ~exist('num_i2','var') || isequal(num_i2,[]) 
+    num_i2=num_i1; %default
+end
+if ~exist('subdir','var')|| isempty(subdir) 
+    subdir='' ; %default
+end
+%detection of mask or mean: filebase of the form [root '_' xxx 'm$$$'] with xxx a number and $$$ three characters
+% if length(filebase)>4 & filebase(end-3)=='m';
+%     basedouble=double(filebase);
+%     val=(48>basedouble)|(basedouble>57);% select the non-numerical characters
+%     i=length(filebase)-4;
+%     while val(i)==0 & i>0
+%         i=i-1;
+%     end
+%     nbslice=str2num(filebase(i+1:end-4));
+%     if ~isequal(nbslice,[]) 
+%         num_i1=mod(num_i1-1,nbslice)+1; %take the rest in the division
+%         if isequal(nom_type,'png_old')|isequal(nom_type,'#a')
+%             num_j1=1;% mask name must end by 'a'
+%         end
+%     end
+% end
+test_pairs=isequal(nom_type,'netc_old')| isequal(nom_type,'netc_2D') | isequal(nom_type,'netc_3D')| isequal(nom_type,'_i1-i2_j1-j2')| ...
+  isequal(nom_type,'netc_series')| isequal(nom_type,'#_ab')| isequal(nom_type,'_i_j1-j2')| isequal(nom_type,'_i1-i2_j')| isequal(nom_type,'_i1-i2');
+test_2D= isequal(nom_type,'netc_old') |isequal(nom_type,'netc_2D')|isequal(nom_type,'#_ab') |isequal(nom_type,'_i_j1-j2');
+test_3D=isequal(nom_type,'netc_3D') |isequal(nom_type,'netc_series')| isequal(nom_type,'_i1-i2_j')| isequal(nom_type,'_i1-i2');
+if isequal(nom_type,'series_i')| isequal(nom_type,'_i');
+        filename=[filebase '_' num2str(num_i1) ext];
+ %       idetect=(exist(filename,'file')==2); 
+elseif length(nom_type)==5 && isequal(nom_type(1:3),'_%0')&& isequal(nom_type(5),'d');
+        filename=[filebase '_' num2str(num_i1,nom_type(2:5)) ext];
+ %       idetect=(exist(filename,'file')==2); 
+elseif isequal(nom_type,'series_i_j')| isequal(nom_type,'_i_j')
+        filename=[filebase '_' num2str(num_i1) '_' num2str(num_j1) ext];
+ %       idetect=(exist(filename,'file')==2);
+elseif isequal(nom_type,'png_old')| isequal(nom_type,'#a')| isequal(nom_type,'#A')
+        filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type) ext];
+   %     idetect=(exist(filename,'file')==2);
+elseif  length(nom_type)>=5 & isequal(nom_type(2:3),'%0') & isequal(nom_type(5),'d')  %isequal(nom_type,'_%04dA') %camera PCO Toulouse
+        filename=[filebase nom_type(1) num2str(num_i1,nom_type(2:4)) num2stra(num_j1,nom_type) ext];
+ %       idetect=(exist(filename,'file')==2);         
+elseif isequal(nom_type,'raw_SMD') %suffix a, b, c without extension
+        filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type)];
+%        idetect=(exist(filename,'file')==2);
+elseif isequal(nom_type,'ima_num')| isequal(nom_type,'#')
+        filename=[filebase num2str(num_i1) ext];
+%        idetect=(exist(filename,'file')==2);
+elseif length(nom_type)>=4 & isequal(nom_type(1:2),'%0') & isequal(nom_type(end),'d')
+            filename=[filebase num2str(num_i1,nom_type) ext]; %test number with a 0 before
+%            idetect=(exist(filename,'file')==2);
+
+%case of derived file indexing (e.g. netcdf files)
+elseif test_pairs
+    if (~exist('num_j2','var')| isequal(num_j2,[])) & test_2D
+          num_j2=num_j1+1; %default if num_j2 undefined
+    end
+    if (~exist('num_i2','var')| isequal(num_i2,[])) & test_3D
+          num_i2=num_i1+1; %default if num_i2 undefined
+    end
+    filebasesub=filebase;
+    % get the root name filebasesub for the netcdf files
+    if  ~isequal(subdir,'') && ~isequal(subdir,'?') 
+            [Path,Name]=fileparts(filebase);
+            filebasesub=fullfile(Path,subdir,Name);
+    end
+     %inexistant pair if num_i2=0 or num_j2=0
+    if isequal(num_i2,0)
+        filename=[filebasesub '*-*_' num2str(num_i1) ext];
+        return
+    end
+    if isequal(num_j2,0)
+        filename=[filebasesub '_' num2str(num_i1) '_*-*' ext];
+        return
+    end
+    % case of an imposed image pair (comp_input=1)
+    if  (exist('comp_input','var') & isequal(comp_input,1)) 
+            if isequal(nom_type,'netc_old')|isequal(nom_type,'#_ab')
+                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
+                    filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) ext];
+                else
+                    filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) num2stra(num_j2,nom_type) ext];
+                end
+            elseif isequal(nom_type,'netc_2D')|isequal(nom_type,'_i_j1-j2')
+                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
+                    filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) ext];
+                else
+                    filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) '-' num2str(num_j2) ext];
+                end
+            elseif isequal(nom_type,'netc_3D') || isequal(nom_type,'_i1-i2_j')
+                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
+                      filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) ext];
+                else
+                    filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) '_' num2str(num_j1) ext];
+                end
+            elseif isequal(nom_type,'netc_series') || isequal(nom_type,'_i1-i2')
+                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
+                     filename=[filebasesub '_' num2str(num_i1) ext];
+                else
+                    filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) ext];
+                end
+            elseif isequal(nom_type,'_i1-i2_j1-j2')
+                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
+                    app1= [num2str(num_i1)];
+                else
+                    app1= [num2str(num_i1) '-' num2str(num_i2)];
+                end
+                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
+                    app2= [num2str(num_j1)];
+                else
+                    app2= [num2str(num_j1) '-' num2str(num_j2)];
+                end     
+                filename=[filebasesub '_' app1 '_' app2 ext];
+            end
+            idetect=1;
+           % idetect=(exist(filename,'file')==2);
+     % case of an image pair to determine (comp_input=0)
+    else
+            [filename,num_i1,num_j1,num_i2,num_j2,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type);
+    end
+    
+     %look for sub-directories containing netcdf files
+    if idetect==0 && isequal(subdir,'?')
+        [pathfile,name]=fileparts(filebase);
+        direct=dir(pathfile);%directory containing filebase
+        datedir=[];%default
+        idir=0;
+        indir=find(cell2mat({direct.isdir}));% find indices of subdirectories
+        direct=direct(indir([3:end]));% keep only the subdirectories,eliminating the two first terms '.' and '..'
+        lengthdir=length(direct);
+        if lengthdir==0
+            subdir='';% no subdirectory found
+        else
+            for idir=1:lengthdir
+                date_str=direct(idir).date;%string of the date of last modification
+                datedir(idir)=0;%default
+                char_code=double(date_str);% code of the date characters
+                special_char=(char_code>127); %non standard Ascii character (e.g. date in french)
+                if isempty(find(special_char))% standard Ascii character 
+                    datedir(idir)=datenum(date_str);
+                end                            
+%                 datedir(idir)=datenum(direct(idir).date); %absolute date of last directory modification
+            end
+            [mostrec,indrec]=max(datedir);% most recently modified subdir chosen by default
+            subdir=direct(indrec).name; %chosen directory
+        end
+        filebasesub=fullfile(pathfile,subdir,name);
+        %if the image pair is imposed
+        if (exist('comp_input','var') & isequal(comp_input,1)) 
+            if isequal(nom_type,'netc_old')|isequal(nom_type,'#_ab')
+                filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) num2stra(num_j2,nom_type) ext];
+            elseif isequal(nom_type,'netc_2D')|isequal(nom_type,'_i1_j1-j2')
+                filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) '-' num2str(num_i2) ext];
+            elseif isequal(nom_type,'netc_3D')|isequal(nom_type,'_i1-i2_j')
+                filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) '_' num2str(num_j1) ext];
+            elseif isequal(nom_type,'netc_series')|isequal(nom_type,'_i1-i2')
+                filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) ext];
+            end
+            idetect=(exist(filename,'file')==2);
+        else
+            [filename,num_i1,num_j1,num_i2,num_j2,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type);             
+        end
+    end
+% elseif isequal(nom_type,'none')|isequal(nom_type,'')|isequal(nom_type,'*')
+else
+    filebasesub=filebase;
+    if ~isequal(subdir,'') && ~isequal(subdir,'?') 
+            [Path,Name]=fileparts(filebase);
+            filebasesub=fullfile(Path,subdir,Name);
+    end
+    filename=[filebasesub ext];
+    idetect=(exist(filename,'file')==2);  
+end
+num_i1_out=num_i1;
+num_j1_out=num_j1;
+if exist('num_i2','var'), num_i2_out=num_i2; else, num_i2_out=[]; end;
+if exist('num_j2','var'), num_j2_out=num_j2; else, num_j2_out=[]; end;
+if ~isequal(subdir,'?'), subdir_out=subdir; else, subdir_out='';end;
+
+%---------------------------------------------------------------
+% search the appropriate image pair (netcdf file) corresponding to a given
+% image number
+%-------------------------------------------------------------------
+function [filename,num_i1,num_j1,num_i2,num_j2,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type)
+% for nom_type=netc_2D or netc_old, it searches all the pairs corresponding
+% to num_i1, and chooses the most recent file.
+%for nom_type=netc_3D or netc_series, it searches all the pairs (num_i1
+%num_i2), with num_i1 as the first  index, and chooses the most recent file.
+
+filename=[];num_j2=[];idetect=0;%default values
+if isequal(nom_type,'netc_old')|isequal(nom_type,'#_ab')
+    dirpair=dir([filebasesub num2str(num_i1,'%03d') '_*.nc']);
+elseif isequal(nom_type,'netc_2D')|isequal(nom_type,'_i_j1-j2')
+    dirpair=dir([filebasesub '_' num2str(num_i1) '_*-*.nc']);
+elseif isequal(nom_type,'netc_3D')|isequal(nom_type,'_i1-i2_j')
+    dirpair=dir([filebasesub '_' num2str(num_i1) '-*_' num2str(num_j1) '.nc']);
+elseif isequal(nom_type,'netc_series')|isequal(nom_type,'_i1-i2')
+    dirpair=dir([filebasesub '_' num2str(num_i1) '-*.nc']);
+    if isempty(dirpair)
+        dirpair=dir([filebasesub '_*-' num2str(num_i2) '.nc']);
+    end
+end
+nbpair=length(dirpair);
+if nbpair >= 1 %choose the most recent file if several are found
+    idetect=1; %detected pair
+    for ipair=1:nbpair
+         date_str=dirpair(ipair).date;%string of the date of last modification
+         datepair(ipair)=0;%default
+         char_code=double(date_str);% code of the date characters
+         special_char=(char_code>127); %non standard Ascii character (e.g. date in french)
+         if isempty(find(special_char))% standard Ascii character 
+             datepair(ipair)=datenum(date_str);
+         end    
+      %  datepair(ipair)=datenum(dirpair(ipair).date);
+    end
+    [choice,indpair]=max(datepair);
+%     [filebase,field_count,str2,str_a,str_b,ext,nom_type]=name2display(dirpair(indpair).name);
+    [pathname,file,field_count,str2,str_a,str_b,ext,nom_type]=name2display(dirpair(indpair).name);
+    num_i1=str2num(field_count);
+    num_i2=str2num(str2);
+    num_j1=stra2num(str_a);
+    num_j2=stra2num(str_b);
+     pathname=fileparts(filebasesub);% CORRIGE LE 6 JUIN (ETAIT DESACTIVE)
+    filename=fullfile(pathname,dirpair(indpair).name);
+end
+
+
Index: /trunk/src/private/nc2struct.m
===================================================================
--- /trunk/src/private/nc2struct.m	(revision 8)
+++ /trunk/src/private/nc2struct.m	(revision 8)
@@ -0,0 +1,269 @@
+%'nc2struct': transform a netcdf file in a corresponding matlab structure
+% it reads all the global attributes and all variables, or a selected list.
+% The corresponding dimensions and variable attributes are then extracted
+%%%%%% TODO: add the possibility to read only attributes, see  nc2struct_toolbox %%%
+%----------------------------------------------------------------------
+% function [Data,var_detect,ichoice]=nc2struct(nc,ListVarName)
+%
+% OUTPUT:
+%  Data: structure containing all the information of the netcdf file (or netcdf object)
+%           with fields:
+%    .ListGlobalAttribute: cell listing the names of the global attributes
+%        .Att_1,Att_2... : values of the global attributes
+%            .ListDimName: cell listing the names of the array dimensions
+%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
+%            .ListVarName: cell listing the names of the variables
+%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
+%            .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName
+%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
+%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
+%  var_detect: vector with same length as ListVarName, with 1 for each detected variable and 0 else.
+%  ichoice: = line 
+%
+%INPUT:
+%     nc:      name of a netcdf file (char string) or netcdf object   
+% ListVarName: optional list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} ) 
+%         if ListVarName=[] or {}, no variables is read (only global attributes and lists of dimensions, variables and attriburtes)
+%         if ListVarName is absent, or = '*', ALL the variables are read. 
+%        if ListVarName is a cell array with n lines, the set of variables
+%                        will be sought by order of priority in the list, while output names will be set by the first line
+% 
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+   
+function [Data,var_detect,ichoice]=nc2struct(nc,varargin)
+List=varargin;
+if nargin==0
+    List{1}='*';
+end
+% if ~exist('ListVarName','var')
+%     ListVarName='*';
+% end
+hhh=which('netcdf.open');% look for built-in matlab netcdf library
+
+if ~isequal(hhh,'')
+    %default output
+    Data=[];
+    var_detect=[];
+    ichoice=[];%default
+    %open the netcdf file for reading
+    if ischar(nc) 
+        if exist(nc,'file')
+            nc=netcdf.open(nc,'NC_NOWRITE');
+            testfile=1;
+        else
+           Data.Txt=['ERROR:file ' nc ' does not exist'];
+           return
+        end
+    else
+        testfile=0;
+    end
+    % short reading of global attributes
+    if isequal(List{1},'ListGlobalAttribute')
+        for ilist=2:numel(List)
+            valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),List{ilist});
+            eval(['Data.' List{ilist} '=valuestr;'])
+        end
+        netcdf.close(nc)
+       return
+    end
+
+    % reading of variables, including attributes
+    ListVarName=List{1};  
+    [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, attributes
+    
+    %  -------- read global attributes (constants)-----------
+    att_key={};%default
+    iatt_g=0;
+    Data.ListGlobalAttribute={};%default
+    for iatt=1:ngatts
+        keystr= netcdf.inqAttName(nc,netcdf.getConstant('NC_GLOBAL'),iatt-1);
+        indstr1=regexp(keystr,'\\');%detect '\\'
+        indstr2=regexp(keystr,'\.');%detect '\.'
+        if isempty(indstr1) && isempty(indstr2)
+           valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),keystr);
+           if ischar(valuestr) && length(valuestr)<200
+                iatt_g=iatt_g+1;
+                indstr1=regexp(keystr,'\\');%detect '\\'
+                indstr2=regexp(keystr,'\.');%detect '\.'
+                if isempty(indstr1) && isempty(indstr2)
+                    eval(['Data.' keystr '=''' valuestr ''';'])
+                    att_key{iatt_g}=keystr;
+                end
+            elseif isempty(valuestr)
+                iatt_g=iatt_g+1;
+                eval(['Data.' keystr '=[];'])
+                att_key{iatt_g}=keystr;
+            elseif isnumeric(valuestr)
+                iatt_g=iatt_g+1;
+                eval(['Data.' keystr '=valuestr;'])
+                att_key{iatt_g}=keystr;
+            end
+        end
+    end
+    Data.ListGlobalAttribute=att_key;
+
+    %  -------- read dimensions -----------
+    dim_name={};
+    dim_value=[];
+    for idim=1:ndims%length(dim_read);
+        [dim_name{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);
+    end
+    if ~isempty(dim_name) && ~isempty(dim_value)
+        Data.ListDimName=dim_name;
+        Data.DimValue=dim_value;
+%         DimIndices=[1:ndims]; %index of the dimension in the netcdf file
+        dim_used=zeros(1,ndims);%initialize test of used dimensions
+    end
+ 
+    %  -------- read variables -----------
+    var_read={}; %default
+    dimids={};
+    nbatt=[];
+    for ivar=1:nvars
+        [var_read{ivar},xtype,dimids{ivar},nbatt(ivar)] = netcdf.inqVar(nc,ivar-1); 
+    end  
+    var_index=1:nvars; %default set of variable indices in the netcdf file
+    testmulti=0;
+    OutputList=[];
+    %select input variables, if requested by the input ListVarName
+    if ~(isequal(ListVarName,'*')||isempty(ListVarName))
+        sizvar=size(ListVarName);
+        testmulti=(sizvar(1)>1);
+        var_index=zeros(1,sizvar(2));%default
+        if testmulti
+            OutputList=ListVarName(1,:);
+            testend=0;
+            for iline=1:sizvar(1)
+                if testend
+                    break
+                end
+          %      var_index=zeros(size(ListVarName));%default
+                for ivar=1:sizvar(2)
+                    if ~isempty(ListVarName{iline,ivar})
+                         for ilist=1:nvars
+                            if isequal(var_read{ilist},ListVarName{iline,ivar})
+                                var_index(ivar)=ilist;
+     %                          var_detect(ivar)=1;
+                            break
+                            end
+                         end
+                         if ivar==1
+                            if var_index(ivar)==0
+                                break%go to next line if the first nc variable is not found
+                            else
+                                testend=1; %this line will be read
+                                ichoice=iline-1; %selectedline number in the list of input names of variables
+                            end
+                         end
+                    end
+                end
+            end
+        else   %single list of input variables
+            for ivar=1:sizvar(2)
+                for ilist=1:nvars
+                    if isequal(var_read{ilist},ListVarName{ivar})
+                        var_index(ivar)=ilist;
+                        var_detect(ivar)=1;
+                        break
+                    end
+                end
+            end
+        end
+        list_index=find(var_index);
+        if ~isempty(list_index)
+            if testmulti
+                OutputList=OutputList(list_index);
+            end
+            var_index=var_index(list_index);
+            var_detect=(var_index~=0);
+            var_read=var_read(var_index);         
+        end
+    end
+    
+    
+    %select variable attributes and associate dimensions
+%     var_dim_index=[]; %default
+    Data.ListVarName={};%default
+    VarDimIndex={};%default
+    for ivar=1:length(var_read)
+        if testmulti
+            Data.ListVarName{ivar}=OutputList{ivar};%new name given by ListVarName(1,:)
+        else
+            Data.ListVarName{ivar}=var_read{ivar};%name of the variable
+        end
+        var_dim=dimids{var_index(ivar)}+1; %dimension indices used by the variable
+        dim_used(var_dim)=ones(size(var_dim));
+        VarDimIndex{ivar}=var_dim;
+
+        %variable attributes
+        if ivar==1
+            Data.VarAttribute={};%initialisation of the list of variable attributes
+        end
+        %variable attributes
+        for iatt=1:nbatt(var_index(ivar))
+            attname = netcdf.inqAttName(nc,var_index(ivar)-1,iatt-1);
+            valuestr= netcdf.getAtt(nc,var_index(ivar)-1,attname);
+            if ischar(valuestr)
+                eval(['Data.VarAttribute{ivar}.' attname '=''' valuestr ''';'])
+            elseif isempty(valuestr)
+                eval(['Data.VarAttribute{ivar}.' attname '=[];'])
+            elseif isnumeric(valuestr)
+                eval(['Data.VarAttribute{ivar}.' attname '=valuestr;'])
+            end
+        end
+    end
+
+    %select the used dimensions
+    if isempty(var_read) 
+        if isfield(Data,'ListDimName') && isfield(Data,'DimValue')
+        Data=rmfield(Data,'ListDimName');
+        Data=rmfield(Data,'DimValue');
+        end
+    else
+%         list_dim=1:ndims;
+        dim_index=find(dim_used);
+%         list_dim=list_dim(dim_index);
+        old2new=cumsum(dim_used); 
+        Data.ListDimName=Data.ListDimName(dim_index);
+        Data.DimValue=Data.DimValue(dim_index);
+    end
+    for ivar=1:length(var_read)
+        Data.VarDimIndex{ivar}=old2new(VarDimIndex{ivar});% ENLEVER Data.VarDimIndex ulterieurement
+        Data.VarDimName{ivar}=Data.ListDimName(Data.VarDimIndex{ivar});
+    end
+    %variable values
+    if  ~isempty(ListVarName)
+        for ivar=1:length(Data.ListVarName)
+            VarName=Data.ListVarName{ivar};
+            indstr=regexp(VarName,'-');%detect '-'
+            if ~isempty(indstr)
+                VarName(indstr)=[];
+            end
+            eval(['Data.' VarName '=netcdf.getVar(nc,var_index(ivar)-1);'])%read the variable data
+            eval(['siz=size(Data.' VarName ');'])
+            if numel(siz)<=2
+            eval(['Data.' VarName '=Data.' VarName ''';'])%read the variable data
+            end
+        end
+    end
+    %  -------- close fle-----------
+    if testfile==1
+        netcdf.close(nc) 
+    end
+else
+    [Data,var_detect,ichoice]=nc2struct_toolbox(nc,varargin);
+end
Index: /trunk/src/private/nc2struct_toolbox.m
===================================================================
--- /trunk/src/private/nc2struct_toolbox.m	(revision 8)
+++ /trunk/src/private/nc2struct_toolbox.m	(revision 8)
@@ -0,0 +1,260 @@
+%'nc2struct_toolbox': transform a netcdf file in a corresponding matlab structure, USE OLD NETCDF LIBRARY
+%----------------------------------------------------------------------
+% function [Data,var_detect,ichoice]=nc2struct_toolbox(nc,ListField)
+%
+% OUTPUT:
+%  Data: structure containing all the information of the netcdf file (or netcdf object)
+%           with fields:
+%    .ListGlobalAttribute: cell listing the names of the global attributes
+%        .Att_1,Att_2... : values of the global attributes
+%            .ListDimName: cell listing the names of the array dimensions
+%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
+%            .ListVarName: cell listing the names of the variables
+%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
+%            .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName
+%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
+%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
+%  var_detect: vector with same length as ListVarName, with 1 for each detected variable and 0 else.
+%  ichoice: = line 
+%
+%INPUT:
+%     nc:      name of a netcdf file (char string) or netcdf object   
+% ListField: optional list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} ) 
+%         if ListField is absent or ='*', ALL the attributes and variables are read.  %      
+%        if  ListField='ListGlobalAttribute', followed by the arguments 'name1', name2'..., only thes global attributes will be read (short option)
+%        if  ListField=[] or{}, no variables is read (only global attributes and lists of vdimensions, variables and attriburtes)
+%        if ListField is a cell array with n lines, the set of variables
+%                        will be sought by order of priority in the list, while output names will be set by the first line
+% 
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function [Data,var_detect,ichoice]=nc2struct_toolbox(nc,varargin)
+
+List=varargin{1};
+%default output
+Data=[];
+var_detect=[];
+ichoice=[];%default
+
+%open the netcdf file for reading
+if ischar(nc)
+    if exist(nc,'file') % rmq: time for exist search = 0.5 ms CPU
+        nc=netcdf(nc,'nowrite'); % rmq: time needed for opening = 2 ms CPU
+        testfile=1;
+    else
+       Data.Txt=['ERROR:file ' nc ' does not exist'];
+       return
+    end
+else
+    testfile=0;
+end
+
+% short reading of global attributes
+if ~isempty(List) && isequal(List{1},'ListGlobalAttribute')
+    for ilist=2:numel(List)
+        att_str=List{ilist};
+        eval(['Data.' att_str '=nc.' att_str '(:);'])
+    end
+    close(nc) 
+        %total time from beginning : 15 ms for a single attribute
+   return
+end
+
+% reading of variables, including attributes
+if isempty(List)
+   ListVarName='*';
+else
+if isempty(List{1})
+    ListVarName='*';
+else
+    ListVarName=List{1};  
+end
+end
+%  -------- read global attributes -----------              
+att_read=att(nc);%cell of 'global attributes' (nc objects), CPU time 30 ms   
+att_key={};%default
+iatt_g=0;
+for iatt=1:length(att_read)
+    aa=att_read{iatt};
+    keystr=name(aa);
+    indstr1=regexp(keystr,'\\');%replace dots'
+    indstr2=regexp(keystr,'\.');%replace dots'
+    if ~isequal(keystr,'title') % PROBLEM WITH civx files do not read 'title' 
+        if  isempty(indstr1) && isempty(indstr2) % 
+           eval(['valuestr=nc.' keystr '(:);'])
+            if ischar(valuestr) && length(valuestr)<200
+                iatt_g=iatt_g+1;
+                indstr1=regexp(keystr,'\\');%replace dots'
+                indstr2=regexp(keystr,'\.');%replace dots'
+                if isempty(indstr1) && isempty(indstr2)
+                    eval(['Data.' keystr '=''' valuestr ''';'])
+                    att_key{iatt_g}=keystr;
+                end
+            elseif isempty(valuestr)
+                iatt_g=iatt_g+1;
+                eval(['Data.' keystr '=[];'])
+                att_key{iatt_g}=keystr;
+            elseif isnumeric(valuestr)
+                iatt_g=iatt_g+1;
+                eval(['Data.' keystr '=valuestr;'])
+                att_key{iatt_g}=keystr;
+            end
+        end
+    end
+end
+Data.ListGlobalAttribute=att_key;
+nbattr=length(att_key);
+neworder=[nbattr+1 (1:nbattr)];
+Data=orderfields(Data,neworder);
+
+%  -------- read dimensions -----------
+dim_read=dim(nc);%cell of variable dimension names (nc objects): CPU time 0.0013
+dim_name={};
+dim_value=[];
+for idim=1:length(dim_read);
+    aa=dim_read{idim};
+    if ~isempty(aa)
+    dim_name{idim}=name(aa);
+    dim_value(idim)=length(aa);
+    end
+end
+if ~isempty(dim_name) && ~isempty(dim_value)
+    Data.ListDimName=dim_name;
+    Data.DimValue=dim_value;
+    used=zeros(1,length(dim_value));%initialize test of used dimensions
+end
+
+%  -------- read variables -----------
+var_read={}; %default
+testmulti=0;
+OutputList=[];
+if isequal(ListVarName,'*')%|| isempty(ListVarName)
+     var_read=var(nc);%cell of all variables
+elseif ~isempty(ListVarName)
+    sizvar=size(ListVarName);
+    testmulti=(sizvar(1)>1);
+    if testmulti
+        OutputList=ListVarName(1,:);
+        testend=0;
+        for iline=1:sizvar(1)
+            if testend
+                break
+            end
+            for ivar=1:sizvar(2)
+                var_read{ivar}=[];%default
+                var_detect(ivar)=0;%default
+                VarName=ListVarName{iline,ivar};
+                if ~isempty(VarName)
+                     var_read{ivar}=nc{VarName};%select the input variable names
+                     if ivar==1
+                        if isempty (var_read{ivar})
+                            break%go to next line if the first nc variable is not found
+                        else
+                            testend=1; %this line will be read
+                            ichoice=iline-1; %selectedline number in the list of input names of variables
+                            var_detect(ivar)=1;
+                        end
+                     else
+                          var_detect(ivar)=~isempty (var_read{ivar});
+                     end
+                end
+            end
+        end
+        if ~isempty(find(var_detect,1))
+            OutputList=OutputList(find(var_detect));  
+        end
+    else   %single list of input variables
+        var_detect=ones(size(ListVarName));
+        for ivar=1:sizvar(2)
+            var_read{ivar}=nc{ListVarName{ivar}};%select the input variable names
+            var_detect(ivar)=~isempty(var_read{ivar});
+        end
+    end
+    var_read=var_read(find(var_detect));
+end
+
+% var_dim_index=[]; %default
+Data.ListVarName={};%default
+for ivar=1:length(var_read)
+    vv=var_read{ivar};
+    Data.ListVarName{ivar}=name(vv);%name of the variable
+    if testmulti
+        Data.ListVarName{ivar}=OutputList{ivar};
+    else
+        Data.ListVarName{ivar}=name(vv);%name of the variable
+    end
+    var_dim=dim(vv);%dimension netcdf object of the variable
+    for ivardim=1:length(var_dim)
+        var_dim_name=name(var_dim{ivardim});%name of the dimension
+        for idim=1:length(dim_name)% find the index of the current dimension in the list of dimensions
+            if isequal(dim_name{idim},var_dim_name)
+                Data.VarDimIndex{ivar}(ivardim)=idim;
+                used(idim)=1;
+                break
+            end
+        end
+    end 
+    Data.VarDimName{ivar}={};
+    %variable attributes
+    Data.VarAttribute{ivar}=[];%initialisation of the list of variable attributes
+    %variable attributes
+    att_read=att(vv);
+    for iatt=1:length(att_read)
+        aa=att_read{iatt};
+        eval(['valuestr=vv.' name(aa) '(:);'])
+        if ischar(valuestr)
+            eval(['Data.VarAttribute{ivar}.' name(aa) '=''' valuestr ''';'])
+        elseif isempty(valuestr)
+            eval(['Data.VarAttribute{ivar}.' name(aa) '=[];'])
+        elseif isnumeric(valuestr)
+            eval(['Data.VarAttribute{ivar}.' name(aa) '=valuestr;'])
+        end
+    end
+end
+
+%select the used dimensions
+if isempty(var_read) 
+    if isfield(Data,'ListDimName') && isfield(Data,'DimValue')
+    Data=rmfield(Data,'ListDimName');
+    Data=rmfield(Data,'DimValue');
+    end
+else
+    old_dim_index=find(used); %dimension indices which are used by the selected variables
+    old2new=cumsum(used); 
+    Data.ListDimName=Data.ListDimName(old_dim_index);
+    Data.DimValue=Data.DimValue(old_dim_index);
+end
+for ivar=1:length(var_read)
+    Data.VarDimIndex{ivar}=(old2new(Data.VarDimIndex{ivar}));
+    Data.VarDimName{ivar}=(Data.ListDimName(Data.VarDimIndex{ivar}));
+end
+%variable values
+
+if  ~isempty(ListVarName)
+    for ivar=1:length(Data.ListVarName)
+        vv=var_read{ivar};
+        vdata=vv(:);%data array of the field variable
+        eval(['Data.' Data.ListVarName{ivar} '=vdata;'])%read the variable data
+    end
+end
+%  -------- close fle-----------
+if testfile==1
+    close(nc) 
+end
+
+%total time from beginning : 150 ms for a full civ2 field, 65 ms for four fields
+
Index: /trunk/src/private/nomtype2pair.m
===================================================================
--- /trunk/src/private/nomtype2pair.m	(revision 8)
+++ /trunk/src/private/nomtype2pair.m	(revision 8)
@@ -0,0 +1,70 @@
+%'nomtype2pair': creates nomencalture for index pairs. 
+%---------------------------------------------------------------------
+% [nom_type_nc]=nomtype2pair(nom_type);
+%---------------------------------------------------------------------           
+% This function detects the existence the constructed file name and it can
+% find indices according to file existence if they are not specified
+%%rmq: this function is related to the reverse functions display2name and name2diplay 
+%---------------------------------------------------------------------
+% OUTPUT:
+%nom_type_nc
+
+%---------------------------------------------------------------------
+% INPUT:
+% 'nom_type': string defining the kind of nomenclature used:
+     %nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
+     %nom_type='*': the same  file [filebase ext] contains successive fields (ex avi movies)
+     %nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
+     %nom_type='#' series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
+     %nom_type='_i_j' matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
+     %nom_type='_i1-i2' from pairs from a single index (e.g. 'aa_45-47.nc') 
+     %nom_type='_i_j1-j2'pairs of j indices (e.g. 'aa_45_2-3.nc')
+     %nom_type='_i1-i2_j' pairs of i indices (e.g. 'aa_45-46_2.nc')
+     %nom_type='#a','#A', with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j')
+     %nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif'
+     %nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif'
+     %nom_type='raw_SMD', same as '#a' but with no extension ext='', OBSOLETE
+     %nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
+     %nom_type='%3dab' from pairs of '%3da' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
+% Dti: ~=0 if i index pairs are used
+% Dtj: ~=0 if i index pairs are used
+
+function [nom_type_pair]=nomtype2pair(nom_type,Dti,Dtj);
+
+%determine nom_type_nc:
+nom_type_nc=[];%default
+switch nom_type
+    case {'_i_j'}
+        if Dtj>0 || Dtj<0
+            nom_type_pair='_i_j1-j2';
+            if Dti>0 || Dti<0
+                nom_type_pair='_i1-i2_j1-j2';
+            end
+            elseif Dti>0 || Dti<0
+            nom_type_pair='_i1-i21_j';   
+        else
+             nom_type_pair='_i_j';
+        end
+    case {'_i1-i2_j'}
+        if Dtj>0 || Dtj<0
+           nom_type_pair='_i1-i2_j1-j2';
+        else
+            nom_type_pair='_i1-i2_j';
+        end
+    case {'i_j1-j2'}
+        if Dti>0 || Dti<0
+           nom_type_pair='_i1-i2_j1-j2';
+        else
+            nom_type_pair='_i1-i2_j';
+        end
+    case {'i1-i2_j1-j2'}
+         nom_type_pair='_i1-i2_j1-j2';
+    case '#a'
+        if Dtj>0 || Dtj<0
+            nom_type_pair='#_ab';
+        end
+    otherwise
+        if Dti>0 || Dti<0
+           nom_type_pair='_i1-i2'; 
+        end
+end
Index: /trunk/src/private/num2stra.m
===================================================================
--- /trunk/src/private/num2stra.m	(revision 8)
+++ /trunk/src/private/num2stra.m	(revision 8)
@@ -0,0 +1,41 @@
+%'num2stra': transform number to the corresponding character string depending on the nomenclature
+%--------------------------------------------
+% function str=num2stra(num,nom_type)
+%
+% OUTPUT: 
+% str: character string
+%
+% INPUT:
+% num: input number (file index)
+% nom_type: nomencalture type (see fct name_generator)
+%
+% see also: stra2num, name_generator, name2display
+
+function str=num2stra(num,nom_type,index);
+if ~exist('index','var')
+    index=2; %index 1 or 2 of the file indices
+end
+switch index
+    case 1
+        if length(nom_type)>=4 && isequal(nom_type(1:2),'%0') && isequal(nom_type(4),'d') 
+           str=num2str(num,nom_type(1:4)); 
+        else
+           str=num2str(num); 
+        end
+    case 2
+        if isempty(nom_type)
+            nom_type='none';
+        end
+        if isequal(nom_type,'png_old') || isequal(nom_type,'netc_old') || isequal(nom_type,'raw_SMD')||...
+            isequal(nom_type(end),'a')||isequal(nom_type(end),'b')
+            str=char(96+num);
+        elseif isequal(nom_type(end),'A')|isequal(nom_type(end),'B')
+            str=char(64+num);
+        elseif isequal(nom_type,'series_i')|isequal(nom_type,'netc_series')...
+                |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none')...
+                isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')
+            str='';
+        else
+            str=num2str(num);
+        end
+end
Index: /trunk/src/private/parseXML.m
===================================================================
--- /trunk/src/private/parseXML.m	(revision 8)
+++ /trunk/src/private/parseXML.m	(revision 8)
@@ -0,0 +1,70 @@
+% PARSEXML Convert XML file to a MATLAB structure. (from matlab help)
+function theStruct = parseXML(filename)
+
+try
+   tree = xmlread(filename);
+catch
+   error('Failed to read XML file %s.',filename);
+end
+
+% Recurse over child nodes. This could run into problems 
+% with very deeply nested trees.
+try
+   theStruct = parseChildNodes(tree);
+catch
+   error('Unable to parse XML file %s.');
+end
+
+
+% ----- Subfunction PARSECHILDNODES -----
+function children = parseChildNodes(theNode)
+% Recurse over node children.
+children = [];
+if theNode.hasChildNodes
+   childNodes = theNode.getChildNodes;
+   numChildNodes = childNodes.getLength;
+   allocCell = cell(1, numChildNodes);
+
+   children = struct(             ...
+      'Name', allocCell, 'Attributes', allocCell,    ...
+      'Data', allocCell, 'Children', allocCell);
+
+    for count = 1:numChildNodes
+        theChild = childNodes.item(count-1);
+        children(count) = makeStructFromNode(theChild);
+    end
+end
+
+% ----- Subfunction MAKESTRUCTFROMNODE -----
+function nodeStruct = makeStructFromNode(theNode)
+% Create structure of node info.
+
+nodeStruct = struct(                        ...
+   'Name', char(theNode.getNodeName),       ...
+   'Attributes', parseAttributes(theNode),  ...
+   'Data', '',                              ...
+   'Children', parseChildNodes(theNode));
+
+if any(strcmp(methods(theNode), 'getData'))
+   nodeStruct.Data = char(theNode.getData); 
+else
+   nodeStruct.Data = '';
+end
+
+% ----- Subfunction PARSEATTRIBUTES -----
+function attributes = parseAttributes(theNode)
+% Create attributes structure.
+
+attributes = [];
+if theNode.hasAttributes
+   theAttributes = theNode.getAttributes;
+   numAttributes = theAttributes.getLength;
+   allocCell = cell(1, numAttributes);
+   attributes = struct('Name', allocCell, 'Value', allocCell);
+
+   for count = 1:numAttributes
+      attrib = theAttributes.item(count-1);
+      attributes(count).Name = char(attrib.getName);
+      attributes(count).Value = char(attrib.getValue);
+   end
+end
Index: /trunk/src/private/peaklock.m
===================================================================
--- /trunk/src/private/peaklock.m	(revision 8)
+++ /trunk/src/private/peaklock.m	(revision 8)
@@ -0,0 +1,197 @@
+%'peaklock': determines peacklocking errors from velocity histograms.
+%-------------------------------------------------------
+%first smooth the input histogram 'histu' in such a way that the integral over
+%n-n+1 is preserved, then deduce the peaklocking 'error' function of the pixcel displacement 'x'.
+%
+% [histinter,x,error]=peaklock(nbb,minim,maxim,histu)
+%OUTPUT:
+%histinter: smoothed interpolated histogram
+% x: vector of displacement values.
+% error: vector of estimated errors corresponding to x
+%INPUT:
+%histu=vector representing the values of histogram  of measured velocity ;
+%minim, maxim: extremal values of the measured velocity (absica for histu)
+%nbb: number of bins inside each integer interval for the histograms
+%SUBROUTINES INCLUDED:
+%spline4.m% spline interpolation at 4th order
+%splinhist.m: give spline coeff cc for a smooth histo (call spline4)
+%histsmooth.m(x,cc): calculate the smooth histo for any value x
+%histder.m(x,cc): calculate the derivative of the smooth histo
+function [histinter,x,error]=peaklock(nbb,minim,maxim,histu)
+
+nint=maxim-minim+1
+xfin=[minim-0.5+1/(2*nbb):(1/nbb):maxim+0.5-(1/(2*nbb))];
+histo=(reshape(histu,nbb,nint));%extract values with x between integer -1/2 integer +1/2
+Integ=sum(histo)/nbb; %integral of the pdf on each integer bin
+[histinter,cc]=splinhist(Integ,minim,nbb);
+histx=reshape(histinter,nbb,nint);
+xint=[minim:1:maxim];
+x=zeros(nbb,nint);
+%determination of the displacement x(j,:)
+%j=1
+delx=histo(1,:)./histsmooth(-0.5*ones(1,nint),cc)/nbb;
+%del(1,:)=delx;
+x(1,:)=-0.5+delx-(delx.*delx/2).*histder(-0.5*ones(1,nint),cc);
+%histx(1,:)=histsmooth(x(j-1,:),cc);
+for j=2:nbb
+    delx=histo(j,:)./histsmooth(x(j-1,:),cc)/nbb;
+    %delx=delx.*(delx<3*ones(1,nint)/nbb)+3*ones(1,nint)/nbb.*~(delx <3*ones(1,nint)/nbb)
+    x(j,:)=x(j-1,:)+delx-(delx.*delx/2).*histder(x(j-1,:),cc);
+end
+%reshape
+xint=ones(nbb,1)*xint;
+x=x+xint;
+x=reshape(x,1,nbb*nint);
+error=xfin+1/(2*nbb)-x;
+
+%-------------------------------------------------------
+% --- determine the spline coefficients cc for the interpolated histogram.
+%-------------------------------------------------
+function [histsmooth,cc]= splinhist(Integ,mini,nbb)
+% provides a smooth histogramm histmooth, which remains always positive,
+% and is such that its sum over each integer bin [i-1/2 i+1/2] is equal to
+% Integ(i). The function determines histmooth as the exponential of a 4th
+% order spline function and adjust the cefficients by a Newton method to
+% fit the integral conditions Integ
+% histmooth is determined at the abscissa
+% xfin=[mini-0.5+1/(2*n):(1/n):maxi+0.5-(1/(2*n))] (maxi=mini+size(aa)-1)
+%cc(1-5,i) provides the spline coefficients
+
+% order 0
+siz=size(Integ);
+nint=siz(2);
+izero=find(Integ==0); %indices of zero elements
+inonzero=find(Integ);
+Integ(izero)=min(Integ(inonzero));
+aa=log(Integ);%initial guess for a coeff
+spli=spline4(aa,mini,nbb);  %appel à la fonction spline4
+histsmooth=exp(spli);
+
+S=(sum(reshape(histsmooth,nbb,nint)))/nbb;% integral of the fit histsmooth on ]i-1/2 i+1/2[
+epsilon=max(abs(Integ-S));
+iter=0;
+while epsilon > 0.000001 & iter<10
+ident=eye(nint);
+dSda=ones(nint);
+for j=1:nint% determination of the jacobian matrix dSda
+dhistda=spline4(ident(j,:),mini,nbb);
+expdhistda=dhistda.*histsmooth;
+dSda(j,:)=(sum(reshape(expdhistda,nbb,nint)))/nbb;
+end
+aa=aa+(Integ-S)*inv(dSda);%new estimate of coefficients aa by linear interpolation
+[spli,bb]=spline4(aa,mini,nbb);% new fit histsmooth
+histsmooth=exp(spli);
+S=(sum(reshape(histsmooth,nbb,nint)))/nbb;% integral of the fit histsmooth on ]i-1/2 i+1/2[
+epsilon=max(abs(Integ-S));
+iter=iter+1;
+end
+if iter==10, errordlg('splinhist did not converge after 10 iterations'),end
+cc(1,:)=aa;
+cc(2,:)=bb(1,:);
+cc(3,:)=bb(2,:);
+cc(4,:)=bb(3,:);
+cc(5,:)=bb(4,:);
+
+%-------------------------------------------------------
+% --- determine the 4th order spline coefficients from the function values aa.
+%-------------------------------------------------
+function [histsmooth,bb]= spline4(aa,mini,n)
+% spline interpolation at 4th order
+%aa=vector of values of a function at integer abscissa, starting at mini
+%n=number of subdivisions for the interpolated function
+% histmooth =interpolated values at absissa
+% xfin=[mini-0.5+1/(2*n):(1/n):maxi+0.5-(1/(2*n))] (maxi=mini+size(aa)-1)
+%bb=[b(i);c(i);d(i); e(i)] matrix of spline coeff
+L1=[1/2 1/4 1/8 1/16;1 1 3/4 1/2;0 2 3 3;0 0 6 12];
+L2=[-1/2 1/4 -1/8 1/16;1 -1 3/4 -1/2;0 2 -3 3;0 0 6 -12];
+M=inv(L2)*L1;
+[V,D]=eig(M);
+F=-inv(V)*inv(L2)*[1 ;0 ;0;0];
+a1rev=[1 -1/D(1,1)];
+b1rev=[F(1)/D(1,1)];
+a2rev=[1 -1/D(2,2)];
+b2rev=[F(2)/D(2,2)];
+a3=[1 -D(3,3)];
+b3=[F(3)];
+a4=[1 -D(4,4)];
+b4=[F(4)];
+
+%data
+% n=10;% résolution de la pdf: nbre de points par unite de u
+% mini=-10.0;%general mini=uint16(min(values)-1 CHOOSE maxi-mini+1 EVEN
+% maxi=9.0; % general maxi=uint16(max(values))+1
+%nint=double(maxi-mini+1); % nombre d'intervals entiers EVEN!
+siz=size(aa);
+nint=siz(2);
+maxi=mini+nint-1;
+npdf=nint*n;% nbre total d'intervals à introduire dans la pdf: hist(u,npdf)
+%simulation de pdf
+xfin=[mini-0.5+1/(2*n):(1/n):maxi+0.5-(1/(2*n))];% valeurs d'interpolation: we take n values in each integer interval
+%histolin=exp(-(xfin-1).*(xfin-1)).*(2+cos(10*(xfin-1)));% simulation d'une pdf
+%histo=log(histolin);
+%histo=sin(2*pi*xfin);
+%histextract=(reshape(histo,n,nint));
+%aa=sum(histextract)/n %integral of the pdf on each integer bin
+IP=[0 diff(aa)];
+Irev=zeros(size(aa));
+for i=1:nint
+    Irev(i)=aa(end-i+1);
+end
+IPrev=[0 diff(Irev)];
+
+%get the spline coelfficients a_d, using filter on the eigen vectors A,B,C
+Arev=filter(b1rev,a1rev,IPrev);
+Brev=filter(b2rev,a2rev,IPrev);
+C=filter(b3,a3,IP);
+D=filter(b4,a4,IP);
+A=zeros(size(Arev));
+B=zeros(size(Brev));
+for i=1:nint
+    A(i)=Arev(end-i+1);
+    B(i)=Brev(end-i+1);
+end
+%Matr=V*[A;B;C;D];
+bb=V*[A;B;C;D];
+%b=Matr(1,:);
+%c=Matr(2,:);
+%d=Matr(3,:);
+%e=Matr(4,:);
+%a=aa;
+
+%calculate the interpolation using the spline coefficients a-d
+%xextract=(reshape(xfin,n,nint));% 
+chi=xfin+1/(2*n)-min(xfin)-double(int16(xfin+(1/(2*n))-min(xfin)))-0.5;% decimal part
+chi2=chi.*chi;
+chi3=chi2.*chi;
+chi4=chi3.*chi;
+avec=reshape(ones(n,1)*aa,1,n*nint);
+bvec=reshape(ones(n,1)*bb(1,:),1,n*nint);
+cvec=reshape(ones(n,1)*bb(2,:),1,n*nint);
+dvec=reshape(ones(n,1)*bb(3,:),1,n*nint);
+evec=reshape(ones(n,1)*bb(4,:),1,n*nint);
+histsmooth=avec+bvec.*chi+cvec.*chi2+dvec.*chi3+evec.*chi4;
+
+%-------------------------------------------------------
+% --- determine the interpolated histogram at points chi from the spline ceff cc.
+%-------------------------------------------------
+function histx= histsmooth(chi,cc)
+% provides the value of the interpolated histogram at values chi=x-i
+%(difference with the mnearest integer)
+% cc(5,size(chi)) is the set of spline coefficients obtained by splinhist
+chi2=chi.*chi;
+chi3=chi2.*chi;
+chi4=chi3.*chi;
+histx=exp(cc(1,:)+cc(2,:).*chi+cc(3,:).*chi2+cc(4,:).*chi3+cc(5,:).*chi4);
+
+%-------------------------------------------------------
+% --- determine the derivative p'/p of the interpolated histogram at points chi from the spline ceff cc.
+%-------------------------------------------------
+function histder= histder(chi,cc)
+% provides the logarithmique derivative p'/p of the interpolated histogram
+%at values chi=x-i
+%(difference with the nearest integer)
+% cc(5,size(chi)) is the set of spline coefficients obtained by splinhist
+chi2=chi.*chi;
+chi3=chi2.*chi;
+chi4=chi3.*chi;
+histder=cc(2,:)+2*cc(3,:).*chi+3*cc(4,:).*chi2+4*cc(5,:).*chi3;
Index: /trunk/src/private/phys.m
===================================================================
--- /trunk/src/private/phys.m	(revision 8)
+++ /trunk/src/private/phys.m	(revision 8)
@@ -0,0 +1,232 @@
+%'phys': transforms image (px) to real world (phys) coordinates using geometric calibration parameters
+% OUTPUT: 
+% DataOut:   structure representing the modified field
+% DataOut_1: structure representing the second modified field
+
+%INPUT:
+% Data:  structure of input data 
+%       with fields .A (image or scalar matrix), AX, AY
+%       .X,.Y,.U,.V, .DjUi
+%       .ZIndex: index of plane in multilevel case 
+% Data.CoordType='phys' or 'px', The function ACTS ONLY IF .CoordType='px'
+% Calib: structure containing calibration parameters or a subtree Calib.GeometryCalib =calibration data (tsai parameters)
+
+function [DataOut,DataOut_1]=phys(varargin)
+% A FAIRE: 1- verifier si DataIn est une 'field structure'(.ListVarName'):
+% chercher ListVarAttribute, for each field (cell of variables):
+%   .CoordType: 'phys' or 'px'   (default==phys, no transform)
+%   .scale_factor: =dt (to transform displacement into velocity) default=1
+%   .covariance: 'scalar', 'coord', 'D_i': covariant (like velocity), 'D^i': contravariant (like gradient), 'D^jD_i' (like strain tensor)
+%   (default='coord' if .Role='coord_x,_y..., 
+%            'D_i' if '.Role='vector_x,...',
+%              'scalar', else (thenno change except scale factor)
+Calib{1}=[];
+if nargin==2||nargin==4 % nargin =nbre of input variables
+    Data=varargin{1};
+    DataOut=Data;%default
+    DataOut_1=[];%default
+    CalibData=varargin{2};
+    if isfield(CalibData,'GeometryCalib')
+        Calib{1}=CalibData.GeometryCalib;
+    end
+    Calib{2}=Calib{1};
+else
+    DataOut.Txt='wrong input: need two or four structures';
+end
+test_1=0;
+if nargin==4
+    test_1=1;
+    Data_1=varargin{3};
+    DataOut_1=Data_1;%default
+    CalibData_1=varargin{4};
+    if isfield(CalibData_1,'GeometryCalib')
+        Calib{2}=CalibData_1.GeometryCalib;
+    end
+end
+iscalar=0;
+if  ~isempty(Calib{1})
+    DataOut=phys_1(Data,Calib{1});
+    %case of images or scalar: in case of two input fields, we need to project the transform of on the same regular grid
+    if isfield(Data,'A') && isfield(Data,'AX') && ~isempty(Data.AX) && isfield(Data,'AY')&&...
+                                           ~isempty(Data.AY) && length(Data.A)>1
+        iscalar=1;
+        A{1}=Data.A;
+    end
+end
+%transform of X,Y coordinates for vector fields
+if isfield(Data,'ZIndex')&&~isempty(Data.ZIndex)
+    ZIndex=Data.ZIndex;
+else
+    ZIndex=0;
+end
+if test_1
+    DataOut_1=phys_1(Data_1,Calib{2});
+    if isfield(Data_1,'A')&&isfield(Data_1,'AX')&&~isempty(Data_1.AX) && isfield(Data_1,'AY')&&...
+                                       ~isempty(Data_1.AY)&&length(Data_1.A)>1
+          iscalar=iscalar+1;
+          Calib{iscalar}=Calib{2};
+          A{iscalar}=Data_1.A;
+          if isfield(Data_1,'ZIndex') && ~isequal(Data_1.ZIndex,ZIndex)
+              DataOut.Txt='inconsistent plane indexes in the two input fields';
+          end
+          if iscalar==1% case for which only the second field is a scalar
+               [A,AX,AY]=phys_Ima(A,Calib,ZIndex);
+               DataOut_1.A=A{1};
+               DataOut_1.AX=AX; 
+               DataOut_1.AY=AY;
+               return
+          end
+    end
+end
+if iscalar~=0
+    [A,AX,AY]=phys_Ima(A,Calib,ZIndex);%TODO : introduire interp2_uvmat ds phys_ima
+    DataOut.A=A{1};
+    DataOut.AX=AX; 
+    DataOut.AY=AY;
+    if iscalar==2
+        DataOut_1.A=A{2};
+        DataOut_1.AX=AX; 
+        DataOut_1.AY=AY;
+    end
+end
+
+%------------------------------------------------
+function DataOut=phys_1(Data,Calib)
+% for icell=1:length(Data)
+
+DataOut=Data;%default
+DataOut.CoordType='phys'; %put flag for physical coordinates
+% The transform ACTS ONLY IF .CoordType='px'and Calib defined
+if isfield(Data,'CoordType')&& isequal(Data.CoordType,'px')&& ~isempty(Calib)
+    if isfield(Calib,'CoordUnit')
+        DataOut.CoordUnit=Calib.CoordUnit;
+    else
+        DataOut.CoordUnit='cm'; %default
+%     elseif isfield(DataOut,'CoordUnit')
+%         DataOut=rmfield(DataOut,'CoordUnit');
+    end
+    DataOut.TimeUnit='s';
+    %transform of X,Y coordinates for vector fields
+    if isfield(Data,'ZIndex') && ~isempty(Data.ZIndex)
+        Z=Data.ZIndex;
+    else
+        Z=0;
+    end
+    if isfield(Data,'X') &&isfield(Data,'Y')&&~isempty(Data.X) && ~isempty(Data.Y)
+        [DataOut.X,DataOut.Y,DataOut.Z]=phys_XYZ(Calib,Data.X,Data.Y,Z); 
+        if isfield(Data,'U')&&isfield(Data,'V')&&~isempty(Data.U) && ~isempty(Data.V)&& isfield(Data,'dt') 
+            if ~isempty(Data.dt)
+            [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z);
+            [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z);
+            DataOut.U=(XOut_2-XOut_1)/Data.dt;
+            DataOut.V=(YOut_2-YOut_1)/Data.dt;
+            end
+        end
+    end
+    %transform of an image or scalar: done in phys_ima
+      
+    %transform of spatial derivatives
+    if isfield(Data,'X') && ~isempty(Data.X) && isfield(Data,'DjUi') && ~isempty(Data.DjUi)...
+          && isfield(Data,'dt')    
+        if ~isempty(Data.dt)
+            % estimate the Jacobian matrix DXpx/DXphys 
+            for ip=1:length(Data.X) 
+                [Xp1,Yp1]=phys_XYZ(Calib,Data.X(ip)+0.5,Data.Y(ip),Z);
+                [Xm1,Ym1]=phys_XYZ(Calib,Data.X(ip)-0.5,Data.Y(ip),Z);
+                [Xp2,Yp2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)+0.5,Z);
+                [Xm2,Ym2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)-0.5,Z); 
+            %Jacobian matrix DXpphys/DXpx
+               DjXi(1,1)=(Xp1-Xm1);
+               DjXi(2,1)=(Yp1-Ym1);
+               DjXi(1,2)=(Xp2-Xm2);
+               DjXi(2,2)=(Yp2-Ym2);
+               DjUi(:,:)=Data.DjUi(ip,:,:);
+               DjUi=(DjXi*DjUi')/DjXi;% =J-1*M*J , curvature effects (derivatives of J) neglected
+               DataOut.DjUi(ip,:,:)=DjUi';
+            end
+            DataOut.DjUi =  DataOut.DjUi/Data.dt;   %     min(Data.DjUi(:,1,1))=DUDX                          
+        end
+    end
+end
+
+
+%%%%%%%%%%%%%%%%%%%%
+function [A_out,Rangx,Rangy]=phys_Ima(A,CalibIn,ZIndex)
+xcorner=[];
+ycorner=[];
+npx=[];
+npy=[];
+for icell=1:length(A)
+    siz=size(A{icell});
+    npx=[npx siz(2)];
+    npy=[npy siz(1)];
+    Calib=CalibIn{icell};
+    xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordiantes of corners
+    yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
+    [xcorner_new,ycorner_new]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates
+    xcorner=[xcorner xcorner_new];
+    ycorner=[ycorner ycorner_new];
+end
+Rangx(1)=min(xcorner);
+Rangx(2)=max(xcorner);
+Rangy(2)=min(ycorner);
+Rangy(1)=max(ycorner);
+test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy)); 
+npx=max(npx);
+npy=max(npy);
+x=linspace(Rangx(1),Rangx(2),npx);
+y=linspace(Rangy(1),Rangy(2),npy);
+[X,Y]=meshgrid(x,y);%grid in physical coordiantes
+vec_B=[];
+A_out={};
+for icell=1:length(A) 
+    Calib=CalibIn{icell};
+    if (isfield(Calib,'R') && ~isequal(Calib.R(2,1),0) && ~isequal(Calib.R(1,2),0)) ||...
+        ((isfield(Calib,'kappa1')&& ~isequal(Calib.kappa1,0))) || test_multi || ~isequal(Calib,CalibIn{1})
+        zphys=0; %default
+        if isfield(Calib,'SliceCoord') %.Z= index of plane
+           SliceCoord=Calib.SliceCoord(ZIndex,:);
+           zphys=SliceCoord(3); %to generalize for non-parallel planes
+        end
+        [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,zphys);%corresponding image indices for each point in the real space grid
+        XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line'
+        YIMA=reshape(round(YIMA),1,npx*npy);
+        flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
+        testuint8=isa(A{icell},'uint8');
+        testuint16=isa(A{icell},'uint16');
+        if numel(siz)==2 %(B/W images)
+            vec_A=reshape(A{icell},1,npx*npy);%put the original image in line
+            ind_in=find(flagin);
+            ind_out=find(~flagin);
+            ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
+            ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
+            vec_B(ind_in)=vec_A(ICOMB);
+            vec_B(ind_out)=zeros(size(ind_out));
+            A_out{icell}=reshape(vec_B,npy,npx);%new image in real coordinates
+        elseif numel(siz)==3     
+            for icolor=1:siz(3)
+                vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line
+                ind_in=find(flagin);
+                ind_out=find(~flagin);
+                ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
+                ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
+                vec_B(ind_in)=vec_A(ICOMB);
+                vec_B(ind_out)=zeros(size(ind_out));
+                A_out{icell}(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates
+            end
+        end
+        if testuint8
+            A_out{icell}=uint8(A_out{icell});
+        end
+        if testuint16
+            A_out{icell}=uint16(A_out{icell});
+        end
+    else%
+        
+        A_out{icell}=A{icell};%no transform
+        Rangx=[0.5 npx-0.5];%image coordiantes of corners
+        Rangy=[npy-0.5 0.5];
+        [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],[ZIndex ZIndex]);%case of translations without rotation and quadratic deformation
+        [xx,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,[ZIndex ZIndex]);
+    end
+end
Index: /trunk/src/private/phys_XYZ.m
===================================================================
--- /trunk/src/private/phys_XYZ.m	(revision 8)
+++ /trunk/src/private/phys_XYZ.m	(revision 8)
@@ -0,0 +1,54 @@
+%'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters
+% function [Xphys,Yphys]=phys_XYZ(Calib,X,Y,Z)
+%
+%OUTPUT:
+%
+%INPUT:
+%Z: index of plane
+function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)
+if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'SliceCoord')&length(Calib.SliceCoord)>=Z
+    Zindex=Z;
+    Zphys=Calib.SliceCoord(Zindex,3);%GENERALISER AUX CAS AVEC ANGLE
+else
+%     if exist('Z','var')
+%         Zphys=Z;
+%     else
+        Zphys=0;
+%     end
+end
+if ~exist('X','var')||~exist('Y','var')
+    Xphys=[];
+    Yphys=[];%default
+    return
+end
+Xphys=X;%default
+Yphys=Y;
+%image transform
+if isfield(Calib,'R')
+    R=(Calib.R)';
+    Dx=R(5)*R(7)-R(4)*R(8);
+    Dy=R(1)*R(8)-R(2)*R(7);
+    D0=Calib.f*(R(2)*R(4)-R(1)*R(5));
+    Z11=R(6)*R(8)-R(5)*R(9);
+    Z12=R(2)*R(9)-R(3)*R(8);  
+    Z21=R(4)*R(9)-R(6)*R(7);
+    Z22=R(3)*R(7)-R(1)*R(9);
+    Zx0=R(3)*R(5)-R(2)*R(6);
+    Zy0=R(1)*R(6)-R(3)*R(4);
+    A11=R(8)*Calib.Ty-R(5)*Calib.Tz+Z11*Zphys;
+    A12=R(2)*Calib.Tz-R(8)*Calib.Tx+Z12*Zphys;
+    A21=-R(7)*Calib.Ty+R(4)*Calib.Tz+Z21*Zphys;
+    A22=-R(1)*Calib.Tz+R(7)*Calib.Tx+Z11*Zphys;
+    X0=Calib.f*(R(5)*Calib.Tx-R(2)*Calib.Ty+Zx0*Zphys);
+    Y0=Calib.f*(-R(4)*Calib.Tx+R(1)*Calib.Ty+Zy0*Zphys);
+        %px to camera:
+    Xd=(Calib.dpx/Calib.sx)*(X-Calib.Cx); % sensor coordinates
+    Yd=Calib.dpy*(Y-Calib.Cy);
+    dist_fact=1+Calib.kappa1*(Xd.*Xd+Yd.*Yd); %distortion factor
+    Xu=dist_fact.*Xd;%undistorted sensor coordinates
+    Yu=dist_fact.*Yd;
+    denom=Dx*Xu+Dy*Yu+D0;
+    % denom2=denom.*denom;
+    Xphys=(A11.*Xu+A12.*Yu+X0)./denom;%world coordinates
+    Yphys=(A21.*Xu+A22.*Yu+Y0)./denom;
+end
Index: /trunk/src/private/phys_polar.m
===================================================================
--- /trunk/src/private/phys_polar.m	(revision 8)
+++ /trunk/src/private/phys_polar.m	(revision 8)
@@ -0,0 +1,226 @@
+%transform image coordinates (px) to physical coordinates
+% then transform to polar coordinates: 
+%[DataOut,DataOut_1]=phys_polar(varargin)
+%
+% OUTPUT: 
+% DataOut: structure of modified data field: .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components
+% DataOut_1:  second data field (if two fields are in input)
+%
+%INPUT:
+% Data:  structure of input data (like UvData)
+% CalibData= structure containing the field .GeometryCalib with calibration parameters
+% Data_1:  second input field (not mandatory)
+% CalibData_1= calibration parameters for the second field
+
+function [DataOut,DataOut_1]=phys_polar(varargin)
+Calib{1}=[];
+if nargin==2||nargin==4
+    Data=varargin{1};
+    DataOut=Data;%default
+    DataOut_1=[];%default
+    CalibData=varargin{2};
+    if isfield(CalibData,'GeometryCalib')
+        Calib{1}=CalibData.GeometryCalib;
+    end
+    Calib{2}=Calib{1};
+else
+    DataOut.Txt='wrong input: need two or four structures';
+end
+test_1=0;
+if nargin==4
+    test_1=1;
+    Data_1=varargin{3};
+    DataOut_1=Data_1;%default
+    CalibData_1=varargin{4};
+    if isfield(CalibData_1,'GeometryCalib')
+        Calib{2}=CalibData_1.GeometryCalib;
+    end
+end
+
+%parameters for polar coordinates (taken from the calibration data of the first field)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+origin_xy=[0 0];%center for the polar coordinates in the original x,y coordinates
+if isfield(Calib{1},'PolarCentre') && isnumeric(Calib{1}.PolarCentre)
+    if isequal(length(Calib{1}.PolarCentre),2);
+        origin_xy= Calib{1}.PolarCentre;
+    end
+end
+radius_offset=0;%reference radius used to offset the radial coordinate r 
+angle_offset=0; %reference angle used as new origin of the polar angle (= axis Ox by default)
+if isfield(Calib{1},'PolarReferenceRadius') && isnumeric(Calib{1}.PolarReferenceRadius)
+    radius_offset=Calib{1}.PolarReferenceRadius;
+end
+if radius_offset > 0
+    angle_scale=radius_offset; %the azimuth is rescale in terms of the length along the reference radius
+else
+    angle_scale=180/pi; %polar angle in degrees 
+end
+if isfield(Calib{1},'PolarReferenceAngle') && isnumeric(Calib{1}.PolarReferenceAngle)
+    angle_offset=Calib{1}.PolarReferenceAngle; %offset angle (in unit of the final angle, degrees or arc length along the reference radius))
+end
+% new x coordinate = radius-radius_offset;
+% new y coordinate = theta*angle_scale-angle_offset
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+iscalar=0;
+if  ~isempty(Calib{1})
+    DataOut=phys_1(Data,Calib{1},origin_xy,radius_offset,angle_offset,angle_scale);
+    %case of images or scalar
+    if isfield(Data,'A')&isfield(Data,'AX')&~isempty(Data.AX) & isfield(Data,'AY')&...
+                                           ~isempty(Data.AY)&length(Data.A)>1
+        iscalar=1;
+        A{1}=Data.A;
+    end
+    %transform of X,Y coordinates for vector fields
+    if isfield(Data,'ZIndex')&~isempty(Data.ZIndex)
+        ZIndex=Data.ZIndex;
+    else
+        ZIndex=0;
+    end
+end
+
+if test_1
+    DataOut_1=phys_1(Data_1,Calib{2},origin_xy,radius_offset,angle_offset,angle_scale);
+    if isfield(Data_1,'A')&isfield(Data_1,'AX')&~isempty(Data_1.AX) & isfield(Data_1,'AY')&...
+                                       ~isempty(Data_1.AY)&length(Data_1.A)>1
+          iscalar=iscalar+1;
+          Calib{iscalar}=Calib{2};
+          A{iscalar}=Data_1.A;
+          if isfield(Data_1,'ZIndex')&~isequal(Data_1.ZIndex,ZIndex)
+              DataOut.Txt='inconsistent plane indexes in the two input fields';
+          end
+          if iscalar==1% case for which only the second field is a scalar
+               [A,AX,AY]=phys_Ima(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);
+               DataOut_1.A=A{1};
+               DataOut_1.AX=AX; 
+               DataOut_1.AY=AY;
+               return
+          end
+    end
+end
+if iscalar~=0
+    [A,AX,AY]=phys_Ima(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);%
+    DataOut.A=A{1};
+    DataOut.AX=AX; 
+    DataOut.AY=AY;
+    if iscalar==2
+        DataOut_1.A=A{2};
+        DataOut_1.AX=AX; 
+        DataOut_1.AY=AY;
+    end
+end
+
+%------------------------------------------------
+function DataOut=phys_1(Data,Calib,origin_xy,radius_offset,angle_offset,angle_scale)
+
+DataOut=Data;
+DataOut.CoordType='phys'; %put flag for physical coordinates
+if isfield(Calib,'CoordUnit')
+    DataOut.CoordUnit=Calib.CoordUnit;
+else
+    DataOut.CoordUnit='cm'; %default
+end
+DataOut.TimeUnit='s';
+%perform a geometry transform if Calib contains a field .GeometryCalib 
+if isfield(Data,'CoordType') && isequal(Data.CoordType,'px') && ~isempty(Calib)
+    if isfield(Data,'CoordUnit')
+         DataOut=rmfield(DataOut,'CoordUnit');
+    end
+    %transform of X,Y coordinates for vector fields
+    if isfield(Data,'ZIndex')&~isempty(Data.ZIndex)
+        Z=Data.ZIndex;
+    else
+        Z=0;
+    end
+    if isfield(Data,'X') &isfield(Data,'Y')&~isempty(Data.X) & ~isempty(Data.Y)
+        [DataOut.X,DataOut.Y,DataOut.Z]=phys_XYZ(Calib,Data.X,Data.Y,Z); %transform from pixels to physical
+        DataOut.X=DataOut.X-origin_xy(1);%origin of coordinates at the tank center
+        DataOut.Y=DataOut.Y-origin_xy(2);%origin of coordinates at the tank center
+        [theta,DataOut.X] = cart2pol(DataOut.X,DataOut.Y);%theta  and X are the polar coordinates angle and radius
+          %shift and renormalize the polar coordinates
+        DataOut.X=DataOut.X-radius_offset;%
+        DataOut.Y=theta*angle_scale-angle_offset;% normalized angle: distance along reference radius
+        %transform velocity field if exists
+        if isfield(Data,'U')&isfield(Data,'V')&~isempty(Data.U) & ~isempty(Data.V)& isfield(Data,'dt') 
+            if ~isempty(Data.dt)
+            [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z);
+            [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z);
+            UX=(XOut_2-XOut_1)/Data.dt;
+            VY=(YOut_2-YOut_1)/Data.dt;      
+            %transform u,v into polar coordiantes
+            DataOut.U=UX.*cos(theta)+VY.*sin(theta);%radial velocity
+            DataOut.V=(-UX.*sin(theta)+VY.*cos(theta));%./(DataOut.X)%+radius_ref);%angular velocity calculated 
+            %shift and renormalize the angular velocity
+            end
+        end
+    end
+end
+
+ 
+%%%%%%%%%%%%%%%%%%%%
+function [A_out,Rangx,Rangy]=phys_Ima(A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)
+xcorner=[];
+ycorner=[];
+npx=[];
+npy=[];
+
+for icell=1:length(A)
+    siz=size(A{icell});
+    npx=[npx siz(2)];
+    npy=[npy siz(1)];
+    zphys=0; %default
+    if isfield(CalibIn{icell},'SliceCoord') %.Z= index of plane
+       SliceCoord=CalibIn{icell}.SliceCoord(ZIndex,:);
+       zphys=SliceCoord(3); %to generalize for non-parallel planes
+    end
+    xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordiantes of corners
+    yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
+    [xcorner_new,ycorner_new]=phys_XYZ(CalibIn{icell},xima,yima,ZIndex);%corresponding physical coordinates
+    %transform the corner coordinates into polar ones    
+    xcorner_new=xcorner_new-origin_xy(1);%shift to the origin of the polar coordinates 
+    ycorner_new=ycorner_new-origin_xy(2);%shift to the origin of the polar coordinates       
+    [theta,xcorner_new] = cart2pol(xcorner_new,ycorner_new);%theta  and X are the polar coordinates angle and radius
+    if (max(theta)-min(theta))>pi   %if the polar origin is inside the image
+        xcorner_new=[0 max(xcorner_new)];
+        theta=[-pi pi];
+    end
+          %shift and renormalize the polar coordinates
+    xcorner_new=xcorner_new-radius_offset;%
+    ycorner_new=theta*angle_scale-angle_offset;% normalized angle: distance along reference radius
+    xcorner=[xcorner xcorner_new];
+    ycorner=[ycorner ycorner_new];
+end
+Rangx(1)=min(xcorner);
+Rangx(2)=max(xcorner);
+Rangy(2)=min(ycorner);
+Rangy(1)=max(ycorner);
+% test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy)); 
+npx=max(npx);
+npy=max(npy);
+x=linspace(Rangx(1),Rangx(2),npx);
+y=linspace(Rangy(1),Rangy(2),npy);
+[X,Y]=meshgrid(x,y);%grid in physical coordinates
+%transform X, Y in cartesian
+X=X+radius_offset;%
+Y=(Y+angle_offset)/angle_scale;% normalized angle: distance along reference radius
+[X,Y] = pol2cart(Y,X);
+X=X+origin_xy(1);%shift to the origin of the polar coordinates 
+Y=Y+origin_xy(2);%shift to the origin of the polar coordinates 
+for icell=1:length(A) 
+    [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,zphys);%corresponding image indices for each point in the real space grid
+    XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line'
+    YIMA=reshape(round(YIMA),1,npx*npy);
+    flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
+    vec_A=reshape(A{icell}(:,:,1),1,npx*npy);%put the original image in line
+    ind_in=find(flagin);
+    ind_out=find(~flagin);
+    ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
+    ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
+    vec_B(ind_in)=vec_A(ICOMB);
+    vec_B(ind_out)=zeros(size(ind_out));
+    A_out{icell}=reshape(vec_B,npy,npx);%new image in real coordinates
+end
+%Rangx=Rangx-radius_offset;
+
+
Index: /trunk/src/private/plot_field.m
===================================================================
--- /trunk/src/private/plot_field.m	(revision 8)
+++ /trunk/src/private/plot_field.m	(revision 8)
@@ -0,0 +1,1160 @@
+%'plot_field': plot any field with the structure defined in the uvmat package
+%------------------------------------------------------------------------
+%
+%  This function is used by uvmat to plot fields. It automatically chooses the representation 
+% appropriate to the input field structure: 
+%     2D vector fields are represented by arrows, 2D scalar fiedlds by grey scale images or contour plots, 1D fields are represented by usual plot with (abscissa, ordinate).
+%  The input field structure is first tested by check_field_structure.m,
+%  then split into blocks of related variables  by find_field_indices.m.
+%  The dimensionality of each block is obtained  by this fuction
+%  considering the presence of variables with the attribute .Role='coord_x'
+%  and/or coord_y and/or coord_z (case of unstructured coordinates), or
+%  dimension variables (case of matrices). 
+%
+% function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,KeepLim,PosColorbar)
+%
+% OUPUT:
+% PlotType: type of plot: 'text','line'(curve plot),'plane':2D view,'volume'
+% PlotParamOut: structure, representing the updated  plotting parameters, in case of automatic scaling
+% haxes: handle of the plotting axis, when a new figure is created.
+%
+%INPUT
+%    Data:   structure describing the field to plot 
+%         (optional) .ListGlobalAttribute: cell listing the names of the global attributes
+%                    .Att_1,Att_2... : values of the global attributes
+%         (requested)  .ListVarName: list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} ) 
+%         (requested)  .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)
+%                      .VarAttribute: cell of attributes for each element of .ListVarName (cell array of structures of the form VarAtt.key=value)
+%         (requested) .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
+%  
+%            Variable attribute .Role :
+%    The only variable attribute used for plotting purpose is .Role which can take
+%    the values
+        %       Role = 'scalar':  (default) represents a scalar field
+        %            = 'coord_x', 'coord_y',  'coord_z': represents a separate set of
+        %                        unstructured coordinate x, y  or z
+        %            = 'vector': represents a vector field whose number of components
+        %                is given by the last dimension (called 'nb_dim')
+        %            = 'vector_x', 'vector_y', 'vector_z'  :represents the x, y or z  component of a vector  
+        %            = 'warnflag' : provides a warning flag about the quality of data in a 'Field', default=0, no warning
+        %            = 'errorflag': provides an error flag marking false data,
+        %                   default=0, no error. Different non zero values can represent different criteria of elimination.
+
+
+%         additional elements characterizing the projection object (should not be necessary)--
+%            Data.Style : style of projection object
+%            Data.XObject,.YObject: set of coordinates defining the object position;
+%            Data.ProjMode=type of projection ;
+%            Data.ProjAngle=angle of projection;
+%            Data.DX,.DY,.DZ=increments;
+%            Data.MaxY,MinY: min and max Y
+
+%   haxes: handle of the plotting axes to update with the new plot. If this input is absent or not a valid axes handle, a new figure is created.
+%
+%   PlotParam: parameters for plotting, as read on the uvmat interface (by function 'read_plot_param.m')
+%            --scalars--
+%    .Scalar.MaxA: upper bound (saturation color) for the scalar representation, max(field) by default
+%    .Scalar.MinA: lower bound (saturation) for the scalar representation, min(field) by default
+%    .Scalar.AutoScal: =1 (default) lower and upper bounds of the scalar representation set to the min and max of the field
+%               =0 lower and upper bound imposed by .AMax and .MinA
+%    .Scalar.BW= 1 black and white representation imposed, =0 by default.
+%    .Scalar.Contours= 1: represent scalars by contour plots (Matlab function 'contour'); =0 by default
+%    .IncrA : contour interval
+%            -- vectors--
+%    .Vectors.VecScale: scale for the vector representation
+%    .Vectors.AutoVec: =0 (default) automatic length for vector representation, =1: length set by .VecScale
+%    .Vectors.HideFalse= 0 (default) false vectors represented in magenta, =1: false vectors not represented;
+%    .Vectors.HideWarning= 0 (default) vectors marked by warnflag~=0 marked in black, 1: no warning representation;
+%    .Vectors.decimate4 = 0 (default) all vectors reprtesented, =1: half of  the vectors represented along each coordinate
+%         -- vector color--
+%    .Vectors.ColorCode= 'black','white': imposed color  (default ='blue')
+%                        'rgb', : three colors red, blue, green depending
+%                        on thresholds .colcode1 and .colcode2 on the input  scalar value (C)
+%                        'brg': like rgb but reversed color order (blue, green, red)
+%                        '64 colors': continuous color from blue to red (multijet)
+%    .Vectors.colcode1 : first threshold for rgb, first value for'continuous' 
+%    .Vectors.colcode2 : second threshold for rgb, last value (saturation) for 'continuous' 
+%    .Vectors.FixedCbounds;  =0 (default): the bounds on C representation are min and max, =1: they are fixed by .Minc and .MaxC
+%    .Vectors.MinC = imposed minimum of the scalar field used for vector color;
+%    .Vectors.MaxC = imposed maximum of the scalar field used for vector color;
+%
+% KeepLim:=0 (default) adjust axes limit to the X,Y data, =1: preserves the previous axes limits
+% PosColorbar: if not empty, display a colorbar for B&W images
+%               imposed position of the colorbar (ex [0.821 0.471 0.019 0.445])
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,KeepLim,PosColorbar)
+%default output
+if ~exist('PlotParam','var'),PlotParam=[];end;
+if ~exist('KeepLim','var'),KeepLim=0;end;
+if ~exist('PosColorbar','var'),PosColorbar=[];end;
+PlotType='text'; %default
+PlotParamOut=PlotParam;%default
+
+% check input structure
+[Data,errormsg]=check_field_structure(Data);
+
+if ~isempty(errormsg)
+    msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg])
+    display(['input of plot_field/check_field_structure:: ' errormsg])
+    return
+end
+
+testnewfig=1;%test to create a new figure (default)
+testzoomaxes=0;%test for the existence of a zoom secondary figure attached to the plotting axes
+if exist('haxes','var')
+    if ishandle(haxes)
+        if isequal(get(haxes,'Type'),'axes')
+%             hfig=get(haxes,'Parent');
+            axes(haxes)
+            testnewfig=0;
+            AxeData=get(haxes,'UserData');
+            if isfield(AxeData,'ZoomAxes')&& ishandle(AxeData.ZoomAxes)
+                if isequal(get(AxeData.ZoomAxes,'Type'),'axes') 
+                    testzoomaxes=1;
+                    zoomaxes=AxeData.ZoomAxes;
+                end
+            end
+        end
+    end
+end
+if testnewfig% create a new figure and axes if the plotting axes does not exist
+    hfig=figure;
+    if isfield(Data,'IndexObj')&isfield(Data,'Style')&isfield(Data,'ProjMode')
+        figname=[num2str(Data.IndexObj) '-' set_title(Data.Style,Data.ProjMode)];
+        set(hfig,'Name',figname)
+    end
+    testhandle=0;
+    if isfield(PlotParam,'text_display_1')& ishandle(PlotParam.text_display_1)
+        set(hfig,'UserData',PlotParam)
+        testhandle=1;
+    end
+    set(hfig,'Units','normalized')
+    set(hfig,'WindowButtonDownFcn','mouse_down')
+    %set(hfig,'WindowButtonMotionFcn',{'mouse_motion',PlotParam})%set mouse action function
+    set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action function
+    set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse action function
+    haxes=axes;
+    set(haxes,'position',[0.13,0.2,0.775,0.73])
+end
+if isfield(PlotParam,'text_display_1')& ishandle(PlotParam.text_display_1)
+    PlotParam=read_plot_param(PlotParam);   
+end
+if testnewfig
+  PlotParam.NextPlot='add'; %parameter for plot_profile and plot_hist
+end
+if isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1) 
+    set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
+end
+
+% check the cells of fields :
+testnbdim=1;
+[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
+
+if ~isempty(errormsg)
+    msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg])
+    display(['input of plot_field: ' errormsg])
+    return
+end
+if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot 
+    [Data.NbDim,imax]=max(NbDim);
+end
+if isequal(Data.NbDim,0) % TODO: chech whether this function is still used, replace by plot_profile ?
+%     if isfield(Data,'Style') & isequal(Data.Style,'points')
+        AxeData=plot_text(Data,haxes);
+        PlotType='text';
+%     else
+%         [AxeData,haxes]=plot_hist(Data,haxes,PlotParam);
+%     end
+elseif isequal(Data.NbDim,1)
+    [AxeData,haxes]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);% 
+    if testzoomaxes
+        [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam);
+        AxeData.ZoomAxes=zoomaxes;
+    end
+    PlotType='line';
+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,KeepLim,PosColorbar);
+    if testzoomaxes
+        [AxeData,zoomaxes,PlotParamOut]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
+        AxeData.ZoomAxes=zoomaxes;
+    end
+elseif isequal(Data.NbDim,3)
+    msgbox_uvmat('ERROR','volume plot not implemented yet')
+    return
+    %plot_volume(haxes,Data,PlotParam)% A FAIRE
+    %PlotType='volume';
+else
+    testnbdim=0;
+end
+
+%display (or delete) error message
+htext=findobj(haxes,'Tag','hTxt');
+if isfield(Data,'Txt')
+    if isempty(htext)
+        Xlim=get(haxes,'XLim');
+        Ylim=get(haxes,'YLim');
+        htext=text(Xlim(1),(Ylim(1)+Ylim(2))/2,Data.Txt,'Tag','hTxt','Color','r');
+        set(htext,'Interpreter','none')
+    else
+        set(htext,'String',Data.Txt)
+    end
+elseif ~isempty(htext)
+    delete(htext)
+end
+
+% set graph aspect ratio
+
+
+set(haxes,'UserData',AxeData)
+%set(haxes,'Tag','uvmat'); 
+
+ 
+% %-------------------------------------------
+% function [AxeData,haxes]=plot_hist(Data,haxes,PlotParam)% TODO: chech whether this function is still used, replace by plot_profile ?
+% %------------------------------------------
+% AxeData=get(haxes,'UserData'); %defau
+% hfig=get(haxes,'parent');
+% if ~isfield(Data,'ListVarName')
+%     return
+% end
+% ColorOrder=[1 0 0;0 0.5 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
+% set(haxes,'ColorOrder',ColorOrder)
+% if isfield(PlotParam,'NextPlot')
+%     set(haxes,'NextPlot',PlotParam.NextPlot)
+% end
+% charplot='''-''';
+% iplot=0;
+% legend_str={};
+% label_str='';
+% textmean={};
+% plotstr='plot(';
+% for ilist=1:length(Data.ListVarName)
+%     VarName=Data.ListVarName{ilist}; 
+%     eval(['[' VarName 'hist,' VarName 'val]=hist(double(Data.' VarName '),100);']);%coordinate variable set as c
+%     plotstr=[plotstr VarName 'val,' VarName 'hist,' charplot ','];
+%     eval(['nbcomponent2=size(Data.' VarName ',2);']);
+%     eval(['nbcomponent1=size(Data.' VarName ',1);']);
+%     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
+%         for ic=1:min(nbcomponent1,nbcomponent2)
+%             legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals  components 
+%                                                                % labeled by their index (e.g. color component)
+%         end
+%     end
+%     label_str=[label_str ' ' VarName]; 
+% end
+% if ~isequal(plotstr,'plot(')
+%     plotstr(end)=')';
+%     eval(plotstr)
+%     hlegend=findobj(hfig,'Tag','legend');%find existing legend on the plot
+%     if ~isempty(hlegend)
+%         legend_old=get(hlegend,'String');
+%         if isequal(size(legend_old,1),size(legend_str,1))
+%              legend_str=[legend_old legend_str];
+%         end
+%     end
+%     legend(legend_str)
+%     xlabel(label_str)
+%     ylabel('nb values')
+%      grid on
+%     title_str='';
+%     if isfield(Data,'filename')
+%        [Path, title_str, ext]=fileparts(Data.filename);
+%        title_str=[title_str ext];
+%     end
+%     if isfield(Data,'Action')
+%         if ~isequal(title_str,'')
+%             title_str=[title_str ', '];
+%         end
+%         title_str=[title_str Data.Action];
+%     end
+%     htitle=title(title_str);
+%     set(htitle,'Interpreter','none')% desable tex interpreter
+%     hlist=findobj(gcf,'Style','listbox');
+%     if isempty(hlist)
+%             uicontrol('Style','popupmenu','Position',[20 20 200 20],'String',textmean);
+%     else
+%             set(hlist(1),'String',textmean)
+%     end
+% end
+% AxeData=Data;
+
+
+%----------------------------------------------------------
+function [AxeData,haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
+%-----------------------------------------------------------
+axes(haxes)
+hfig=get(haxes,'parent');
+AxeData=data;
+ColorOrder=[1 0 0;0 0.5 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
+set(haxes,'ColorOrder',ColorOrder)
+if isfield(PlotParam,'NextPlot')
+    set(haxes,'NextPlot',PlotParam.NextPlot)
+end
+legend_str={};
+
+%initiates string of the plot command
+plotstr='plot(';
+textmean={};
+abscissa_name='';
+coord_x_index=[];
+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;
+    else
+        coord_x_index_cell=VarType{icell}.coord(1);
+        if isequal(coord_x_index_cell,0)
+            continue  % the cell has no abscissa, skip it
+        end
+        if ~isempty(coord_x_index)&&~isequal(coord_x_index_cell,coord_x_index)
+            continue %all the selected variables must have the same first dimension
+        else
+            coord_x_index=coord_x_index_cell;
+        end
+    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 ')'];
+    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;
+    end
+    if ~isempty(VarType{icell}.warnflag')
+            testplot(VarType{icell}.warnflag)=0;
+    end
+    if ~isempty(VarType{icell}.discrete')
+         charplot_0='''+''';
+    else
+          charplot_0='''-''';
+    end
+%     if testcoordvar==0
+%         coord_x{icell}=[1:data.DimValue(DimIndices(1))];%abscissa by default if no coordinate variable
+%        % charplot_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
+    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 ','];
+            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
+if ~isequal(plotstr,'plot(')
+    plotstr(end)=')';
+                %execute plot (instruction  plotstr)
+    eval(plotstr)
+                %%%%%
+    grid on
+    hxlabel=xlabel(xtitle);
+    set(hxlabel,'Interpreter','none')% desable tex interpreter
+    if length(legend_str)>=1
+        hylabel=ylabel(legend_str{end});
+        set(hylabel,'Interpreter','none')% desable tex interpreter
+    end
+    if ~isempty(legend_str)
+        hlegend=findobj(hfig,'Tag','legend');
+        if isempty(hlegend)
+            hlegend=legend(legend_str);
+            txt=ver;
+            Release=txt(1).Release;
+            relnumb=str2num(Release(3:4));
+            if relnumb >= 14
+                set(hlegend,'Interpreter','none')% desable tex interpreter
+            end
+        else
+            legend_old=get(hlegend,'String');
+            if isequal(size(legend_old,1),size(legend_str,1))&~isequal(legend_old,legend_str)
+                set(hlegend,'String',[legend_old legend_str]);
+            end
+        end 
+    end
+    title_str='';
+    if isfield(data,'filename')
+       [Path, title_str, ext]=fileparts(data.filename);
+       title_str=[title_str ext];
+    end
+    if isfield(data,'Action')
+        if ~isequal(title_str,'')
+            title_str=[title_str ', '];
+        end
+        title_str=[title_str data.Action];
+    end
+    htitle=title(title_str);
+    txt=ver;
+    Release=txt(1).Release;
+    relnumb=str2num(Release(3:4));
+    if relnumb >= 14
+        set(htitle,'Interpreter','none')% desable tex interpreter
+    end
+    % A REPRENDRE Mean
+%         hlist=findobj(gcf,'Style','listbox','Tag','liststat');
+%         if isempty(hlist)
+%             'text'
+%             textmean
+%             set(gca,'position',[0.13,0.2,0.775,0.73])
+%             uicontrol('Style','popupmenu','Position',[20 20 200 20],'String',textmean,'Tag','liststat');
+%         else
+%             set(hlist(1),'String',textmean)
+%         end
+end
+
+
+%---------------------------------------
+% plot_plane
+%----------------------------------------
+function [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,KeepLim,PosColorbar)
+
+%default plotting parameters
+PlotType='plane';%default
+if ~exist('PlotParam','var')
+    PlotParam=[];
+end
+if ~isfield(PlotParam,'Scalar')
+    PlotParam.Scalar=[];
+end
+if ~isfield(PlotParam,'Vectors')
+    PlotParam.Vectors=[];
+end
+PlotParamOut=PlotParam;%default
+
+%plotting axes
+hfig=get(haxes,'parent');
+hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
+hima=findobj(haxes,'Tag','ima');% search existing image in the current axes
+AxeData=get(haxes,'UserData'); %default
+if ~isstruct(AxeData)% AxeData must be a structure
+    AxeData=[];
+end
+AxeData.NbDim=2;
+if isfield(Data,'ObjectCoord')
+    AxeData.ObjectCoord=Data.ObjectCoord;
+end
+
+test_ima=0; %default: test for image or map plot
+test_vec=0; %default: test for vector plots
+test_black=0;
+test_false=0;
+test_C=0;
+XName='';
+x_units='';
+YName='';
+y_units='';
+for icell=1:length(CellVarIndex) % length(CellVarIndex) =1 or 2 (from the calling function)
+%     VarIndex=CellVarIndex{icell};
+    VarType=VarTypeCell{icell};
+    ivar_X=VarType.coord_x; % defines (unique) index for the variable representing unstructured x coordinate (default =[])
+    ivar_Y=VarType.coord_y; % defines (unique)index for the variable representing unstructured y coordinate (default =[])
+    ivar_U=VarType.vector_x; % defines (unique) index for the variable representing x vector component (default =[])
+    ivar_V=VarType.vector_y; % defines (unique) index for the variable representing y vector component (default =[])
+    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')
+        return
+    end
+    ivar_F=VarType.warnflag; %defines index (unique) for warning flag variable
+    ivar_FF=VarType.errorflag; %defines index (unique) for error flag variable
+    ind_coord=find(VarType.coord);
+    if numel(ind_coord)==2
+        VarType.coord=VarType.coord(ind_coord);
+    end
+    idim_Y=[];  
+    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')
+            return
+        else
+            test_vec=1;
+            eval(['vec_U=Data.' Data.ListVarName{ivar_U} ';']) 
+            eval(['vec_V=Data.' Data.ListVarName{ivar_V} ';']) 
+            if ~isempty(ivar_X) && ~isempty(ivar_Y)% 2D field (with unstructured coordinates or structured ones (then ivar_X and ivar_Y empty)     
+                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
+                eval(['y=Data.' Data.ListVarName{VarType.coord(1)} ';']) 
+                eval(['x=Data.' Data.ListVarName{VarType.coord(2)} ';'])
+                if numel(y)==2 % y defined by first and last values on aregular mesh
+                    y=linspace(y(1),y(2),size(vec_U,1));
+                end
+                if numel(x)==2 % y defined by first and last values on aregular mesh
+                    x=linspace(x(1),x(2),size(vec_U,2));
+                end
+                [vec_X,vec_Y]=meshgrid(x,y);  
+            else
+                msgbox_uvmat('ERROR','error in plot_field: invalid coordinate definition for vector field')
+                return
+            end
+            if ~isempty(ivar_C)
+                 eval(['vec_C=Data.' Data.ListVarName{ivar_C} ';']) ;
+                 vec_C=reshape(vec_C,1,numel(vec_C));
+                 test_C=1;
+            end
+            if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1)) 
+                if test_vec 
+                    eval(['vec_F=Data.' Data.ListVarName{ivar_F} ';']) % warning flags for  dubious vectors
+                    if  ~(isfield(PlotParam.Vectors,'HideWarning') && isequal(PlotParam.Vectors.HideWarning,1)) 
+                        test_black=1;
+                    end
+                end
+            end
+            if ~isempty(ivar_FF) %&& ~test_false
+                if test_vec% TODO: deal with FF for structured coordinates
+                    eval(['vec_FF=Data.' Data.ListVarName{ivar_FF} ';']) % flags for false vectors
+                end
+            end
+        end
+    elseif ~isempty(ivar_C) %scalar or image
+        if test_ima
+             msgbox_uvmat('ERROR','attempt to plot two scalar fields or images')
+            return
+        end
+        eval(['A=squeeze(Data.' Data.ListVarName{ivar_C} ');']) ;% scalar represented as color image
+        test_ima=1;
+        if ~isempty(ivar_X) && ~isempty(ivar_Y)% 2D field (with unstructured coordinates or structured ones (then ivar_X and ivar_Y empty) 
+            XName=Data.ListVarName{ivar_X};
+            YName=Data.ListVarName{ivar_Y};
+            eval(['AX=Data.' XName ';']) 
+            eval(['AY=Data.' YName ';'])
+            [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256');  % interpolate on a grid  
+            if isfield(Data,'VarAttribute')
+                if numel(Data.VarAttribute)>=ivar_X & isfield(Data.VarAttribute{ivar_X},'units')
+                    x_units=['(' Data.VarAttribute{ivar_X}.units ')'];
+                end
+                if numel(Data.VarAttribute)>=ivar_Y & isfield(Data.VarAttribute{ivar_Y},'units')
+                    y_units=['(' Data.VarAttribute{ivar_Y}.units ')'];
+                end
+            end        
+        elseif numel(VarType.coord)==2 %structured coordinates
+            XName=Data.ListVarName{VarType.coord(2)};
+            YName=Data.ListVarName{VarType.coord(1)};
+            eval(['AY=Data.' Data.ListVarName{VarType.coord(1)} ';']) 
+            eval(['AX=Data.' Data.ListVarName{VarType.coord(2)} ';'])
+            test_interp_X=0; %default, regularly meshed X coordinate
+            test_interp_Y=0; %default, regularly meshed Y coordinate
+            if isfield(Data,'VarAttribute')
+                if numel(Data.VarAttribute)>=VarType.coord(2) & isfield(Data.VarAttribute{VarType.coord(2)},'units')
+                    x_units=['(' Data.VarAttribute{VarType.coord(2)}.units ')'];
+                end
+                if numel(Data.VarAttribute)>=VarType.coord(1) & isfield(Data.VarAttribute{VarType.coord(1)},'units')
+                    y_units=['(' Data.VarAttribute{VarType.coord(1)}.units ')'];
+                end
+            end  
+            if numel(AY)>2
+                DAY=diff(AY);
+                DAY_min=min(DAY);
+                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)} ];
+                      return
+                end 
+                test_interp_Y=(DAY_max-DAY_min)> 0.0001*abs(DAY_max);
+            end
+            if numel(AX)>2
+                DAX=diff(AX);
+                DAX_min=min(DAX);
+                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)} ];
+                      return
+                end 
+                test_interp_X=(DAX_max-DAX_min)> 0.0001*abs(DAX_max);
+            end  
+            if test_interp_Y          
+                npxy(1)=max([256 floor((AY(end)-AY(1))/DAY_min) floor((AY(end)-AY(1))/DAY_max)]);
+                yI=linspace(AY(1),AY(end),npxy(1));
+                if ~test_interp_X
+                    xI=linspace(AX(1),AX(end),size(A,2));%default 
+                    AX=xI;
+                end
+            end
+            if test_interp_X  
+                npxy(1)=max([256 floor((AX(end)-AX(1))/DAX_min) floor((AX(end)-AX(1))/DAX_max)]);
+                xI=linspace(AX(1),AX(end),npxy(2));   
+                if ~test_interp_Y
+                   yI=linspace(AY(1),AY(end),size(A,1)); 
+                   AY=yI;
+                end
+            end
+            if test_interp_X || test_interp_Y               
+                [AX2D,AY2D]=meshgrid(AX,AY);
+                A=interp2(AX2D,AY2D,double(A),xI,yI');
+            end
+            AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation 
+            AY=[AY(1) AY(end)];
+        else
+            msgbox_uvmat('ERROR','error in plot_field: invalid coordinate definition ')
+            return
+        end
+          x_label=[Data.ListVarName{ivar_X} '(' x_units ')'];
+    end       
+%     if isfield(Data,'VarAttribute')
+%         VarAttribute=Data.VarAttribute;
+%     end    
+end 
+
+%%%%%%%%%%%%%%%%%%%%%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
+
+if ~isfield(PlotParam.Scalar,'Contours')
+    PlotParam.Scalar.Contours=0; %default
+end
+PlotParamOut=PlotParam; %default
+if test_ima
+    % distinguish B/W and color images
+    np=size(A);%size of image
+    siz=size(np);
+    %set the color map
+    if siz(2)==2 %for black and white images
+        if ~isfield(PlotParam.Scalar,'AutoScal')
+            PlotParam.Scalar.AutoScal=0;%default
+        end
+        if ~isfield(PlotParam.Scalar,'MinA')
+            PlotParam.Scalar.MinA=[];%default
+        end
+        if ~isfield(PlotParam.Scalar,'MaxA')
+            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
+            MinA=double(min(min(A)));
+        else
+            MinA=PlotParam.Scalar.MinA;  
+        end; 
+        if isequal(PlotParam.Scalar.AutoScal,0)|isempty(PlotParam.Scalar.MaxA)|~isa(PlotParam.Scalar.MaxA,'double') %correct if there is no numerical data in edit box
+            MaxA=double(max(max(A)));
+        else
+            MaxA=PlotParam.Scalar.MaxA;  
+        end; 
+        PlotParamOut.Scalar.MinA=MinA;
+        PlotParamOut.Scalar.MaxA=MaxA;
+        axes(haxes)
+        if isequal(PlotParam.Scalar.Contours,1)
+            if ~isempty(hima) & ishandle(hima)
+                delete(hima)
+            end
+            if ~isfield(PlotParam.Scalar,'IncrA')
+                PlotParam.Scalar.IncrA=[];
+            end
+            if isempty(PlotParam.Scalar.IncrA)% | PlotParam.Scalar.AutoScal==0
+                cont=colbartick(MinA,MaxA);
+                intercont=cont(2)-cont(1);%default
+                PlotParamOut.Scalar.IncrA=intercont;
+            else
+               intercont=PlotParam.Scalar.IncrA;
+            end
+            B=A;            
+            abscontmin=intercont*floor(MinA/intercont);
+            abscontmax=intercont*ceil(MaxA/intercont);
+            contmin=intercont*floor(min(min(B))/intercont);
+            contmax=intercont*ceil(max(max(B))/intercont);
+            cont_pos_plus=[0:intercont:contmax];
+            cont_pos_min=[double(contmin):intercont:-intercont];
+            cont_pos=[cont_pos_min cont_pos_plus];
+            sizpx=(AX(end)-AX(1))/(np(2)-1);
+            sizpy=(AY(1)-AY(end))/(np(1)-1);
+            x_cont=[AX(1):sizpx:AX(end)]; % pixel x coordinates for image display 
+            y_cont=[AY(1):-sizpy:AY(end)]; % pixel x coordinates for image display
+            txt=ver;%version of Matlab
+            Release=txt(1).Release;
+            relnumb=str2num(Release(3:4));
+            if relnumb >= 14
+                    vec=linspace(0,1,(abscontmax-abscontmin)/intercont);%define a greyscale colormap with steps intercont
+                map=[vec' vec' vec'];
+                colormap(map);
+                [var,hcontour]=contour(x_cont,y_cont,B,cont_pos);        
+                set(hcontour,'Fill','on')
+                set(hcontour,'LineStyle','none')
+                hold on
+            end
+            [var_p,hcontour_p]=contour(x_cont,y_cont,B,cont_pos_plus,'k-');
+            hold on
+            [var_m,hcontour_m]=contour(x_cont,y_cont,B,cont_pos_min,':');
+            set(hcontour_m,'LineColor',[1 1 1])
+            hold off
+            caxis([abscontmin abscontmax]) 
+            colormap(map);
+        end
+        if ~isequal(PlotParam.Scalar.Contours,1)       
+            % rescale the grey levels with min and max, put a grey scale colorbar
+            if (isfield(PlotParam.Scalar,'BW')& (isequal(PlotParam.Scalar.BW,1))|isa(A,'uint8')| isa(A,'uint16'))%images
+                B=A;
+                vec=linspace(0,1,255);%define a linear greyscale colormap
+                map=[vec' vec' vec'];
+                colormap(map);  %grey scale color map 
+            else
+                B=A;
+                colormap('default'); % standard faulse colors for div, vort , scalar fields 
+            end
+        end
+    elseif siz(2)==3 %color images
+        axes(haxes)
+        B=uint8(A); 
+        MinA=0;
+        MaxA=255;
+    end
+    if ~isequal(PlotParam.Scalar.Contours,1)
+        %interpolate to increase resolution
+        test_interp=1;
+        if max(np) <= 64 
+            npxy=8*np;% increase the resolution 8 times
+        elseif max(np) <= 128 
+            npxy=4*np;% increase the resolution 4 times
+        elseif max(np) <= 256 
+            npxy=2*np;% increase the resolution 2 times
+        else
+            npxy=np;
+            test_interp=0; % no interpolation done
+        end
+        if test_interp==1%if we interpolate              
+            x=linspace(AX(1),AX(2),np(2));
+            y=linspace(AY(1),AY(2),np(1));
+            [X,Y]=meshgrid(x,y);
+            xi=linspace(AX(1),AX(2),npxy(2));
+            yi=linspace(AY(1),AY(2),npxy(1));
+            B = interp2(X,Y,double(B),xi,yi');
+        end        
+        if isempty(hima)
+            tag=get(haxes,'Tag');
+            hima=imagesc(AX,AY,B,[MinA MaxA]);
+            set(hima,'Tag','ima','HitTest','off')
+            set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!)       
+        else
+            set(hima,'CData',B);
+            if MinA<MaxA
+                caxis([MinA MaxA])
+            else
+                caxis([MinA MinA+1])
+            end
+            set(hima,'XData',AX);
+            set(hima,'YData',AY);
+        end
+    end
+    if ~isstruct(AxeData)
+        AxeData=[];
+    end
+    AxeData.A=A;
+    AxeData.AX=[AX(1) AX(end)];
+    AxeData.AY=[AY(1) AY(end)];
+    test_ima=1;
+    %display the colorbar code for B/W images if Poscolorbar not empty
+    if siz(2)==2 & exist('PosColorbar','var')& ~isempty(PosColorbar)
+        if isempty(hcol)|~ishandle(hcol)
+             hcol=colorbar;%create new colorbar
+        end
+        if length(PosColorbar)==4
+                 set(hcol,'Position',PosColorbar)           
+        end 
+        YTick=0;%default
+        if MaxA>MinA
+            if isequal(PlotParam.Scalar.Contours,1)
+                colbarlim=get(hcol,'YLim');
+                scale_bar=(colbarlim(2)-colbarlim(1))/(abscontmax-abscontmin);                
+                YTick=cont_pos(2:end-1);
+                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
+                hi=get(hcol,'children');
+                if iscell(hi)%multiple images in colorbar
+                    hi=hi{1};
+                end
+                set(hi,'YData',[MinA MaxA])
+                set(hi,'CData',[1:256]')
+                set(hcol,'YLim',[MinA MaxA])
+                YTick=colbartick(MinA,MaxA);
+                set(hcol,'YTick',YTick)                
+            else
+                hi=get(hcol,'children');
+                if iscell(hi)%multiple images in colorbar
+                    hi=hi{1};
+                end
+                set(hi,'YData',[MinA MaxA])
+                set(hi,'CData',[1:64]')
+                YTick=colbartick(MinA,MaxA); 
+                set(hcol,'YLim',[MinA MaxA])
+                set(hcol,'YTick',YTick)
+            end
+            set(hcol,'Yticklabel',num2str(YTick'));
+        end
+    elseif ishandle(hcol)
+        delete(hcol); %erase existing colorbar if not needed 
+    end
+else%no scalar plot
+    if ~isempty(hima) && ishandle(hima) 
+        delete(hima)
+    end
+    if ~isempty(hcol)&& ishandle(hcol)
+       delete(hcol)
+    end
+    AxeData.A=[];
+    AxeData.AX=[];
+    AxeData.AY=[];
+    PlotParamOut=rmfield(PlotParamOut,'Scalar');
+end
+
+%%%%%%%%%%%%%%%%%%%%%   vector plot %%%%%%%%%%%%%%%%%%%%%%%%%%
+if test_vec
+   %vector scale representation
+    if size(vec_U,1)==numel(vec_Y) && size(vec_U,2)==numel(vec_X); % x, y  coordinate variables
+        [vec_X,vec_Y]=meshgrid(vec_X,vec_Y);
+    end   
+    vec_X=reshape(vec_X,1,numel(vec_X));%reshape in matlab vectors
+    vec_Y=reshape(vec_Y,1,numel(vec_Y));
+    vec_U=reshape(vec_U,1,numel(vec_U));
+    vec_V=reshape(vec_V,1,numel(vec_V));
+    MinMaxX=max(vec_X)-min(vec_X);
+    MinMaxY=max(vec_Y)-min(vec_Y);
+    AxeData.Mesh=sqrt((MinMaxX*MinMaxY)/length(vec_X));
+    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=[];
+        if test_false %remove false vectors
+            indsel=find(AxeData.FF==0);%indsel =indices of good vectors
+        else     
+            indsel=[1:numel(vec_X)];%
+        end
+        if isempty(vec_U)
+            scale=1;
+        else
+            if isempty(indsel)
+                MaxU=max(abs(vec_U));
+                MaxV=max(abs(vec_V));
+            else
+                MaxU=max(abs(vec_U(indsel)));
+                MaxV=max(abs(vec_V(indsel)));
+            end
+            scale=MinMaxX/(max(MaxU,MaxV)*50);
+            PlotParam.Vectors.VecScale=scale;%update the 'scale' display
+        end
+    else
+        scale=PlotParam.Vectors.VecScale;  %impose the length of vector representation
+    end;
+    
+    %record vectors on the plotting axes
+    if test_C==0
+        vec_C=ones(1,numel(vec_X));
+    end
+    AxeData.X=vec_X';
+    AxeData.Y=vec_Y';
+    AxeData.U=vec_U';
+    AxeData.V=vec_V';
+    AxeData.C=vec_C';
+    if isempty(ivar_F)
+        AxeData.F=[];
+    else
+        AxeData.F=vec_F';
+    end
+    if isempty(ivar_FF)
+        AxeData.FF=[];
+    else
+        AxeData.FF=vec_FF';
+    end
+%     if isfield(Data,'W')
+%         AxeData.W=Data.W;
+%     end
+    
+    %decimate by a factor 2 in vector mesh(4 in nbre of vectors)
+    if isfield(PlotParam.Vectors,'decimate4')&isequal(PlotParam.Vectors.decimate4,1)
+        diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
+        dy_thresh=max(abs(diffy))/2; 
+        ind_jump=find(abs(diffy) > dy_thresh); %indices with diff(vec_Y)> max/2, detect change of line
+        ind_sel=[1:ind_jump(1)];%select the first line
+        for i=2:2:length(ind_jump)-1
+            ind_sel=[ind_sel [ind_jump(i)+1:ind_jump(i+1)]];% select the odd lines
+        end
+        nb_sel=length(ind_sel);
+        ind_sel=ind_sel([1:2:nb_sel]);% take half the points on a line
+        vec_X=vec_X(ind_sel);
+        vec_Y=vec_Y(ind_sel);
+        vec_U=vec_U(ind_sel);
+        vec_V=vec_V(ind_sel);
+        vec_C=vec_C(ind_sel);
+        if ~isempty(ivar_F)
+           vec_F=vec_F(ind_sel);
+        end
+        if ~isempty(ivar_FF)
+           vec_FF=vec_FF(ind_sel);
+        end
+    end
+    
+    %get main level color code
+    [colorlist,col_vec,PlotParamOut.Vectors]=set_col_vec(PlotParam.Vectors,vec_C);
+    % take flags into account: add flag colors to the list of colors
+    sizlist=size(colorlist);
+    nbcolor=sizlist(1);
+    if test_black 
+       nbcolor=nbcolor+1;
+       colorlist(nbcolor,:)=[0 0 0]; %add black to the list of colors
+       if ~isempty(ivar_FF)
+            ind_flag=find(vec_F~=1 & vec_FF==0);  %flag warning but not false
+       else
+            ind_flag=find(vec_F~=1);
+       end
+       col_vec(ind_flag)=nbcolor;    
+    end
+    nbcolor=nbcolor+1;
+    if ~isempty(ivar_FF)
+        ind_flag=find(vec_FF~=0);
+        if isfield(PlotParam.Vectors,'HideFalse') && PlotParam.Vectors.HideFalse==1
+            colorlist(nbcolor,:)=[NaN NaN NaN];% no plot of false vectors
+        else
+            colorlist(nbcolor,:)=[1 0 1];% magenta color
+        end
+        col_vec(ind_flag)=nbcolor;
+    end
+    %plot vectors:
+    quiresetn(haxes,vec_X,vec_Y,vec_U,vec_V,scale,colorlist,col_vec);   
+else
+    hvec=findobj(haxes,'Tag','vel');
+    if ~isempty(hvec)
+        delete(hvec);
+    end
+    AxeData.X=[];
+    AxeData.Y=[];
+    AxeData.U=[];
+    AxeData.V=[];
+    AxeData.C=[];
+    AxeData.W=[];
+    AxeData.F=[];
+     AxeData.FF=[];
+    AxeData.Mesh=[];
+    PlotParamOut=rmfield(PlotParamOut,'Vectors');
+end
+if isfield(Data,'Z')
+    AxeData.Z=Data.Z;% A REVOIR
+end
+listfields={'AY','AX','A','X','Y','U','V','C','W','F','FF'};
+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=[];
+nbvar=0;
+AxeData.ListVarName={};
+AxeData.VarDimName={};
+AxeData.VarAttribute={};
+for ilist=1:numel(listfields)
+    eval(['testvar=isfield(AxeData,listfields{ilist}) && ~isempty(AxeData.' listfields{ilist} ');'])
+    if testvar
+        nbvar=nbvar+1;
+        AxeData.ListVarName{nbvar}=listfields{ilist};
+        AxeData.VarDimName{nbvar}=listdim{ilist};
+        AxeData.VarAttribute{nbvar}.Role=Role{ilist};
+    end
+end
+
+% adjust the size of the plot to include the whole field, except if KeepLim=1
+if ~(exist('KeepLim','var') && isequal(KeepLim,1))  %adjust the graph limits*
+        test_lim=0;
+        if test_vec
+            Xlim=[min(vec_X) max(vec_X)];
+            Ylim=[min(vec_Y) max(vec_Y)];
+            test_lim=1;
+            if test_ima%both background image and vectors coexist, take the wider bound
+                Xlim(1)=min(AX(1),Xlim(1));
+                Xlim(2)=max(AX(end),Xlim(2));
+                Ylim(1)=min(AY(end),Ylim(1));
+                Ylim(2)=max(AY(1),Ylim(2));
+            end
+        elseif test_ima %only image plot
+            Xlim(1)=min(AX(1),AX(end));
+            Xlim(2)=max(AX(1),AX(end));
+            Ylim(1)=min(AY(1),AY(end));
+            Ylim(2)=max(AY(1),AY(end));
+            test_lim=1;
+        end 
+        if test_lim
+            set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates
+            set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
+        end
+end
+if ~(isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1))
+     set(haxes,'DataAspectRatio',[1 1 1])
+end
+set(haxes,'YDir','normal') 
+set(get(haxes,'XLabel'),'String',[XName x_units]);
+set(get(haxes,'YLabel'),'String',[YName y_units]);
+%---------------------------------------------
+%function for plotting vectors
+%------------------------------------------------
+%INPUT:
+% haxes: handles of the plotting axes
+%x,y,u,v: vectors coordinates and vector components to plot, arrays withb the same dimension
+% scale: scaling factor for vector length representation
+%colorlist(icolor,:): list of vector colors, dim (nbcolor,3), depending on color #i
+%col_vec: matlab vector setting the color number #i for each velocity vector
+function quiresetn(haxes,x,y,u,v,scale,colorlist,col_vec)
+
+%define arrows
+theta=0.5 ;%angle arrow
+alpha=0.3 ;%length arrow
+rot=alpha*[cos(theta) -sin(theta); sin(theta) cos(theta)]';
+%find the existing lines
+%h=findobj(gca,'Type','Line');% search existing lines in the current axes
+h=findobj(haxes,'Tag','vel');% search existing lines in the current axes
+sizh=size(h);
+set(h,'EraseMode','xor');
+set(haxes,'NextPlot','replacechildren');
+%htext=findobj('Tag','scalevec');
+      
+%drawnow
+%create lines (if no lines) or modify them
+if ~isequal(size(col_vec),size(x))
+    col_vec=ones(size(x));% case of error in col_vec input
+end
+sizlist=size(colorlist);
+ncolor=sizlist(1);
+
+for icolor=1:ncolor
+    %determine the line positions for each color icolor 
+    ind=find(col_vec==icolor);
+    xc=x(ind);
+    yc=y(ind);
+    uc=u(ind)*scale;
+    vc=v(ind)*scale;
+    n=size(xc);
+    xN=NaN*ones(size(xc));
+    matx=[xc(:) xc(:)+uc(:) xN(:)]';
+    matx=reshape(matx,1,3*n(2));
+    maty=[yc(:) yc(:)+vc(:) xN(:)]';
+    maty=reshape(maty,1,3*n(2));
+    
+    %determine arrow heads
+    arrowplus=rot*[uc;vc];
+    arrowmoins=rot'*[uc;vc];
+    x1=xc+uc-arrowplus(1,:);
+    x2=xc+uc;
+    x3=xc+uc-arrowmoins(1,:);
+    y1=yc+vc-arrowplus(2,:);
+    y2=yc+vc;
+    y3=yc+vc-arrowmoins(2,:);
+    matxar=[x1(:) x2(:) x3(:) xN(:)]';
+    matxar=reshape(matxar,1,4*n(2));
+    matyar=[y1(:) y2(:) y3(:) xN(:)]';
+    matyar=reshape(matyar,1,4*n(2));
+    %draw the line or modify the existing ones
+    isn=isnan(colorlist(icolor,:));%test if color NaN
+    if 2*icolor > sizh(1) %if icolor exceeds the number of existing ones
+        axes(haxes)
+        if ~isn(1) %if the vectors are visible color not nan
+            if n(2)>0
+                hold on
+                line(matx,maty,'Color',colorlist(icolor,:),'Tag','vel');% plot new lines
+                line(matxar,matyar,'Color',colorlist(icolor,:),'Tag','vel');% plot arrows
+            end
+        end
+    else
+        if isn(1) 
+            delete(h(2*icolor-1))
+            delete(h(2*icolor))
+        else
+            set(h(2*icolor-1),'Xdata',matx,'Ydata',maty);
+            set(h(2*icolor-1),'Color',colorlist(icolor,:));
+            set(h(2*icolor-1),'EraseMode','xor');
+            set(h(2*icolor),'Xdata',matxar,'Ydata',matyar);
+            set(h(2*icolor),'Color',colorlist(icolor,:));
+            set(h(2*icolor),'EraseMode','xor');
+        end
+     end
+end
+if sizh(1) > 2*ncolor
+    for icolor=ncolor+1 : sizh(1)/2%delete additional objects
+        delete(h(2*icolor-1))
+        delete(h(2*icolor))
+    end
+end
+
+%---------------------------------------
+%determine tick positions for colorbar
+%------------------------------------
+function YTick=colbartick(MinA,MaxA)
+%determine tick positions with "simple" values between MinA and MaxA
+YTick=0;%default
+maxabs=max([abs(MinA) abs(MaxA)]);
+if maxabs>0 
+ord=10^(floor(log10(maxabs)));%order of magnitude
+div=1;
+siz2=1;
+while siz2<2
+%     values=[-9:div:9];
+    values=-10:div:10;
+    ind=find((ord*values-MaxA)<0 & (ord*values-MinA)>0);%indices of 'values' such that MinA<ord*values<MaxA
+    siz=size(ind);
+    if siz(2)<4%if there are less than 4 selected values (4 levels)
+        values=[-9:0.5*div:9];
+        ind=find((ord*values-MaxA)<0 & (ord*values-MinA)>0);
+    end
+    siz2=size(ind,2);
+%     siz2=siz(2)
+    div=div/10;
+end
+YTick=ord*values(ind);
+end
Index: /trunk/src/private/plot_object.m
===================================================================
--- /trunk/src/private/plot_object.m	(revision 8)
+++ /trunk/src/private/plot_object.m	(revision 8)
@@ -0,0 +1,408 @@
+%'plot_object': draws a projection object (points, line, plane...)
+%-------------------------------------------------------------------
+% function [ObjectData_out,hh]=plot_object(ObjectData,hplot,col)
+%
+%OUTPUT
+%             hh: handles of the graphic object (core part)
+%
+%INPUT:
+%
+% ObjectDataIn: structure representing the object properties:
+%        .Style : style of projection object
+%        .Coord: set of coordinates defining the object position;
+%        .ProjMode=type of projection ;
+%       .ProjAngle=angle of projection;
+%       .DX,.DY,.DZ=increments;
+%       .YMax,YMin: min and max Y
+% ProjObject: projection object corresponding to the current plot (e. g. plane) 
+% hplot: handle of the object plot to modify or if it is an axis, the axis
+%            where the object must be plotted, or if it is a figure the plotting figure 
+% col: color of the plot, e;g; 'm', 'b' ..;
+
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function [hh]=plot_object(ObjectDataIn,ProjObject,hplot,col)
+hh=[];%default output
+if isequal(ProjObject,ObjectDataIn)% object representation does not appear in its own projection plot
+    return
+end
+if ~isfield(ProjObject,'Style') 
+    ObjectData=ObjectDataIn;
+elseif isequal(ProjObject.Style,'plane')
+    ObjectData=ObjectDataIn;% TODO: modify take into account rotation of axis
+else
+    return % no object representation yet available
+end
+if ~isfield(ObjectData,'Style')|isempty(ObjectData.Style)|~ischar(ObjectData.Style)
+    warndlg_uvmat('undefined ObjectData.Style in plot_object.m','ERROR')
+    return
+end
+if ~isfield(ObjectData,'Style')|isempty(ObjectData.Style)|~ischar(ObjectData.Style)
+    warndlg_uvmat('undefined ObjectData.Style in plot_object.m','ERROR')
+    return
+end
+XMin=0;%default
+XMax=0;
+YMin=0;
+YMax=0;
+ZMin=0;
+ZMax=0;
+
+%determine the plotting axes (with handle 'haxes')
+test_newobj=1;
+if ishandle(hplot)
+    if isequal(get(hplot,'Tag'),'proj_object')  
+        test_newobj=0;
+        haxes=get(hplot,'parent');
+    elseif isequal(get(hplot,'Type'),'axes')
+        axes(hplot)
+        haxes=hplot;
+    elseif isequal(get(hplot,'Type'),'figure')
+        figure(hplot);%set the input figure as the current one
+        haxes=findobj(hplot,'Type','axes');%look for axes in the figure
+        haxes=haxes(1);
+        axes(haxes); %set the first found axis as the current one
+    else
+        figure; %create new figure
+        hplot=axes;%create new axes
+        haxes=hplot;
+    end
+else
+    figure; %create new figure
+    hplot=axes;%create new axes
+    haxes=hplot;
+end
+
+%default input parameters
+if ~isfield(ObjectData,'ProjMode')|isempty(ObjectData.ProjMode)
+     ObjectData.ProjMode='projection';%default
+end
+if ~isfield(ObjectData,'Coord')|isempty(ObjectData.Coord)
+     ObjectData.Coord=[0 0 0];%default
+end
+if ~isfield(ObjectData,'Phi')|isempty(ObjectData.Phi)
+     ObjectData.Phi=0;%default
+end
+if ~isfield(ObjectData,'Range')
+    ObjectData.Range(1,1)=0; %edfault
+end
+if size(ObjectData.Range,2)>=2
+    YMax=ObjectData.Range(1,2);%default
+end
+if size(ObjectData.Range,2)>=2 & size(ObjectData.Range,1)>=2
+    YMin=ObjectData.Range(2,2);
+else
+    YMin=0;
+end
+XMax=ObjectData.Range(1,1);
+if size(ObjectData.Range,1)>=2 
+    XMin=ObjectData.Range(2,1);
+end
+if isfield(ObjectData,'RangeX')
+   XMax=max(ObjectData.RangeX);
+   XMin=min(ObjectData.RangeX);
+end
+if isfield(ObjectData,'RangeY')
+   YMax=max(ObjectData.RangeY);
+   YMin=min(ObjectData.RangeY);
+end
+if isfield(ObjectData,'RangeZ')
+   ZMax=max(ObjectData.RangeZ);
+   ZMin=min(ObjectData.RangeZ);
+end
+if isequal(ObjectData.Style,'points')&isequal(ObjectData.ProjMode,'projection')
+    YMax=max(XMax,YMax);
+    YMax=max(YMax,ZMax);
+elseif isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'ellipse')|isequal(ObjectData.Style,'volume')
+    if  isequal(YMax,0)
+        ylim=get(haxes,'YLim');
+        YMax=(ylim(2)-ylim(1))/100;
+    end
+    if isequal(XMax,0)
+        XMax=YMax;%default
+    end
+elseif isequal(ObjectData.Style,'plane')
+   if  isequal(XMax,0)
+        xlim=get(haxes,'XLim');
+        XMax=xlim(2);
+   end
+   if  isequal(YMax,0)
+        ylim=get(haxes,'YLim');
+        YMax=ylim(2);
+   end
+end
+sizcoord=size(ObjectData.Coord);
+
+%determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot
+test_line= isequal(ObjectData.Style,'points')|isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|...
+    isequal(ObjectData.Style,'polygon')| isequal(ObjectData.Style,'plane')| isequal(ObjectData.Style,'volume');
+test_patch=isequal(ObjectData.ProjMode,'inside')||isequal(ObjectData.ProjMode,'outside')||isequal(ObjectData.Style,'volume')...
+    ||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside');
+if test_line
+    xline=ObjectData.Coord(:,1);
+    yline=ObjectData.Coord(:,2);
+    if isequal(ObjectData.Style,'polygon')
+        xline=[xline; ObjectData.Coord(1,1)];%closing the line
+        yline=[yline; ObjectData.Coord(1,2)];
+    elseif isequal(ObjectData.Style,'plane')| isequal(ObjectData.Style,'volume') 
+        phi=ObjectData.Phi*pi/180;%angle in radians
+        Xend_x=xline(1)+XMax*cos(phi);
+        Xend_y=yline(1)+XMax*sin(phi);
+        Xbeg_x=xline(1)+XMin*cos(phi);
+        Xbeg_y=yline(1)+XMin*sin(phi);
+        Yend_x=xline(1)-YMax*sin(phi);
+        Yend_y=yline(1)+YMax*cos(phi);
+        Ybeg_x=xline(1)-YMin*sin(phi);
+        Ybeg_y=yline(1)+YMin*cos(phi);
+        xline=[Xbeg_x Xend_x NaN Ybeg_x Yend_x];
+        yline=[Xbeg_y Xend_y NaN Ybeg_y Yend_y];
+    end
+    SubLineStyle='none';%default
+    if isfield(ObjectData,'ProjMode')
+        if isequal(ObjectData.ProjMode,'projection')
+            SubLineStyle='--'; %range of projection marked by dash
+            if isfield (ObjectData,'DX')
+               rmfield(ObjectData,'DX');
+            end
+            if isfield (ObjectData,'DY')
+               rmfield(ObjectData,'DY');
+            end
+        elseif isequal(ObjectData.ProjMode,'filter')
+            SubLineStyle=':';%range of projection not visible
+        end
+    end 
+    if isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|isequal(ObjectData.Style,'polygon')
+        if length(xline)<2
+            theta=0;
+        else
+            theta=angle(diff(xline)+i*diff(yline));
+            theta(length(xline))=theta(length(xline)-1);
+        end
+        xsup(1)=xline(1)+YMax*sin(theta(1));
+        xinf(1)=xline(1)-YMax*sin(theta(1));
+        ysup(1)=yline(1)-YMax*cos(theta(1));
+        yinf(1)=yline(1)+YMax*cos(theta(1));
+        for ip=2:length(xline)
+            xsup(ip)=xline(ip)+YMax*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
+            xinf(ip)=xline(ip)-YMax*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
+            ysup(ip)=yline(ip)-YMax*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
+            yinf(ip)=yline(ip)+YMax*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
+        end
+    end
+end
+
+%shading image
+if test_patch
+    npMx=512;
+    npMy=512;  
+    flag=zeros(npMy,npMx);
+    if isequal(ObjectData.Style,'ellipse')
+        XimaMin=ObjectData.Coord(1,1)-XMax;
+        XimaMax=ObjectData.Coord(1,1)+XMax;
+        YimaMin=ObjectData.Coord(1,2)-YMax;
+        YimaMax=ObjectData.Coord(1,2)+YMax; 
+        xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];%create an image around the ellipse
+        ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
+        scale_x=2*1.4*XMax/npMx;
+        scale_y=2*1.4*YMax/npMy;
+        xi=[0.5:npMx-0.5]*scale_x+xlim(1);
+        yi=[0.5:npMy-0.5]*scale_y+ylim(1);
+        [Xi,Yi]=meshgrid(xi,yi);
+        X2Max=XMax*XMax;
+        Y2Max=YMax*YMax;
+        distX=(Xi-ObjectData.Coord(1,1));
+        distY=(Yi-ObjectData.Coord(1,2));
+        flag=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;
+    elseif isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'volume')
+        XimaMin=ObjectData.Coord(1,1)-XMax;
+        XimaMax=ObjectData.Coord(1,1)+XMax;
+        YimaMin=ObjectData.Coord(1,2)-YMax;
+        YimaMax=ObjectData.Coord(1,2)+YMax; 
+        xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];%create an image around the ellipse
+        ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
+        scale_x=2*1.4*XMax/npMx;
+        scale_y=2*1.4*YMax/npMy;
+        xi=[0.5:npMx-0.5]*scale_x+xlim(1);
+        yi=[0.5:npMy-0.5]*scale_y+ylim(1);
+        [Xi,Yi]=meshgrid(xi,yi);
+        distX=abs(Xi-ObjectData.Coord(1,1));
+        distY=abs(Yi-ObjectData.Coord(1,2));
+        flag=distX<XMax & distY< YMax;
+    elseif isequal(ObjectData.Style,'polygon')
+        XimaMin=min(ObjectData.Coord(:,1));
+        XimaMax=max(ObjectData.Coord(:,1));
+        YimaMin=min(ObjectData.Coord(:,2));
+        YimaMax=max(ObjectData.Coord(:,2)); 
+        xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];
+        ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
+        [Xlim,Ylim]=meshgrid(linspace(xlim(1),xlim(2),npMx),linspace(ylim(1),ylim(2),npMy));
+        %flag=roipoly(xlim,ylim,flag,ObjectData.Coord(:,1),ObjectData.Coord(:,2));%=1 inside the polygon, 0 outsid
+        flag=inpolygon(Xlim,Ylim,ObjectData.Coord(:,1),ObjectData.Coord(:,2));%=1 inside the polygon, 0 outsid
+    end 
+    if isequal(ObjectData.ProjMode,'outside')||isequal(ObjectData.ProjMode,'mask_outside')
+        flag=~flag;
+    end
+    imflag=zeros(npMx,npMy,3);
+    imflag(:,:,3)=flag; % blue color
+    if isequal(col,'m')
+         imflag(:,:,1)=flag; % magenta color
+    end
+    dx=(xlim(2)-xlim(1))/npMx;
+    dy=(ylim(2)-ylim(1))/npMy;
+end
+
+PlotData=[];%default
+%MODIFY AN EXISTING OBJECT PLOT
+if test_newobj==0;
+    hh=hplot;
+    PlotData=get(hplot,'UserData');            
+    if test_line
+        set(hplot,'XData',xline)
+        set(hplot,'YData',yline)
+    %modify subobjects
+        if isfield(PlotData,'SubObject') 
+           if length(PlotData.SubObject)==2 && ~isequal(ObjectData.Style,'points')&& ~isequal(ObjectData.Style,'plane');
+                set(PlotData.SubObject(1),'XData',xinf);
+                set(PlotData.SubObject(1),'YData',yinf);
+                set(PlotData.SubObject(2),'XData',xsup);
+                set(PlotData.SubObject(2),'YData',ysup);
+           elseif isequal(ObjectData.Style,'points')&& ~isequal(YMax,0)
+               for ipt=1:min(length(PlotData.SubObject),size(ObjectData.Coord,1))
+                    set(PlotData.SubObject(ipt),'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax])
+               end
+               %complement missing points
+               if size(ObjectData.Coord,1)>length(PlotData.SubObject)
+                   for ipt=length(PlotData.SubObject)+1:size(ObjectData.Coord,1)
+                     PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
+                  'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
+                  'LineStyle',SubLineStyle,'Tag','proj_object');
+                   end
+               end                                         
+           end
+        end
+        if isfield(PlotData,'DeformPoint')
+           for ipt=1:length(PlotData.DeformPoint)
+               if ishandle(PlotData.DeformPoint(ipt))
+                   if length(xline)>=ipt &   length(yline)>=ipt    
+                        set(PlotData.DeformPoint(ipt),'XData',xline(ipt),'YData',yline(ipt));
+                    end
+               end
+           end
+           if length(xline)>length(PlotData.DeformPoint)
+               for ipt=length(PlotData.DeformPoint)+1:length(xline)
+                    PlotData.DeformPoint(ipt)=line(xline(ipt),yline(ipt),'Color',col,'LineStyle','.','Tag','DeformPoint',...
+                        'SelectionHighlight','off','UserData',hplot);
+               end
+               set(hplot,'UserData',PlotData)
+           end
+        end
+    elseif isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'ellipse')
+        set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax])          
+    end
+    if test_patch 
+        for iobj=1:length(PlotData.SubObject)
+            objtype=get(PlotData.SubObject(iobj),'Type');
+            if isequal(objtype,'image')
+                set(PlotData.SubObject(iobj),'CData',imflag,'AlphaData',(flag)*0.2)
+                set(PlotData.SubObject(iobj),'XData',[xlim(1)+dx/2 xlim(2)-dx/2])
+                set(PlotData.SubObject(iobj),'YData',[ylim(1)+dy/2 ylim(2)-dy/2])
+            end
+        end
+    end
+end
+
+%create the object
+if test_newobj
+    axes(haxes)
+    hother=findobj('Tag','proj_object');%find all the proj objects
+    for iobj=1:length(hother)
+        if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
+            set(hother(iobj),'EdgeColor','b')
+            if isequal(get(hother(iobj),'FaceColor'),'m')
+                set(hother(iobj),'FaceColor','b')
+            end
+        elseif isequal(get(hother(iobj),'Type'),'image')
+               Acolor=get(hother(iobj),'CData');
+               Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
+               set(hother(iobj),'CData',Acolor);
+        else
+             set(hother(iobj),'Color','b')
+        end
+        set(hother(iobj),'Selected','off')
+    end
+    hother=findobj('Tag','DeformPoint');
+    set(hother,'Color','b');
+    set(hother,'Selected','off')  
+    if isequal(ObjectData.Style,'points')
+        hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color',col,'LineStyle','.','Marker','+');
+        for ipt=1:length(xline)
+              PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
+                  col,'LineStyle','.','SelectionHighlight','off','UserData',hh,'Tag','DeformPoint');
+              %create circle around each point
+              if ~isequal(YMax,0)
+                 PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
+                  'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
+                  'LineStyle',SubLineStyle,'Tag','proj_object');
+              end
+        end
+    elseif  isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|...        
+          isequal(ObjectData.Style,'polygon') |isequal(ObjectData.Style,'plane')|isequal(ObjectData.Style,'volume')%  (isequal(ObjectData.Style,'polygon') & ~test_patch) |isequal(ObjectData.Style,'plane')
+        hh=line(xline,yline,'Color',col);
+        if ~isequal(ObjectData.Style,'plane')& ~isequal(ObjectData.Style,'volume')
+            for ipt=1:sizcoord(1)
+                PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
+                      col,'LineStyle','none','Marker','.','Tag','DeformPoint','SelectionHighlight','off','UserData',hh);
+            end
+            PlotData.SubObject(1)=line(xinf,yinf,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');%draw sub-lines
+            PlotData.SubObject(2)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
+        end
+    
+    elseif isequal(ObjectData.Style,'rectangle')
+        hh=rectangle('Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col);   
+    elseif isequal(ObjectData.Style,'ellipse')
+        hh=rectangle('Curvature',[1 1],'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col);
+    else
+        warndlg_uvmat('unknown ObjectData.Style in plot_object.m','ERROR')
+        return
+    end
+    set(hh,'Tag','proj_object')
+    %set(hh,'UserData',ObjectData)%
+%         hh=hplot;
+%     set(hh,'DeleteFcn',@deletefcn)
+%     if isequal(ObjectData.ProjMode,'inside')
+%          if isequal(ObjectData.Style,'ellipse')|isequal(ObjectData.Style,'rectangle')
+%             set(hh,'FaceColor',col)
+%             set(hh,'EdgeColor',col)
+%          end
+%     end
+    if test_patch
+        hold on
+        hhh=image([xlim(1)+dx/2 xlim(2)-dx/2],[ylim(1)+dy/2 ylim(2)-dy/2],imflag,'Tag','proj_object','HitTest','off');
+        set(hhh,'AlphaData',(flag)*0.2)
+        PlotData.SubObject=hhh;    
+    end
+    if isfield(PlotData,'SubObject')
+        set(PlotData.SubObject,'UserData',hh)%record the parent handles in the SubObjects
+    end
+    if isfield(PlotData,'DeformPoint')
+        for ipt=1:sizcoord(1)
+            set(PlotData.DeformPoint(ipt),'UserData',hh);%record the parent handles in the SubObjects
+        end
+        set(PlotData.DeformPoint,'UserData',hh)%record the parent handles in the SubObjects
+    end
+end
+set(hh,'UserData',PlotData)
Index: /trunk/src/private/plot_text.m
===================================================================
--- /trunk/src/private/plot_text.m	(revision 8)
+++ /trunk/src/private/plot_text.m	(revision 8)
@@ -0,0 +1,86 @@
+%'plot_text': function for displaying the content of a Matlab structure in a figure
+%------------------------------------------------------------------------
+% function hdisplay=plot_text(FieldData,hdisplay_in)
+%
+% OUTPUT:
+% hdisplay: handle of the display edit box
+%
+%  INPUT: 
+% FieldData: input Matlab structure
+% hdisplay_in: handles of the display box, if it is not defined create a new figure
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function hdisplay=plot_text(FieldData,hdisplay_in)
+
+if exist('hdisplay_in','var') & ishandle(hdisplay_in) & isequal(get(hdisplay_in,'Type'),'uicontrol')
+    hdisplay=hdisplay_in;
+else
+    figure;%create new figure
+    hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced');
+end
+    
+ff=fields(FieldData);%list of field names
+vv=struct2cell(FieldData);%list of field values
+
+for icell=1:length(vv)
+    Tabcell{icell,1}=ff{icell};
+    ss=vv{icell};
+    sizss=size(ss);
+    if isnumeric(ss)
+        if sizss(1)<=1 & length(ss)<5
+            displ{icell}=num2str(ss);
+        else
+            displ{icell}=[class(ss) ', size ' num2str(size(ss))];
+        end
+    elseif ischar(ss)
+        displ{icell}=ss;
+    elseif iscell(ss)
+        sizcell=size(ss);
+        if sizcell(1)==1 & length(sizcell)==2 %line cell
+           ssline='{''';
+           for icolumn=1:sizcell(2)
+               if isnumeric(ss{icolumn})
+                   if size(ss{icolumn},1)<=1 & length(ss{icolumn})<5
+                      sscolumn=num2str(ss{icolumn});%line vector
+                   else
+                      sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))];
+                   end
+               elseif ischar(ss{icolumn})
+                   sscolumn=ss{icolumn};
+               else
+                   sscolumn=class(ss{icolumn});
+               end
+               if icolumn==1
+                   ssline=[ssline sscolumn];
+               else
+                   ssline=[ssline ''',''' sscolumn];
+               end
+           end
+           displ{icell}=[ssline '''}'];
+        else
+           displ{icell}=[class(ss) ', size ' num2str(sizcell)];
+        end
+    else
+        displ{icell}=class(ss);
+    end
+    Tabcell{icell,2}=displ{icell};
+end 
+Tabchar=cell2tab(Tabcell,': '); 
+set(hdisplay,'String', Tabchar)
+
+
Index: /trunk/src/private/probe_calib.m
===================================================================
--- /trunk/src/private/probe_calib.m	(revision 8)
+++ /trunk/src/private/probe_calib.m	(revision 8)
@@ -0,0 +1,877 @@
+%'probe_calib': performs geometric calibration from a set of reference points
+function varargout = probe_calib(varargin)
+% PROBE_CALIB M-file for probe_calib.fig
+%      PROBE_CALIB, by itself, creates a MenuCoord PROBE_CALIB or raises the existing
+%      singleton*.
+%
+%      H = PROBE_CALIB returns the handle to a MenuCoord PROBE_CALIB or the handle to
+%      the existing singleton*.
+%
+%      PROBE_CALIB('CALLBACK',hObject,eventData,handles,...) calls the local
+%      function named CALLBACK in PROBE_CALIB.M with the given input arguments.
+%
+%      PROBE_CALIB('Property','Value',...) creates a MenuCoord PROBE_CALIB or raises the
+%      existing singleton*.  Starting from the left, property value pairs are
+%      applied to the GUI before probe_calib_OpeningFunction gets called.  An
+%      unrecognized property name or invalid value makes property application
+%      stop.  All inputs are passed to probe_calib_OpeningFcn via varargin.
+%
+%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
+%      instance to run (singleton)".
+%
+% See also: GUIDE, GUIDATA, GUIHANDLES
+
+% Edit the above text to modify the response to help probe_calib
+
+% Last Modified by GUIDE v2.5 04-Feb-2008 15:46:42
+
+% Begin initialization code - DO NOT EDIT
+gui_Singleton = 1;
+gui_State = struct('gui_Name',       mfilename, ...
+                   'gui_Singleton',  gui_Singleton, ...
+                   'gui_OpeningFcn', @probe_calib_OpeningFcn, ...
+                   'gui_OutputFcn',  @probe_calib_OutputFcn, ...
+                   'gui_LayoutFcn',  [] , ...
+                   'gui_Callback',   []);
+if nargin & isstr(varargin{1})
+    gui_State.gui_Callback = str2func(varargin{1});
+end
+
+if nargout
+    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
+else
+    gui_mainfcn(gui_State, varargin{:});
+end
+% End initialization code - DO NOT EDIT
+
+
+% --- Executes just before probe_calib is made visible.
+%INPUT: 
+%handles: handles of the probe_calib interface elements
+% PlotHandles: set of handles of the elements contolling the plotting
+% parameters on the uvmat interface (obtained by 'get_plot_handle.m')
+function probe_calib_OpeningFcn(hObject, eventdata, handles, data,pos,inputfile)
+
+% Choose default command line output for probe_calib
+handles.output = hObject;
+
+% Update handles structure
+guidata(hObject, handles);
+
+%default
+% set(hObject,'Unit','Normalized')% set the unit normalized to the screen size
+% set(hObject,'Position',[0.7 0.1 0.25 0.5])%set the position of the probe_calib interface 
+set(hObject,'DeleteFcn',@closefcn)
+
+%set the position of the interface
+if exist('pos','var')& length(pos)>2
+    pos_gui=get(hObject,'Position');
+    pos_gui(1)=pos(1);
+    pos_gui(2)=pos(2);
+    set(hObject,'Position',pos_gui);
+end
+% set(handles.XImage,'String','')
+% set(handles.YImage,'String','')
+% set(handles.XObject,'String','')
+% set(handles.YObject,'String','')
+% set(handles.ZObject,'String','')
+inputxml='';
+if exist('inputfile','var')& ~isempty(inputfile)
+    [Path,Name,ext]=fileparts(inputfile);
+    if isequal(ext,'.png')
+        set(hObject,'UserData',inputfile)
+        [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(inputfile);
+        inputxml=[fullfile(Pathsub,RootFile) '.xml'];
+    end   
+end
+if exist(inputxml,'file')
+    loadfile(handles,inputxml)
+end
+set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
+
+
+% --- Outputs from this function are returned to the command line.
+function varargout = probe_calib_OutputFcn(hObject, eventdata, handles)
+% varargout  cell array for returning output args (see VARARGOUT);
+% hObject    handle to figure
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Get default command line output from handles structure
+varargout{1} = handles.output;
+varargout{2}=handles;
+
+%------------
+function Phi_Callback(hObject, eventdata, handles)
+
+
+%-----------------------------------------------------
+% --- Executes on button press in import.
+function import_Callback(hObject, eventdata, handles)
+%get the object file 
+huvmat=findobj('Tag','uvmat');
+UvData=get(huvmat,'UserData');
+hchild=get(huvmat,'Children');
+hrootpath=findobj(hchild,'Tag','RootPath');
+oldfile=get(hrootpath,'String');
+if isempty(oldfile)
+    oldfile='';
+end
+%[FileName,PathName] = uigetfile('*.civ','Select a .civ file',oldfile)
+[FileName, PathName, filterindex] = uigetfile( ...
+       {'*.xml;*.mat', ' (*.xml,*.mat)';
+       '*.xml',  '.xml files '; ...
+        '*.mat',  '.mat matlab files '}, ...
+        'Pick a file',oldfile);
+fileinput=[PathName FileName];%complete file name 
+testblank=findstr(fileinput,' ');%look for blanks
+if ~isempty(testblank)
+    warndlg_uvmat('forbidden input file name or path: no blank character allowed','ERROR')
+    return
+end
+sizf=size(fileinput);
+if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
+loadfile(handles,fileinput)
+
+%--------------------------------------------------
+%read input xml file and update the edit boxes
+function loadfile(handles,fileinput)
+
+%read the input xml file
+t=xmltree(fileinput);
+s=convert(t);%convert to matlab structure
+
+%read data currently displayed on the interface
+PointCoord=[];
+data=read_probe_calib(handles);
+Coord=[]; %default
+if isfield(data,'Coord')
+    Coord=data.Coord;
+end
+TabChar_0=get(handles.ListCoord,'String');
+nbcoord_0=size(TabChar_0,1);
+if isequal(get(handles.edit_append,'Value'),1) %edit mode
+    val=get(handles.ListCoord,'Value')-1;
+else
+   val=length(TabChar_0); 
+end
+nbcoord=0;
+
+%case of calibration (ImaDoc) input file
+if isfield(s,'GeometryCalib')
+    Calib=s.GeometryCalib;
+    if isfield(Calib,'SourceCalib')
+        if isfield(Calib.SourceCalib,'PointCoord')
+            PointCoord=Calib.SourceCalib.PointCoord;
+        end
+        if isfield(Calib.SourceCalib,'ImageCalib')
+            hcalib=get(handles.import,'parent');
+            set(hcalib,'UserData',Calib.SourceCalib.ImageCalib);%store the source image name in the interface 'UserData'
+        end
+    end
+    nbcoord=length(PointCoord);
+    if ~isfield(Calib,'ErrorRms')&~isfield(Calib,'ErrorMax') %old convention of Gauthier (cord in mm)
+        for i=1:length(PointCoord)
+          line=str2num(PointCoord{i});
+          Coord(i+val,4:5)=line(4:5);%px x
+          Coord(i+val,1:3)=line(1:3)/10;%phys x
+        end
+    else
+        for i=1:length(PointCoord)
+          line=str2num(PointCoord{i});
+          Coord(i,4:5)=line(4:5);%px x
+          Coord(i,1:3)=line(1:3);%phys x
+       end
+    end
+end
+
+%case of xml files of points 
+if isfield(s,'Coord')
+    PointCoord=s.Coord;
+    nbcoord=length(PointCoord);
+     %case of image coordinates
+    if isfield(s,'CoordType')& isequal(s.CoordType,'px')
+        for i=1:nbcoord
+           line=str2num(PointCoord{i});
+           Coord(i+val,4:5)=line(1:2);
+        end
+     %case of  physical coordinates
+    else
+        for i=1:nbcoord
+           line=str2num(PointCoord{i})
+           Coord(i+val,1:3)=line(1:3);
+           nbcolumn=size(Coord,2);
+           if nbcolumn<5
+               Coord(i+val,nbcolumn+1:5)=zeros(1,5-nbcolumn);
+           end
+        end
+     end
+end
+CoordCell={};
+for iline=1:size(Coord,1)
+    for j=1:5
+        CoordCell{iline,j}=num2str(Coord(iline,j));
+    end
+end
+        
+Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
+set(handles.ListCoord,'Value',1)
+set(handles.ListCoord,'String',Tabchar)
+
+
+%----------------------------------------------------
+% executed when closing: set the parent interface button to value 0
+function closefcn(gcbo,eventdata)
+SetData=get(gcbf,'UserData');
+if isfield(SetData,'ParentButton') & ishandle(SetData.ParentButton)
+    set(SetData.ParentButton, 'Value',0)
+end
+
+%-----------------------------------------------------------------------
+% --- Executes on button press in edit: PLOT the defined object and its projected field
+function edit_Callback(hObject, eventdata, handles)
+%hsetobject=get(hObject,'parent');
+%SetData=get(hsetobject,'UserData');%get the hidden interface data
+%IndexObj=SetData.IndexObj;%index of the current projection object in the list of projection objects (UvData.ProjObject)
+huvmat=findobj(allchild(0),'name','uvmat');%find the current uvmat interface handle
+UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
+hplot=findobj(huvmat,'Tag','axes3');
+h_menu_coord=findobj(huvmat,'Tag','menu_coord');
+menu=get(h_menu_coord,'String');
+choice=get(h_menu_coord,'Value');
+if iscell(menu)
+    option=menu{choice};
+else
+    option='px'; %default
+end
+%get axis
+%get CoordType
+ObjectData=read_probe_calib(handles);%read the interface input parameters defining the object
+if isequal(option,'phys')
+    ObjectData.Coord=ObjectData.Coord(:,[1:3]);
+elseif isequal(option,'px')
+    ObjectData.Coord=ObjectData.Coord(:,[4:5]);
+else
+    errordlg('the choice in coord_coord must be px or phys ')
+end
+% [UvData,IndexObj]=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles);
+% SetData.IndexObj=IndexObj;
+% set(gcbf,'UserData',SetData)%update object index in the probe_calib interface
+% set(huvmat,'UserData',UvData)%update the data in the uvmat interface
+ObjectData.ProjMode='none';
+plot_object(ObjectData,[],hplot,'b');
+
+
+% --- Executes on button press in MenuCoord.
+function MenuCoord_Callback(hObject, eventdata, handles)
+
+
+% --- Executes on button press in delete.
+function delete_Callback(hObject, eventdata, handles)
+SetData=get(gcbf,'UserData');%get the interface data
+IndexObj=SetData.IndexObj;
+delete_object(IndexObj);
+
+% --- Executes on button press in calibrate_lin.
+function calib_offset_Callback(hObject, eventdata, handles)
+Object=read_probe_calib(handles);
+
+%make linear calibration
+% 'calibration_lin' provides a linear transform on coordinates, 
+X=Object.Coord(:,1);
+Y=Object.Coord(:,2);
+x_ima=Object.Coord(:,4);
+y_ima=Object.Coord(:,5);
+[px,sx]=polyfit(X,x_ima,1);
+[py,sy]=polyfit(Y,y_ima,1);
+%err_X1=max(abs(x1-x_ima));%error
+%err_Y1=max(abs(y1-y_ima));%error
+T_x=px(2);
+T_y=py(2);
+GeometryCalib.focal=1;
+GeometryCalib.Tx_Ty_Tz=[T_x T_y 1];
+GeometryCalib.R=[px(1),0,0;0,py(1),0;0,0,1];
+%check error
+Calib.dpx=1;
+Calib.dpy=1;
+Calib.sx=1;
+Calib.Cx=0;
+Calib.Cy=0;
+Calib.Tz=1;
+Calib.kappa1=0;
+Calib.f=GeometryCalib.focal;
+Calib.Tx=T_x;
+Calib.Ty=T_y;
+Calib.R=GeometryCalib.R;
+[Xpoints,Ypoints]=px_XYZ(Calib,X,Y,0);
+GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));
+GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima));
+GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
+GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima))
+%calibrate_lin calibration results and point coordinates
+huvmat=findobj('Tag','uvmat');
+hchild=get(huvmat,'Children');
+hrootpath=findobj(hchild,'Tag','RootPath');
+hrootfile=findobj(hchild,'Tag','RootFile');
+RootPath='';
+RootFile='';
+if ~isempty(hrootpath)& ~isempty(hrootfile)
+    testhandle=1;
+    RootPath=get(hrootpath,'String');
+    RootFile=get(hrootfile,'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
+testappend=0;
+if exist(outputfile,'file');%=1 if the output file already exists, 0 else  
+    t=xmltree(outputfile); %read the file
+    uid=find(t,'ImaDoc');
+    if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup)
+        backupfile=outputfile;
+        testexist=2;
+        while testexist==2
+            backupfile=[backupfile '~'];
+            testexist=exist(backupfile,'file');       
+        end
+        [success,message]=copyfile(outputfile,backupfile);%make backup
+        if isequal(success,1)
+            delete(outputfile)
+        else
+            return
+        end
+    else
+        uid_calib=find(t,'ImaDoc/GeometryCalib');
+        if ~isempty(uid) %if GeometryCalib already exists, delete its content
+            backupfile=outputfile;
+            testexist=2;
+            while testexist==2
+                backupfile=[backupfile '~'];
+                testexist=exist(backupfile,'file');      
+            end
+            [success,message]=copyfile(outputfile,backupfile)%make backup
+            if isequal(success,1)
+                delete(outputfile)
+            else
+                return
+            end
+            uid_child=children(t,uid_calib);
+            t=delete(t,uid_child);
+            testappend=1;
+        end
+    end
+end
+if ~testappend
+    t=xmltree;
+    t=set(t,1,'name','ImaDoc');
+    [t,uid_calib]=add(t,1,'element','GeometryCalib');
+%     t=struct2xml(GeometryCalib,t,uid_calib);
+end
+Object.Coord(:,[1:3])=Object.Coord(:,[1:3])*10; %transform in
+GeometryCalib.SourceCalib.PointCoord=Object.Coord;
+t=struct2xml(GeometryCalib,t,uid_calib); 
+save(t,outputfile)
+
+warndlg_uvmat([outputfile 'updated with linear calibration data'],'CONFIRMATION')
+
+%display image with new calibration in the currently opened uvmat interface
+Indices=get(findobj(hchild,'Tag','FileIndex'),'String');
+Ext=get(findobj(hchild,'Tag','FileExt'),'String');
+imagename=[fullfile(RootPath,RootFile) Indices Ext];
+% input.menu_coord=1;
+huvmat=uvmat(imagename,1);%open uvmat, set phys coord (Value 1)
+
+
+
+% --- Executes on button press in calibrate_lin.
+function calib_lin_Callback(hObject, eventdata, handles)
+Object=read_probe_calib(handles);
+
+%make linear calibration
+% 'calibration_lin' provides a linear transform on coordinates, 
+X=Object.Coord(:,1);
+Y=Object.Coord(:,2);
+x_ima=Object.Coord(:,4);
+y_ima=Object.Coord(:,5);
+XY_mat=[ones(size(X)) X Y];
+a_X1=XY_mat\x_ima; %transformation matrix for X
+x1=XY_mat*a_X1;%reconstruction
+err_X1=max(abs(x1-x_ima));%error
+a_Y1=XY_mat\y_ima;%transformation matrix for X
+y1=XY_mat*a_Y1;
+err_Y1=max(abs(y1-y_ima));%error
+T_x=a_X1(1);
+T_y=a_Y1(1);
+GeometryCalib.focal=1;
+GeometryCalib.Tx_Ty_Tz=[T_x T_y 1];
+GeometryCalib.R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,1];
+
+%check error
+GeometryCalib.ErrorRms(1)=sqrt(mean((x1-x_ima).*(x1-x_ima)));
+GeometryCalib.ErrorMax(1)=max(abs(x1-x_ima));
+GeometryCalib.ErrorRms(2)=sqrt(mean((y1-y_ima).*(y1-y_ima)));
+GeometryCalib.ErrorMax(2)=max(abs(y1-y_ima))
+
+%calibrate_lin calibration results and point coordinates
+huvmat=findobj('Tag','uvmat');
+hchild=get(huvmat,'Children');
+hrootpath=findobj(hchild,'Tag','RootPath');
+hrootfile=findobj(hchild,'Tag','RootFile');
+RootPath='';
+RootFile='';
+if ~isempty(hrootpath)& ~isempty(hrootfile)
+    testhandle=1;
+    RootPath=get(hrootpath,'String');
+    RootFile=get(hrootfile,'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
+testappend=0;
+if exist(outputfile,'file');%=1 if the output file already exists, 0 else  
+    t=xmltree(outputfile); %read the file
+    uid=find(t,'ImaDoc');
+    if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup)
+        backupfile=outputfile;
+        testexist=2;
+        while testexist==2
+            backupfile=[backupfile '~'];
+            testexist=exist(backupfile,'file');       
+        end
+        [success,message]=copyfile(outputfile,backupfile)%make backup
+        if isequal(success,1);
+            delete(outputfile)
+        else
+            return
+        end
+    else
+        uid_calib=find(t,'ImaDoc/GeometryCalib');
+        if ~isempty(uid) %if GeometryCalib already exists, delete its content
+            backupfile=outputfile;
+            testexist=2;
+            while testexist==2
+                backupfile=[backupfile '~'];
+                testexist=exist(backupfile,'file');      
+            end
+            [success,message]=copyfile(outputfile,backupfile)%make backup
+            if isequal(success,1)
+                delete(outputfile)
+            else
+                return
+            end
+            uid_child=children(t,uid_calib);
+            t=delete(t,uid_child);
+            testappend=1;
+        end
+    end
+end
+if ~testappend
+    t=xmltree;
+    t=set(t,1,'name','ImaDoc');
+    [t,uid_calib]=add(t,1,'element','GeometryCalib');
+%     t=struct2xml(GeometryCalib,t,uid_calib);
+end
+% Object.Coord(:,[1:3])=Object.Coord(:,[1:3]); %transform in
+GeometryCalib.SourceCalib.PointCoord=Object.Coord;
+t=struct2xml(GeometryCalib,t,uid_calib); 
+save(t,outputfile)
+
+warndlg_uvmat([outputfile 'updated with linear calibration data'],'CONFIRMATION')
+
+%display image with new calibration in the currently opened uvmat interface
+Indices=get(findobj(hchild,'Tag','FileIndex'),'String');
+Ext=get(findobj(hchild,'Tag','FileExt'),'String');
+imagename=[fullfile(RootPath,RootFile) Indices Ext];
+% input.menu_coord=1;
+if exist(imagename,'file')
+    huvmat=uvmat(imagename,1);%open uvmat, set phys coord (Value 1)
+else
+    huvmat=uvmat;
+end
+
+
+% --- Executes on button press in translation.
+function translation_Callback(hObject, eventdata, handles)
+
+
+function T_x_Callback(hObject, eventdata, handles)
+% hObject    handle to T_x (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of T_x as text
+%        str2double(get(hObject,'String')) returns contents of T_x as a double
+
+
+
+
+
+function T_y_Callback(hObject, eventdata, handles)
+% hObject    handle to T_y (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of T_y as text
+%        str2double(get(hObject,'String')) returns contents of T_y as a double
+
+
+function T_z_Callback(hObject, eventdata, handles)
+% hObject    handle to T_z (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of T_z as text
+%        str2double(get(hObject,'String')) returns contents of T_z as a double
+
+
+% --- Executes on button press in rotation.
+function rotation_Callback(hObject, eventdata, handles)
+angle_rot=(pi/180)*str2num(get(handles.Phi,'String'))
+data=read_probe_calib(handles)
+data.Coord(:,1)=cos(angle_rot)*data.Coord(:,1)+sin(angle_rot)*data.Coord(:,2);
+data.Coord(:,1)=-sin(angle_rot)*data.Coord(:,1)+cos(angle_rot)*data.Coord(:,2);
+set(handles.XObject,'String',num2str(data.Coord(:,1)));
+set(handles.YObject,'String',num2str(data.Coord(:,2)));
+
+
+function XImage_Callback(hObject, eventdata, handles)
+update_list(hObject, eventdata,handles)
+
+function YImage_Callback(hObject, eventdata, handles)
+update_list(hObject, eventdata,handles)
+
+function XObject_Callback(hObject, eventdata, handles)
+update_list(hObject, eventdata,handles)
+
+function YObject_Callback(hObject, eventdata, handles)
+update_list(hObject, eventdata,handles)
+
+function ZObject_Callback(hObject, eventdata, handles)
+update_list(hObject, eventdata,handles)
+
+function update_list(hObject, eventdata, handles)
+str4=get(handles.XImage,'String');
+str5=get(handles.YImage,'String');
+str1=get(handles.XObject,'String');
+tt=double(str1);
+str2=get(handles.YObject,'String');
+str3=get(handles.ZObject,'String');
+if ~isempty(str1) & ~isequal(double(str1),32) & (isempty(str3)|isequal(double(str3),32))
+    str3='0';%put z to 0 by default
+end
+strline=[str1 '    |    ' str2 '    |    ' str3 '    |    ' str4 '    |    ' str5];
+Coord=get(handles.ListCoord,'String');
+testappend=get(handles.edit_append,'Value');
+if isequal(testappend,1); %edit mode  
+    val=get(handles.ListCoord,'Value');
+    Coord{val}=strline;
+else
+    val=length(get(handles.ListCoord,'String'));
+    Coord{val+1}=strline;
+    set(handles.ListCoord,'Value',val+1)
+% if val+1<=length(Coord)
+%     set(handles.ListCoord,'Value',val+1)
+%     ListCoord_Callback(hObject, eventdata, handles)
+end
+set(handles.ListCoord,'String',Coord)
+%set(handles.ListCoord,'Value',val+1)
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function data=read_probe_calib(handles)
+data_XIma=[];
+data_YIma=[];
+data_XObject=[];
+data_YObject=[];
+data_ZObject=[];
+Coord=get(handles.ListCoord,'String');
+% XImage=get(handles.XImage,'String');
+% YImage=get(handles.YImage,'String');
+% XObject=get(handles.XObject,'String');
+% YObject=get(handles.YObject,'String');
+% ZObject=get(handles.ZObject,'String');
+% if ischar(Xcolumn)
+%     Xcolumn={Xcolumn};
+% end
+nb_defining_points=length(Coord);
+iline=0;
+for i=1:nb_defining_points
+    coord_str=Coord{i};%character string of line number i
+    k=findstr('|',coord_str);%find 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)
+        iline=iline+1;
+        if ~isempty(data1)
+            data.Coord(iline,1)=data1;
+        end    
+        if ~isempty(data2)
+            data.Coord(iline,2)=data2;
+        end
+        if ~isempty(data3)
+            data.Coord(iline,3)=data3;
+        end
+        if ~isempty(data4)
+            data.Coord(iline,4)=data4;
+        end
+        if isempty(data5)
+            data.Coord(iline,5)=0;
+        else
+            data.Coord(iline,5)=data5;
+        end
+    end
+end
+data.Style='points';
+
+
+% --- Executes on selection change in ListCoord.
+function ListCoord_Callback(hObject, eventdata, handles)
+% hObject    handle to ListCoord (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: contents = get(hObject,'String') returns ListCoord contents as cell array
+%        contents{get(hObject,'Value')} returns selected item from ListCoord
+set(handles.edit_append,'Value',1); %set to edit mode
+Coord=get(handles.ListCoord,'String');
+val=get(handles.ListCoord,'Value');
+if length(Coord)>0
+coord_str=Coord{val};
+k=findstr('|',coord_str);
+set(handles.XObject,'String',coord_str(1:k(1)-5))
+set(handles.YObject,'String',coord_str(k(1)+5:k(2)-5))
+set(handles.ZObject,'String',coord_str(k(2)+5:k(3)-5))
+set(handles.XImage,'String',coord_str(k(3)+5:k(4)-5))
+set(handles.YImage,'String',coord_str(k(4)+5:end))
+end
+
+%------------------------------------------------------
+% --- Executes on button press in translation_plus.
+function translation_plus_Callback(hObject, eventdata, handles)
+
+T=[0 0 0];
+T_x=get(handles.T_x,'String')
+T_y=get(handles.T_y,'String')
+T_z=get(handles.T_z,'String')
+if ~isempty(T_x)
+    T(1)=str2num(T_x);
+end
+if ~isempty(T_y)
+    T(2)=str2num(T_y);
+end
+if ~isempty(T_z)
+    T(3)=str2num(T_z);
+end
+translation(handles,T)
+
+
+
+% --- Executes on button press in translation_minus.
+function translation_minus_Callback(hObject, eventdata, handles)
+
+T=[0 0 0];
+T_x=get(handles.T_x,'String')
+T_y=get(handles.T_y,'String')
+T_z=get(handles.T_z,'String')
+if ~isempty(T_x)
+    T(1)=-str2num(T_x);
+end
+if ~isempty(T_y)
+    T(2)=-str2num(T_y);
+end
+if ~isempty(T_z)
+    T(3)=-str2num(T_z);
+end
+translation(handles,T)
+
+
+%%%--------------------------------------
+function translation(handles,T)
+data=read_probe_calib(handles);
+data.Coord(:,1)=T(1)+data.Coord(:,1);
+data.Coord(:,2)=T(2)+data.Coord(:,2);
+data.Coord(:,3)=T(3)+data.Coord(:,3);
+data.Coord(:,[4 5])=data.Coord(:,[4 5]);
+for i=1:size(data.Coord,1)
+    for j=1:5
+          Coord{i,j}=num2str(data.Coord(i,j));%phys x,y,z
+   end
+end
+Tabchar=cell2tab(Coord,'    |    ');
+set(handles.ListCoord,'String',Tabchar)
+
+%----------------------------------------------------
+% --- Executes on button press in rotation_plus.
+function rotation_plus_Callback(hObject, eventdata, handles)
+Phi=0;
+Phi=get(handles.Phi,'String')
+if ~isempty(Phi)
+    Phi=str2num(Phi);
+end
+rotation(handles,Phi)
+
+%-------------------------------------------------
+% --- Executes on button press in rotation_minus.
+function rotation_minus_Callback(hObject, eventdata, handles)
+Phi=0;
+Phi=get(handles.Phi,'String')
+if ~isempty(Phi)
+    Phi=-str2num(Phi);
+end
+rotation(handles,Phi)
+
+%-----------------------------------------------------
+%rotation
+function rotation(handles,Phi)
+O_x=str2num(get(handles.O_x,'String'));
+O_y=str2num(get(handles.O_y,'String'));
+if isempty(O_x)
+    O_x=0;%default
+end
+if isempty(O_y)
+    O_y=0;%default
+end
+data=read_probe_calib(handles);
+r1=cos(pi*Phi/180);
+r2=-sin(pi*Phi/180);
+r3=sin(pi*Phi/180);
+r4=cos(pi*Phi/180);
+data.Coord(:,1)=r1*data.Coord(:,1)+r2*data.Coord(:,2);
+data.Coord(:,2)=r3*data.Coord(:,1)+r4*data.Coord(:,2);
+% data.Coord(:,[4 5])=data.Coord(:,[4 5]);
+for i=1:size(data.Coord,1)
+    for j=1:5
+          Coord{i,j}=num2str(data.Coord(i,j));%phys x,y,z
+   end
+end
+Tabchar=cell2tab(Coord,'    |    ');
+set(handles.ListCoord,'String',Tabchar)
+
+function O_x_Callback(hObject, eventdata, handles)
+% hObject    handle to O_x (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of O_x as text
+%        str2double(get(hObject,'String')) returns contents of O_x as a double
+
+
+
+function O_y_Callback(hObject, eventdata, handles)
+% hObject    handle to O_y (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of O_y as text
+%        str2double(get(hObject,'String')) returns contents of O_y as a double
+
+
+function O_z_Callback(hObject, eventdata, handles)
+% hObject    handle to O_z (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: get(hObject,'String') returns contents of O_z as text
+%        str2double(get(hObject,'String')) returns contents of O_z as a double
+
+
+
+
+
+
+
+% --- Executes on selection change in edit_append.
+function edit_append_Callback(hObject, eventdata, handles)
+val=get(handles.edit_append,'Value');
+if isequal(val,2); %append mode
+    %appeler mouse
+end
+
+
+function NEW_Callback(hObject, eventdata, handles)
+%A METTRE SOUS UN BOUTON
+huvmat=findobj('name','uvmat');
+hchild=get(huvmat,'children');
+hcoord=findobj(hchild,'Tag','menu_coord')
+coordtype=get(hcoord,'Value')
+haxes=findobj(hchild,'Tag','axes3');
+AxeData=get(haxes,'UserData');
+if ~isequal(hcoord,2)
+    set(hcoord,'Value',2)
+    huvmat=uvmat(AxeData)
+    'relancer uvmat'
+end
+if ~isfield(AxeData,'ZoomAxes')
+    warndlg_uvmat('first draw a window around a grid marker','ERRROR')
+    return
+end 
+XLim=get(AxeData.ZoomAxes,'XLim');
+YLim=get(AxeData.ZoomAxes,'YLim');
+np=size(AxeData.A);
+ind_sub_x=round(XLim)
+ind_sub_y=np(1)-round(YLim)
+Mfiltre=AxeData.A([ind_sub_y(2):ind_sub_y(1)] ,ind_sub_x,:);
+Mfiltre_norm=double(Mfiltre);
+Mfiltre_norm=Mfiltre_norm/sum(sum(Mfiltre_norm));
+Mfiltre_norm=100*(Mfiltre_norm-mean(mean(Mfiltre_norm)));
+Atype=class(AxeData.A)
+Data.NbDim=2;
+Data.A=filter2(Mfiltre_norm,double(AxeData.A)); 
+Data.A=feval(Atype,Data.A);
+Data.AName='image';
+Data.AX=AxeData.AX;
+Data.AY=AxeData.AY;
+Data.CoordType='px';
+plot_field(Data)
+ 
+
+% --- Executes on button press in HELP.
+function HELP_Callback(hObject, eventdata, handles)
+% hObject    handle to HELP (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+path_to_uvmat=which ('uvmat');% check the path of uvmat
+pathelp=fileparts(path_to_uvmat);
+helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
+if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
+else
+   web([helpfile '#probe_calib'])
+end
+
+%'move_key:' function activated when a key is pressed on the keyboard
+%-----------------------------------
+function key_press_fcn(hObject,eventdata,handles)
+hh=get(hObject,'parent')
+xx=double(get(hh,'CurrentCharacter')) %get the keyboard character
+
+if isequal(xx,8)%move arrow right
+   data=read_probe_calib(handles);
+    Coord=[]; %default
+    if isfield(data,'Coord')
+        Coord=data.Coord
+    end
+    val=get(handles.ListCoord,'Value');
+    Coord(val,:)=[];
+    CoordCell={};
+    for iline=1:size(Coord,1)
+        for j=1:5
+            CoordCell{iline,j}=num2str(Coord(iline,j));
+        end
+    end
+    Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
+    val=min(size(Coord,1),val);
+    set(handles.ListCoord,'Value',max(val,1))
+    set(handles.ListCoord,'String',Tabchar)  
+end
Index: /trunk/src/private/proj_field.m
===================================================================
--- /trunk/src/private/proj_field.m	(revision 8)
+++ /trunk/src/private/proj_field.m	(revision 8)
@@ -0,0 +1,1617 @@
+%'proj_field': projects the field on a projection object
+%--------------------------------------------------------------------------
+%  function [ProjData,errormsg]=proj_field(FieldData,ObjectData,IndexObj)
+%
+% OUTPUT:
+% ProjData structure containing the fields of the input field FieldData,
+% transmitted or projected on the object, plus the additional fields
+%    .UMax, .UMin, .VMax, .VMin: min and max of velocity components in a domain
+%    .UMean,VMean: mean of the velocity components in a domain
+%    .AMin, AMax: min and max of a scalar
+%    .AMean: mean of a scalar in a domain  
+%  .NbPix;
+%  .DimName=  names of the matrix dimensions (matlab cell)
+%  .DimValue= values of the matricx dimensions (matlab vector, same length as .DimName);
+%  .VarName= names of the variables [ProjData.VarName {'A','AMean','AMin','AMax'}];
+%  .VarDimNameIndex= dimensions of the variables, indicated by indices in the list .DimName;
+%
+%INPUT
+% ObjectData: structure characterizing the projection object
+%    .Style : style of projection object
+%    .ProjMode=type of projection ;
+%    .CoordType: 'px' or 'phys' type of coordinates defining the object position
+%    .Phi  angle of rotation (=0 by default)
+%    .ProjAngle=angle of projection;
+%    .DX,.DY,.DZ=increments along each coordinate
+%    .Coord(nbpoints,3): set of coordinates defining the object position;
+
+%FieldData: data of the field to be projected on the projection object, with optional fields
+%    .Txt: error message, transmitted to the projection
+%    .CoordType: 'px' or 'phys' type of coordinates of the field, must be the same as for the projection object, transmitted
+%    .Mesh: typical distance between data points (used for mouse action or display), transmitted
+%    .CoordUnit, .TimeUnit, .dt: transmitted
+% standardised description of fields, nc-formated Matlab structure with fields:
+%         .ListGlobalAttribute: cell listing the names of the global attributes
+%        .Att_1,Att_2... : values of the global attributes
+%            .ListDimName: cell listing the names of the array dimensions
+%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
+%            .ListVarName: cell listing the names of the variables
+%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
+%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
+%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
+% The variables are grouped in 'fields', made of a set of variables with common dimensions (using the function find_field_indices)
+% The variable attribute 'Role' is used to define the role for plotting:
+%       Role = 'scalar':  (default) represents a scalar field
+%            = 'coord':  represents a set of unstructured coordinates, whose
+%                     space dimension is given by the last array dimension (called 'nb_dim').
+%            = 'coord_x', 'coord_y',  'coord_z': represents a separate set of
+%                        unstructured coordinate x, y  or z
+%            = 'vector': represents a vector field whose number of components
+%                is given by the last dimension (called 'nb_dim')
+%            = 'vector_x', 'vector_y', 'vector_z'  :represents the x, y or z  component of a vector  
+%            = 'warnflag' : provides a warning flag about the quality of data in a 'Field', default=0, no warning
+%            = 'errorflag': provides an error flag marking false data,
+%                   default=0, no error. Different non zero values can represent different criteria of elimination.
+%
+% Default role of variables (by name)
+%  vector field:
+%    .X,.Y: position of the velocity vectors, projected on the object
+%    .U, .V, .W: velocity components, projected on the object
+%    .C, .CName: scalar associated to the vector
+%    .F : equivalent to 'warnflag'
+%    .FF: equivalent to 'errorflag'
+%  scalar field or image:
+%    .AName: name of a scalar (to be calculated from velocity fields after projection), transmitted 
+%    .A: scalar, projected on the object
+%    .AX, .AY: positions for the scalar
+%     case of a structured grid: A is a dim 2 matrix and .AX=[first last] (length 2 vector) represents the first and last abscissa of the grid
+%     case of an unstructured scalar: A is a vector, AX and AY the corresponding coordinates 
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function [ProjData,errormsg]=proj_field(FieldData,ObjectData,IndexObj)
+
+if isfield(ObjectData,'ProjMode') && (isequal(ObjectData.ProjMode,'none')||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'))
+    ProjData=[];
+    return
+end
+%introduce default field properties (reading old standards)
+if ~isfield(ObjectData,'Style')||~isfield(ObjectData,'Coord')||~isfield(ObjectData,'ProjMode')
+    ProjData=FieldData;
+    return
+end
+
+% OBSOLETE
+if isfield(ObjectData,'XMax') && ~isempty(ObjectData.XMax)
+    ObjectData.RangeX(1)=ObjectData.XMax;
+end
+if isfield(ObjectData,'XMin') && ~isempty(ObjectData.XMin)
+    ObjectData.RangeX(2)=ObjectData.XMin;
+end
+if isfield(ObjectData,'YMax') && ~isempty(ObjectData.YMax)
+    ObjectData.RangeY(1)=ObjectData.YMax;
+end
+if isfield(ObjectData,'YMin') && ~isempty(ObjectData.YMin)
+    ObjectData.RangeY(2)=ObjectData.YMin;
+end
+if isfield(ObjectData,'ZMax') && ~isempty(ObjectData.ZMax)
+    ObjectData.RangeZ(1)=ObjectData.ZMax;
+end
+if isfield(ObjectData,'ZMin') && ~isempty(ObjectData.ZMin)
+    ObjectData.RangeZ(2)=ObjectData.ZMin;
+end
+%%%%%%%%%%
+
+% FieldData=document_field(FieldData);%transform FieldData to the standard format
+% if ~isfield(FieldData,'VarAttribute')
+%     FieldData.VarAttribute={};
+% end
+
+if isequal(ObjectData.Style,'points')
+    [ProjData,errormsg]=proj_points(FieldData,ObjectData);
+elseif isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')
+     [ProjData,errormsg] = proj_line(FieldData,ObjectData);
+elseif isequal(ObjectData.Style,'polygon')|isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'ellipse')
+    if isequal(ObjectData.ProjMode,'inside')|isequal(ObjectData.ProjMode,'outside')
+        [ProjData,errormsg] = proj_patch(FieldData,ObjectData);
+    else
+        [ProjData,errormsg] = proj_line(FieldData,ObjectData);
+    end
+     %A FAIRE : GERER MASK
+elseif isequal(ObjectData.Style,'plane')
+%         if isfield(FieldData,'NbDim') & isequal(FieldData.NbDim,3)
+%             ProjData= proj_plane3D(FieldData,ObjectData);%
+%         else
+            [ProjData,errormsg] = proj_plane(FieldData,ObjectData);
+%         end
+end
+if exist('IndexObj','var')
+    ProjData.IndexObj=IndexObj;%transfer object index
+end
+
+%-----------------------------------------------------------------
+%project on a set of points
+function  [ProjData,errormsg]=proj_points(FieldData,ObjectData)%%
+%-------------------------------------------------------------------
+
+siz=size(ObjectData.Coord);
+width=0;
+if isfield(ObjectData,'Range')
+    width=ObjectData.Range(1,2);
+end
+if isfield(ObjectData,'RangeX')&~isempty(ObjectData.RangeX)
+    width=max(ObjectData.RangeX);
+end
+if isfield(ObjectData,'RangeY')&~isempty(ObjectData.RangeY)
+    width=max(width,max(ObjectData.RangeY));
+end
+if isfield(ObjectData,'RangeZ')&~isempty(ObjectData.RangeZ)
+    width=max(width,max(ObjectData.RangeZ));
+end
+if isequal(ObjectData.ProjMode,'projection') 
+    if width==0
+        errormsg='projection range around points needed';
+        return
+    end
+elseif  ~isequal(ObjectData.ProjMode,'interp')
+    errormsg=(['ProjMode option ' ObjectData.ProjMode ' not available in proj_field']);
+        return
+end
+ProjData=proj_heading(FieldData,ObjectData);
+ProjData.NbDim=0;
+%ProjData.ListDimName= {'nb_points'};
+%ProjData.DimValue=siz(1);  %nbre of projection points  
+
+
+% idimvar=0;
+[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
+if ~isempty(errormsg)
+    errormsg=['error in proj_field/proj_points:' errormsg];
+    return
+end
+%LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
+% CellVarIndex=cells of variable index arrays
+% ivar_new=0; % index of the current variable in the projected field
+% icoord=0;
+for icell=1:length(CellVarIndex)
+    if NbDim(icell)==1
+        continue
+    end
+    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
+    VarType=VarTypeCell{icell};
+    ivar_X=VarType.coord_x;
+    ivar_Y=VarType.coord_y;
+    ivar_Z=VarType.coord_z;
+%     ivar_U=VarType.vector_x;
+%     ivar_V=VarType.vector_y;
+%     ivar_W=VarType.vector_z;
+%     ivar_C=VarType.scalar ;
+    ivar_Anc=VarType.ancillary;
+%     test_anc=zeros(size(VarIndex));
+    test_anc(ivar_Anc)=ones(size(ivar_Anc));
+    ivar_F=VarType.warnflag;
+    ivar_FF=VarType.errorflag;
+    VarIndex([ivar_X ivar_Y ivar_Z ivar_Anc ivar_F ivar_FF])=[];% not projected variables removed frlom list
+    if isempty(ivar_X)
+        test_grid=1;%test for input data on regular grid (e.g. image)coordinates
+      
+    else
+        if length(ivar_X)>1 | length(ivar_Y)>1 | length(ivar_Z)>1
+                 errormsg='multiple coordinate input in proj_field.m';
+                    return
+        end
+        if length(ivar_Y)~=1
+                errormsg='y coordinate not defined in proj_field.m';
+                return
+        end
+        test_grid=0;
+    end
+    ProjData.ListVarName={'Y','X','NbVal'};
+    ProjData.VarDimName={'nb_points','nb_points','nb_points'};
+    %ProjData.VarDimIndex={[1],[1],[1]}; 
+    ProjData.VarAttribute{1}.Role='ancillary';
+    ProjData.VarAttribute{2}.Role='ancillary';
+    ProjData.VarAttribute{3}.Role='ancillary';
+    for ivar=VarIndex        
+        VarName=FieldData.ListVarName{ivar};
+        ProjData.ListVarName=[ProjData.ListVarName {VarName}];
+        %ProjData.VarDimIndex=[ProjData.VarDimIndex {[1]}];
+        ProjData.VarDimName=[ProjData.VarDimName {'nb_points'}];
+    end
+    if ~test_grid
+        eval(['coord_x=FieldData.' FieldData.ListVarName{ivar_X} ';'])
+        eval(['coord_y=FieldData.' FieldData.ListVarName{ivar_Y} ';'])
+        test3D=0;% TEST 3D CASE : NOT COMPLETED ,  3D CASE : NOT COMPLETED 
+        if length(ivar_Z)==1
+            eval(['coord_z=FieldData.' FieldData.ListVarName{ivar_Z} ';'])
+            test3D=1;
+        end
+%         if length(ivar_U)>1 | length(ivar_V)>1 | length(ivar_W)>1
+%                  warndlg_uvmat('multiple vector input in proj_field.m','ERROR')
+%                     return
+%         end
+        if length(ivar_F)>1 | length(ivar_FF)>1 
+                 warndlg_uvmat('multiple flag input in proj_field.m','ERROR')
+                    return
+        end
+       
+        for ipoint=1:siz(1)
+           Xpoint=ObjectData.Coord(ipoint,:);
+           distX=coord_x-Xpoint(1);
+           distY=coord_y-Xpoint(2);          
+           dist=distX.*distX+distY.*distY;
+           indsel=find(dist<width*width);
+           ProjData.X(ipoint,1)=Xpoint(1);
+           ProjData.Y(ipoint,1)=Xpoint(2);
+           if isequal(length(ivar_FF),1)
+               FFName=FieldData.ListVarName{ivar_FF};
+               eval(['FF=FieldData.' FFName '(indsel);'])
+               ind_indsel=find(~FF);
+               indsel=indsel(ind_indsel);
+           end
+           ProjData.NbVal(ipoint,1)=length(indsel);
+            for ivar=VarIndex 
+               VarName=FieldData.ListVarName{ivar};
+               if isempty(indsel)
+                    eval(['ProjData.' VarName '(ipoint,1)=NaN;'])
+               else
+                    eval(['Var=FieldData.' VarName '(indsel);'])
+                    eval(['ProjData.' VarName '(ipoint,1)=mean(Var);'])
+                    if isequal(ObjectData.ProjMode,'interp')
+                         eval(['ProjData.' VarName '(ipoint,1)=griddata_uvmat(coord_x(indsel),coord_y(indsel),Var,Xpoint(1),Xpoint(2)))';])
+                    end
+               end
+            end
+        end
+    else 
+        %DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
+        %case of structured coordinates
+        if  numel(VarType.coord)>=2 & VarType.coord(1:2) > 0;
+            AYName=FieldData.ListVarName{VarType.coord(1)};
+            AXName=FieldData.ListVarName{VarType.coord(2)};
+            eval(['AX=FieldData.' AXName ';']);% set of x positions
+            eval(['AY=FieldData.' AYName ';']);% set of y positions  
+            AName=FieldData.ListVarName{VarIndex(1)};
+            eval(['A=FieldData.' AName ';']);% scalar
+            npxy=size(A);
+
+% %             nbcolor=1; %default
+%             for idim=1:length(ListDimName)
+%                 DimName=ListDimName{idim};
+%                 if isequal(DimName,'rgb')|isequal(DimName,'nb_coord')|isequal(DimName,'nb_coord_i')
+%                    nbcolor=npxy(idim);
+%                    DimIndices(idim)=[];
+%                    npxy(idim)=[];
+%                 end
+%                 if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED
+%                     DimIndices(idim)=[];
+%                     npxy(idim)=[];
+%                 end
+%             end  
+            ind_1=find(npxy==1);
+            %DimIndices(ind_1)=[]; %suppress singleton dimensions 
+%             indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero)
+            %nb_dim=length(DimIndices)%number of space dimensions
+            nb_dim=numel(VarType.coord);
+            Coord_z=[];
+            Coord_y=[];
+            Coord_x=[];   
+            for idim=1:nb_dim %loop on space dimensions
+                test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
+                test_coord(idim)=0;%test for defined coordinates, =0 by default
+                %ivar=DimVarIndex(DimIndices(idim));% index of the variable corresponding to the current dimension
+                ivar=VarType.coord(idim);
+%                 if ~isequal(ivar,0)%  a variable corresponds to the current dimension
+                    eval(['Coord{idim}=FieldData.' FieldData.ListVarName{ivar} ';']) ;% position for the first index
+                    if numel(Coord{idim})==2
+                       DCoord_min(idim)= (Coord{idim}(2)-Coord{idim}(1))/(npxy(idim)-1);
+                    else
+                        DCoord=diff(Coord{idim});
+                        DCoord_min(idim)=min(DCoord);
+                        DCoord_max=max(DCoord);
+                        test_direct(idim)=DCoord_max>0;% =1 for increasing values, 0 otherwise
+                        test_direct_min=DCoord_min(idim)>0;% =1 for increasing values, 0 otherwise
+                        if ~isequal(test_direct(idim),test_direct_min)
+                            errormsg=['non monotonic dimension variable # ' num2str(idim)  ' in proj_field.m'];
+                                    return
+                        end               
+                        test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity
+                        test_coord(idim)=1;
+                    end
+%                 else  % no variable associated with the first dimension, look fo variable  attributes Coord_1, _2 or _3
+%                     Coord_i_str=['Coord_' num2str(idim)];
+%                     DCoord_min(idim)=1;%default
+%                     Coord{idim}=[0.5 npxy(idim)];
+%                     test_direct(idim)=1;
+%                 end
+            end
+            DX=DCoord_min(2);
+            DY=DCoord_min(1);
+            for ipoint=1:siz(1)
+                xwidth=width/(abs(DX));
+                ywidth=width/(abs(DY));
+                i_min=round((ObjectData.Coord(ipoint,1)-Coord{2}(1))/DX+0.5-xwidth); %minimum index of the selected region
+                i_min=max(1,i_min);%restrict to field limit
+                i_plus=round((ObjectData.Coord(ipoint,1)-Coord{2}(1))/DX+0.5+xwidth);
+                i_plus=min(npxy(2),i_plus); %restrict to field limit
+                j_min=round((ObjectData.Coord(ipoint,2)-Coord{1}(1))/DY-ywidth+0.5);
+                j_min=max(1,j_min);
+                j_plus=round((ObjectData.Coord(ipoint,2)-Coord{1}(1))/DY+ywidth+0.5);
+                j_plus=min(npxy(1),j_plus);
+                ProjData.X(ipoint,1)=ObjectData.Coord(ipoint,1);
+                ProjData.Y(ipoint,1)=ObjectData.Coord(ipoint,2);
+                i_int=[i_min:i_plus];
+                j_int=[j_min:j_plus];
+                ProjData.NbVal(ipoint,1)=length(j_int)*length(i_int);
+                if isempty(i_int) | isempty(j_int)
+                   for ivar=VarIndex   
+                        eval(['ProjData.' FieldData.ListVarName{ivar} '(ipoint,:)=NaN;']);
+                   end
+                   errormsg=['no data points in the selected projection range ' num2str(width) ];
+                else
+                    %TODO: introduce circle in the selected subregion
+                    %[I,J]=meshgrid([1:j_int],[1:i_int]);
+                    for ivar=VarIndex   
+                        eval(['Avalue=FieldData.' FieldData.ListVarName{ivar} '(j_int,i_int,:);']);
+                        eval(['ProjData.' FieldData.ListVarName{ivar} '(ipoint,:)=mean(mean(Avalue));']);
+                    end
+                end
+            end
+        end
+   end
+end
+
+%-----------------------------------------------------------------
+%project in a patch
+function  [ProjData,errormsg]=proj_patch(FieldData,ObjectData)%%
+%-------------------------------------------------------------------
+ProjData=proj_heading(FieldData,ObjectData);
+
+objectfield=fieldnames(ObjectData);
+widthx=0;
+widthy=0;
+if isfield(ObjectData,'RangeX')&~isempty(ObjectData.RangeX)
+    widthx=max(ObjectData.RangeX);
+end
+if isfield(ObjectData,'RangeY')&~isempty(ObjectData.RangeY)
+    widthy=max(ObjectData.RangeY);
+end
+
+%A REVOIR, GENERALISER: UTILISER proj_line
+ProjData.NbDim=1;
+ProjData.ListDimName={};%name of dimension 
+ProjData.DimValue=[];%values of dimension (nbre of vectors)
+ProjData.ListVarName={};
+%ProjData.VarDimIndex={};
+ProjData.VarDimName={};
+if isfield (FieldData,'ListVarAttribute')
+    ProjData.ListVarAttribute=FieldData.ListVarAttribute;%list of variable attribute names
+    for iattr=1:length(ProjData.ListVarAttribute)%initialization of variable attribute values
+        AttrName=ProjData.ListVarAttribute{iattr};
+        eval(['ProjData.' AttrName '={};'])
+    end;
+end
+
+%group the variables (fields of 'FieldData') in cells of variables with the same dimensions
+testfalse=0;
+ListIndex={};
+% DimVarIndex=0;%initilise list of indices for dimension variables
+idimvar=0;
+[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
+if ~isempty(errormsg)
+    errormsg=['error in proj_field/proj_patch:' errormsg];
+    return
+end
+
+%LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
+dimcounter=0;
+for icell=1:length(CellVarIndex)
+    testX=0;
+    testY=0;
+    test_Amat=0;
+    testfalse=0;
+    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
+    VarType=VarTypeCell{icell};
+  %  DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
+    if NbDim(icell)~=2% proj_patch acts only on fields of space dimension 2
+        continue
+    end
+    testX=~isempty(VarType.coord_x) && ~isempty(VarType.coord_y);
+    testfalse=~isempty(VarType.errorflag);
+    testproj(VarIndex)=zeros(size(VarIndex));%default
+    testproj(VarType.scalar)=1;
+    testproj(VarType.vector_x)=1;
+    testproj(VarType.vector_y)=1;
+    testproj(VarType.vector_z)=1;
+    testproj(VarType.image)=1;
+    testproj(VarType.color)=1;
+    VarIndex=VarIndex(find(testproj(VarIndex)));%select only the projected variables
+    if testX %case of unstructured coordinates
+         eval(['nbpoint=numel(FieldData.' FieldData.ListVarName{VarIndex(1)} ');'])
+         for ivar=[VarIndex VarType.coord_x VarType.coord_y VarType.errorflag]
+               VarName=FieldData.ListVarName{ivar};
+            eval(['FieldData.' VarName '=reshape(FieldData.' VarName ',nbpoint,1);'])
+         end
+         XName=FieldData.ListVarName{VarType.coord_x};
+         YName=FieldData.ListVarName{VarType.coord_y};
+         eval(['coord_x=FieldData.' XName ';'])
+         eval(['coord_y=FieldData.' YName ';'])
+    end
+    if testfalse
+        FFName=FieldData.ListVarName{VarType.errorflag};
+        eval(['errorflag=FieldData.' FFName ';'])
+    end
+    % image or 2D matrix
+    if numel(VarType.coord)>=2 & VarType.coord(1:2) > 0;
+        test_Amat=1;%image or 2D matrix
+        AYName=FieldData.ListVarName{VarType.coord(1)};
+        AXName=FieldData.ListVarName{VarType.coord(2)};
+        eval(['AX=FieldData.' AXName ';'])% x coordinate
+        eval(['AY=FieldData.' AYName ';'])% y coordinate
+        VarName=FieldData.ListVarName{VarIndex(1)};
+        eval(['DimValue=size(FieldData.' VarName ');'])
+        testcolor=find(numel(DimValue)==3);
+%                     errormsg='multicomponent field not projected';
+
+        for idim=1:length(DimValue)        
+            Coord_i_str=['Coord_' num2str(idim)];
+            DCoord_min(idim)=1;%default
+            Coord{idim}=[0.5 DimValue(idim)];
+            test_direct(idim)=1;
+%             if isfield(FieldData,'VarAttribute')
+%                 for ivar=VarIndex
+%                     if length(FieldData.VarAttribute)>=ivar & isfield(FieldData.VarAttribute{ivar},Coord_i_str)% if there is a variable  attribute named Coord_1, _2 or _3
+%                         eval(['Coord_i=FieldData.VarAttribute{ivar}.' Coord_i_str ';']);%'range x 
+%                         if isnumeric(Coord_i)
+%                              if length(Coord_i)>=2
+%                                 Coord{idim}=[Coord_i(1) Coord_i(end)];
+%                                 %test_direct(idim)=(Coord{idim}(2)>Coord{idim}(1));
+%                              else 
+%                                 warndlg_uvmat(['two values needed for ' Coord_i_str 'in proj_field.m'],'ERROR')
+%                                 return
+%                              end
+%                          else
+%                             warndlg_uvmat(['non numerical coordinate attributes' Coord_i_str 'in proj_field.m'],'ERROR')
+%                             return
+%                          end
+%                          %test_coord(idim)=1;
+%                          DCoord_min(idim)=(Coord{idim}(end)-Coord{idim}(1))/(DimValue(idim)-1);
+%                     end
+%                 end
+%             end
+        end
+        AX=linspace(Coord{2}(1),Coord{2}(2),DimValue(2));
+        AY=linspace(Coord{1}(1),Coord{1}(2),DimValue(1));  %TODO : 3D case 
+        if length(DimValue)==3
+            testcolor=1;
+            npxy(3)=3;
+        else
+            testcolor=0;
+            npxy(3)=1;
+        end
+        [Xi,Yi]=meshgrid(AX,AY);
+        npxy(1)=length(AY);
+        npxy(2)=length(AX);
+        Xi=reshape(Xi,npxy(1)*npxy(2),1);
+        Yi=reshape(Yi,npxy(1)*npxy(2),1);
+        for ivar=1:length(VarIndex)
+            VarName=FieldData.ListVarName{VarIndex(ivar)};
+            eval(['FieldData.' VarName '=reshape(FieldData.' VarName ',npxy(1)*npxy(2),npxy(3));']); % keep only non false vectors 
+        end
+    end
+%select the indices in the range of action
+    testin=[];%default
+    if isequal(ObjectData.Style,'rectangle')
+%            if ~isfield(ObjectData,'RangeX')|~isfield(ObjectData,'RangeY')
+%                 errormsg='rectangle half sides RangeX and RangeY needed'
+%                 return
+%            end
+       if testX
+            distX=abs(coord_x-ObjectData.Coord(1,1));
+            distY=abs(coord_y-ObjectData.Coord(1,2));
+            testin=distX<widthx & distY<widthy;
+       elseif test_Amat
+           distX=abs(Xi-ObjectData.Coord(1,1));
+           distY=abs(Yi-ObjectData.Coord(1,2));
+           testin=distX<widthx & distY<widthy;
+       end
+    elseif isequal(ObjectData.Style,'polygon')
+        if testX
+            testin=inpolygon(coord_x,coord_y,ObjectData.Coord(:,1),ObjectData.Coord(:,2));
+        elseif test_Amat
+           testin=inpolygon(Xi,Yi,ObjectData.Coord(:,1),ObjectData.Coord(:,2));
+       else%calculate the scalar
+           testin=[]; %A REVOIR
+       end
+    elseif isequal(ObjectData.Style,'ellipse')
+       X2Max=widthx*widthx;
+       Y2Max=(widthy)*(widthy);
+       if testX
+            distX=(coord_x-ObjectData.Coord(1,1));
+            distY=(coord_y-ObjectData.Coord(1,2));
+            testin=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;
+       elseif test_Amat %case of usual 2x2 matrix
+           distX=(Xi-ObjectData.Coord(1,1));
+           distY=(Yi-ObjectData.Coord(1,2));
+           testin=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;
+       end
+    end
+    %selected indices
+    if isequal(ObjectData.ProjMode,'outside')
+            testin=~testin;
+    end
+    if testfalse
+        testin=testin & (errorflag==0); % keep only non false vectors         
+    end
+    indsel=find(testin);
+    for ivar=VarIndex
+        if testproj(ivar)
+            VarName=FieldData.ListVarName{ivar};
+            eval(['ProjData.' VarName 'Mean=mean(mean(double(FieldData.' VarName '(indsel,:))));']); % keep only non false vectors
+            eval(['[ProjData.' VarName 'Histo,ProjData.' VarName ']=hist(double(FieldData.' VarName '(indsel,:)),100);']); % keep only non false vectors 
+            ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']}];
+            if test_Amat && testcolor
+                 ProjData.VarDimName=[ProjData.VarDimName  {VarName} {{VarName,'rgb'}} {'rgb'}];%{{'nb_point','rgb'}};
+            else
+               ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'nbpoint'}];
+            end
+        end
+    end 
+%     if test_Amat & testcolor
+%        %ProjData.ListDimName=[ProjData.ListDimName {'rgb'}];
+%       % ProjData.DimValue=[ProjData.DimValue 3];
+%       % ProjData.VarDimIndex={[1 2]};
+%        ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName,'rgb'}];%{{'nb_point','rgb'}};
+%        ProjData.VarDimName
+%     end
+end
+
+
+
+%-----------------------------------------------------------------
+%project on a line
+% AJOUTER flux,circul,error
+function  [ProjData,errormsg] = proj_line(FieldData, ObjectData)
+%-----------------------------------------------------------------
+ProjData=proj_heading(FieldData,ObjectData);%transfer global attributes
+ProjData.NbDim=1;
+
+%initialisation of the input parameters and defaultoutput
+ProjMode='projection';%direct projection on the line by default
+if isfield(ObjectData,'ProjMode'),ProjMode=ObjectData.ProjMode; end; 
+ProjAngle=90; %90 degrees projection by default
+if isfield(FieldData,'ProjAngle'),ProjAngle=ObjectData.ProjAngle; end; 
+width=0;%default width of the projection band
+if isfield(ObjectData,'Range')&size(ObjectData.Range,2)>=2
+    width=abs(ObjectData.Range(1,2));
+end
+if isfield(ObjectData,'RangeY')
+    width=max(ObjectData.RangeY);
+end
+
+% default output
+errormsg=[];%default
+Xline=[];
+flux=0;
+circul=0;
+liny=ObjectData.Coord(:,2);
+siz_line=size(ObjectData.Coord);
+if siz_line(1)<2
+    return% line needs at least 2 points to be defined
+end
+testfalse=0;
+ListIndex={};
+
+%angles of the polyline and boundaries of action
+dlinx=diff(ObjectData.Coord(:,1));
+dliny=diff(ObjectData.Coord(:,2));
+theta=angle(dlinx+i*dliny);%angle of each segment
+theta(siz_line(1))=theta(siz_line(1)-1);
+% determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'filter')
+if isequal(ProjMode,'projection') || isequal(ProjMode,'filter')
+    xsup(1)=ObjectData.Coord(1,1)-width*sin(theta(1));
+    xinf(1)=ObjectData.Coord(1,1)+width*sin(theta(1));
+    ysup(1)=ObjectData.Coord(1,2)+width*cos(theta(1));
+    yinf(1)=ObjectData.Coord(1,2)-width*cos(theta(1));
+    for ip=2:siz_line(1)
+        xsup(ip)=ObjectData.Coord(ip,1)-width*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
+        xinf(ip)=ObjectData.Coord(ip,1)+width*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
+        ysup(ip)=ObjectData.Coord(ip,2)+width*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
+        yinf(ip)=ObjectData.Coord(ip,2)-width*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
+    end
+end
+
+%group the variables (fields of 'FieldData') in cells of variables with the same dimensions
+[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
+if ~isempty(errormsg)
+    errormsg=['error in proj_field/proj_line:' errormsg];
+    return
+end
+
+% loop on variable cells with the same space dimension
+ProjData.ListVarName={};
+ProjData.VarDimName={};
+for icell=1:length(CellVarIndex)
+    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
+    VarType=VarTypeCell{icell}; %types of variables
+    if NbDim(icell)~=2% proj_line acts only on fields of space dimension 2, TODO: check 3D case
+        continue
+    end
+    testX=~isempty(VarType.coord_x) && ~isempty(VarType.coord_y);% test for unstructured coordinates
+    testU=~isempty(VarType.vector_x) && ~isempty(VarType.vector_y);% test for vectors
+    testfalse=~isempty(VarType.errorflag);% test for error flag
+    testproj(VarIndex)=zeros(size(VarIndex));% test =1 for simply projected variables, default =0
+                                             %=0 for vector components, treated separately
+    testproj(VarType.scalar)=1;
+    testproj(VarType.image)=1;
+    testproj(VarType.color)=1;
+    VarIndex=VarIndex(find(testproj(VarIndex)));%select only the projected variables
+    if testU
+         VarIndex=[VarIndex VarType.vector_x VarType.vector_y];%append u and v at the end of the list of variables
+    end
+    %identify vector components   
+    if testU
+        UName=FieldData.ListVarName{VarType.vector_x};
+        VName=FieldData.ListVarName{VarType.vector_y};
+        eval(['vector_x=FieldData.' UName ';'])
+        eval(['vector_y=FieldData.' VName ';'])
+    end  
+    %identify error flag
+    if testfalse
+        FFName=FieldData.ListVarName{VarType.errorflag};
+        eval(['errorflag=FieldData.' FFName ';'])
+    end   
+    % check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y
+    if testX
+        if  ~isequal(ProjMode,'interp')
+            if width==0
+                errormsg='range of the projection object is missing';
+                return      
+            else
+                lambda=2/(width*width); %smoothing factor used for filter: weight exp(-2) at distance width from the line
+            end
+        end
+        if ~isequal(ProjMode,'projection')
+            if isfield(ObjectData,'DX')&~isempty(ObjectData.DX)
+                DX=abs(ObjectData.DX);%mesh of interpolation points along the line
+            else
+                errormsg='DX missing';
+                return
+            end
+        end
+        XName= FieldData.ListVarName{VarType.coord_x};
+        YName= FieldData.ListVarName{VarType.coord_y};
+        eval(['coord_x=FieldData.' XName ';'])    
+        eval(['coord_y=FieldData.' YName ';'])
+    end   
+    %initiate projection
+    for ivar=1:length(VarIndex)
+        ProjLine{ivar}=[];
+    end
+    XLine=[];
+    linelengthtot=0;
+
+%         circul=0;
+%         flux=0;
+  %%%%%%%  % A FAIRE CALCULER MEAN DES QUANTITES    %%%%%%
+   %case of unstructured coordinates
+    if testX   
+        for ip=1:siz_line(1)-1     %Loop on the segments of the polyline
+            linelength=sqrt(dlinx(ip)*dlinx(ip)+dliny(ip)*dliny(ip));  
+            %select the vector indices in the range of action
+            if testfalse
+                flagsel=(errorflag==0); % keep only non false vectors
+            else
+                flagsel=ones(size(coord_x));
+            end
+            if isequal(ProjMode,'projection') | isequal(ProjMode,'filter')
+                flagsel=flagsel & ((coord_y -yinf(ip))*(xinf(ip+1)-xinf(ip))>(coord_x-xinf(ip))*(yinf(ip+1)-yinf(ip))) ...
+                & ((coord_y -ysup(ip))*(xsup(ip+1)-xsup(ip))<(coord_x-xsup(ip))*(ysup(ip+1)-ysup(ip))) ...
+                & ((coord_y -yinf(ip+1))*(xsup(ip+1)-xinf(ip+1))>(coord_x-xinf(ip+1))*(ysup(ip+1)-yinf(ip+1))) ...
+                & ((coord_y -yinf(ip))*(xsup(ip)-xinf(ip))<(coord_x-xinf(ip))*(ysup(ip)-yinf(ip)));
+            end
+            indsel=find(flagsel);%indsel =indices of good vectors 
+            X_sel=coord_x(indsel);
+            Y_sel=coord_y(indsel);
+            nbvar=0;
+            for iselect=1:numel(VarIndex)-2*testU
+                VarName=FieldData.ListVarName{VarIndex(iselect)};
+                eval(['ProjVar{iselect}=FieldData.' VarName '(indsel);']);%scalar value
+            end   
+            if testU
+                ProjVar{numel(VarIndex)-1}=cos(theta(ip))*vector_x(indsel)+sin(theta(ip))*vector_y(indsel);% longitudinal component
+                ProjVar{numel(VarIndex)}=-sin(theta(ip))*vector_x(indsel)+cos(theta(ip))*vector_y(indsel);%transverse component         
+            end
+            if isequal(ProjMode,'projection')
+                sintheta=sin(theta(ip));
+                costheta=cos(theta(ip));
+                Xproj=(X_sel-ObjectData.Coord(ip,1))*costheta + (Y_sel-ObjectData.Coord(ip,2))*sintheta; %projection on the line
+                [Xproj,indsort]=sort(Xproj);
+                for ivar=1:numel(ProjVar)
+                    if ~isempty(ProjVar{ivar})
+                        ProjVar{ivar}=ProjVar{ivar}(indsort);
+                     end
+                end
+            elseif isequal(ProjMode,'interp') %linear interpolation:
+                npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX)
+                Xproj=[linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint)];
+                xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1);
+                yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2);
+                for ivar=1:numel(ProjVar)
+                     if ~isempty(ProjVar{ivar})
+                        ProjVar{ivar}=griddata_uvmat(X_sel,Y_sel,ProjVar{ivar},xreg,yreg);
+                     end
+                end
+            elseif isequal(ProjMode,'filter') %filtering
+                npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX)
+                Xproj=[linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint)];
+                siz=size(X_sel);
+                xregij=cos(theta(ip))*Xproj'*ones(1,siz(2))+ObjectData.Coord(ip,1);
+                yregij=sin(theta(ip))*Xproj'*ones(1,siz(2))+ObjectData.Coord(ip,2);
+                xij=ones(npoint,1)*X_sel;
+                yij=ones(npoint,1)*Y_sel;
+                Aij=exp(-lambda*((xij-xregij).*(xij-xregij)+(yij-yregij).*(yij-yregij)));
+                norm=ones(1,siz(2))*Aij';
+                for ivar=1:numel(ProjVar)
+                     if ~isempty(ProjVar{ivar})
+                        ProjVar{ivar}=ProjVar{ivar}*Aij'./norm;
+                     end
+                end              
+            end
+            %prolongate the total record
+            for ivar=1:numel(ProjVar)
+                  if ~isempty(ProjVar{ivar})
+                     ProjLine{ivar}=[ProjLine{ivar}; ProjVar{ivar}];
+                  end
+            end
+            XLine=[XLine ;(Xproj+linelengthtot)];%along line abscissa
+            linelengthtot=linelengthtot+linelength;
+            %     circul=circul+(sum(U_sel))*linelength/npoint;
+            %     flux=flux+(sum(V_sel))*linelength/npoint;
+        end
+        ProjData.X=XLine';
+        cur_index=1;
+        ProjData.ListVarName=[ProjData.ListVarName {XName}];
+        ProjData.VarDimName=[ProjData.VarDimName {XName}];
+        ProjData.VarAttribute{1}.long_name='abscissa along line';
+        for iselect=1:numel(VarIndex)
+            VarName=FieldData.ListVarName{VarIndex(iselect)};
+            eval(['ProjData.' VarName '=ProjLine{iselect};'])
+            ProjData.ListVarName=[ProjData.ListVarName {VarName}];
+            ProjData.VarDimName=[ProjData.VarDimName {XName}];
+            ProjData.VarAttribute{iselect}=FieldData.VarAttribute{VarIndex(iselect)};
+        end
+    
+    %case of structured coordinates
+    elseif  numel(VarType.coord)>=2 & VarType.coord(1:2) > 0;
+        if ~isequal(ObjectData.Style,'line')% exclude polyline
+            errormsg=['no  projection available on ' ObjectData.Style 'for structured coordinates']; % 
+        else
+            test_Amat=1;%image or 2D matrix
+            test_interp2=0;%default
+%             if ~isempty(VarType.coord_y)  
+            AYName=FieldData.ListVarName{VarType.coord(1)};
+            AXName=FieldData.ListVarName{VarType.coord(2)};
+            eval(['AX=FieldData.' AXName ';']);% set of x positions
+            eval(['AY=FieldData.' AYName ';']);% set of y positions  
+            AName=FieldData.ListVarName{VarIndex(1)};
+            eval(['A=FieldData.' AName ';']);% scalar
+            npxy=size(A);
+            npx=npxy(2);
+            npy=npxy(1); 
+            if numel(AX)==2
+                DX=(AX(2)-AX(1))/(npx-1);
+            else
+                DX_vec=diff(AX);
+                DX=max(DX_vec);
+                DX_min=min(DX_vec);
+                if (DX-DX_min)>0.0001*abs(DX) 
+                    test_interp2=1;
+                    DX=DX_min;
+                end    
+            end
+            if numel(AY)==2
+                DY=(AY(2)-AY(1))/(npy-1);
+            else
+                DY_vec=diff(AY);
+                DY=max(DY_vec);
+                DY_min=min(DY_vec);
+                if (DY-DY_min)>0.0001*abs(DY)
+                   test_interp2=1;
+                    DY=DY_min;
+                end     
+            end              
+            AXI=linspace(AX(1),AX(end), npx);%set of  x  positions for the interpolated input data
+            AYI=linspace(AY(1),AY(end), npy);%set of  x  positions for the interpolated input data
+            if isfield(ObjectData,'DX')
+                DXY_line=ObjectData.DX;%mesh on the projection line
+            else
+                DXY_line=sqrt(abs(DX*DY));% mesh on the projection line
+            end
+            dlinx=ObjectData.Coord(2,1)-ObjectData.Coord(1,1);
+            dliny=ObjectData.Coord(2,2)-ObjectData.Coord(1,2);
+            linelength=sqrt(dlinx*dlinx+dliny*dliny);
+            theta=angle(dlinx+i*dliny);%angle of the line   
+            if isfield(FieldData,'RangeX')
+                XMin=min(FieldData.RangeX);%shift of the origin on the line
+            else
+                XMin=0;
+            end
+            eval(['ProjData.' AXName '=linspace(XMin,XMin+linelength,linelength/DXY_line+1);'])%abscissa of the new pixels along the line
+            y=linspace(-width,width,2*width/DXY_line+1);%ordintes of the new pixels (coordinate across the line)
+            eval(['npX=length(ProjData.' AXName ');'])
+            npY=length(y); %TODO: utiliser proj_grid
+            eval(['[X,Y]=meshgrid(ProjData.' AXName ',y);'])%grid in the line coordinates
+            XIMA=ObjectData.Coord(1,1)+(X-XMin)*cos(theta)-Y*sin(theta);
+            YIMA=ObjectData.Coord(1,2)+(X-XMin)*sin(theta)+Y*cos(theta);
+            XIMA=(XIMA-AX(1))/DX+1;%  index of the original image along x
+            YIMA=(YIMA-AY(1))/DY+1;% index of the original image along y
+            XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line'
+            YIMA=reshape(round(YIMA),1,npX*npY);
+            flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
+            ind_in=find(flagin);
+            ind_out=find(~flagin);
+            ICOMB=(XIMA-1)*npy+YIMA;
+            ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
+            nbcolor=1; %color images
+            if numel(npxy)==2
+                nbcolor=1;
+            elseif length(npxy)==3
+                nbcolor=npxy(3);
+            else
+                errormsg='multicomponent field not projected';
+                display(errormsg)
+                return
+            end 
+            nbvar=length(ProjData.ListVarName);% number of var from previous cells
+            ProjData.ListVarName=[ProjData.ListVarName {AXName}];
+            ProjData.VarDimName=[ProjData.VarDimName {AXName}];
+            for ivar=VarIndex
+                VarName{ivar}=FieldData.ListVarName{ivar};
+                if test_interp2% interpolate on new grid
+                    eval(['FieldData.' VarName{ivar} '=interp2(FieldData.' AXName ',FieldData.' AYName ',FieldData.' VarName{ivar} ',AXI,AYI'');']) %TO TEST
+                end
+                eval(['vec_A=reshape(squeeze(FieldData.' VarName{ivar} '),npx*npy,nbcolor);']) %put the original image in colum
+                if nbcolor==1
+                    vec_B(ind_in)=vec_A(ICOMB);
+                    vec_B(ind_out)=zeros(size(ind_out));
+                    A_out=reshape(vec_B,npY,npX);
+                    eval(['ProjData.' VarName{ivar} '=((sum(A_out,1)/npY))'';']);
+                elseif nbcolor==3
+                    vec_B(ind_in,[1:3])=vec_A(ICOMB,:);
+                    vec_B(ind_out,1)=zeros(size(ind_out));
+                    vec_B(ind_out,2)=zeros(size(ind_out));
+                    vec_B(ind_out,3)=zeros(size(ind_out));
+                    A_out=reshape(vec_B,npY,npX,nbcolor);
+                    eval(['ProjData.' VarName{ivar} '=squeeze(sum(A_out,1)/npY);']);
+                end  
+                ProjData.ListVarName=[ProjData.ListVarName VarName{ivar} ];
+                ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate
+            end
+            if testU
+                 eval(['vector_x =ProjData.' VarName{VarType.vector_x} ';'])
+                 eval(['vector_y =ProjData.' VarName{VarType.vector_y} ';'])
+                 eval(['ProjData.' VarName{VarType.vector_x} '=cos(theta)*vector_x+sin(theta)*vector_y;'])
+                 eval(['ProjData.' VarName{VarType.vector_y} '=-sin(theta)*vector_x+cos(theta)*vector_y;'])
+            end
+            ProjData.VarAttribute{nbvar+1}.long_name='abscissa along line';
+            if nbcolor==3
+                ProjData.VarDimName{end}={XName,'rgb'};
+            end
+        end      
+    end
+end
+
+% %shotarter case for horizontal or vertical line (A FAIRE 
+% %     Rangx=[0.5 npx-0.5];%image coordiantes of corners
+% %     Rangy=[npy-0.5 0.5];
+% %     if isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib
+% %         Rangx=Rangx/Calib.Pxcmx;
+% %         Rangy=Rangy/Calib.Pxcmy;
+% %     else
+% %         [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],[0 0]);%case of translations without rotation and quadratic deformation
+% %         [xx,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,[0 0]);
+% %     end 
+% 
+% %     test_scal=0;%default% 3- 'UserData':(get(handles.Tag,'UserData')
+
+
+%-----------------------------------------------------------------
+%project on a plane 
+% AJOUTER flux,circul,error
+ function  [ProjData,errormsg] = proj_plane(FieldData, ObjectData)
+%-----------------------------------------------------------------
+
+%initialisation of the input parameters of the projection plane
+%-----------------------------------------------------------------
+ProjMode='projection';%direct projection by default
+if isfield(ObjectData,'ProjMode'),ProjMode=ObjectData.ProjMode; end;
+
+%axis origin
+if isempty(ObjectData.Coord)
+    ObjectData.Coord(1,1)=0;%origin of the plane set to [0 0] by default
+    ObjectData.Coord(1,2)=0;
+    ObjectData.Coord(1,3)=0;
+end
+
+%rotation angles 
+Phi=0;%default
+Theta=0;
+Psi=0;
+if isfield(ObjectData,'Phi')&& ~isempty(ObjectData.Phi)
+    Phi=(pi/180)*ObjectData.Phi;%first Euler angle in radian
+end
+if isfield(ObjectData,'Theta')&& ~isempty(ObjectData.Theta)
+    Theta=(pi/180)*ObjectData.Theta;%second Euler angle in radian
+end
+if isfield(ObjectData,'Psi')&& ~isempty(ObjectData.Psi)
+    Psi=(pi/180)*ObjectData.Psi;%third Euler angle in radian
+end
+
+%components of the unity vector normal to the projection plane
+NormVec_X=-sin(Phi)*sin(Theta);
+NormVec_Y=cos(Phi)*sin(Theta);
+NormVec_Z=cos(Theta);
+
+% test for 3D fields
+test3D=0;
+if isfield(FieldData,'NbDim')
+    test3D=isequal(FieldData.NbDim,3);
+end
+test3C=test3D; %default 3 vel components
+
+%mesh sizes DX and DY
+DX=0;
+DY=0; %default 
+if isfield(ObjectData,'DX')&~isempty(ObjectData.DX)
+     DX=abs(ObjectData.DX);%mesh of interpolation points 
+end
+if isfield(ObjectData,'DY')&~isempty(ObjectData.DY)
+     DY=abs(ObjectData.DY);%mesh of interpolation points 
+end
+if  ~isequal(ProjMode,'projection') & (DX==0|DY==0)
+        errormsg='DX or DY missing';
+        display(errormsg)
+        return
+end
+
+%extrema along each axis
+testXMin=0;
+testXMax=0;
+testYMin=0;
+testYMax=0;
+if isfield(ObjectData,'RangeX')
+        XMin=min(ObjectData.RangeX);
+        XMax=max(ObjectData.RangeX);
+        testXMin=XMax>XMin;
+        testXMax=1;
+end
+if isfield(ObjectData,'RangeY')
+        YMin=min(ObjectData.RangeY);
+        YMax=max(ObjectData.RangeY);
+        testYMin=YMax>YMin;
+        testYMax=1;
+end
+width=0;%default width of the projection band
+if isfield(ObjectData,'RangeZ')
+        width=max(ObjectData.RangeZ);
+end
+
+% initiate Matlab  structure for physical field
+ProjData=proj_heading(FieldData,ObjectData);
+ProjData.NbDim=2;
+ProjData.ListDimName={};%name of dimension 
+ProjData.DimValue=[];%values of dimension (nbre of vectors)
+ProjData.ListVarName={};
+ProjData.VarDimName={};
+
+error=0;%default
+flux=0;
+testfalse=0;
+ListIndex={};
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%group the variables (fields of 'FieldData') in cells of variables with the same dimensions
+%-----------------------------------------------------------------
+idimvar=0;
+[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
+if ~isempty(errormsg)
+    errormsg=['error in proj_field/proj_plane:' errormsg];
+    return
+end
+%LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
+% CellVarIndex=cells of variable index arrays
+ivar_new=0; % index of the current variable in the projected field
+icoord=0;
+nbcoord=0;%number of added coordinate variables brought by projection
+for icell=1:length(CellVarIndex)
+    if NbDim(icell)<2
+        continue
+    end
+    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
+    VarType=VarTypeCell{icell};
+    ivar_X=VarType.coord_x;
+    ivar_Y=VarType.coord_y;
+    ivar_Z=VarType.coord_z;
+    ivar_U=VarType.vector_x;
+    ivar_V=VarType.vector_y;
+    ivar_W=VarType.vector_z;
+    ivar_C=VarType.scalar ;
+    ivar_Anc=VarType.ancillary;
+    test_anc=zeros(size(VarIndex));
+    test_anc(ivar_Anc)=ones(size(ivar_Anc));
+    ivar_F=VarType.warnflag;
+    ivar_FF=VarType.errorflag;
+    testX=~isempty(ivar_X) && ~isempty(ivar_Y);
+    %DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
+    DimCell=FieldData.VarDimName{VarIndex(1)};
+    if ischar(DimCell)
+        DimCell={DimCell};%name of dimensions
+    end
+    
+%case of input fields with unstructured coordinates
+    if testX
+        XName=FieldData.ListVarName{ivar_X};
+        YName=FieldData.ListVarName{ivar_Y};
+        eval(['coord_x=FieldData.' XName ';'])
+        eval(['coord_y=FieldData.' YName ';'])
+        if length(ivar_Z)==1
+            ZName=FieldData.ListVarName{ivar_X};
+            eval(['coord_z=FieldData.' ZName ';'])
+        end
+
+        % translate  initial coordinates
+        coord_x=coord_x-ObjectData.Coord(1,1);
+        coord_y=coord_y-ObjectData.Coord(1,2);
+        if ~isempty(ivar_Z)
+            coord_z=coord_z-ObjectData.Coord(1,3);
+        end
+        
+        % selection of the vectors in the projection range (3D case)
+        if length(ivar_Z)==1 &&  width > 0
+            %components of the unitiy vector normal to the projection plane
+            fieldZ=NormVec_X*coord_x + NormVec_Y*coord_y+ NormVec_Z*coord_z;% distance to the plane            
+            indcut=find(abs(fieldZ) <= width);
+            for ivar=VarIndex
+                VarName=FieldData.ListVarName{ivar};
+                eval(['FieldData.' VarName '=FieldData.' VarName '(indcut);'])
+%                 end      
+                    % A VOIR : CAS DE VAR STRUCTUREE MAIS PAS GRILLE REGULIERE : INTERPOLER SUR GRILLE REGULIERE              
+            end
+            coord_x=coord_x(indcut);
+            coord_y=coord_y(indcut);
+            coord_z=coord_z(indcut);
+        end
+
+       %rotate coordinates if needed
+        if isequal(Phi,0)
+            coord_X=coord_x;
+            coord_Y=coord_y;
+            if ~isequal(Theta,0)
+                coord_Y=coord_Y *cos(Theta);
+            end
+        else
+            coord_X=(coord_x *cos(Phi) + coord_y* sin(Phi));
+            coord_Y=(-coord_x *sin(Phi) + coord_y *cos(Phi))*cos(Theta);
+        end
+        if ~isempty(ivar_Z)
+            coord_Y=coord_Y+coord_z *sin(Theta);
+        end
+        if ~isequal(Psi,0)
+                coord_X=(coord_X *cos(Psi) - coord_Y* sin(Psi));%A VERIFIER
+                coord_Y=(coord_X *sin(Psi) + coord_Y* cos(Psi));
+        end
+        
+        %restriction to the range of x and y if imposed
+        testin=ones(size(coord_X)); %default
+        testbound=0;
+        if testXMin
+            testin=testin & (coord_X >= XMin);
+            testbound=1;
+        end
+        if testXMax
+            testin=testin & (coord_X <= XMax);
+            testbound=1;
+        end
+        if testYMin
+            testin=testin & (coord_Y >= YMin);
+            testbound=1;
+        end
+        if testYMin
+            testin=testin & (coord_Y <= YMax);
+            testbound=1;
+        end
+        if testbound
+            indcut=find(testin);
+            for ivar=VarIndex
+                VarName=FieldData.ListVarName{ivar};
+                eval(['FieldData.' VarName '=FieldData.' VarName '(indcut);'])            
+            end
+            coord_X=coord_X(indcut);
+            coord_Y=coord_Y(indcut);
+            if length(ivar_Z)==1
+                coord_Z=coord_Z(indcut);
+            end
+        end
+        % different cases of projection
+        if isequal(ObjectData.ProjMode,'projection')
+            ProjData.ListDimName=[ProjData.ListDimName FieldData.ListDimName(DimIndices(1))];%add the point index to the list of dimensions
+            ProjData.DimValue=[ProjData.DimValue length(coord_X)];
+            nbvar=0;
+            for ivar=VarIndex %transfer variables to the projection plane
+                VarName=FieldData.ListVarName{ivar};
+                if ivar==ivar_X %x coordinate
+                    eval(['ProjData.' VarName '=coord_X;'])
+                elseif ivar==ivar_Y % y coordinate
+                    eval(['ProjData.' VarName '=coord_Y;'])
+                elseif isempty(ivar_Z) || ivar~=ivar_Z % other variables (except Z coordinate wyhich is not reproduced)
+                    eval(['ProjData.' VarName '=FieldData.' VarName ';'])
+                end
+                if isempty(ivar_Z) || ivar~=ivar_Z 
+                    ProjData.ListVarName=[ProjData.ListVarName VarName];
+                    ProjData.VarDimIndex=[ProjData.VarDimIndex DimIndices(1)];
+                    nbvar=nbvar+1;
+                    if isfield(FieldData,'VarAttribute') & length(FieldData.VarAttribute) >=ivar
+                        ProjData.VarAttribute{nbvar}=FieldData.VarAttribute{ivar};
+                    end
+                end
+            end  
+        elseif isequal(ObjectData.ProjMode,'interp')||isequal(ObjectData.ProjMode,'filter')%interpolate data on a regular grid
+            coord_x_proj=[XMin:DX:XMax];
+            coord_y_proj=[YMin:DY:YMax];
+            DimCell={'coord_y','coord_x'};
+            %ProjData.DimValue=[length(coord_y_proj) length(coord_x_proj)];
+            ProjData.ListVarName={'coord_y','coord_x'};
+            ProjData.VarDimName={'coord_y','coord_x'};   
+            nbcoord=2;
+            %ProjData.VarDimIndex={};   
+            ProjData.coord_y=[YMin YMax];
+            ProjData.coord_x=[XMin XMax];
+            if isempty(ivar_X), ivar_X=0; end;
+            if isempty(ivar_Y), ivar_Y=0; end;
+            if isempty(ivar_Z), ivar_Z=0; end;
+            if isempty(ivar_U), ivar_U=0; end;
+            if isempty(ivar_V), ivar_V=0; end;
+            if isempty(ivar_W), ivar_W=0; end;
+            if isempty(ivar_F), ivar_F=0; end;
+            if isempty(ivar_FF), ivar_FF=0; end;
+            if ~isequal(ivar_FF,0)
+                VarName_FF=FieldData.ListVarName{ivar_FF};
+                eval(['indsel=find(FieldData.' VarName_FF '==0);'])
+                coord_X=coord_X(indsel);
+                coord_Y=coord_Y(indsel);
+            end
+            FF=zeros(1,length(coord_y_proj)*length(coord_x_proj));
+            testFF=0;
+            for ivar=VarIndex
+                VarName=FieldData.ListVarName{ivar}; 
+                if ~( ivar==ivar_X | ivar==ivar_Y | ivar==ivar_Z | ivar==ivar_F | ivar==ivar_FF | test_anc(ivar)==1)                 
+                    ivar_new=ivar_new+1;
+                    ProjData.ListVarName=[ProjData.ListVarName {VarName}];
+                    ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
+                    %ProjData.VarDimIndex=[ProjData.VarDimIndex {[1 2]}];
+                    if isfield(FieldData,'VarAttribute') & length(FieldData.VarAttribute) >=ivar
+                        ProjData.VarAttribute{ivar_new+nbcoord}=FieldData.VarAttribute{ivar};
+                    end
+%                     ProjData.VarAttribute{ivar_new}.Coord_2=[XMin XMax];
+%                     ProjData.VarAttribute{ivar_new}.Coord_1=[YMin YMax];
+                    if  ~isequal(ivar_FF,0)
+                        eval(['FieldData.' VarName '=FieldData.' VarName '(indsel);'])
+                    end
+                    eval(['ProjData.' VarName '=griddata_uvmat(coord_X,coord_Y,FieldData.' VarName ',coord_x_proj,coord_y_proj'');'])
+                    eval(['varline=reshape(ProjData.' VarName ',1,length(coord_y_proj)*length(coord_x_proj));'])
+                    FFlag= isnan(varline); %detect undefined values NaN
+                    indnan=find(FFlag);
+                    if~isempty(indnan)
+                        varline(indnan)=zeros(size(indnan));
+                        eval(['ProjData.' VarName '=reshape(varline,length(coord_y_proj),length(coord_x_proj));'])
+                        FF(indnan)=ones(size(indnan));
+%                         eval(['ProjData.' VarName '(indnan)=zeros(size(indnan));'])%put NaN to 0
+%                         FF=FF|FFlag;
+                        testFF=1;
+                    end
+                    if ivar==ivar_U
+                        ivar_U=ivar_new;
+                    end
+                    if ivar==ivar_V
+                        ivar_V=ivar_new;
+                    end
+                    if ivar==ivar_W
+                        ivar_W=ivar_new;
+                    end
+                end
+            end
+            if testFF
+                ProjData.FF=reshape(FF,length(coord_y_proj),length(coord_x_proj));
+                ProjData.ListVarName=[ProjData.ListVarName {'FF'}];
+              %  ProjData.VarDimIndex=[ProjData.VarDimIndex {[1 2]}];
+               ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
+                ProjData.VarAttribute{ivar_new+1+nbcoord}.Role='errorflag';
+            end
+        end
+%case of fields defined on a structured  grid 
+    else  
+        AYName=FieldData.ListVarName{VarType.coord(1)};
+        AXName=FieldData.ListVarName{VarType.coord(2)};
+        eval(['AX=FieldData.' AXName ';'])
+        eval(['AY=FieldData.' AYName ';'])
+        VarName=FieldData.ListVarName{VarIndex(1)};
+        eval(['DimValue=size(FieldData.' VarName ');'])
+        ListDimName=FieldData.ListDimName(DimIndices);
+        ProjData.ListVarName=[{AYName} {AXName} ProjData.ListVarName]; %TODO: check if it already exists in Projdata (several cells)
+        ProjData.VarDimName=[{AYName} {AXName} ProjData.VarDimName];
+        nbcolor=1; %default
+        for idim=1:length(ListDimName)
+            DimName=ListDimName{idim};
+            if isequal(DimName,'rgb')|isequal(DimName,'nb_coord')|isequal(DimName,'nb_coord_i')
+               nbcolor=DimValue(idim);
+               DimIndices(idim)=[];
+               DimValue(idim)=[];
+            end
+            if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED
+                DimIndices(idim)=[];
+                DimValue(idim)=[];
+            end
+        end  
+        ind_1=find(DimValue==1);
+        DimIndices(ind_1)=[]; %suppress singleton dimensions 
+%         indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero)
+        nb_dim=length(DimIndices);%number of space dimensions
+        Coord_z=[];
+        Coord_y=[];
+        Coord_x=[];   
+    
+        for idim=1:nb_dim %loop on space dimensions
+            test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
+            test_coord(idim)=0;%test for defined coordinates, =0 by default
+            ivar=DimVarIndex(DimIndices(idim));% index of the variable corresponding to the current dimension
+            if ~isequal(ivar,0)%  a variable corresponds to the current dimension
+                eval(['Coord{idim}=FieldData.' FieldData.ListVarName{ivar} ';']) ;% position for the first index
+                DCoord=diff(Coord{idim});
+                DCoord_min(idim)=min(DCoord);
+                DCoord_max=max(DCoord);
+                test_direct(idim)=DCoord_max>0;% =1 for increasing values, 0 otherwise
+                test_direct_min=DCoord_min(idim)>0;% =1 for increasing values, 0 otherwise
+                if ~isequal(test_direct(idim),test_direct_min)
+                     warndlg_uvmat(['non monotonic dimension variable # ' num2str(idim)  ' in proj_field.m'],'ERROR')
+                                return
+                end               
+                test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity
+                test_coord(idim)=1;
+
+            else  % no variable associated with the first dimension, look for variable  attributes Coord_1, _2 or _3
+                Coord_i_str=['Coord_' num2str(idim)];
+                DCoord_min(idim)=1;%default
+                Coord{idim}=[0.5 DimValue(idim)-0.5];
+                test_direct(idim)=1;
+%                 for ivar=VarIndex
+%                     if  isfield(FieldData.VarAttribute{ivar},Coord_i_str)% if there is a variable  attribute named Coord_1, _2 or _3
+%                          eval(['Coord{idim}=FieldData.VarAttribute{ivar}.' Coord_i_str ';']);%'range x 
+%                          if isnumeric(Coord{idim})
+%                              if length(Coord{idim})>=2
+%                                 test_direct(idim)=(Coord{idim}(2)>Coord{idim}(1));
+%                              else 
+%                                 warndlg_uvmat(['two values needed for ' Coord_i_str 'in proj_field.m'],'ERROR')
+%                                 return
+%                              end
+%                          else
+%                             warndlg_uvmat(['non numerical coordinate attributes' Coord_i_str 'in proj_field.m'],'ERROR')
+%                             return
+%                          end
+%                          DCoord_min(idim)=(Coord{idim}(end)-Coord{idim}(1))/(DimValue(idim)-1);
+%                     end
+%                 end
+            end
+        end
+        if nb_dim==2
+            if DY==0
+                DY=abs(DCoord_min(1));
+            end
+            npY=1+round(abs(Coord{1}(end)-Coord{1}(1))/DY);%nbre of points after interpolation 
+            npy=1+round(abs(Coord{1}(end)-Coord{1}(1))/abs(DCoord_min(1)));%nbre of points after possible interpolation on a regular grid
+            if DX==0
+                DX=abs(DCoord_min(2));
+            end
+            npX=1+round(abs(Coord{2}(end)-Coord{2}(1))/DX);%nbre of points after interpol  
+            npx=1+round(abs(Coord{2}(end)-Coord{2}(1))/abs(DCoord_min(2)));%nbre of points after possible interpolation on a regular grid 
+            Coord_y=linspace(Coord{1}(1),Coord{1}(end),npY);
+            test_direct_y=test_direct(1);
+            Coord_x=linspace(Coord{2}(1),Coord{2}(end),npX);
+            test_direct_x=test_direct(2);
+            DAX=DCoord_min(2);
+            DAY=DCoord_min(1);
+        elseif nb_dim==3
+            DZ=abs(DCoord_min(1));
+            npz=1+round(abs(Coord{1}(end)-Coord{1}(1))/DZ);%nbre of points after interpolation
+            if DY==0
+                DY=abs(DCoord_min(2));
+            end
+            npY=1+round(abs(Coord{2}(end)-Coord{2}(1))/DY);%nbre of points after interpol 
+            npy=1+round(abs(Coord{2}(end)-Coord{2}(1))/abs(DCoord_min(2)));%nbre of points before interpol 
+            if DX==0
+                DX=abs(DCoord_min(3));
+            end
+            npX=1+round(abs(Coord{3}(end)-Coord{3}(1))/DX);%nbre of points after interpol
+            npx=1+round(abs(Coord{3}(end)-Coord{3}(1))/abs(DCoord_min(3)));%nbre of points before interpol 
+            Coord_z=linspace(Coord{1}(1),Coord{1}(end),npz);
+            test_direct_z=test_direct(1);
+            Coord_y=linspace(Coord{2}(1),Coord{2}(end),npY);
+            test_direct_y=test_direct(2);
+            Coord_x=linspace(Coord{3}(1),Coord{3}(end),npX);
+            test_direct_x=test_direct(3);
+        end  
+        minAX=min(Coord_x);
+        maxAX=max(Coord_x);
+        minAY=min(Coord_y);
+        maxAY=max(Coord_y);
+        xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);
+        ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);
+        xcor_new=xcorner*cos(Phi)+ycorner*sin(Phi);%coord new frame
+        ycor_new=-xcorner*sin(Phi)+ycorner*cos(Phi);
+        if ~testXMax
+            XMax=max(xcor_new);
+        end
+        if ~testXMin
+            XMin=min(xcor_new);
+        end
+        if ~testYMax
+            YMax=max(ycor_new);
+        end
+        if ~testYMin
+            YMin=min(ycor_new);
+        end
+        DXinit=(maxAX-minAX)/(npx-1);
+        DYinit=(maxAY-minAY)/(npy-1);
+        if DX==0
+            DX=DXinit;
+        end
+        if DY==0
+            DY=DYinit;
+        end
+        npX=floor((XMax-XMin)/DX+1);
+        npY=floor((YMax-YMin)/DY+1);    
+        if test_direct_y
+            coord_y_proj=linspace(YMin,YMax,npY);%abscissa of the new pixels along the line
+        else
+            coord_y_proj=linspace(YMax,YMin,npY);%abscissa of the new pixels along the line
+        end
+        if test_direct_x
+            coord_x_proj=linspace(XMin,XMax,npX);%abscissa of the new pixels along the line
+        else
+            coord_x_proj=linspace(XMax,XMin,npX);%abscissa of the new pixels along the line
+        end 
+        
+        % case with no rotation and interpolation
+        if isequal(ProjMode,'projection') && isequal(Phi,0) && isequal(Theta,0) && isequal(Psi,0)
+            if test_direct(1)
+                min_ind1=ceil((YMin-Coord{1}(1))/DYinit)+1;
+                max_ind1=floor((YMax-Coord{1}(1))/DYinit)+1;
+                Ybound(1)=Coord{1}(1)+DYinit*(min_ind1-1);
+                Ybound(2)=Coord{1}(1)+DYinit*(max_ind1-1);
+            else
+                min_ind1=ceil((Coord{1}(1)-YMax)/DYinit)+1;
+                max_ind1=floor((Coord{1}(1)-YMin)/DYinit)+1;
+                Ybound(2)=Coord{1}(1)-DYinit*(max_ind1-1);
+                Ybound(1)=Coord{1}(1)-DYinit*(min_ind1-1);
+            end              
+            if test_direct(2)==1
+                min_ind2=ceil((XMin-Coord{2}(1))/DXinit)+1;
+                max_ind2=floor((XMax-Coord{2}(1))/DXinit)+1;
+                Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
+                Xbound(2)=Coord{2}(1)+DXinit*(max_ind2-1);
+            else
+                min_ind2=ceil((Coord{2}(1)-XMax)/DXinit)+1;
+                max_ind2=floor((Coord{2}(1)-XMin)/DXinit)+1;
+                Xbound(2)=Coord{2}(1)+DXinit*(max_ind2-1);
+                Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
+            end 
+            min_ind1=max(min_ind1,1);% deals with margin (bound lower than the first index)
+            min_ind2=max(min_ind2,1);
+            max_ind1=min(max_ind1,npy);
+            max_ind2=min(max_ind2,npx);
+            for ivar=VarIndex
+                VarName=FieldData.ListVarName{ivar}; 
+%                 if isequal(ObjectData.ProjMode,'interp')||isequal(ObjectData.ProjMode,'filter')% coordinates common to all fields
+%                     ProjData.ListDimName={'coord_y','coord_x'};
+%                     ProjData.DimValue=[length(coord_y_proj) length(coord_x_proj)];
+%                 else
+%                     icoord=icoord+1;
+%                     ProjData.ListDimName=[ProjData.ListDimName {['coord_y_' num2str(icoord)],['coord_x_' num2str(icoord)]}];
+%                     ProjData.DimValue=[ProjData.DimValue length(coord_y_proj) length(coord_x_proj)];
+%                 end
+                ProjData.ListVarName=[ProjData.ListVarName VarName];
+                ProjData.VarDimIndex=[ProjData.VarDimIndex [nb_dim-1 nb_dim]];
+                if length(FieldData.VarAttribute)>=ivar
+                    ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar};
+                end
+%                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=Xbound;
+%                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=Ybound;
+                eval(['ProjData.' VarName '=FieldData.' VarName '(min_ind1:max_ind1,min_ind2:max_ind2) ;']);
+            end         
+        else
+        % case with rotation and/or interpolation
+            if isempty(Coord_z) %2D case
+                [X,Y]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
+                XIMA=ObjectData.Coord(1,1)+(X)*cos(Phi)-Y*sin(Phi);%corresponding coordinates in the original image
+                YIMA=ObjectData.Coord(1,2)+(X)*sin(Phi)+Y*cos(Phi);
+                XIMA=(XIMA-minAX)/DXinit+1;% image index along x
+                YIMA=(-YIMA+maxAY)/DYinit+1;% image index along y
+                XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line'
+                YIMA=reshape(round(YIMA),1,npX*npY);
+                flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image 
+                if isequal(ObjectData.ProjMode,'filter')
+                    npx_filter=ceil(abs(DX/DAX));
+                    npy_filter=ceil(abs(DY/DAY));
+                    Mfilter=ones(npy_filter,npx_filter)/(npx_filter*npy_filter);
+                    test_filter=1;
+                else
+                    test_filter=0;
+                end
+                for ivar=VarIndex
+                    VarName=FieldData.ListVarName{ivar} ; 
+                    if test_interp(1) | test_interp(2)%interpolate on a regular grid         
+                          eval(['FieldData.' VarName '=interp2(Coord{2},Coord{1},FieldData.' VarName ',Coord_x,Coord_y'');']) %TO TEST
+                    end
+                    %filter the field (image) if option 'filter' is used
+                    if test_filter  
+                         Aclass=class(FieldData.A);
+                         eval(['FieldData.' VarName '=filter2(Mfilter,FieldData.' VarName ',''valid'');'])
+                         if ~isequal(Aclass,'double')
+                             eval(['FieldData.' VarName '=' Aclass '(FieldData.' VarName ');'])%revert to integer values
+                         end
+                    end
+                    eval(['vec_A=reshape(FieldData.' VarName ',npx*npy,nbcolor);'])%put the original image in line              
+                    ind_in=find(flagin);
+                    ind_out=find(~flagin);
+                    ICOMB=(XIMA-1)*npy+YIMA;
+                    ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
+                    vec_B(ind_in,[1:nbcolor])=vec_A(ICOMB,:); 
+                    for icolor=1:nbcolor
+                        vec_B(ind_out,icolor)=zeros(size(ind_out));
+                    end
+                    % TODO: A REVOIR:
+%                     if isequal(ObjectData.ProjMode,'interp') || isequal(ObjectData.ProjMode,'filter')% coordinates common to all fields
+%                         ProjData.ListDimName={'coord_y','coord_x'};
+%                         ProjData.DimValue=[length(coord_y_proj) length(coord_x_proj)];
+%                     else
+%                         icoord=icoord+1;
+%                         ProjData.ListDimName=[ProjData.ListDimName {['coord_y_' num2str(icoord)],['coord_x_' num2str(icoord)]}];
+%                         ProjData.DimValue=[ProjData.DimValue length(coord_y_proj) length(coord_x_proj)];
+%                     end
+                    ProjData.ListVarName=[ProjData.ListVarName VarName];                 
+                   % ProjData.VarDimIndex=[ProjData.VarDimIndex [nb_dim-1 nb_dim]];
+                    if length(FieldData.VarAttribute)>=ivar
+                        ProjData.VarAttribute{length(ProjData.ListVarName)+nbcoord}=FieldData.VarAttribute{ivar};
+                    end
+                    % A REVOIR:
+%                     if test_direct(2)==1
+%                         ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=[XMin XMax];
+%                     else
+%                         ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=[XMax XMin];
+%                     end
+%                     if test_direct(1)==1
+%                         ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=[YMin YMax];
+%                     else
+%                         ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=[YMax YMin];
+%                     end      
+                    eval(['ProjData.' VarName '=reshape(vec_B,npY,npX,nbcolor);']);
+                end
+                ProjData.FF=reshape(~flagin,npY,npX);%false flag A FAIRE: tenir compte d'un flga antérieur  
+                ProjData.ListVarName=[ProjData.ListVarName 'FF'];
+              %  ProjData.VarDimIndex=[ProjData.VarDimIndex [nb_dim-1 nb_dim]];
+                ProjData.VarAttribute{length(ProjData.ListVarName)}.Role='errorflag';
+            else %3D case
+                if isequal(Theta,0) & isequal(Phi,0)       
+                    test_sup=(Coord{1}>=ObjectData.Coord(1,3));
+                    iz_sup=find(test_sup);
+                    iz=iz_sup(1);
+                    if iz>=1 & iz<=npz
+                        ProjData.ListDimName=[ProjData.ListDimName ListDimName(2:end)];
+                        ProjData.DimValue=[ProjData.DimValue npY npX];
+                        for ivar=VarIndex
+                            VarName=FieldData.ListVarName{ivar}; 
+                            ProjData.ListVarName=[ProjData.ListVarName VarName];
+                          %  ProjData.VarDimIndex=[ProjData.VarDimIndex [nb_dim-2 nb_dim-1]];
+                            ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar}; %reproduce the variable attributes
+                            % A REVOIR
+%                             if test_direct_x==1
+%                                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=[XMin XMax];
+%                             else
+%                                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=[XMax XMin];
+%                             end
+%                             if test_direct_y==1
+%                                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=[YMin YMax];
+%                             else
+%                                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=[YMax YMin];
+%                             end      
+                            eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz
+                            %TODO : do a vertical average for a thick plane
+                            if test_interp(2) | test_interp(3)
+                                eval(['ProjData.' VarName '=interp2(Coord{3},Coord{2},ProjData.' VarName ',Coord_x,Coord_y'');']) 
+                            end
+                        end
+                    end
+                else
+                    errormsg='projection of structured coordinates on oblique plane not yet implemented';
+                    %TODO: use interp3
+                    return
+                end
+            end
+        end
+    end
+    %projection of  velocity components in the rotated coordinates
+    if ~isequal(Phi,0) & length(ivar_U)==1
+        if isempty(ivar_V)
+            warndlg_uvmat('v velocity component missing in proj_field.m','ERROR')
+            return
+        end
+        UName=FieldData.ListVarName{ivar_U};
+        VName=FieldData.ListVarName{ivar_V};    
+        eval(['ProjData.' UName  '=cos(Phi)*ProjData.' UName '+ sin(Phi)*ProjData.' VName ';'])
+        eval(['ProjData.' VName  '=cos(Theta)*(-sin(Phi)*ProjData.' UName '+ cos(Phi)*ProjData.' VName ');'])
+        if ~isempty(ivar_W)
+            WName=FieldData.ListVarName{ivar_W};
+            eval(['ProjData.' VName '=ProjData.' VName '+ ProjData.' WName '*sin(Theta);'])% 
+            eval(['ProjData.' WName '=NormVec_X*ProjData.' UName '+ NormVec_Y*ProjData.' VName '+ NormVec_Z* ProjData.' WName ';']);
+        end
+        if ~isequal(Psi,0)
+            eval(['ProjData.' UName '=cos(Psi)* ProjData.' UName '- sin(Psi)*ProjData.' VName ';']);
+            eval(['ProjData.' VName '=sin(Psi)* ProjData.' UName '+ cos(Psi)*ProjData.' VName ';']);
+        end
+    end
+end
+
+%-----------------------------------------------------------------
+%transmit the global attributes
+function [ProjData,errormsg]=proj_heading(FieldData,ObjectData)
+%-----------------------------------------------------------------
+% ProjData=FieldData;
+ProjData=[];%default
+if ~isfield(FieldData,'ListGlobalAttribute')
+    ProjData.ListGlobalAttribute={};
+else
+    ProjData.ListGlobalAttribute=FieldData.ListGlobalAttribute;
+end
+if isfield(FieldData,'Txt')
+    errormsg=FieldData.Txt; %transmit erreur message
+    return;
+end
+for iattr=1:length(ProjData.ListGlobalAttribute)
+    AttrName=ProjData.ListGlobalAttribute{iattr};
+    if isfield(FieldData,AttrName)
+        eval(['ProjData.' AttrName '=FieldData.' AttrName ';']);
+    end
+end
+if isfield(FieldData,'CoordType')
+    if isfield(ObjectData,'CoordType')&~isequal(FieldData.CoordType,ObjectData.CoordType)
+        errormsg=[ObjectData.Style ' in ' ObjectData.CoordType ' coordinates, while field in ' FieldData.CoordType ' coordinates'];
+        return
+    else
+         ProjData.CoordType=FieldData.CoordType;
+    end
+end
+
+ListObject={'Style','ProjMode','RangeX','RangeY','RangeZ','Phi','Theta','Psi','Coord'};
+for ilist=1:length(ListObject)
+    if isfield(ObjectData,ListObject{ilist})
+        eval(['val=ObjectData.' ListObject{ilist} ';'])
+        if ~isempty(val)
+            eval(['ProjData.Object' ListObject{ilist} '=val;']);
+            ProjData.ListGlobalAttribute=[ProjData.ListGlobalAttribute {['Object' ListObject{ilist}]}];
+        end
+    end   
+end
Index: /trunk/src/private/proj_grid.m
===================================================================
--- /trunk/src/private/proj_grid.m	(revision 8)
+++ /trunk/src/private/proj_grid.m	(revision 8)
@@ -0,0 +1,83 @@
+%'proj_grid': project  fields with unstructured coordinantes on a regular grid
+% -------------------------------------------------------------------------
+% function [A,rangx,rangy]=proj_grid(vec_X,vec_Y,vec_A,rgx_in,rgy_in,npxy_in)
+
+
+function [A,rangx,rangy]=proj_grid(vec_X,vec_Y,vec_A,rgx_in,rgy_in,npxy_in)
+    if length(vec_Y)<2
+        warndlg_uvmat('less than 2 points in proj_grid.m','ERROR');
+        return; 
+    end
+    diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
+    index=find(diffy);% find the indices of vec_Y after wich a change of horizontal line occurs(diffy non zero)
+    if isempty(index); warndlg_uvmat('points aligned along abscissa in proj_grid.m','ERROR'); return; end;%points aligned% A FAIRE: switch to line plot.
+    diff2=diff(diffy(index));% diff2 = fluctuations of the detected vertical grid mesh dy 
+    if max(abs(diff2))>0.001*abs(diffy(index(1))) % if max(diff2) is larger than 1/1000 of the first mesh dy
+        % the data are not regularly spaced and must be interpolated  on a regular grid
+        if exist('rgx_in','var') & ~isempty (rgx_in) & isnumeric(rgx_in) & length(rgx_in)==2%  positions imposed from input
+            rangx=rgx_in; % first and last positions
+            rangy=rgy_in;
+%             npxy=npxy_in;
+            dxy(1)=1/(npxy_in(1)-1);%grid mesh in y
+            dxy(2)=1/(npxy_in(2)-1);%grid mesh in x
+            dxy(1)=(rangy(2)-rangy(1))/(npxy_in(1)-1);%grid mesh in y
+            dxy(2)=(rangx(2)-rangx(1))/(npxy_in(2)-1);%grid mesh in x
+        else % interpolation grid automatically determined
+            rangx(1)=min(vec_X);
+            rangx(2)=max(vec_X);
+            rangy(2)=min(vec_Y);
+            rangy(1)=max(vec_Y);
+            dxymod=sqrt((rangx(2)-rangx(1))*(rangy(1)-rangy(2))/length(vec_X));
+            dxy=[-dxymod/4 dxymod/4];% increase the resolution 4 times
+        end
+        xi=[rangx(1):dxy(2):rangx(2)];
+        yi=[rangy(1):dxy(1):rangy(2)];
+        [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
+        A=griddata_uvmat(vec_X,vec_Y,vec_A,xi,yi'); 
+        A=reshape(A,length(yi),length(xi));
+    else
+        x=vec_X(1:index(1));% the set of abscissa (obtained on the first line)
+        indexend=index(end);% last vector index of line change
+        ymax=vec_Y(indexend+1);% y coordinate AFTER line change
+        ymin=vec_Y(index(1));
+        %y=[vec_Y(index) ymax]; % the set of y ordinates including the last one
+        y=vec_Y(index);
+        y(length(y)+1)=ymax;
+        nx=length(x);   %number of grid points in x
+        ny=length(y);   % number of grid points in y
+        B=(reshape(vec_A,nx,ny))'; %vec_A reshaped as a rectangular matrix
+        [X,Y]=meshgrid(x,y);% positions X and Y also reshaped as matrix 
+        
+        %linear interpolation to improve the image resolution and/or adjust
+        %to prescribed positions 
+        test_interp=1;
+        if exist('rgx_in','var') & ~isempty (rgx_in) & isnumeric(rgx_in) & length(rgx_in)==2%  positions imposed from input
+            rangx=rgx_in; % first and last positions
+            rangy=rgy_in;
+            npxy=npxy_in;
+        else        
+            rangx=[vec_X(1) vec_X(nx)];% first and last position found for x
+%             rangy=[ymin ymax];
+              rangy=[max(ymax,ymin) min(ymax,ymin)];
+            if max(nx,ny) <= 64 & isequal(npxy_in,'np>256')
+                npxy=[8*ny 8*nx];% increase the resolution 8 times
+            elseif max(nx,ny) <= 128 & isequal(npxy_in,'np>256')
+                npxy=[4*ny 4*nx];% increase the resolution 4 times
+            elseif max(nx,ny) <= 256 & isequal(npxy_in,'np>256')
+                npxy=[2*ny 2*nx];% increase the resolution 2 times
+            else
+                npxy=[ny nx];
+                test_interp=0; % no interpolation done
+            end
+        end
+        if test_interp==1%if we interpolate
+            xi=[rangx(1):(rangx(2)-rangx(1))/(npxy(2)-1):rangx(2)];
+            yi=[rangy(1):(rangy(2)-rangy(1))/(npxy(1)-1):rangy(2)];
+            [XI,YI]=meshgrid(xi,yi);
+            A = interp2(X,Y,B,XI,YI);
+        else %no interpolation for a resolution higher than 256
+            A=B;
+            XI=X;
+            YI=Y;
+        end
+    end
Index: /trunk/src/private/px.m
===================================================================
--- /trunk/src/private/px.m	(revision 8)
+++ /trunk/src/private/px.m	(revision 8)
@@ -0,0 +1,87 @@
+%'px': transform fields from physical coordinates (phys) to image (px) coordinates 
+
+% OUTPUT: 
+% DataOut:   structure of modified data (transforms DataIn)
+%       DataOut.CoordType='px': labels image coordinates
+%       DataOut.CoordUnit= 'px' : units of output coordinates
+%       DataOut.X and .Y arrays of image coordinates X, Y
+%       DataOut.U, .V velocity in pixel displacement on the image (unit=px), if velocity exists as input 
+%    
+%INPUT:
+% DataIn:  structure of possible input data (like UvData) or cell of structures (several fields):
+%      DataIn.CoordType='phys': allows transform to px, else no transform   (DataOut=DataIn)
+%      DataIn.X and .Y arrays of physical coordinates X, Y
+%      DataIn.Z corresponding array of Z coordinates (=0 by default)
+%      DataIn.U, V corresponding array of velocity components
+%      DataIn.W corresponding array of the third velocity component in 3D case
+%      DataIn.dt: time interval of the image pair used for velocity measurement (NEEDED TO GET OUTPUT RESULT))
+%      DataIn.A, AX, AY : image or scalar input -> EMPTY  CORRESPONDING OUTPUT (A REVOIR)
+%      Other fields in DataIn: copied to DataOut without modification
+% Calib: structure containing the calibration parameters (Tsai) or containing a subtree Calib.GeometryCalib with these parameters
+%
+% call the functions phys_XYZ or px_XYZ (case of images) for pointwise coordinate transforms
+
+function [DataOut,DataOut_1]=px(Data,CalibData,Data_1,CalibData_1)%DataIn,Calib)
+% A FAIRE: 1- verifier si DataIn est une 'field structure'(.ListVarName'):
+% chercher ListVarAttribute, for each field (cell of variables):
+%   .CoordType: 'phys' or 'px'   (default==px, no transform)
+%   .scale_factor: =dt (to transform displacement into velocity) default=1
+%   .covariance: 'scalar', 'coord', 'D_i': covariant (like velocity), 'D^i': contravariant (like gradient), 'D^jD_i' (like strain tensor)
+%   (default='coord' if .Role='coord_x,_y..., 
+%            'D_i' if '.Role='vector_x,...',
+%              'scalar', else (thenno change except scale factor)
+if  ~(exist('CalibData','var') && isfield(CalibData,'GeometryCalib'))
+    DataOut=Data;
+else
+    DataOut=px_1(Data,CalibData.GeometryCalib);
+end
+if exist('Data_1','var')
+    if ~(exist('CalibData_1','var') && isfield(CalibData_1,'GeometryCalib'))
+        DataOut_1=Data_1;
+    else
+        DataOut_1=px_1(Data_1,CalibData_1.GeometryCalib);
+    end
+else
+    DataOut_1=[];
+end
+
+
+%------------------------------------------------
+function DataOut=px_1(Data,Calib)
+DataOut=Data;%default
+
+%Act only if .CoordType=phys, and Calib defined
+if isfield(Data,'CoordType')& isequal(Data.CoordType,'phys')& ~isempty(Calib)
+    DataOut.CoordType='px'; %put flag for pixel coordinates
+    DataOut.CoordUnit='px';
+    %transform of X,Y coordinates
+    if isfield(Data,'Z')&~isempty(Data.Z)
+        Z=Data.Z;
+    else
+        Z=0;
+    end
+    if isfield(Data,'X') & isfield(Data,'Y')
+        [DataOut.X,DataOut.Y]=px_XYZ(Calib,Data.X,Data.Y,Z);
+        if isfield(Data,'U')&isfield(Data,'V')& isfield(Data,'dt')& ~isequal(Data.dt,0)
+            Data.U=Data.U*Data.dt;
+            Data.V=Data.V*Data.dt;
+            if isfield(Data,'W')
+                W=Data.W*Data.dt;
+            else
+                W=0;
+            end
+            [XOut_1,YOut_1]=px_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z-W/2);
+            [XOut_2,YOut_2]=px_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z+W/2);
+            DataOut.U=XOut_2-XOut_1;
+            DataOut.V=YOut_2-YOut_1;
+        end
+    end
+    %transform of an image
+    if isfield(Data,'A')&isfield(Data,'AX')&~isempty(Data.AX) & isfield(Data,'AY')&...
+                                   isfield(Data,'AY')&~isempty(Data.AY)&length(Data.A)>1
+%         if isfield(Data,'Field')&isequal(Data.Field,'images')
+          %NO TRANSFORM FROM phys to px for images
+            DataOut.A=[];% 
+    end
+end
+
Index: /trunk/src/private/px_XYZ.m
===================================================================
--- /trunk/src/private/px_XYZ.m	(revision 8)
+++ /trunk/src/private/px_XYZ.m	(revision 8)
@@ -0,0 +1,50 @@
+%'px_XYZ': transform phys coordinates to image coordinates (px)
+%
+% OUPUT:
+% X,Y: array of coordinates in the image cooresponding to the input physical positions 
+%                    (origin at lower leftcorner, unit=pixel)
+
+% INPUT:
+% Calib: structure containing the calibration parameters (read from the ImaDoc .xml file)
+% Xphys, Yphys: array of x,y physical coordinates
+% [Zphys]: corresponding array of z physical coordinates (0 by default)
+
+
+function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
+X=[];%default
+Y=[];
+% if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
+%     Zindex=Z;
+%     planepos=Calib.PlanePos{Zindex};
+%     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
+% else
+%     zphys=0;
+% end
+if ~exist('Zphys','var')
+    Zphys=0;
+end
+
+%%%%%%%%%%%%%
+if isfield(Calib,'R')
+    R=(Calib.R)';
+    xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
+    yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
+    zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
+%undistorted image coordinates
+    Xu=Calib.f*xc./zc;
+    Yu=Calib.f*yc./zc;
+%distorted image coordinates
+    distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
+% distortion=1;
+    Xd=Xu./distortion;
+    Yd=Yu./distortion;
+%pixel coordinates
+    X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
+    Y=Yd/Calib.dpy+Calib.Cy;
+
+elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib  
+        X=Xphys*Calib.Pxcmx;
+        Y=Yphys*Calib.Pxcmy;
+end
+
+
Index: /trunk/src/private/pxcm_tsai.m
===================================================================
--- /trunk/src/private/pxcm_tsai.m	(revision 8)
+++ /trunk/src/private/pxcm_tsai.m	(revision 8)
@@ -0,0 +1,79 @@
+%'pxcm_tsai': find differentials of the Tsai calibration
+%
+function [A11,A12,A13,A21,A22,A23]=pxcm_tsai(a,var_phys)
+a_read=a;
+
+R=(a.R)';
+
+x=var_phys(:,1);
+y=var_phys(:,2);
+
+if isfield(a,'PlanePos')
+    prompt={'Plane 1 Index','Plane 2 Index'};
+    Rep=inputdlg(prompt,'Target displacement test');
+    Z1=str2double(Rep(1));
+    Z2=str2double(Rep(2));
+    z=(a.PlanePos(Z2,3)+a.PlanePos(Z1,3))/2
+else
+    z=0;
+end
+
+%transform coeff for differentiels
+a.C11=R(1)*R(8)-R(2)*R(7);
+a.C12=R(2)*R(7)-R(1)*R(8);
+a.C21=R(4)*R(8)-R(5)*R(7);
+a.C22=R(5)*R(7)-R(4)*R(8);
+a.C1x=R(3)*R(7)-R(9)*R(1);
+a.C1y=R(3)*R(8)-R(9)*R(2);
+a.C2x=R(6)*R(7)-R(9)*R(4);
+a.C2y=R(6)*R(8)-R(9)*R(5);
+
+
+%dependence in x,y
+denom=(R(7)*x+R(8)*y+R(9)*z+a.Tz).*(R(7)*x+R(8)*y+R(9)*z+a.Tz);
+A11=(a.f*a.sx*(a.C11*y-a.C1x*z+R(1)*a.Tz-R(7)*a.Tx)./denom)/a.dpx;
+A12=(a.f*a.sx*(a.C12*x-a.C1y*z+R(2)*a.Tz-R(8)*a.Tx)./denom)/a.dpx;
+A21=(a.f*a.sx*(a.C21*y-a.C2x*z+R(4)*a.Tz-R(7)*a.Ty)./denom)/a.dpy;
+A22=(a.f*(a.C22*x-a.C2y*z+R(5)*a.Tz-R(8)*a.Ty)./denom)/a.dpy;
+A13=(a.f*(a.C1x*x+a.C1y*y+R(3)*a.Tz-R(9)*a.Tx)./denom)/a.dpx;
+A23=(a.f*(a.C2x*x+a.C2y*y+R(6)*a.Tz-R(9)*a.Ty)./denom)/a.dpy;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%Old Version for z=0
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %'camera' coordinates
+% xc=R(1)*x+R(2)*y+a.Tx;
+% yc=R(4)*x+R(5)*y+a.Ty;
+% zc=R(7)*x+R(8)*y+a.Tz;
+% %undistorted image coordinates
+% Xu=a.f*xc./zc;
+% Yu=a.f*yc./zc;
+% %distorted image coordinates
+% distortion=(a.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %!! intégrer derivation kappa
+% % distortion=1;
+% Xd=Xu./distortion;
+% Yd=Yu./distortion;
+% %pixel coordinates
+% X=Xd*a.sx/a.dpx+a.Cx;
+% Y=Yd/a.dpy+a.Cy;
+% 
+% %transform coeff for differentiels
+% a.C11=R(1)*R(8)-R(2)*R(7);
+% a.C12=R(2)*R(7)-R(1)*R(8);
+% a.C21=R(4)*R(8)-R(5)*R(7);
+% a.C22=R(5)*R(7)-R(4)*R(8);
+% a.C1x=R(3)*R(7)-R(9)*R(1);
+% a.C1y=R(3)*R(8)-R(9)*R(2);
+% a.C2x=R(6)*R(7)-R(9)*R(4);
+% a.C2y=R(6)*R(8)-R(9)*R(5);
+% 
+% 
+% %dependence in x,y
+% denom=(R(7)*x+R(8)*y+a.Tz).*(R(7)*x+R(8)*y+a.Tz);
+% A11=(a.f*a.sx*(a.C11*y+R(1)*a.Tz-R(7)*a.Tx)./denom)/a.dpx;
+% A12=(a.f*a.sx*(a.C12*x+R(2)*a.Tz-R(8)*a.Tx)./denom)/a.dpx;
+% A21=(a.f*a.sx*(a.C21*y+R(4)*a.Tz-R(7)*a.Ty)./denom)/a.dpy;
+% A22=(a.f*(a.C22*x+R(5)*a.Tz-R(8)*a.Ty)./denom)/a.dpy;
+% A13=(a.f*(a.C1x*x+a.C1y*y+R(3)*a.Tz-R(9)*a.Tx)./denom)/a.dpx;
+% A23=(a.f*(a.C2x*x+a.C2y*y+R(6)*a.Tz-R(9)*a.Ty)./denom)/a.dpy;
+% 
Index: /trunk/src/private/raw2phys.m
===================================================================
--- /trunk/src/private/raw2phys.m	(revision 8)
+++ /trunk/src/private/raw2phys.m	(revision 8)
@@ -0,0 +1,151 @@
+%'raw2phys': transform raw signal to physical values using different calibrations laws
+%
+function FieldPhys=raw2phys(Field)
+
+% do not transform if Field already in phys coordinates
+FieldPhys=Field;%default
+if isfield(Field,'CoordType') & isequal(Field.CoordType,'phys')
+    return %no transform if the data are already physical
+else
+    FieldPhys.CoordType='phys';
+end
+
+%Filtering of the initial data
+nbfilter=51;
+nbhalf=floor(nbfilter/2);
+for ivar=1:length(FieldPhys.ListVarName)
+    VarName=FieldPhys.ListVarName{ivar};
+    if ~isequal(VarName,'time')
+        eval(['FirstVal=FieldPhys.' VarName '(1);'])
+        eval(['LastVal=FieldPhys.' VarName '(end);'])
+        FirstVal=ones(nbhalf,1)*FirstVal;
+        LastVal=ones(nbhalf,1)*LastVal;    
+        eval(['FieldPhys.' VarName '=[FirstVal;FieldPhys.' VarName ';LastVal];'])
+        eval(['FieldPhys.' VarName '=conv(ones(1,nbfilter)/nbfilter,FieldPhys.' VarName ');']);
+         eval(['FieldPhys.' VarName '([1:nbfilter-1])=[];']);
+         eval(['FieldPhys.' VarName '([end-nbfilter+2:end])=[];']);
+    end
+end
+
+
+
+ScanRate=240; %data points per second
+VelTranslation=1; % 1 cm/s A VERIFIER
+test_Offset=0;
+test_Thermistance_B=0;
+test_Thermistance_M=0;
+if isfield(Field,'ListVarAttribute')
+    for ilist=1:length(Field.ListVarAttribute)
+        attr_name=Field.ListVarAttribute{ilist}
+        if isequal(attr_name,'PhysUnits')
+            FieldPhys.units =Field.PhysUnits;
+        end
+        if isequal(attr_name,'Offset')
+            test_Offset=1;
+        end
+        if isequal(attr_name,'ThermistanceCalib_B')
+            test_Thermistance_B=1;
+        end  
+        if isequal(attr_name,'ThermistanceCalib_M')
+            test_Thermistance_M=1;
+        end
+    end
+end
+
+
+
+% substract offset
+if test_Offset
+    for ivar=1:length(Field.ListVarName)
+        Val_Offset=Field.Offset{ivar};
+        if isnumeric(Val_Offset)&~isempty(Val_Offset)
+            VarName=Field.ListVarName{ivar};
+            eval(['FieldPhys.' VarName '=FieldPhys.' VarName '-Val_Offset;'])
+        end
+    end
+end
+
+%thermistance calibration
+if test_Thermistance_M & test_Thermistance_B
+    for ivar=1:length(Field.ListVarName)
+        Val_B=Field.ThermistanceCalib_B{ivar};
+        Val_M=Field.ThermistanceCalib_M{ivar};
+        if isnumeric(Val_B) & ~isempty(Val_B) & isnumeric(Val_M) & ~isempty(Val_M)
+            VarName=Field.ListVarName{ivar};
+            eval(['FieldPhys.' VarName '=(Val_M ./ (log( FieldPhys.' VarName ')-Val_B)) -273.15;'])
+        end
+    end
+end
+return
+
+%NON USED
+%density profile
+Density=(Conductivity-B)/A;%calibration
+Density=Density(find(Motor>1));%restrict the record to the time motor on
+Density=flipdim(Density,2)';
+%detect free surface
+[dmax,imax]=max(diff(Density));
+nbpoints=length(Density);
+Pos=linspace(0,nbpoints*VelTranslation/ScanRate,nbpoints);
+Pos=Pos-imax*VelTranslation/ScanRate;
+
+%[dmax,jmax]=max(diff(Conductivity))
+napoints=length(Conductivity);
+Pos1=linspace(0,napoints*VelTranslation/ScanRate,napoints);
+%Pos1=Pos1-jmax*VelTranslation/ScanRate;
+
+figure(2);
+clf
+plot(Pos1,Conductivity)
+grid on
+figure(3);
+size(Pos)
+size(Density)
+plot(Pos,Density)
+hold on
+grid on
+%determination of N
+PosCentr=Pos([floor(nbpoints/4):floor(3*nbpoints/4)]);
+DensityCentr=Density([floor(nbpoints/4):floor(3*nbpoints/4)]);
+p=polyfit(PosCentr,DensityCentr,1);
+LinDens=polyval(p,PosCentr);
+plot(PosCentr,LinDens,'r')
+grad=p(1)
+%find(Motor>1)
+
+% data.conductivity=flipdim(Conductivity(find(Motor>5)),1)';
+% data.deplacement=[100/size(data.conductivity,2):100/size(data.conductivity,2):100];
+% 
+% figure;plot(data.deplacement,data.conductivity);hold on;
+
+%data.density=flipdim(Conductivity(find(Motor>1)),1)'*3.4764+15.1367;
+%data.density=flipdim(Conductivity(find(Motor>1)),2)'*5+14.6090;
+%data.density=flipdim(Conductivity(find(Motor>1)),2)'*4.1525+19.50;
+% data.density=flipdim(Conductivity(find(Motor>1)),2)'
+% data.deplacement=[92/size(data.density,2):92/size(data.density,2):92];
+% figure(101)
+% plot(data.deplacement,data.density);hold on;
+
+% t=data.deplacement(find(data.deplacement>20&data.deplacement<80));
+%t=data.deplacement(find(data.deplacement>0&data.deplacement<90));
+% X=[ones(size(t,2),1)';t];
+% Y=data.density(find(data.deplacement>20&data.deplacement<80));
+% %Y=data.density(find(data.deplacement>0&data.deplacement<90));
+% coeff=Y/X;
+
+% plot(data.deplacement,data.deplacement*coeff(2)+coeff(1),'r');
+
+% grad=abs(coeff(2)*100)
+Tbv=2*pi/sqrt(981*0.001*grad)
+N=2*pi/Tbv
+title(strcat('',name,''))
+xpos=get(gca,'XLim')
+ypos=get(gca,'YLim')
+%xtext=xpos(1)+(xpos(2)-xpos(1))*3/4
+xtext=xpos(1)+(xpos(2)-xpos(1))/2
+ytext=ypos(1)+(ypos(2)-ypos(1))/4
+TabText={strcat('Tbv : ',num2str(Tbv),'s'); strcat('Stratification : ',num2str(grad)); strcat('N : ',num2str(2*pi/Tbv),'rad.s-1')}
+text(xtext,ytext,TabText)
+% text(xtext,13,strcat('Tbv : ',num2str(Tbv),'s'));
+% text(55,10,strcat('Stratification : ',num2str(grad)));
+% text(55,16,strcat('N : ',num2str(2*pi/Tbv),'rad.s-1'));
Index: /trunk/src/private/read_civxdata.m
===================================================================
--- /trunk/src/private/read_civxdata.m	(revision 8)
+++ /trunk/src/private/read_civxdata.m	(revision 8)
@@ -0,0 +1,275 @@
+%'read_civxdata': reads civx data from netcdf files
+%------------------------------------------------------------------
+% COMBINE ET REMPLACE read_ncfield, read_vel et read_scalar_new
+%------------------------------------------------------------------
+% OUTPUT:
+% nb_coord,nb_dim,
+% Civ: =0 or 1, indicates whether the data is civ (A SUPPRIMER ?)
+% CivStage: =0, ??? A UTILISER POUR REMPLACER civ
+%           =1, civ1 has been performed only
+%           =2, fix1 has been performed
+%           =3, pacth1 has been performed
+%           =4, civ2 has been performed 
+%           =5, fix2 has been performed
+%           =6, pacth2 has been performed
+% time: absolute time
+% Field
+%            .Txt: (char string) error message if any
+%            .NbDim: number of dimensions (=0 by default)
+%            .NbCoord: number of vector components
+%            .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
+%            .dt: time interval for the corresponding image pair
+%            .CivStage: =0, ??? A UTILISER POUR REMPLACER civ
+        %           =1, civ1 has been performed only
+        %           =2, fix1 has been performed
+        %           =3, pacth1 has been performed
+        %           =4, civ2 has been performed 
+        %           =5, fix2 has been performed
+        %           =6, pacth2 has been performed
+%            .X, .Y, .Z: set of vector coordinates 
+%            .U,.V,.W: corresponding set of vector components
+%            .F: warning flags
+%            .FF: error flag, =0 for good vectors
+%            .C: scalar associated with velocity (used for vector colors)
+%            .CoordType
+%            .DijU; matrix of spatial derivatives (DijU(1,1,:)=DUDX,
+%            DijU(1,2,:)=DUDY, Dij(2,1,:)=DVDX, DijU(2,2,:)=DVDY
+%            .A, .AX, .AY: additional scalar
+% dt:time interval of the image pair red from a single file, or vector with
+ 
+% pixcmx,pixcmy: scaling factors (from the first file)
+% vel_type_out: string representing the selected velocity type (civ1,civ2,filter1...)
+%
+% INPUT:
+% filename: file name (string).
+% FieldNames =cell of field names to get, which can contain the strings:
+%             'ima_cor': image correlation, vec_c or vec2_C
+%             'vort','div','strain': requires velocity derivatives DUDX...
+%             'error': error estimate (vec_E or vec2_E)
+%             
+% VelType : character string indicating the types of velocity fields to read ('civ1','civ2'...)
+%            if vel_type=[] or'*', a  priority choice, given by vel_type_out{1,2}, is done depending 
+%            if vel_type='filter'; a structured field is sought (filter2 in priority, then filter1)
+
+
+% FUNCTIONS called: 
+% 'varcivx_generator':, sets the names of vaiables to read in the netcdf file 
+% 'nc2struct': reads a netcdf file 
+
+function [Field,VelTypeOut]=read_civxdata(filename,FieldNames,VelType)
+
+if ~exist('VelType','var')
+    VelType=[];
+end
+if isequal(VelType,'*')
+    VelType=[];
+end
+if ~exist('FieldNames','var') 
+    FieldNames=[]; %default
+end
+
+VelTypeOut=VelType;%default
+[var,role,units,vel_type_out_cell]=varcivx_generator(FieldNames,VelType);%determine the names of constants and variables to read
+[Field,vardetect,ichoice]=nc2struct(filename,var);
+if isfield(Field,'Txt')
+    return % error in file reading
+end
+if isequal(vardetect,0)
+     Field.Txt=[FieldNames ' not accessible in ' filename '/' VelType];
+     return
+end
+var_ind=find(vardetect);
+for ivar=1:length(var_ind)
+    Field.VarAttribute{ivar}.Role=role{var_ind(ivar)};
+%     Field.VarAttribute{ivar}.units=units{var_ind(ivar)};% not necessary: set with calc_field
+end
+VelTypeOut=VelType;
+if ~isempty(ichoice)
+    VelTypeOut=vel_type_out_cell{ichoice};
+end
+
+%adjust for Djui:
+if isfield(Field,'DjUi')
+    Field.ListVarName(end-2:end)=[];
+    Field.ListVarName{end}='DjUi';
+    Field.VarDimIndex(end-2:end)=[];
+    Field.VarAttribute(end-2:end)=[];
+end
+
+%determine the appropriate constant for time and dt for the PIV pair
+test_civ1=isequal(VelTypeOut,'civ1')||isequal(VelTypeOut,'interp1')||isequal(VelTypeOut,'filter1');
+test_civ2=isequal(VelTypeOut,'civ2')||isequal(VelTypeOut,'interp2')||isequal(VelTypeOut,'filter2');
+if test_civ1
+    Field.Time=Field.absolut_time_T0;
+elseif test_civ2
+    Field.Time=Field.absolut_time_T0_2;
+    Field.dt=Field.dt2;
+else
+    Field.Txt='the input file is not civx';
+    display(Field.Txt)
+end
+
+% CivStage
+if isfield(Field,'patch2')&& isequal(Field.patch2,1)
+    Field.CivStage=6;
+elseif isfield(Field,'fix2')&& isequal(Field.fix2,1)
+    Field.CivStage=5;
+elseif isfield(Field,'civ2')&& isequal(Field.civ2,1)
+    Field.CivStage=4; 
+elseif isfield(Field,'patch')&& isequal(Field.patch,1)
+    Field.CivStage=3; 
+elseif isfield(Field,'fix')&& isequal(Field.fix,1)
+    Field.CivStage=2;
+else
+    Field.CivStage=1;
+end 
+
+%update list of global attributes
+List=Field.ListGlobalAttribute;
+ind_remove=[];
+for ilist=1:length(List)
+    switch(List{ilist})
+        case {'patch2','fix2','civ2','patch','fix','dt2','absolut_time_T0','absolut_time_T0_2'}
+            ind_remove=[ind_remove ilist];
+            Field=rmfield(Field,List{ilist});
+    end
+end
+List(ind_remove)=[];
+Field.ListGlobalAttribute=[List {'Time','CivStage','CoordUnit'}];
+
+% rescale to pixel coordiantes
+if isfield(Field,'pixcmx')
+Field.U=Field.U*Field.pixcmx;
+Field.V=Field.V*Field.pixcmy;
+Field.X=Field.X*Field.pixcmx;
+Field.Y=Field.Y*Field.pixcmy; 
+end
+if ~isequal(Field.dt,0)
+    Field.U=Field.U*Field.dt;%translate in px displacement
+    Field.V=Field.V*Field.dt;
+    if isfield(Field,'DjUi')
+       Field.DjUi(:,1,1)=Field.dt*Field.DjUi(:,1,1);
+       Field.DjUi(:,2,2)=Field.dt*Field.DjUi(:,2,2);
+       Field.DjUi(:,1,2)=(Field.pixcmy/Field.pixcmx)*Field.dt*Field.DjUi(:,1,2);
+       Field.DjUi(:,2,1)=(Field.pixcmx/Field.pixcmy)*Field.dt*Field.DjUi(:,2,1);
+    end
+end
+Field.CoordType='px';% TODO: abandon, use COORdUnit instead ? (to adapt 'px' and 'phys')
+Field.CoordUnit='pixel';
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type) 
+%INPUT:
+% FieldNames =cell of field names to get, which can contain the strings:
+%             'ima_cor': image correlation, vec_c or vec2_C
+%             'vort','div','strain': requires velocity derivatives DUDX...
+%             'error': error estimate (vec_E or vec2_E)
+%             
+% vel_type: character string indicating the types of velocity fields to read ('civ1','civ2'...)
+%            if vel_type=[] or'*', a  priority choice, given by vel_type_out{1,2}, is done depending 
+%            if vel_type='filter'; a structured field is sought (filter2 in priority, then filter1)
+
+function [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type) 
+
+%default input values
+if ~exist('vel_type','var'),vel_type=[];end;
+if iscell(vel_type),vel_type=vel_type{1}; end;%transform cell to string if needed
+% if ~exist('display','var'),display=[];end;
+if ~exist('FieldNames','var'),FieldNames={'ima_cor'};end;%default scalar 
+if ischar(FieldNames), FieldNames={FieldNames}; end;
+
+%select the priority order for automatic vel_type selection
+testder=0;
+for ilist=1:length(FieldNames)
+    if ~isempty(FieldNames{ilist})
+    switch FieldNames{ilist}
+        case {'vort','div','strain'}
+            testder=1;
+    end
+    end
+end      
+if isempty(vel_type) || isequal(vel_type,'*') %undefined velocity type (civ1,civ2...)
+    if testder
+         vel_type_out{1}='filter2'; %priority to filter2 for scalar reading, filter1 as second
+        vel_type_out{2}='filter1';
+    else
+        vel_type_out{1}='civ2'; %priority to civ2 for vector reading, civ1 as second priority      
+        vel_type_out{2}='civ1';
+    end
+elseif isequal(vel_type,'filter')
+        vel_type_out{1}='filter2'; %priority to filter2 for scalar reading, filter1 as second
+        vel_type_out{2}='filter1';
+        if ~testder
+            vel_type_out{3}='civ1';%civ1 as third priority if derivatives are not needed
+        end
+elseif testder
+    test_civ1=isequal(vel_type,'civ1')||isequal(vel_type,'interp1')||isequal(vel_type,'filter1');
+    if test_civ1
+        vel_type_out{1}='filter1'; %switch to filter for reading spatial derivatives
+    else
+        vel_type_out{1}='filter2';
+    end
+else   
+    vel_type_out{1}=vel_type;%imposed velocity field 
+end
+vel_type_out=vel_type_out';
+
+%determine names of netcdf variables to read
+var={'X','Y','Z','U','V','W','C','F','FF'};
+role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
+units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
+if testder
+    var=[var {'DjUi(:,1,1)','DjUi(:,1,2)','DjUi(:,2,1)','DjUi(:,2,2)'}];
+    role=[role {'tensor','tensor','tensor','tensor'}];
+    units=[units {'pixel','pixel','pixel','pixel'}];
+end
+for ilist=1:length(vel_type_out)
+    var=[var;varname1(vel_type_out{ilist},FieldNames)];
+end
+
+  
+%-------------------------
+%determine  var names to read
+%--------------------------------------
+function varin=varname1(vel_type,FieldNames)
+
+testder=0;
+C1='';
+C2='';
+for ilist=1:length(FieldNames)
+    if ~isempty(FieldNames{ilist})
+    switch FieldNames{ilist}
+        case 'ima_cor' %image correlation corresponding to a vel vector
+            C1='vec_C';
+            C2='vec2_C';
+        case 'error'
+            C1='vec_E';
+            C2='vec2_E';
+        case {'vort','div','strain'}
+            testder=1;
+    end
+    end
+end      
+switch vel_type
+    case 'civ1'
+        varin={'vec_X','vec_Y','vec_Z','vec_U','vec_V','vec_W',C1,'vec_F','vec_FixFlag'};
+    case 'interp1'
+        varin={'vec_patch_X','vec_patch_Y','','vec_patch0_U','vec_patch0_V','','','',''};
+    case 'filter1'
+        varin={'vec_patch_X','vec_patch_Y','','vec_patch_U','vec_patch_V','','','',''};
+    case 'civ2'
+        varin={'vec2_X','vec2_Y','vec2_Z','vec2_U','vec2_V','vec2_W',C2,'vec2_F','vec2_FixFlag'};
+    case 'interp2'
+        varin={'vec2_patch_X','vec2_patch_Y','vec2_patch_Z','vec2_patch0_U','vec2_patch0_V','vec2_patch0_W','','',''};
+    case 'filter2'
+        varin={'vec2_patch_X','vec2_patch_Y','vec2_patch_Z','vec2_patch_U','vec2_patch_V','vec2_patch0_W','','',''};
+end
+if testder
+     switch vel_type
+        case 'filter1'
+            varin=[varin {'vec_patch_DUDX','vec_patch_DVDX','vec_patch_DUDY','vec_patch_DVDY'}];
+        case 'filter2'
+            varin=[varin {'vec2_patch_DUDX','vec2_patch_DVDX','vec2_patch_DUDY','vec2_patch_DVDY'}];
+    end   
+end
Index: /trunk/src/private/read_geometry_calib.m
===================================================================
--- /trunk/src/private/read_geometry_calib.m	(revision 8)
+++ /trunk/src/private/read_geometry_calib.m	(revision 8)
@@ -0,0 +1,51 @@
+%'read_geometry_calib': read data on the GUI geometry_calib
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function data=read_geometry_calib(Coord_cell)
+data_XIma=[];
+data_YIma=[];
+data_XObject=[];
+data_YObject=[];
+data_ZObject=[];
+%Coord=get(handles.ListCoord,'String');
+% XImage=get(handles.XImage,'String');
+% YImage=get(handles.YImage,'String');
+% XObject=get(handles.XObject,'String');
+% YObject=get(handles.YObject,'String');
+% ZObject=get(handles.ZObject,'String');
+% if ischar(Xcolumn)
+%     Xcolumn={Xcolumn};
+% end
+nb_defining_points=length(Coord_cell);
+iline=0;
+for i=1:nb_defining_points
+    coord_str=Coord_cell{i};%character string of line number i
+    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)
+            iline=iline+1;
+            if ~isempty(data1)
+                data.Coord(iline,1)=data1;
+            end    
+            if ~isempty(data2)
+                data.Coord(iline,2)=data2;
+            end
+            if ~isempty(data3)
+                data.Coord(iline,3)=data3;
+            end
+            if ~isempty(data4)
+                data.Coord(iline,4)=data4;
+            end
+            if isempty(data5)
+                data.Coord(iline,5)=0;
+            else
+                data.Coord(iline,5)=data5;
+            end
+        end
+    end
+end
+data.Style='points';
Index: /trunk/src/private/read_get_field.m
===================================================================
--- /trunk/src/private/read_get_field.m	(revision 8)
+++ /trunk/src/private/read_get_field.m	(revision 8)
@@ -0,0 +1,743 @@
+%'read_get_field': read the list of selected variables from the GUI get_field (SAME AS THE FIRST
+% INPUT: 
+% hget_field: handles of the GUI get_field
+
+function [SubField,errormsg]=read_get_field(hget_field)
+%---------------------------------------------------------
+SubField=[];%default
+errormsg=[]; %default
+handles=guidata(hget_field);%handles of GUI elements in get_field
+Field=get(hget_field,'UserData');% read the current field Structure in the get_field interface
+if isfield(Field,'VarAttribute')
+    VarAttribute=Field.VarAttribute;
+else
+    VarAttribute={};
+end
+
+% select the indices of field variables for 2D plots
+test_1Dplot=get(handles.check_1Dplot,'Value');
+test_scalar=get(handles.check_scalar,'Value');
+test_vector=get(handles.check_vector,'Value');
+
+nbvar=0;
+empty_coord_x=0;
+empty_coord_y=0;
+dimname_y={};
+ListVarName={};
+VarDimName={};
+SubVarAttribute={};
+dim_x=0;
+dim_y=0;
+dim_z=0;
+dim_vec_x=0;
+dim_vec_y=0;
+dim_vec_z=0;
+c_index=[];
+if test_1Dplot
+     % select ordinate variable(s)
+    inputlist=get(handles.ordinate,'String'); 
+    val=get(handles.ordinate,'Value');% selection(s) for ordinate
+    VarNameCell=inputlist(val); %names of the variable(s) in the list
+    for ilist=1:length(VarNameCell)
+        VarIndex_y(ilist)=name2index(VarNameCell{ilist},Field.ListVarName);%index of the variable in ListVarName
+        dim_ordinate{ilist}=Field.VarDimName{VarIndex_y(ilist)};% name of the corresponding dimension
+%         if iscell(dim_ordinate{ilist})
+%             dim_ordinate{ilist}=dim_ordinate{ilist}{1};%take the first dimension name (char chain) in case of a matrix
+%         end
+        testpermute(ilist)=0;%default
+        nbvar=nbvar+1;
+        ListVarName{nbvar}=Field.ListVarName{VarIndex_y(ilist)};
+        VarDimName{nbvar}=Field.VarDimName{VarIndex_y(ilist)};
+        subvarindex(ilist)=nbvar;
+        if numel(VarAttribute)>=VarIndex_y(ilist)
+            SubVarAttribute{nbvar}=VarAttribute{VarIndex_y(ilist)};
+        end
+        SubVarAttribute{nbvar}.Role='scalar';           
+    end
+    
+        % select abscissa variable
+    inputlist=get(handles.abscissa,'String'); 
+    val=get(handles.abscissa,'Value');% a single selection is expected for abscissa
+    VarName=inputlist{val}; %name of the variable in the list
+    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
+    if isempty(VarIndex)% default abscissa = matrix index
+        coord_x_name=dim_ordinate{1};% name of the x coordinate = dimension of the plotted quantity
+        if iscell(coord_x_name)
+            coord_x_name=coord_x_name{1};
+        end
+        empty_coord_x=1;
+    else
+        dimname_x=Field.VarDimName{VarIndex};
+        if numel(dimname_x)~=1
+            errormsg='abscissa must be a one-dimensional variable';
+            return
+        end
+        nbvar=nbvar+1; 
+        ListVarName{nbvar}=Field.ListVarName{VarIndex};
+        VarDimName{nbvar}=Field.VarDimName{VarIndex};
+        if numel(VarAttribute)>=VarIndex
+            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
+        end
+        SubVarAttribute{nbvar}.Role='coord_x';
+         %check consistency of ordinate dimensions
+        for ilist=1:length(VarNameCell)
+            if iscell(dim_ordinate{ilist})
+                if ~strcmp(dim_ordinate{ilist}{1},dimname_x)
+                    if strcmp(dim_ordinate{ilist}{2},dimname_x)
+                        testpermute(ilist)=1;
+                    else
+                        errormsg='inconsistent dimensions for ordinate and abscissa';
+                        return
+                    end
+                end
+            end
+        end
+    end
+end
+
+test3D=strcmp(get(handles.coord_z_scalar,'Visible'),'on')||strcmp(get(handles.coord_z_vectors,'Visible'),'on');
+VarSubIndexA=[];
+
+%scalar variable
+test_xdimvar=0;%default
+test_ydimvar=0;%default
+test_zdimvar=0;%defaul
+dimname_x=[];
+dimname_y=[];
+dimname_z=[];
+if test_scalar
+    inputlist=get(handles.scalar,'String');
+    if isempty(inputlist)
+        errormsg='empty input field';
+        return
+    end
+    val=get(handles.scalar,'Value');%selected indices in the ordinate listbox
+    VarNameScalar=inputlist{val}; %name of the variable in the list
+    VarIndexA=name2index(VarNameScalar,Field.ListVarName);%index of the variable in ListVarName
+    dimname_A=Field.VarDimName{VarIndexA};
+    nbvar=nbvar+1;
+    ListVarName{nbvar}=Field.ListVarName{VarIndexA};
+    VarSubIndexA=nbvar;
+    VarDimName{nbvar}=dimname_A;
+    if numel(VarAttribute)>=VarIndexA
+        SubVarAttribute{nbvar}=VarAttribute{VarIndexA};
+    end
+    SubVarAttribute{nbvar}.Role='scalar';
+    field_var_index=VarIndexA; %store the last variable index to determine the absissa dimension if not defiend
+
+     % select x variable 
+    inputlist=get(handles.coord_x_scalar,'String'); 
+    val=get(handles.coord_x_scalar,'Value');% a single selection is expected for abscissa
+    VarName=inputlist{val}; %name of the variable in the list
+    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
+    if isempty(VarIndex)% default abscissa = matrix index
+        empty_coord_x=1;
+    else
+        dimname_x=Field.VarDimName{VarIndex};
+        nbvar=nbvar+1;
+        ListVarName{nbvar}=Field.ListVarName{VarIndex};
+        VarDimName{nbvar}=dimname_x;
+        if numel(VarAttribute)>=VarIndex
+            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
+        end
+         %check consistency of dimensions
+        if ~isequal(dimname_x,dimname_A)% case of dimension variables
+            if iscell(dimname_x)
+                if numel(dimname_x)==1
+                    dimname_x=dimname_x{1};%transform to char chain
+                else
+                    errormsg='invalid x coordinate selection in get_field';
+                    return
+                end
+            end
+            test_xdimvar=1;
+            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
+        else
+            SubVarAttribute{nbvar}.Role='coord_x';%abcissa with unstructured coordinates
+        end
+    end
+    
+    % select y variable
+    inputlist=get(handles.coord_y_scalar,'String'); 
+    val=get(handles.coord_y_scalar,'Value');% a single selection is expected for abscissa
+    VarName=inputlist{val}; %name of the variable in the list    
+    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
+    if isempty(VarIndex)% default abscissa = matrix index
+        empty_coord_y=1;
+    else
+        dimname_y=Field.VarDimName{VarIndex};
+         %check consistency of dimensions
+        nbvar=nbvar+1;
+        ListVarName{nbvar}=Field.ListVarName{VarIndex};
+        VarDimName{nbvar}=dimname_y;
+        if numel(VarAttribute)>=VarIndex
+            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
+        end
+         %check consistency of dimensions
+        if ~isequal(dimname_y,dimname_A)% case of dimension variables
+             if iscell(dimname_y)
+                if numel(dimname_y)==1
+                    dimname_y=dimname_y{1};%transform to char chain
+                else
+                    errormsg='invalid y coordinate selection in get_field';
+                    return
+                end
+             end
+            test_ydimvar=1;
+            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
+        else
+            SubVarAttribute{nbvar}.Role='coord_y';%abcissa with unstructured coordinates
+        end
+        if isequal(dimname_y,dimname_x)
+            errormsg='identical x and y coordinates selected in get_field';
+            return
+        end
+    end
+
+        % select z variable
+   if test3D % TODO: Lire z comme x et y
+        inputlist=get(handles.coord_z_scalar,'String'); 
+        val=get(handles.coord_z_scalar,'Value');% a single selection is expected for abscissa
+        VarName=inputlist{val}; %name of the variable in the list    
+        VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
+        if isempty(VarIndex)% default abscissa = matrix index
+%             coord_z_name=dimname_A{1};% name of the x coordinate = dimension of the plotted quantity
+            empty_coord_z=1;
+        else
+            dimname_z=Field.VarDimName{VarIndex};
+             %check consistency of dimensions
+            if ~isequal(dimname_z,dimname_A)
+                for icoord=1:numel(dimname_A)
+                    if strcmp(dimname_z,dimname_A{icoord})%  a dimension variable
+                         dim_z=icoord;
+                        break
+                    end
+                end
+                if ~dim_z
+                    errormsg='inconsistent dimensions for coordinate z';
+                    return
+                end
+            end
+            nbvar=nbvar+1;
+            ListVarName{nbvar}=Field.ListVarName{VarIndex};
+            VarDimName{nbvar}=dimname_z;
+            if numel(VarAttribute)>=VarIndex
+                SubVarAttribute{nbvar}=VarAttribute{VarIndex};
+            end
+            if dim_z
+                SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
+            else
+                SubVarAttribute{nbvar}.Role='coord_z';%z coordinate with unstructured coordinates
+            end
+        end
+   end
+end
+test_vec_x_dimvar=0;%default
+test_vec_y_dimvar=0;%default
+test_vec_z_dimvar=0;%defaul
+dimname_vec_x=[];
+dimname_vec_y=[];
+dimname_vec_z=[];
+if test_vector 
+    %select u variable
+    inputlist=get(handles.vector_x,'String');
+    if isempty(inputlist)
+        errormsg='empty input field';
+        return
+    end
+    val=get(handles.vector_x,'Value');%selected indices in the ordinate listbox
+    VarNameU=inputlist{val}; %name of the variable in the list
+    VarIndexU=name2index(VarNameU,Field.ListVarName);%index of the variable in ListVarName
+    nbvar=nbvar+1;
+    VarSubIndexU=nbvar;
+    ListVarName{nbvar}=Field.ListVarName{VarIndexU};
+    dimname_u=Field.VarDimName{VarIndexU};
+    VarDimName{nbvar}=dimname_u;
+    if numel(VarAttribute)>=VarIndexU
+        SubVarAttribute{nbvar}=VarAttribute{VarIndexU};
+    end
+    SubVarAttribute{nbvar}.Role='vector_x';
+    field_var_index=VarIndexU; %store the last variable index to determine the absissa dimension if not defiend
+    
+    %scalar v variable
+    inputlist=get(handles.vector_y,'String');
+    val=get(handles.vector_y,'Value');%selected indices in the ordinate listbox
+    VarNameV=inputlist{val}; %name of the variable in the list
+    VarIndexV=name2index(VarNameV,Field.ListVarName);%index of the variable in ListVarName 
+     %check consistency of dimensions with u
+    dimname_v=Field.VarDimName{VarIndexV};
+    if ~isequal(dimname_v,dimname_u)
+       errormsg='inconsistent dimensions for u and v';
+        return
+    end
+    nbvar=nbvar+1;
+    VarSubIndexV=nbvar;
+    ListVarName{nbvar}=Field.ListVarName{VarIndexV};
+    VarDimName{nbvar}=dimname_u;
+    if numel(VarAttribute)>=VarIndexV
+        SubVarAttribute{nbvar}=VarAttribute{VarIndexV};
+    end
+    SubVarAttribute{nbvar}.Role='vector_y';
+    
+ 
+     % select x variable for vector
+    inputlist=get(handles.coord_x_vectors,'String'); 
+    val=get(handles.coord_x_vectors,'Value');% a single selection is expected for abscissa
+    VarName=inputlist{val}; %name of the variable in the list
+    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
+    if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
+%         coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity
+        empty_coord_vec_x=1;
+    else
+        empty_coord_vec_x=0;
+        dimname_vec_x=Field.VarDimName{VarIndex};
+        nbvar=nbvar+1;
+        ListVarName{nbvar}=Field.ListVarName{VarIndex};
+        VarDimName{nbvar}=dimname_vec_x;
+        if numel(VarAttribute)>=VarIndex
+            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
+        end
+         %check consistency of dimensions
+        if ~isequal(dimname_vec_x,dimname_u)% case of dimension variables
+            if iscell(dimname_vec_x)
+                if numel(dimname_vec_x)==1
+                    dimname_vec_x=dimname_vec_x{1};%transform to char chain
+                else
+                    errormsg='invalid x coordinate selection in get_field';
+                    return
+                end
+            end
+            test_vec_x_dimvar=1;
+            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
+        else
+            SubVarAttribute{nbvar}.Role='coord_x';%abcissa with unstructured coordinates
+        end
+    end
+        
+         % select y variable for vector
+    inputlist=get(handles.coord_y_vectors,'String'); 
+    val=get(handles.coord_y_vectors,'Value');% a single selection is expected for abscissa
+    VarName=inputlist{val}; %name of the variable in the list
+    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
+    if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
+%         coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity
+        empty_coord_vec_y=1;
+    else
+        empty_coord_vec_y=0;
+        dimname_vec_y=Field.VarDimName{VarIndex};
+        nbvar=nbvar+1;
+        ListVarName{nbvar}=Field.ListVarName{VarIndex};
+        VarDimName{nbvar}=dimname_vec_y;
+        if numel(VarAttribute)>=VarIndex
+            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
+        end
+         %check consistency of dimensions
+        if ~isequal(dimname_vec_y,dimname_u)% case of dimension variables
+            if iscell(dimname_vec_y)
+                if numel(dimname_vec_y)==1
+                    dimname_vec_y=dimname_vec_y{1};%transform to char chain
+                else
+                    errormsg='invalid y coordinate selection in get_field';
+                    return
+                end
+            end
+            test_vec_y_dimvar=1;
+            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
+        else
+            SubVarAttribute{nbvar}.Role='coord_y';%abcissa with unstructured coordinates
+        end
+    end    
+        
+     % select z variable for vector
+    if test3D
+        inputlist=get(handles.coord_z_vectors,'String'); 
+        val=get(handles.coord_z_vectors,'Value');% a single selection is expected for abscissa
+        VarName=inputlist{val}; %name of the variable in the list
+        VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
+        if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
+    %         coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity
+            empty_coord_vec_z=1;
+        else
+            dimname_vec_z=Field.VarDimName{VarIndex};
+            nbvar=nbvar+1;
+            ListVarName{nbvar}=Field.ListVarName{VarIndex};
+            VarDimName{nbvar}=dimname_vec_z;
+            if numel(VarAttribute)>=VarIndex
+                SubVarAttribute{nbvar}=VarAttribute{VarIndex};
+            end
+             %check consistency of dimensions
+            if ~isequal(dimname_vec_z,dimname_u)% case of dimension variables
+                if iscell(dimname_vec_z)
+                    if numel(dimname_vec_z)==1
+                        dimname_vec_z=dimname_vec_y{1};%transform to char chain
+                    else
+                        errormsg='invalid y coordinate selection in get_field';
+                        return
+                    end
+                end
+                test_vec_z_dimvar=1;
+                SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
+            else
+                SubVarAttribute{nbvar}.Role='coord_z';%abcissa with unstructured coordinates
+            end
+        end        
+    end   
+        
+      
+     if test3D %  (a revoir)  
+         %scalar w variable
+        inputlist=get(handles.vector_z,'String');
+        val=get(handles.vector_z,'Value');%selected indices in the ordinate listbox
+        VarNameW=inputlist{val}; %name of the variable in the list
+        VarIndex=name2index(VarNameW,Field.ListVarName);%index of the variable in ListVarName 
+         %check consistency of dimensions with u
+        dimname_w=Field.VarDimName{VarIndex};
+        if ~isequal(dimname_w,dimname_u)
+           errormsg='inconsistent dimensions for u and v';
+            return
+        end
+        nbvar=nbvar+1;
+        w_index=nbvar;
+        ListVarName{nbvar}=Field.ListVarName{VarIndex};
+        VarDimName{nbvar}=dimname_u;
+        if numel(VarAttribute)>=VarIndex
+            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
+        end
+        SubVarAttribute{nbvar}.Role='vector_z';
+    end  
+    
+    % select color variable
+    inputlist=get(handles.vec_color,'String'); 
+    val=get(handles.vec_color,'Value');% a single selection is expected for abscissa
+    VarNameC=inputlist{val}; %name of the variable in the list
+    VarIndex=name2index(VarNameC,Field.ListVarName);%index of the variable in ListVarName
+       %check consistency of dimensions with u
+    if ~isempty(VarIndex)
+        if ~isequal(Field.VarDimName{VarIndex},dimname_u)
+            errormsg='inconsistent dimensions for u and v';
+            return
+        end
+        nbvar=nbvar+1;
+        c_index=nbvar;
+        ListVarName{nbvar}=Field.ListVarName{VarIndex};
+        VarDimName{nbvar}=Field.VarDimName{VarIndex};
+        if numel(VarAttribute)>=VarIndex
+            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
+        end
+        SubVarAttribute{nbvar}.Role='scalar';
+    end
+end 
+
+% get the input field
+inputfield=get(handles.inputfile,'String');
+if exist(inputfield,'file')% read the input data corresponding to the list of selected varaibles
+    SubField=nc2struct(inputfield,ListVarName);
+else  % subfield stored in memory
+    SubField.ListVarName=ListVarName;
+    SubField.VarDimName=VarDimName;
+end
+SubField.ListGlobalAttribute=['InputFile' SubField.ListGlobalAttribute];
+SubField.InputFile=get(handles.inputfile,'String');
+SubField.VarAttribute=SubVarAttribute;
+
+%permute indices if coord_y is not the first matrix index
+if test_scalar
+    VarNameA=Field.ListVarName{VarIndexA};
+    DimCellA=Field.VarDimName{VarIndexA};   
+    eval(['npxy=size(SubField.' VarNameA ')'])
+    SingleCellA={};
+    if numel(npxy) < numel(DimCellA)
+        SingleCellA=DimCellA(1:end-numel(npxy));
+        DimCellA=DimCellA(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
+    end
+    ind_single=find(npxy==1);
+    SingleCellA=[SingleCellA DimCellA(ind_single)];
+    ind_select=find(npxy~=1);%look for non singleton dimensions
+    DimCellA=DimCellA(ind_select);
+    npxy=npxy(ind_select);
+    dimA=[];
+    if test_zdimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
+        for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
+            if strcmp(dimname_z,SingleCellA{icoord})% a singleton dimension
+                errormsg=['the singleton dimension ' dimname_z ' has been selected for z'];
+                return
+            end
+        end
+        for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
+             if strcmp(dimname_z,DimCellA{icoord})% a dimension variable
+                 dimA=[dimA icoord];
+                 break
+             end
+        end
+    end
+    if test_ydimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
+        for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
+            if strcmp(dimname_y,SingleCellA{icoord})% a singleton dimension
+                errormsg=['the singleton dimension ' dimname_y ' has been selected for ordiante'];
+                return
+            end
+        end
+        for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
+             if strcmp(dimname_y,DimCellA{icoord})% a dimension variable
+                 dimA=[dimA icoord];
+                 break
+             end
+        end
+    end
+    if test_xdimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
+        for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar
+            if strcmp(dimname_x,SingleCellA{icoord})% a singleton dimension
+                errormsg=['the singleton dimension ' dimname_x ' has been selected for abscissa'];
+                return
+            end
+        end
+        for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
+             if strcmp(dimname_x,DimCellA{icoord})% a dimension variable
+                 dimA=[dimA icoord];
+                 break
+             end
+        end
+    end
+    dimextra=(1:numel(DimCellA));
+    dimextra(dimA)=[]; %list of unselected dimension indices
+    DimCellA=DimCellA([dimA dimextra]);
+    eval(['SubField.' VarNameA '=permute(squeeze(SubField.' VarNameA '),[dimA dimextra]);'])
+    SubField.VarDimName{VarSubIndexA}=DimCellA;  
+    %add default coord_x and/or coord_y if empty
+    if empty_coord_x || empty_coord_y
+        VarName=Field.ListVarName{field_var_index};
+        DimCell=Field.VarDimName{field_var_index};    
+        eval(['npxy=size(SubField.' VarName ')'])
+        if numel(npxy) < numel(DimCell)
+            DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 
+        end
+        ind_select=find(npxy~=1) ;%look for non singleton dimensions
+        DimCell=DimCell(ind_select);
+        npxy=npxy(ind_select);
+        testold=0;
+    %old convention; use of coord_1 and Coord_2
+        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
+            if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1')
+                Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
+                Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
+                testold=1;
+            end
+        end
+        if empty_coord_x        
+                coord_x_name=DimCell{2};
+                SubField.ListVarName=[{coord_x_name} SubField.ListVarName];
+                SubField.VarDimName=[{coord_x_name} SubField.VarDimName];  
+                if testold
+                    eval(['SubField.' coord_x_name '=linspace(Coord_2(1),Coord_2(end),npxy(2));'])
+                else
+                    eval(['SubField.' coord_x_name '=[0.5 npxy(2)-0.5];'])
+                end
+            
+            if ~testold
+                coord_x_attr.units='index';
+            else
+                coord_x_attr.units='cm';
+            end
+            SubField.VarAttribute=[{coord_x_attr} SubField.VarAttribute];  
+        end
+        if empty_coord_y 
+            coord_y_name=DimCell{1};
+            SubField.ListVarName=[{coord_y_name} SubField.ListVarName];
+            SubField.VarDimName=[{coord_y_name} SubField.VarDimName];
+            if testold
+                eval(['SubField.' coord_y_name '=linspace(Coord_1(1),Coord_1(end),npxy(1));']) 
+            else
+                eval(['SubField.' coord_y_name '=[npxy(1)-0.5 0.5];'])
+            end
+            if ~testold
+                coord_y_attr.units='index';
+            else
+                coord_y_attr.units='cm';
+            end
+            SubField.VarAttribute=[{coord_y_attr} SubField.VarAttribute];       
+        end
+    end
+end
+
+%permute indices if coord_y is not the first matrix index
+if test_vector
+    VarNameU=Field.ListVarName{VarIndexU};
+    DimCellU=Field.VarDimName{VarIndexU};   
+    eval(['npxy=size(SubField.' VarNameU ')'])
+    SingleCellU={};
+    if numel(npxy) < numel(DimCellU)
+        SingleCellU=DimCellU(1:end-numel(npxy));
+        DimCellU=DimCellU(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
+    end
+    ind_single=find(npxy==1);
+    SingleCellU=[SingleCellU DimCellU(ind_single)];
+    ind_select=find(npxy~=1);%look for non singleton dimensions
+    DimCellU=DimCellU(ind_select);
+    npxy=npxy(ind_select);
+    dimU=[];
+    if test_zdimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
+        for icoord=1:numel(SingleCellU)% look for coincidence of dimension with one of the dimensions of the scalar 
+            if strcmp(dimname_vec_z,SingleCellU{icoord})% a singleton dimension
+                errormsg=['the singleton dimension ' dimname_vec_z ' has been selected for z'];
+                return
+            end
+        end
+        for icoord=1:numel(DimCellU)% look for coincidence of dimension with one of the dimensions of the scalar 
+             if strcmp(dimname_vec_z,DimCellU{icoord})% a dimension variable
+                 dimU=[dimU icoord];
+                 break
+             end
+        end
+    end
+    if test_ydimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
+        for icoord=1:numel(SingleCellU)% look for coincidence of dimension with one of the dimensions of the scalar 
+            if strcmp(dimname_vec_y,SingleCellU{icoord})% a singleton dimension
+                errormsg=['the singleton dimension ' dimname_vec_y ' has been selected for ordinate'];
+                return
+            end
+        end
+        for icoord=1:numel(DimCellU)% look for coincidence of dimension with one of the dimensions of the scalar 
+             if strcmp(dimname_vec_y,DimCellU{icoord})% a dimension variable
+                 dimU=[dimU icoord];
+                 break
+             end
+        end
+    end
+    if test_xdimvar
+        for icoord=1:numel(SingleCellU)% look for coincidence of dimension with one of the dimensions of the scalar
+            if strcmp(dimname_x,SingleCellU{icoord})% a singleton dimension
+                errormsg=['the singleton dimension ' dimname_vec_x ' has been selected for abscissa'];
+                return
+            end
+        end
+        for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
+             if strcmp(dimname_vec_x,DimCellU{icoord})% a dimension variable
+                 dimU=[dimU icoord];
+                 break
+             end
+        end
+    end
+    dimextra=(1:numel(DimCellU));
+    dimextra(dimU)=[]; %list of unselected dimension indices
+    DimCellU=DimCellU([dimU dimextra]);
+    eval(['SubField.' VarNameU '=permute(squeeze(SubField.' VarNameU '),[dimU dimextra]);'])
+    eval(['SubField.' VarNameV '=permute(squeeze(SubField.' VarNameV '),[dimU dimextra]);'])
+    SubField.VarDimName{VarSubIndexU}=DimCellU;
+    SubField.VarDimName{VarSubIndexV}=DimCellU;
+    
+    %add default coord_x and/or coord_y if empty
+    if empty_coord_vec_x || empty_coord_vec_y
+        VarName=Field.ListVarName{field_var_index};
+        DimCell=Field.VarDimName{field_var_index};    
+        eval(['npxy=size(SubField.' VarName ')'])
+        if numel(npxy) < numel(DimCell)
+            DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 
+        end
+        ind_select=find(npxy~=1) ;%look for non singleton dimensions
+        DimCell=DimCell(ind_select);
+        npxy=npxy(ind_select);
+        testold=0;
+    %old convention; use of coord_1 and Coord_2
+        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
+            if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1')
+                Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
+                Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
+                testold=1;
+            end
+        end
+        if empty_coord_vec_x        
+                coord_x_name=DimCell{2};
+                SubField.ListVarName=[{coord_x_name} SubField.ListVarName];
+                SubField.VarDimName=[{coord_x_name} SubField.VarDimName];  
+                if testold
+                    eval(['SubField.' coord_x_name '=linspace(Coord_2(1),Coord_2(end),npxy(2));'])
+                else
+                    eval(['SubField.' coord_x_name '=[0.5 npxy(2)-0.5];'])
+                end
+            
+            if ~testold
+                coord_x_attr.units='index';
+            else
+                coord_x_attr.units='cm';
+            end
+            SubField.VarAttribute=[{coord_x_attr} SubField.VarAttribute];  
+        end
+        if empty_coord_vec_y 
+            coord_y_name=DimCell{1};
+            SubField.ListVarName=[{coord_y_name} SubField.ListVarName];
+            SubField.VarDimName=[{coord_y_name} SubField.VarDimName];
+            if testold
+                eval(['SubField.' coord_y_name '=linspace(Coord_1(1),Coord_1(end),npxy(1));']) 
+            else
+                eval(['SubField.' coord_y_name '=[npxy(1)-0.5 0.5];'])
+            end
+            if ~testold
+                coord_y_attr.units='index';
+            else
+                coord_y_attr.units='cm';
+            end
+            SubField.VarAttribute=[{coord_y_attr} SubField.VarAttribute];       
+        end
+    end
+end
+if test_1Dplot 
+    for ilist=1:numel(VarIndex_y)
+        VarName=Field.ListVarName{VarIndex_y(ilist)};
+        eval(['npxy=size(SubField.' VarName ');'])
+        ind_select=find(npxy~=1);
+        SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}(ind_select);
+        eval(['SubField.' VarName '=squeeze(SubField.' VarName ');'])%remove singleton dimensions
+        if testpermute(ilist)
+            eval(['SubField.' VarName '=permute(SubField.' VarName ',[2 1]);'])
+            subvarindex(ilist)
+            SubField.VarDimName{subvarindex(ilist)}
+            SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}([2 1]);
+        end
+    end
+    if empty_coord_x
+        SubField.ListVarName=[{[coord_x_name '_index']} SubField.ListVarName];
+        SubField.VarDimName=[{coord_x_name } SubField.VarDimName];
+        VarName=Field.ListVarName{VarIndex_y(1)};
+        DimCell=Field.VarDimName{VarIndex_y(1)};    
+        eval(['npxy=size(SubField.' VarName ')'])
+        if numel(npxy) < numel(DimCell)
+            DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 
+        end
+        ind_select=find(npxy~=1) ;%look for non singleton dimensions
+        DimCell=DimCell(ind_select);
+        npxy=npxy(ind_select);
+        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=VarIndex_y(1) ...
+                             && isfield(Field.VarAttribute{VarIndex_y(1)},'Coord_1')
+             Coord_1=Field.VarAttribute{VarIndex_y(1)}.Coord_1;%old convention; use of coord_1 
+             eval(['SubField.' coord_x_name '_index=linspace(Coord_1(1),Coord_1(end),npxy(1));']) 
+        else
+            eval(['SubField.' coord_x_name '_index=linspace(0.5,npxy(1)-0.5,npxy(1));']) 
+        end
+        struct.Role='coord_x';
+        SubField.VarAttribute=[{struct} SubField.VarAttribute];
+    end
+end
+
+%-------------------------------------------------
+% give index numbers of the strings str in the list ListvarName
+function VarIndex_y=name2index(cell_str,ListVarName)
+VarIndex_y=[];
+if ischar(cell_str)
+    for ivar=1:length(ListVarName)
+        varlist=ListVarName{ivar};
+        if isequal(varlist,cell_str)
+            VarIndex_y= ivar;
+            break
+        end
+    end
+elseif iscell(cell_str)
+    for isel=1:length(cell_str)
+        varsel=cell_str{isel};
+        for ivar=1:length(ListVarName)
+            varlist=ListVarName{ivar};
+            if isequal(varlist,varsel)
+                VarIndex_y=[VarIndex_y ivar];
+            end
+        end
+    end
+end
Index: /trunk/src/private/read_imadoc.m
===================================================================
--- /trunk/src/private/read_imadoc.m	(revision 8)
+++ /trunk/src/private/read_imadoc.m	(revision 8)
@@ -0,0 +1,243 @@
+%'read_imadoc': reads the xml file for image documentation, OBSOLETE: replaced by imadoc2struct
+%
+%function [error,Heading,nom_type_ima,ext_ima,abs_time,TimeUnit,mode,NbSlice,npx,npy,GeometryCalib]=read_imadoc(filecivxml,testime) 
+%--------------------------------------------------------
+% OUTPUT:
+%error= 0: all right
+%        2: input file not found
+%        1: input file is not an image documentation file 'ImaDoc'
+%           1.1: 'ImaDoc/Heading' element absent
+%           1.2: 'ImaDoc/Camera' element absent
+%                 1.21: 'ImaDoc/Camera/BurstTiming' absent
+%                     1.211: 'ImaDoc/Camera/BurstTiming/FrameFrequency' absent
+%                     1.212: 'ImaDoc/Camera/BurstTiming/Time' absent
+%
+% INPUT:
+% filecivxml: full name of the xml input file
+% testime=1 read the list of times), =0 (default) do not read it to save computing  time
+%
+%  -- TODO: should be replaced by xml2struct --
+
+function [error,Heading,nom_type_ima,ext_ima,abs_time,TimeUnit,mode,NbSlice,npx,npy,GeometryCalib]=read_imadoc(filecivxml,testime) 
+% global t
+error=0;%default
+Heading=[];%default
+nom_type_ima=[];%default
+ext_ima=[];%default
+abs_time=[];%initiation
+TimeUnit='s'; %default
+% GeometryCalib.CoordUnit='cm';%default
+mode=[]; %default
+NbSlice=1;%default
+npx=[];%default
+npy=[];%default
+% GeometryCalib.Pxcmx=1;
+% GeometryCalib.Pxcmy=1;
+GeometryCalib=[];
+NbDtj=1;
+tsai=[];%default
+if ~exist('testime','var')
+    testime=1;%default
+end
+if exist(filecivxml,'file')~=2, error=2, return;end;%input file does not exist
+filecivxml;
+t=xmltree(filecivxml);
+uid_root=find(t,'/ImaDoc');
+if isempty(uid_root), error=1; return; end;%not an ImaDoc .xml file
+%Heading
+uid_Heading=find(t,'/ImaDoc/Heading');
+if isempty(uid_Heading), 
+    error=1.1;
+else
+    uid_Campaign=find(t,'/ImaDoc/Heading/Campaign');
+    uid_Exp=find(t,'/ImaDoc/Heading/Experiment');
+    uid_Device=find(t,'/ImaDoc/Heading/Device');
+    uid_Record=find(t,'/ImaDoc/Heading/Record');
+    uid_FirstImage=find(t,'/ImaDoc/Heading/ImageName');
+    Heading.Campaign=get(t,children(t,uid_Campaign),'value');
+    Heading.Experiment=get(t,children(t,uid_Exp),'value');
+    Heading.Device=get(t,children(t,uid_Device),'value');
+    if ~isempty(uid_Record)
+        Heading.Record=get(t,children(t,uid_Record),'value');
+    end
+    Heading.ImageName=get(t,children(t,uid_FirstImage),'value');
+    FirstImage=Heading.ImageName;
+    if ~isempty(FirstImage)
+        [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type_ima]=name2display(FirstImage);
+    end
+end
+%Camera   
+uid_Camera=find(t,'/ImaDoc/Camera');
+if isempty(uid_Camera)
+    error=1.2;
+else
+    uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');
+    if ~isempty(uid_ImageSize);
+        ImageSize=get(t,children(t,uid_ImageSize),'value');
+        xindex=findstr(ImageSize,'x');
+        if length(xindex)>=2
+            npx=str2num(ImageSize(1:xindex(1)-1));
+            npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1));
+        end
+    end
+    uid_NbSlice=find(t,'/ImaDoc/Camera/NbSlice');
+    if ~isempty(uid_NbSlice)
+        NbSlice=str2num(get(t,children(t,uid_NbSlice),'value'));
+        if isempty(NbSlice),NbSlice=1;end; %default
+    end
+    uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');
+    if ~isempty(uid_TimeUnit)
+        TimeUnit=get(t,children(t,uid_TimeUnit),'value');
+        if isempty(TimeUnit),TimeUnit='s';end; %default
+    end
+    uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');
+    if isempty(uid_BurstTiming), error=1.12,return,end;
+    if testime
+        for k=1:length(uid_BurstTiming)
+            Dtj=[];%default
+            NbDtj=1;%default
+            subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming
+            uid_FrameFrequency=find(subt,'/BurstTiming/FrameFrequency');
+           % if isempty(uid_FrameFrequency), error=1.211,return;
+            if isempty(uid_FrameFrequency),
+                Frequency=1;
+            else
+                Frequency=str2num(get(subt,children(subt,uid_FrameFrequency),'value'));
+            end
+            uid_Dtj=find(subt,'/BurstTiming/Dtj');
+            uid_NbDtj=find(subt,'/BurstTiming/NbDtj');
+            uid_Dti=find(subt,'/BurstTiming/Dti');%new
+            uid_NbDti=find(subt,'/BurstTiming/NbDti');%new
+            if ~isempty(uid_Dtj)
+               Dtj=str2num(get(subt,children(subt,uid_Dtj),'value'));%time intervals in frames
+            end
+            uid_child=children(subt,uid_NbDtj);
+            for ivalue=1:length(uid_child)
+                if isequal(get(subt,uid_child(ivalue),'type'),'chardata')
+                     NbDtj=str2num(get(subt,uid_child(ivalue),'value'));%nbre of intervals Dtj
+               end
+            end
+            if isempty(uid_Dti)|isempty(uid_NbDti)
+               Dti=[]; %default
+            else
+               Dti=str2num(get(subt,children(subt,uid_Dti),'value'));%time intervals in frames
+               uid_child=children(subt,uid_NbDti);
+               for ivalue=1:length(uid_child)
+                  if isequal(get(subt,uid_child(ivalue),'type'),'chardata')
+                     NbDti=str2num(get(subt,uid_child(ivalue),'value'));%nbre of intervals Dti
+                  end
+               end
+            end
+            if ~isempty(Dtj)
+                Dtj=reshape(Dtj'*ones(1,NbDtj),1,length(Dtj)*NbDtj);
+            end
+            Dtj=[0 Dtj];
+            dtunit=Dtj/Frequency;
+            uid_Time=find(subt,'/BurstTiming/Time');
+            if isempty(uid_Time)
+                error=1.212;
+            else
+                nbfield=length(uid_Time);
+               Time=get(subt,children(subt,uid_Time),'value');
+               abstime_read=str2num(char(Time))*ones(1,length(Dtj))+ones(nbfield,1)*cumsum(dtunit);
+               abs_time=[abs_time;abstime_read];
+               if ~isempty(Dti)&size(abs_time,1)==1
+                  abs_time=ones(NbDti+1,1)*abs_time+(Dti/Frequency)*[0:NbDti]'*ones(size(abs_time));
+               end
+            end
+        end
+    end
+end
+% if isempty(abs_time)
+%     abs_time=0;%default
+% end
+%read calibration
+uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');
+if ~isempty(uid_GeometryCalib)
+    if length(uid_GeometryCalib)>1
+        errordlg(['More than one GeometryCalib in ' filecivxml])
+        return
+    end
+    subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib
+    cont=get(subt,1,'contents');
+    if ~isempty(cont)
+        uid_pixcmx=find(subt,'/GeometryCalib/Pxcmx');
+        uid_pixcmy=find(subt,'/GeometryCalib/Pxcmy');
+        if ~isempty(uid_pixcmx) & ~isempty(uid_pixcmy)%NON UTILISE 
+           pixcmx=str2num(get(subt,children(subt,uid_pixcmx),'value'));
+            if isempty(pixcmx),pixcmx=1;end; %default
+            pixcmy=str2num(get(subt,children(subt,uid_pixcmy),'value'));
+            if isempty(pixcmy),pixcmy=1;end; %default
+            tsai.Pxcmx=pixcmx;
+            tsai.Pxcmy=pixcmy;
+        end
+        %default values:
+        tsai.f=1;
+        tsai.dpx=1;
+        tsai.dpy=1;
+        tsai.sx=1;
+        tsai.Cx=0;
+        tsai.Cy=0;
+        tsai.Tz=1;
+        tsai.Tx=0;
+        tsai.Ty=0;
+        tsai.R=[1 0 0; 0 1 0; 0 0 0];
+        tsai.kappa1=0;
+        uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');
+        if ~isempty(uid_CoordUnit) 
+            tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');
+        end
+        uid_focal=find(subt,'/GeometryCalib/focal');
+        uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');
+        uid_sx=find(subt,'/GeometryCalib/sx');
+        uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');
+        uid_kappa1=find(subt,'/GeometryCalib/kappa1');
+        uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');
+        uid_R=find(subt,'/GeometryCalib/R');
+        if ~isempty(uid_focal) & ~isempty(uid_dpx_dpy) & ~isempty(uid_Cx_Cy)
+            tsai.f=str2num(get(subt,children(subt,uid_focal),'value'));
+            dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));
+            tsai.dpx=dpx_dpy(1);
+            tsai.dpy=dpx_dpy(2);
+            if ~isempty(uid_sx)
+               tsai.sx=str2num(get(subt,children(subt,uid_sx),'value')); 
+            end
+            Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));
+            tsai.Cx=Cx_Cy(1);
+            tsai.Cy=Cx_Cy(2);
+        end
+        if ~isempty(uid_Tx_Ty_Tz) 
+            Tx_Ty_T_char=get(subt,children(subt,uid_Tx_Ty_Tz),'value');
+%             if ~ischar(Tx_Ty_T_char)
+%                 error='multiple values for Tx_Ty_Tz';
+%             else
+                Tx_Ty_Tz=str2num(Tx_Ty_T_char);
+%             end
+            tsai.Tx=Tx_Ty_Tz(1);
+            tsai.Ty=Tx_Ty_Tz(2);
+            tsai.Tz=Tx_Ty_Tz(3);
+        end
+        if ~isempty(uid_R)
+            RR=get(subt,children(subt,uid_R),'value');
+            if length(RR)==3
+                tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];
+            end
+        end
+        if ~isempty(uid_kappa1)     
+            tsai.kappa1=str2num(get(subt,children(subt,uid_kappa1),'value'));
+        end
+        %look for laser plane definitions   
+        uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');
+        uid_Pos=find(subt,'/GeometryCalib/PlanePos');
+        if ~isempty(uid_Angle) 
+            tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));
+        end
+        if ~isempty(uid_Pos)
+            for j=1:length(uid_Pos)
+                tsai.PlanePos(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));
+            end
+        end
+        GeometryCalib=tsai;
+    end
+end   
+
Index: /trunk/src/private/read_image.m
===================================================================
--- /trunk/src/private/read_image.m	(revision 8)
+++ /trunk/src/private/read_image.m	(revision 8)
@@ -0,0 +1,36 @@
+%'read_image': reads an image from a single file or a movie file
+function [A,error]=read_image(filename,NomType,num);
+ %read  images in different formats. 
+A=[]; %default
+error=0; %default
+if ~exist(filename,'file')
+    error='input file not found in read_image'
+    return
+end
+testframe=0;
+if ~exist('NomType','var')
+    NomType=[];
+end
+if ~exist('num','var')
+    num=1;
+end
+[pth,fl,ext]=fileparts(filename);
+if isequal(lower(ext),'.avi')
+    mov=aviread(filename,num);
+    A=frame2im(mov(1));
+elseif isequal(lower(ext),'.vol')
+     A=imread(filename);
+else
+     form=imformats(ext([2:end]));
+     if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
+         if isequal(NomType,'*');
+            A=imread(filename,num);
+         else 
+           A=imread(filename);  
+         end
+     else
+         error=['ERROR in read_image: file extension not recognized by matlab as image'];
+         return
+     end
+end
+ 
Index: /trunk/src/private/read_imatext.m
===================================================================
--- /trunk/src/private/read_imatext.m	(revision 8)
+++ /trunk/src/private/read_imatext.m	(revision 8)
@@ -0,0 +1,30 @@
+%'read_imatext': reads the .civ file for image documentation (obsolete)
+% fileinput: name of the documentation file 
+% time: matrix of times for the set of images
+%pxcmx: scale along x in pixels/cm
+%pxcmy: scale along y in pixels/cm
+function [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext(fileinput);
+error=0;%default
+time=[]; %default
+TimeUnit='s';
+mode='pairs';
+npx=[]; %default
+npy=[]; %default
+pxcmx=1;%default
+pxcmy=1;%default
+if exist(fileinput,'file')~=2, error=2, return;end;%input file does not exist
+dotciv=textread(fileinput);
+sizdot=size(dotciv);
+if ~isequal(sizdot(1)-8,dotciv(1,1));
+    error=1; %inconsistent number of bursts
+end
+nbfield=sizdot(1)-8;
+npx=(dotciv(2,1));
+npy=(dotciv(2,2));
+pxcmx=(dotciv(6,1));% pixels/cm in the .civ file 
+pxcmy=(dotciv(6,2));
+% nburst=dotciv(3,1); % nbre of bursts
+abs_time1=dotciv([9:nbfield+8],2);
+dtime=dotciv(5,1)*(dotciv([9:nbfield+8],[3:end-1])+1);
+timeshift=[abs_time1 dtime];
+time=cumsum(timeshift,2);
Index: /trunk/src/private/read_plot_param.m
===================================================================
--- /trunk/src/private/read_plot_param.m	(revision 8)
+++ /trunk/src/private/read_plot_param.m	(revision 8)
@@ -0,0 +1,52 @@
+%'read_plot_param':  read plotting parameters from the interface uvmat
+%------------------------------------------
+% function PlotParam=read_plot_param(handles)
+%
+% OUTPUT:
+% PlotParam: structure containing the values of all the relevant plotting parameters 
+%
+% INPUT: 
+% handles: structure containing the handles of the relevant uicontrols in the uvmat interface 
+%
+%      -- TODO:   get the handles using get_plot_handles and findobj as  default input --
+
+function PlotParam=read_plot_param(handles)
+
+PlotParam.Auto_xy=get(handles.auto_xy,'Value');
+
+% scalars
+Scalar.MaxA=str2double(get(handles.MaxA,'String'));
+Scalar.MinA=str2double(get(handles.MinA,'String'));
+Scalar.AutoScal=get(handles.AutoScal,'Value');
+Scalar.BW=get(handles.BW,'Value');
+Scalar.Contours=get(handles.Contours,'Value')==2;
+Scalar.IncrA=str2double(get(handles.IncrA,'String'));
+PlotParam.Scalar=Scalar;
+
+%vectors
+Vectors.VecScale=str2double(get(handles.VecScale,'String'));
+Vectors.AutoVec=get(handles.AutoVec,'Value');%automatic vector length
+Vectors.HideFalse=get(handles.HideFalse,'Value');
+Vectors.HideWarning=get(handles.HideWarning,'Value');
+Vectors.decimate4=get(handles.decimate4,'Value');% =1; for reducing the nbre of vectors
+
+%vector color
+code_list=get(handles.color_code,'String');
+val=get(handles.color_code,'Value');
+% menu_col=get(handles.col_vec,'String');
+% menu_val=get(handles.col_vec,'Value');
+colcode1=str2double(get(handles.colcode1,'String'));% first threshold for rgb, first value for'continuous' 
+colcode2=str2double(get(handles.colcode2,'String'));% second threshold for rgb, last value (saturation) for 'continuous' 
+
+Vectors.ColorCode=code_list{val}; % option of color code for vectors
+Vectors.FixedCbounds=get(handles.AutoVecColor,'Value');% =1; fixed scale for color vector, =0 otherwise (default)
+Vectors.MinC=str2num(get(handles.min_vec,'String')); % imposed min of C, (needed if .FixedCbounds=1)
+Vectors.MaxC=str2num(get(handles.max_vec,'String')); % imposed max of C, needed if .FixedCbounds=1
+if Vectors.MaxC <= Vectors.MinC
+    Vectors.ColorCode='black';
+else
+    Vectors.colcode1=Vectors.MinC+(colcode1-Vectors.MinC)/(Vectors.MaxC-Vectors.MinC);% relative thresholds
+    Vectors.colcode2=Vectors.MinC+(colcode2-Vectors.MinC)/(Vectors.MaxC-Vectors.MinC);
+end
+PlotParam.Vectors=Vectors;
+
Index: /trunk/src/private/read_set_object.m
===================================================================
--- /trunk/src/private/read_set_object.m	(revision 8)
+++ /trunk/src/private/read_set_object.m	(revision 8)
@@ -0,0 +1,210 @@
+%'read_set_object': read the data on the 'set_object' interface
+%--------------------------------------------------------
+% data=read_set_object(handles)
+%--------------------------------------------------------
+%OUTPUT
+%data: structure of data read on the set_object interface
+%    .Style : style of projection object
+%    .Coord(nbpos,3): set of coordinates defining the object position;
+%    .ProjMode=type of projection ;
+%    .Phi=angle of projection;
+%    .DX,.DY,.DZ=increments;
+%    .YMax,YMin: min and max Y
+%INPUT:
+% handles: structure describing the tags of the edit boxes and menus
+function data=read_set_object(handles)
+%menus 
+if isfield(handles,'ObjectStyle')%case of the set_object interface
+	menu=get(handles.ObjectStyle,'String');
+	value=get(handles.ObjectStyle,'Value');
+	data.Style=menu{value};
+	menu=get(handles.ProjMode,'String');
+	value=get(handles.ProjMode,'Value');
+	data.ProjMode=menu{value};
+	menu=get(handles.MenuCoord,'String');
+	value=get(handles.MenuCoord,'Value');
+	data.CoordType=menu{value};
+    testcalib=0;
+else %default
+    data.Style='points';
+    testcalib=1;
+end
+
+%Euler angles and projection ranges
+if ~testcalib
+	if isequal(get(handles.Phi,'Visible'),'on')
+        data.Phi=str2num(get(handles.Phi,'String'));
+	end
+	if isequal(get(handles.Theta,'Visible'),'on')
+        data.Theta=str2num(get(handles.Theta,'String'));
+	end
+	if isequal(get(handles.Psi,'Visible'),'on')
+        data.Psi=str2num(get(handles.Psi,'String'));
+    end	
+	if isequal(get(handles.DX,'Visible'),'on')
+        data.DX=str2num(get(handles.DX,'String'));
+	end
+	if isequal(get(handles.DY,'Visible'),'on')
+        data.DY=str2num(get(handles.DY,'String'));
+	end
+	if isequal(get(handles.DZ,'Visible'),'on')
+        data.DZ=str2num(get(handles.DZ,'String'));
+    end
+    dimrange=[1 1];%default
+    if isequal(get(handles.ZMin,'Visible'),'on')
+        ZMin=str2num(get(handles.ZMin,'String'));
+        if ~isempty(ZMin)
+           data.RangeZ(1)=ZMin;
+           dimrange=[2 3];
+        end
+    end
+	if isequal(get(handles.ZMax,'Visible'),'on')
+        ZMax=str2num(get(handles.ZMax,'String'));
+        if isempty(ZMax)
+            if dimrange(1)>1
+%                 set(handles.ZMax,'String',get(handles.ZMin,'String'))
+                data.RangeZ(1)=ZMax;
+            end
+        else 
+           data.RangeZ=ZMax;
+           dimrange=[dimrange(1) 3];
+        end
+    end
+    if isequal(get(handles.YMin,'Visible'),'on')
+        YMin=str2num(get(handles.YMin,'String'));
+        if isempty(YMin) 
+%             if dimrange(2)>2
+% %                 set(handles.YMin,'String','0')
+%                 data.RangeY(2)=0;
+%             end
+        else
+            data.RangeY(2)=YMin;
+            dimrange=[2 max(dimrange(2),2)];
+        end
+    end
+    if isequal(get(handles.YMax,'Visible'),'on')
+%         data.YMax=str2num(get(handles.YMax,'String'));
+        YMax=str2num(get(handles.YMax,'String'));
+        if isempty(YMax) 
+%             if dimrange(1)>1
+% %                 set(handles.YMax,'String',get(handles.YMin,'String'))
+%                 if ~isempty(YMin)
+%                 data.RangeY(1)=YMin;
+%                 end
+%             elseif dimrange(2)>2
+% %                 set(handles.YMax,'String',get(handles.ZMin,'String'))
+%                 data.RangeY(2)=ZMin;
+%             end
+        else
+            data.RangeY(1)=YMax;
+            dimrange=[dimrange(1) max(dimrange(2),2)];
+        end
+    end
+    if isequal(get(handles.XMin,'Visible'),'on')
+        XMin=str2num(get(handles.XMin,'String'));
+        if isempty(XMin) 
+%             if ~isempty(YMin)
+%                 if dimrange(2)>1
+% %                     set(handles.XMin,'String',get(handles.YMin,'String'))
+%                     data.RangeX(2)=YMin;
+%                     XMin=YMin;
+%                 end
+%             end
+        else
+            data.RangeX(2)=XMin;
+            %dimrange=[2 max(dimrange(2),1)];
+        end
+	end
+	if isequal(get(handles.XMax,'Visible'),'on')
+         XMax=str2num(get(handles.XMax,'String'));
+         if isempty(XMax) 
+%             if dimrange(1)>1
+% %                 set(handles.XMax,'String',get(handles.XMin,'String'))
+%                 if ~isempty(XMin)
+%                 data.RangeX(2)=XMin;
+%                 end
+%             elseif dimrange(2)>1
+% %                 set(handles.XMax,'String',get(handles.YMax,'String'))
+%                 data.RangeX(1)=YMax;
+%             end
+        else
+            data.RangeX(1)=XMax;
+         end
+    end
+end
+
+
+%positions x,y,z
+Xcolumn=get(handles.XObject,'String');
+Ycolumn=get(handles.YObject,'String');
+if ischar(Xcolumn)
+    sizchar=size(Xcolumn);
+    for icol=1:sizchar(1)
+        Xcolumn_cell{icol}=Xcolumn(icol,:);
+    end
+    Xcolumn=Xcolumn_cell;
+end
+if ischar(Ycolumn)
+    sizchar=size(Ycolumn);
+    for icol=1:sizchar(1)
+        Ycolumn_cell{icol}=Ycolumn(icol,:);
+    end
+    Ycolumn=Ycolumn_cell;
+end
+Zcolumn={};%default
+if isequal(get(handles.ZObject,'Visible'),'on')
+    data.NbDim=3; %test 3D object
+    Zcolumn=get(handles.ZObject,'String');
+    if ischar(Zcolumn)
+        Zcolumn={Zcolumn};
+    end
+end
+nb_points=min(length(Xcolumn),length(Ycolumn));%number of point positions needed to define the object position
+if isequal (data.Style,'line');
+    nb_defining_points=2;
+elseif isequal(data.Style,'plane')|isequal(data.Style,'rectangle')|isequal(data.Style,'ellipse')
+    nb_defining_points=1;
+else
+    nb_defining_points=nb_points;
+end
+data_XObject=[];
+data_YObject=[];
+data_ZObject=[];
+for i=1:nb_points
+    Xnumber=str2num(Xcolumn{i});
+    Ynumber=str2num(Ycolumn{i});
+    if isempty(Xnumber)|isempty(Ynumber)
+        break
+    else
+        data_XObject=[data_XObject; Xnumber(1)];
+        data_YObject=[data_YObject; Ynumber(1)];
+    end
+    if length(Zcolumn)<i | isempty(str2num(Zcolumn{i}))
+        data_ZObject=[data_ZObject; 0];
+    else
+        data_ZObject=[data_ZObject; str2num(Zcolumn{i})];
+    end
+end
+if nb_defining_points > nb_points
+    for i=nb_points+1:nb_defining_points
+        data_XObject=[0;data_XObject];
+        data_YObject=[0;data_YObject];
+        data_ZObject=[0;data_ZObject];
+    end
+end
+if isempty(data_XObject)
+    data_XObject=0;
+end
+if isempty(data_YObject)
+    data_YObject=0;
+end
+if isempty(data_ZObject)
+    data_ZObject=0;
+end
+data.Coord=[data_XObject data_YObject data_ZObject];
+
+set(handles.XObject,'String',mat2cell(data_XObject,length(data_XObject)))%correct the interface display
+set(handles.YObject,'String',mat2cell(data_YObject,length(data_XObject)))
+set(handles.ZObject,'String',mat2cell(data_ZObject,length(data_XObject)))
+
+
Index: /trunk/src/private/read_xls.m
===================================================================
--- /trunk/src/private/read_xls.m	(revision 8)
+++ /trunk/src/private/read_xls.m	(revision 8)
@@ -0,0 +1,328 @@
+%'read_xls': function for reading and displaying Excel files  
+%------------------------------------------------------------------------
+% function [hfig_xls]=read_xls(fileinput,hfig)
+% 
+% OUTPUT:
+%  hfig_xls: figure handle for display
+%
+% INPUT:
+% fileinput: name of the input file (char string)
+% hfig: handle of the display figure (a new display figure hfig_xls is created if hfig undefined)
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function [hfig_xls]=read_xls(fileinput,hfig)
+[Tabnum,Tabtext]=xlsread(fileinput);
+    [textnx,textny]=size(Tabtext);
+    [numnx,numny]=size(Tabnum);
+    ilastxt=textnx-numnx;%index of last text row
+    jlastxt=textny-numny;%index of last text column
+    for jtab=1:textny%read line
+        for itab=1:textnx% read column
+            textlu=cell2mat(Tabtext(itab,jtab));
+            if isequal(textlu,[])& itab > ilastxt & jtab > jlastxt %replace txt by number
+                textlu=num2str(Tabnum(itab-ilastxt,jtab-jlastxt));
+            end
+            Tabdisplay(itab,jtab)={textlu};
+            lengthtext(itab)=length(textlu);
+        end
+        widthcolumn(jtab)=max(lengthtext);
+    end
+    Tabchar={};%default
+    for itab=1:textnx    %justify table
+        charchain=[];         
+        for jtab=1:textny% read line
+            textlu=Tabdisplay{itab,jtab};
+            if widthcolumn(jtab)>length(textlu)
+                blankstr=char(46*ones(1,widthcolumn(jtab)-length(textlu)));
+                textlu=[textlu blankstr ];
+            end
+            charchain=[charchain textlu char(9) ' | '];
+        end
+        Tabchar(itab)={charchain};
+    end 
+    if exist('hfig','var') & ishandle(hfig)
+        figure(hfig);
+        hfig_xls=hfig;
+    else
+        hfig_xls=figure;
+    end
+    set(hfig_xls,'Name',fileinput)
+    set(hfig_xls,'MenuBar','none')
+    hpos=get(hfig_xls,'Pos');
+    ExpName.cell=Tabtext([2:textnx],1);%first column (dir name)
+    ExpName.Num=Tabnum;
+%     ExpName.Units=Tabtext(2,[2:textny]);%look for the units line (needs to be the second line)
+    iparam=0;
+    for icol=2:textny
+%         Tabtext(2,icol)
+        if ~isempty(Tabtext{2,icol})&~isequal(Tabtext{2,icol},'')
+            iparam=iparam+1;
+            ExpName.Param{iparam}=Tabtext{1,icol};
+            ExpName.Units{iparam}=Tabtext{2,icol};
+            ExpName.Column(iparam)=icol;
+        end
+    end
+ 
+    ExpName.path=fileparts(fileinput);
+    h=uicontrol('Style','listbox', 'Position', [5 5 0.9*hpos(3) 0.9*hpos(4)], 'String', Tabchar, ...
+        'FontName','Monospaced','Callback',@link2file,'UserData',ExpName,'Tag','listbox');  
+%     hh=uicontrol('Style','Pushbutton', 'Position', [0.93*hpos(1) 0.93*hpos(2) 0.05*hpos(3) 0.05*hpos(4)], 'String', 'Update','Callback',@project_update);
+%      set(h,'HorizontalAlignment','left')
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%called by xlsdisplay to navigate from  a .xls file or create the
+% the experiment directories
+function link2file(obj,event,fileinput)
+global t
+bla=get(gcbo,'String');
+ind=get(gcbo,'Value')
+if (ind==1|ind==2),return,end; %no action on the first line
+ExpNameStruct=get(gcbo,'UserData')
+ExpName=ExpNameStruct.cell{ind-1}
+ProjectFullName=ExpNameStruct.path;%full name of the project (including path)
+[Pth,ProjectName]=fileparts(ProjectFullName);
+ExpPath=fullfile(ProjectFullName,ExpName);% full name of the experiment directory
+ExpDocName=fullfile(ExpPath,[ExpName '.xml']);% full name of the .xml file ExpDoc
+if exist(ExpDocName,'file')
+    hh=editxml({ExpDocName})   
+%     [FileName, PathName, filterindex] = uigetfile( ...
+%        {'*.xml','(*.xml)';
+%        '*.xml',  '.xml files '; 
+%         '*.*',  'All Files (*.*)'}, ...
+%         'Pick a file',ExpDocName);
+%      fileinput=[PathName FileName];%complete file name
+%      sizf=size(fileinput);
+%     if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
+%         [path,name,ext]=fileparts(fileinput);
+%     if isequal(ext,'.civ') | isequal(ext,'.log') | isequal(ext,'.cmx') isequal(ext,'.txt')
+%         edit(fileinput)
+%     elseif isequal(ext,'.xml')
+%         varargin{1}=fileinput;
+%         editxml(varargin)
+%     elseif isequal(ext,'.fig')
+%         open(fileinput)
+%     elseif isequal(ext,'.xls')
+%         xlsdisplay(fileinput)
+%     else
+%         uvmat({fileinput})
+%     end
+else
+    answer=questdlg({['ExpDoc file ' ExpDocName ' does not exist, create the experiment?'];''})
+    if isequal(answer,'Yes')
+        if exist(ExpPath,'dir')~=7 %create a directory if it does not exist
+            dircur=pwd; %current working directory
+            cd(ProjectFullName);
+            [m1,m2,m3]=mkdir(ExpName);
+            cd(pwd);%come back to the initial working dir
+        end
+%         %copy exp parameters
+        ParamNames=ExpNameStruct.Param;
+        ParamValues=ExpNameStruct.Num(ind-1,ExpNameStruct.Column-1);
+        ParamUnits=ExpNameStruct.Units;
+        t=xmltree;%new xmltree
+        t=set(t,1,'name','ExpDoc');
+        t=attributes(t,'add',1,'xmlns:xsi','none');
+        [t,ExpElement]=add(t,1,'element','Exp');
+        [t]=add(t,ExpElement,'chardata',ExpName);
+        for iparam=1:length(ParamNames)
+            [t,ParamElement]=add(t,1,'element',ParamNames{iparam});
+            t=add(t,ParamElement,'chardata',num2str(ParamValues(iparam)));
+            t=attributes(t,'add',ParamElement,'unit',ParamUnits{iparam}); %ADD UNIT ATTRIBUTE
+        end
+        list_dir=dir(ExpPath);%list of the Exp directory,  detect sub-directories,.xml and image files
+        nbdir_exp=0;
+        %scan the Exp directory
+        for idir_exp=3:length(list_dir)
+            %detect subdirectories  
+            if list_dir(idir_exp).isdir% 'device' subdirectories
+                nbdir_exp=nbdir_exp+1;
+                ExpData.Device{nbdir_exp}=list_dir(idir_exp).name;
+                [t,DeviceElement]=add(t,1,'element',list_dir(idir_exp).name);
+                t=attributes(t,'add',DeviceElement,'type','DEVICE_DIR');
+                t=attributes(t,'add',DeviceElement,'source','dir');
+                list_subdir=dir(fullfile(ExpPath,list_dir(idir_exp).name));
+                nbsubdir=0;
+                testrecord=1;
+                RootIma='';
+                RootNc='';
+                nbfile=0;
+%                 nbfile={};
+                %scan the Device subdirectory
+                for isubdir=3:length(list_subdir)
+                    if list_subdir(isubdir).isdir
+                        nbsubdir=nbsubdir+1;
+                        Device.Record{nbsubdir}=list_subdir(isubdir).name;
+                    else
+                        nbfile=nbfile+1;
+                        fname{nbfile}=list_subdir(isubdir).name;
+                    end
+                end
+                if isunix%sort by root names and indices , change the separator '_' so that 1_1 come as the first name
+                    fname_mod=regexprep(fname,'_','/');
+                    fname_mod=sort(fname_mod);     %sort by name
+                    fname=regexprep(fname_mod,'/','_');
+                end
+                for ifile=1:nbfile;
+                    [Path,Name,Ext]=fileparts(fname{ifile});
+                    if isequal(Ext,'.xml')
+                       [t,ImaDocElement]=add(t,DeviceElement,'element','ImaDoc');
+                       t=add(t,ImaDocElement,'chardata',fname{ifile});
+                       t=attributes(t,'add',ImaDocElement,'source','file');
+                       testrecord=0;%we have an image series without 'record' subdir
+                    elseif isequal(Ext,'.png')
+                       [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
+                       if ~isequal(Root,RootIma)%only one image recorded for each root name
+                           [t,ImaDocElement]=add(t,DeviceElement,'element','Image');
+                           t=add(t,ImaDocElement,'chardata',fname{ifile});
+                           t=attributes(t,'add',ImaDocElement,'source','file');
+                           RootIma=Root;
+                       end
+                       testrecord=0;%we have an image series without 'record' subdir
+                    elseif isequal(Ext,'.nc')
+                       [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
+                       if ~isequal(Root,RootNc)%only one image recorded for each root name
+                           [t,ImaDocElement]=add(t,DeviceElement,'element','Ncdata');
+                           t=add(t,ImaDocElement,'chardata',fname{ifile});
+                           t=attributes(t,'add',ImaDocElement,'source','file');
+                           RootNc=Root;
+                       end
+                       testrecord=0;%we have an image series without 'record' subdir
+                    end
+                end
+                if testrecord
+                    %the subdevice directory is 'record' (no images detected at this level)
+                    for idir_s=1:nbsubdir
+                        [t,RecordElement]=add(t,DeviceElement,'element',Device.Record{idir_s});
+                        t=attributes(t,'add',RecordElement,'type','RECORD_DIR');
+                        t=attributes(t,'add',RecordElement,'source','dir');
+                        list_subdir=dir(fullfile(ExpPath,list_dir(idir_exp).name,Device.Record{idir_s}));
+                        nbsubdir=0;
+                        RootIma='';
+                        RootNc='';
+                        nbfile=0;
+                        fname={};
+                        for isubdir=3:length(list_subdir)
+                            if list_subdir(isubdir).isdir
+                                nbsubdir=nbsubdir+1;
+                                [t,RecordElement]=add(t,DeviceElement,'element',Device.Record{idir_exp});
+                                t=attributes(t,'add',RecordElement,'type','RECORD_DIR');
+                                t=attributes(t,'add',RecordElement,'source','dir');
+                                %VOIR les .netcdf a l'interieur
+                            else
+                                nbfile=nbfile+1;
+                                fname{nbfile}=list_subdir(isubdir).name;
+                            end
+                        end
+                        if isunix
+                            fname_mod=regexprep(fname,'_','/');
+                            fname_mod=sort(fname_mod);     %sort by name
+                            fname=regexprep(fname_mod,'/','_');
+                        end
+                        for ifile=1:nbfile;           
+                            [Path,Name,Ext]=fileparts(fname{ifile});
+                            if isequal(Ext,'.xml')
+                               [t,ImaDocElement]=add(t,DeviceElement,'element','ImaDoc');
+                               t=add(t,ImaDocElement,'chardata',fname{ifile});
+                               t=attributes(t,'add',ImaDocElement,'source','file');
+                            elseif isequal(Ext,'.png')
+                               [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
+                               if ~isequal(Root,RootIma)
+                                   [t,ImaDocElement]=add(t,DeviceElement,'element','Image');
+                                   t=add(t,ImaDocElement,'chardata',fname{ifile});
+                                   t=attributes(t,'add',ImaDocElement,'source','file');
+                                   RootIma=Root;
+                               end
+                            elseif isequal(Ext,'.nc')
+                               [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
+                               if ~isequal(Root,RootNc)%only one image recorded for each root name
+                                  [t,ImaDocElement]=add(t,DeviceElement,'element','Ncdata');
+                                  t=add(t,ImaDocElement,'chardata',fname{ifile});
+                                  t=attributes(t,'add',ImaDocElement,'source','file');
+                                  RootNc=Root;
+                               end
+                            end
+                        end
+                    end
+                else%the subdevice directory is a civ directory (coexist with images)
+                     for idir_s=1:nbsubdir
+                        [t,RecordElement]=add(t,DeviceElement,'element',Device.Record{idir_s});
+                        t=attributes(t,'add',RecordElement,'type','CIV_DIR');
+                        t=attributes(t,'add',RecordElement,'source','dir');
+                        %list files under the civ directory
+                        list_subdir=dir(fullfile(ExpPath,list_dir(idir_exp).name,Device.Record{idir_s}));
+                                        
+                        nbsubdir=0;
+                        nbfile=0;
+                        RootXml='';
+                        RootNc='';       
+                        fname={};
+                        for isubdir=3:length(list_subdir)
+                            if list_subdir(isubdir).isdir
+                                nbsubdir=nbsubdir+1;
+                                [t,SubElement]=add(t,RecordElement,'element',list_subdir(isubdir).name);
+                                t=attributes(t,'add',SubElement,'type','UNKNOWN_DIR');
+                                t=attributes(t,'add',SubElement,'source','dir');
+                            else
+                                nbfile=nbfile+1;
+                                fname{nbfile}=list_subdir(isubdir).name;
+                            end
+                        end
+                        if isunix
+                            fname_mod=regexprep(fname,'_','/');
+                            fname_mod=sort(fname_mod);     %sort by name
+                            fname=regexprep(fname_mod,'/','_');
+                        end
+                        for ifile=1:nbfile;
+                            [Path,Name,Ext]=fileparts(fname{ifile});
+                            if isequal(Ext,'.xml')
+                               [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
+                               if ~isequal(Root,RootXml)%only one image recorded for each root name
+                                   [t,ImaDocElement]=add(t,RecordElement,'element','CivDoc');
+                                   t=add(t,ImaDocElement,'chardata',fname{ifile});
+                                   t=attributes(t,'add',ImaDocElement,'source','file');
+                                   RootXml=Root;
+                               end
+                            elseif isequal(Ext,'.nc')
+                               [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
+                               if ~isequal(Root,RootNc)%only one image recorded for each root name
+                                  [t,ImaDocElement]=add(t,RecordElement,'element','Ncdata');
+                                  t=add(t,ImaDocElement,'chardata',fname{ifile});
+                                  t=attributes(t,'add',ImaDocElement,'source','file');
+                                  RootNc=Root;
+                               end
+                            end
+                        end
+                    end
+                end
+            end
+        end
+        save(t);%display xml file on the screen
+        save(t,ExpDocName);
+    end
+end
+% [erread,message]=fileattrib('./DATA');
+% if ~isempty(message) & ~isequal(message.UserWrite,1)
+%      errordlg(['Need writting access to ' message.Name])
+%      return
+% end
+
+
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    function project_update(obj,event,fileinput)
+    hchild=get(gcbf,'children');
+    h=findobj(gcbf,'Tag','listbox')
+    
Index: /trunk/src/private/set_col_vec.m
===================================================================
--- /trunk/src/private/set_col_vec.m	(revision 8)
+++ /trunk/src/private/set_col_vec.m	(revision 8)
@@ -0,0 +1,89 @@
+%'set_col_vec': sets the color code for vectors depending on a scalar vec_C and parameters given by the struct colcode
+%function [colorlist,col_vec,minC,colcode1,colcode2,maxC]=colvec(colcode,vec_C)
+%OUTPUT
+%colorlist(nb,3); %list of nb colors
+%col_vec, size=[length(vec_C),3)];%list of color indices corresponding to vec_C
+%minC, maxC: min and max of vec_C
+%colcode1, colcode2: absolute threshold in vec_C corresponding to colcode.colcode1 and colcode.colcode2
+%INPUT
+% colcode: struture setting the colorcode for vectors
+            % colcode.CName: 'ima_cor','black','white',...
+            % colcode.ColorCode ='black', 'white', 'rgb','brg', '64 colors'
+            % colcode.FixedCbounds =0; thresholds scaling relative to min and max, =1 fixed thresholds
+            % colcode.MinC; min 
+            % colcode.MaxC; max
+            % colcode.colcode1: first threshold for rgb, relative to min (0) and max (1)
+            % colcode.colcode2: second threshold for rgb, relative to min (0) and max (1), 
+            % rmq: we need min <= colcode1 <= colcode2 <= max, otherwise
+            % colcode1 and colcode2 are adjusted to the bounds
+% vec_C: matlab vector representing the scalar setting the color
+function [colorlist,col_vec,colcode_out]=set_col_vec(colcode,vec_C)
+
+col_vec=[]; 
+colcode_out=colcode;%default
+if isempty(vec_C) || ~isnumeric(vec_C)
+    colorlist=[0 0 1]; %blue  
+    return
+end
+if (isfield(colcode,'FixedCbounds') && isequal(colcode.FixedCbounds,1))
+    minC=colcode.MinC;
+    maxC=colcode.MaxC;
+else
+    minC=min(vec_C);
+    maxC=max(vec_C);
+end
+
+%default input parameters
+if ~isstruct(colcode),colcode=[];end;
+if ~isfield(colcode,'ColorCode') || isempty(colcode.ColorCode)
+    colorlist=[0 0 1]; %blue  
+    return
+end
+if  isfield(colcode,'colcode1')
+    colcode1=minC+colcode.colcode1*(maxC-minC);
+else
+    colcode1=minC+(maxC-minC)/3;%default
+end
+if isfield(colcode,'colcode2')
+    colcode2=minC+colcode.colcode2*(maxC-minC);
+else
+    colcode2=minC+2*(maxC-minC)/3;%default
+end
+colcode_out.MinC=minC;
+colcode_out.MaxC=maxC;
+
+if strcmp(colcode.ColorCode,'black')
+    colorlist(1,:)=[0 0 0];%black
+    col_vec=ones(size(vec_C));%all vectors at color#1
+elseif strcmp(colcode.ColorCode,'white')
+    colorlist(1,:)=[1 1 1];%white
+    col_vec=ones(size(vec_C));%all vectors at color#1
+elseif strcmp(colcode.ColorCode,'rgb')|| strcmp(colcode.ColorCode,'bgr')% 3 color representation
+    ind1=find(vec_C < colcode1); % =1 for red vectors
+    ind_green=find((vec_C >= colcode1) & (vec_C < colcode2));% =1 for green vectors
+    ind3=find(vec_C >= colcode2);% =1 for blue vectors
+    colorlist(2,:)=[0 1 0];%green
+    col_vec(ind1)=1;
+    col_vec(ind_green)=2;
+    col_vec(ind3)=3;
+    if strcmp(colcode.ColorCode,'rgb')
+        colorlist(1,:)=[1 0 0];%red
+        colorlist(3,:)=[0 0 1];%blue
+    else
+        colorlist(1,:)=[0 0 1];%blue
+        colorlist(3,:)=[1 0 0];%red
+    end
+else
+    colorjet=jet;% ususal colormap from blue to red
+    sizlist=size(colorjet);
+    indsel=ceil((sizlist(1)/64)*(1:64));
+    colorlist(:,1)=colorjet(indsel,1);
+    colorlist(:,2)=colorjet(indsel,2);
+    colorlist(:,3)=colorjet(indsel,3);
+    sizlist=size(colorlist);
+    nblevel=sizlist(1);
+    col2_1=maxC-minC;
+    col_vec=1+floor(nblevel*(vec_C-minC)/col2_1);
+    col_vec=col_vec.*(col_vec<= nblevel)+nblevel*(col_vec >nblevel);% take color #nblevel at saturation
+    col_vec=col_vec.*(col_vec>= 1)+  (col_vec <1);% take color #1 for values below 1
+end
Index: /trunk/src/private/set_title.m
===================================================================
--- /trunk/src/private/set_title.m	(revision 8)
+++ /trunk/src/private/set_title.m	(revision 8)
@@ -0,0 +1,30 @@
+%'set_title': defines the 'TITLE' of a projection object
+%-----------------------------------------------------------
+% function TITLE=set_title(Style,ProjMode)
+% OUTPUT:
+%    TITLE: char string defining the title
+%
+% INPUT:
+%    Style: char string defining the style of the projection opbject
+%    ProjMode:  char string defining the projection mode 
+%------------------------------------------------
+function TITLE=set_title(Style,ProjMode)
+%------------------------------------------------
+TITLE=[]; %default
+if isequal(Style,'points')
+    TITLE='POINTS';
+elseif isequal(Style,'line')|isequal(Style,'polyline')
+    TITLE='LINE';
+elseif isequal(Style,'plane')
+    TITLE='PLANE';
+elseif isequal(Style,'volume')
+    TITLE='VOLUME';
+elseif isequal(Style,'polygon')|isequal(Style,'rectangle')|isequal(Style,'ellipse')
+    if isequal(ProjMode,'inside')|isequal(ProjMode,'outside')
+        TITLE='PATCH';
+    elseif isequal(ProjMode,'mask_inside')|isequal(ProjMode,'mask_outside')
+        TITLE='MASK';
+    else
+        TITLE='LINE';
+    end
+end
Index: /trunk/src/private/stra2num.m
===================================================================
--- /trunk/src/private/stra2num.m	(revision 8)
+++ /trunk/src/private/stra2num.m	(revision 8)
@@ -0,0 +1,21 @@
+%'stra2num': transform letters (a, b, c) or numerical strings ('1','2'..) to the corresponding numbers
+%--------------------------------------------
+%  function numres=stra2num(str)
+%
+% OUTPUT: 
+% numres: number (double)
+%
+% INPUT:
+% str: string corresponding to a number or a letter 'a' 'b',.., otherwise the output is empty
+%
+% see also num2stra, name_generator, name2display
+
+function numres=stra2num(str)
+numres=[]; %default
+if double(str) >= 48 & double(str) <= 57 % = test for number strings
+    numres=str2num(str);
+elseif double(str) >= 65 & double(str) <= 90 % test on ascii code for capital letters
+    numres=double(str)-64; %change capital letters to corresponding number in the alphabet
+elseif double(str) >= 97 & double(str) <= 122 % test on ascii code for small letters 
+    numres=double(str)-96; %change small letters to corresponding number in the alphabet
+end
Index: /trunk/src/private/struct2nc.m
===================================================================
--- /trunk/src/private/struct2nc.m	(revision 8)
+++ /trunk/src/private/struct2nc.m	(revision 8)
@@ -0,0 +1,144 @@
+%'struct2nc': create a netcdf file from a Matlab structure
+%---------------------------------------------------------------------
+% errormsg=struct2nc(flname,Data)
+%
+%OUPUT:
+%errormsg=error message, =[]: default, no error
+%
+%INPUT:
+%flname: name of the netcdf file to create (must end with the extension '.nc')
+%  Data: structure containing all the information of the netcdf file (or netcdf object)
+%           with fields:
+%    .ListGlobalAttribute: cell listing the names of the global attributes (note that a global atribute with the same name as a variable is excluded)
+%        .Att_1,Att_2... : values of the global attributes
+%            .ListDimName: cell listing the names of the array dimensions
+%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
+%            .ListVarName: cell listing the names of the variables
+%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
+%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
+%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function errormsg=struct2nc(flname,Data)
+if ~ischar(flname)
+    errormsg='no name input for the netcf file';
+    return
+end
+if ~exist('Data','var')
+     errormsg='no data  input for the netcdf file';
+    return
+end 
+hhh=which('netcdf.create');% look for built-in matlab library
+
+%USE OF built-in  netcdf library
+if ~isequal(hhh,'')
+    FilePath=fileparts(flname);
+    if ~strcmp(FilePath,'') && ~exist(FilePath,'dir')
+        errormsg=['directory ' FilePath ' needs to be created'];
+        return
+    end
+    [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure
+    ListVarName=Data.ListVarName;
+    nc=netcdf.create(flname,'NC_CLOBBER');%,'clobber'); %create the netcdf file with name flname   
+    %write global constants
+    if isfield(Data,'ListGlobalAttribute')
+        keys=Data.ListGlobalAttribute;
+        for iattr=1:length(keys)
+            if isfield(Data,keys{iattr})
+                 testvar=0;
+                for ivar=1:length(ListVarName)% eliminate possible global attributes with the same name as a variable
+                    if isequal(ListVarName{ivar}, keys{iattr})
+                        testvar=1;
+                        break
+                    end
+                end
+                if ~testvar               
+                    eval(['cte=Data.' keys{iattr} ';'])
+                    if (ischar(cte) ||isnumeric(cte)) &&  ~isempty(cte)&& ~isequal(cte,'')
+                        netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),keys{iattr},cte)
+                    else
+                        errormsg='global attributes must be characters or numbers';
+                        return
+                    end
+                end
+            end
+        end
+    end
+    %create dimensions
+    dimid=[];
+    for idim=1:length(Data.ListDimName)
+         dimid(idim) = netcdf.defDim(nc,Data.ListDimName{idim},Data.DimValue(idim)); 
+    end
+    VarAttribute={}; %default
+    testattr=0;
+    if isfield(Data,'VarAttribute')
+        VarAttribute=Data.VarAttribute;
+        testattr=1;
+    end
+    varid=[];
+    for ivar=1:length(ListVarName)
+        varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'double',dimid(Data.VarDimIndex{ivar}));%define variable  
+    end
+     %write variable attributes
+    if testattr
+        for ivar=1:length(VarAttribute)  
+            if isstruct(VarAttribute{ivar})
+                attr_names=fields(VarAttribute{ivar});
+                for iattr=1:length(attr_names)
+                    eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);
+                    netcdf.putAtt(nc,varid(ivar),attr_names{iattr},attr_val);
+                end
+            end
+        end
+    end
+    netcdf.endDef(nc); %put in data mode
+    for ivar=1:length(ListVarName)
+        if isfield(Data,ListVarName{ivar})
+            eval(['VarVal=Data.' ListVarName{ivar} ';'])%varval=values of the current variable 
+            VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
+            siz=size(VarVal);
+            VarDimName=Data.VarDimName{ivar};%NEW
+            if ischar(VarDimName)%NEW
+                VarDimName={VarDimName};%NEW
+            end%NEW
+            testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2); %NEW
+            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);
+            if ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex))
+                errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
+                break
+            end 
+            if testline || testrange%NEW
+                if testrange
+                    VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));%NEW
+                end
+               %nc{ListVarName{ivar}}=ncfloat(Data.ListDimName(VarDimIndex));%vector of x coordinates
+               netcdf.putVar(nc,varid(ivar), VarVal');
+            else
+                netcdf.putVar(nc,varid(ivar), VarVal);
+                %nc{ListVarName{ivar}}(:) = VarVal;
+            end
+            
+        end
+    end
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%OLD netcdf toolbox
+else
+    errormsg=struct2nc_toolbox(flname,Data);
+end
+
Index: /trunk/src/private/struct2nc_toolbox.m
===================================================================
--- /trunk/src/private/struct2nc_toolbox.m	(revision 8)
+++ /trunk/src/private/struct2nc_toolbox.m	(revision 8)
@@ -0,0 +1,132 @@
+%'struct2nc_toolbox': create a netcdf file from a Matlab structure: use of netcdf toolbox
+%---------------------------------------------------------------------
+% errormsg=struct2nc_toolbox(flname,Data)
+%
+%OUPUT:
+%errormsg=error message, =[]: default, no error
+%
+%INPUT:
+%flname: name of the netcdf file to create (must end with the extension '.nc')
+%  Data: structure containing all the information of the netcdf file (or netcdf object)
+%           with fields:
+%    .ListGlobalAttribute: cell listing the names of the global attributes (note that a global atribute with the same name as a variable is excluded)
+%        .Att_1,Att_2... : values of the global attributes
+%            .ListDimName: cell listing the names of the array dimensions
+%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
+%            .ListVarName: cell listing the names of the variables
+%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
+%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
+%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function errormsg=struct2nc_toolbox(flname,Data)
+
+FilePath=fileparts(flname);
+if ~strcmp(FilePath,'') &&~exist(FilePath,'dir')
+    errormsg=['directory ' FilePath ' needs to be created'];
+    return
+end
+[Data,errormsg]=check_field_structure(Data);
+if ~isempty(errormsg)
+    return
+end
+ListVarName=Data.ListVarName;
+nc=netcdf(flname,'clobber'); %create the netcdf file with name flname
+%write global constants
+if isfield(Data,'ListGlobalAttribute')
+    keys=Data.ListGlobalAttribute;
+    for iattr=1:length(keys)
+        if isfield(Data,keys{iattr})
+             testvar=0;
+            for ivar=1:length(ListVarName)% eliminate possible global attributes with the same name as a variable
+                if isequal(ListVarName{ivar}, keys{iattr})
+                    testvar=1;
+                    break
+                end
+            end
+            if ~testvar               
+                eval(['cte=Data.' keys{iattr} ';'])
+                if ischar(cte) && ~isequal(cte,'')
+                    eval(['nc.' keys{iattr} '=''' cte ''';']);
+                elseif isnumeric(cte)&& ~isempty(cte)
+                    eval(['nc.' keys{iattr} '= cte; ']);
+                else
+                    errormsg='global attributes must be characters or numbers';
+                    return
+                end
+            end
+        end
+    end
+end
+for idim=1:length(Data.ListDimName)
+    nc(Data.ListDimName{idim})=Data.DimValue(idim);%create dimensions
+end
+
+VarAttribute={}; %default
+testattr=0;
+if isfield(Data,'VarAttribute')
+    VarAttribute=Data.VarAttribute;
+    testattr=1;
+end
+for ivar=1:length(ListVarName)
+    if isfield(Data,ListVarName{ivar})
+        eval(['VarVal=Data.' ListVarName{ivar} ';'])%varval=values of the current variable 
+        siz=size(VarVal);
+        VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
+        VarDimName=Data.VarDimName{ivar};%NEW
+        if ischar(VarDimName)%NEW
+            VarDimName={VarDimName};%NEW
+        end%NEW
+        testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2); %NEW
+        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);
+        if ~testrange && ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex))
+            errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
+            break
+        end 
+        if testline || testrange%NEW
+           dimname=Data.ListDimName{VarDimIndex};
+           if testrange%NEW
+               VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));%NEW
+           end%NEW
+           nc{ListVarName{ivar}}=ncfloat(dimname);%vector of x coordinates
+           nc{ListVarName{ivar}}(:) = VarVal';  
+        else
+            nc{ListVarName{ivar}}=ncfloat(Data.ListDimName(VarDimIndex));%vector of x coordinates
+            nc{ListVarName{ivar}}(:) = VarVal;
+        end
+        %write variable attributes
+        if testattr
+            for ivar=1:length(VarAttribute)  
+                if isstruct(VarAttribute{ivar})
+                    attr_names=fields(VarAttribute{ivar});
+                    for iattr=1:length(attr_names)
+                        eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);
+                        if ischar(attr_val) && ~isequal(attr_val,'')
+                            eval(['nc{''' ListVarName{ivar} '''}.' attr_names{iattr} '=''' attr_val ''';'])
+                        elseif isnumeric(attr_val)&& ~isempty(attr_val)
+                             eval(['nc{''' ListVarName{ivar} '''}.' attr_names{iattr} '=attr_val ;'])
+                        end
+                    end
+                end
+            end
+         end
+    end
+end
+
+close(nc);
Index: /trunk/src/private/struct2xml.m
===================================================================
--- /trunk/src/private/struct2xml.m	(revision 8)
+++ /trunk/src/private/struct2xml.m	(revision 8)
@@ -0,0 +1,62 @@
+%'struct2xml': transform a matlab structure to a xml tree.
+%--------------------------------------------------------------
+% each field with char string or num vector is transformed into a corresponding  xml element
+% each field with a matrix containing n lines is transformed into a xml element repeated n times 
+% WARNING: PROBLEM WITH HIERARCHICAL structures
+%%%%%%%%%%%%%%%%%%%%%%%
+% OUTPUT:
+% t: xmltree reproducing the structure of Object
+% type 'save(t)' to visualize the xml text and save(filename,t) to save it in a file
+%
+% INPUT:
+%  Object: matlab structure, possibly hierarchical
+%  t: optional input xml tree in which a new branch needs to be appended
+%  root_uid: optional uid of the xml element under which the new subtree must be appended
+
+function t=struct2xml(Object,t,root_uid)
+get(t,root_uid)
+if ~exist('t','var')
+    t=xmltree;
+end
+if ~exist('root_uid','var')
+    root_uid=1;
+end
+fieldnames=fields(Object);
+for ilist=1:length(fieldnames)
+   eval(['val=Object.' fieldnames{ilist} ';'])
+   if isstruct(val)
+      [t,uid]=add(t,root_uid,'element',fieldnames{ilist});
+      fieldnames_sub=fields(val);
+      for ilist_sub=1:length(fieldnames_sub)
+          if isstruct(fieldnames_sub{ilist_sub})
+                t=struct2xml(fieldnames_sub{ilist_sub},t,uid);
+                save(t)
+          else
+              eval(['val_sub=val.' fieldnames_sub{ilist_sub} ';'])
+              t=add_element(t,uid,fieldnames_sub{ilist_sub},val_sub);
+          end
+      end
+   else
+       t=add_element(t,root_uid,fieldnames{ilist},val);
+   end
+end
+
+    
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function t=add_element(t,uid,key,val)
+ if ischar(val)
+     [t,new_uid]=add(t,uid,'element',key);
+     [t]=add(t,new_uid,'chardata',val);
+ elseif isnumeric(val)
+       siz=size(val);
+       if length(siz)<=2 %do not translate matrices with more than 2 indices
+           for iline=1:siz(1)
+                val_str=num2str(val(iline,:),'%g\t');
+                [t,new_uid]=add(t,uid,'element',key);
+                if siz(1)>1
+                    t = attributes(t,'add',new_uid,'i',num2str(iline));
+                end
+                [t]=add(t,new_uid,'chardata',val_str);
+           end
+       end
+ end   
Index: /trunk/src/private/sub_field.m
===================================================================
--- /trunk/src/private/sub_field.m	(revision 8)
+++ /trunk/src/private/sub_field.m	(revision 8)
@@ -0,0 +1,354 @@
+%'sub_field': combines two input fields 
+%-----------------------------------------------------------------------
+% function SubData=sub_field(Field,Field_1)
+%
+% OUPUT: 
+% SubData: structure representing the resulting field
+%
+% INPUT: 
+% UvData: main structure UvData associated to the uvmat GUI as 'UserData'
+% Field: cell of Matlab structures representing the input fields
+% 
+%    -- TODO: need to be rationalized --
+
+function [SubData,errormsg]=sub_field(Field,Field_1)
+test_attr=0;
+if isfield(Field,'ListGlobalAttribute')
+    SubData.ListGlobalAttribute=Field.ListGlobalAttribute;
+    for ilist=1:numel(Field.ListGlobalAttribute)
+        AttrName=Field.ListGlobalAttribute{ilist};
+        eval(['SubData.' AttrName '=Field.' AttrName ';'])
+    end
+    test_attr=1;
+end
+if isfield(Field_1,'ListGlobalAttribute')
+    for ilist=1:numel(Field_1.ListGlobalAttribute)
+        test_1=1;
+        AttrName=Field_1.ListGlobalAttribute{ilist};
+        if test_attr
+            for i_prev=1:numel(Field.ListGlobalAttribute)
+                if isequal(Field.ListGlobalAttribute{i_prev},AttrName)
+                    test_1=0; %attribute already written
+                    eval(['Val=Field.' AttrName ';'])                  
+                    eval(['Val_1=Field_1.' AttrName ';'])
+                    if isequal(Val,Val_1)           
+                        break% data already written
+                    else
+                        eval(['SubData.' AttrName '_1=Field_1.' AttrName ';']) 
+                    end
+                end 
+            end
+        end
+        if test_1
+            eval(['SubData.' AttrName '=Field_1.' AttrName ';']) 
+        end
+    end
+end
+SubData.ListVarName=Field.ListVarName;
+SubData.VarDimName=Field.VarDimName;
+if isfield(Field,'VarAttribute')
+    SubData.VarAttribute=Field.VarAttribute;
+end
+%reproduce Field by default
+for ivar=1:numel(Field.ListVarName)
+   VarName=Field.ListVarName{ivar};
+   eval(['SubData.' VarName '=Field.' VarName ';']) 
+end
+
+%fields     
+[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(Field);
+if ~isempty(errormsg)
+    errormsg=['invalid  first input to sub_field:' errormsg];
+    return
+end
+[CellVarIndex_1,NbDim_1,VarTypeCell_1,errormsg]=find_field_indices(Field_1);
+if ~isempty(errormsg)
+    errormsg=['invalid second input to sub_field:' errormsg];
+    return
+end
+iselect=find(NbDim==2);
+if ~isequal(numel(iselect),1)
+    errormsg='invalid  first input to sub_field: it must  contain a single 2D field cell';
+    return
+end
+iselect_1=find(NbDim_1==2);
+if ~isequal(numel(iselect_1),1)
+    errormsg='invalid  second input to sub_field: it must  contain a single 2D field cell';
+    return
+end
+% VarIndex=CellVarIndex{iselect};
+% VarIndex_1=CellVarIndex_1{iselect_1};
+VarType=VarTypeCell{iselect};
+VarType_1=VarTypeCell_1{iselect_1};
+testX=~isempty(VarType.coord_x)&& ~isempty(VarType.coord_y);%unstructured coordiantes
+testX_1=~isempty(VarType_1.coord_x)&& ~isempty(VarType_1.coord_y);%unstructured coordiantes
+testU=~isempty(VarType.vector_x)&& ~isempty(VarType.vector_y);%vector field
+testU_1=~isempty(VarType_1.vector_x)&& ~isempty(VarType_1.vector_y);%vector field
+% testfalse=~isempty(VarType.errorflag);
+testfalse_1=~isempty(VarType_1.errorflag);
+ivar_C=[VarType.scalar VarType.image VarType.color VarType.ancillary]; %defines index (indices) for the scalar or ancillary fields
+if numel(ivar_C)>1
+    errormsg='too many scalar fields in the first input of sub_field.m';
+    return
+end
+ivar_C_1=[VarType_1.scalar VarType_1.image VarType_1.color VarType_1.ancillary]; %defines index (indices) for the scalar or ancillary fields
+if numel(ivar_C_1)>1
+    errormsg='too many scalar fields in the second input of sub_field.m';
+    return
+end
+
+%substract two vector fields or two scalars
+if (testU && testU_1) || (~testU && ~testU_1)
+   %check coincidence in positions
+   %unstructured coordinates
+   if testX
+       XName=Field.ListVarName{VarType.coord_x};
+       YName=Field.ListVarName{VarType.coord_y};
+       eval(['vec_X=Field.' XName ';']) 
+       eval(['vec_Y=Field.' YName ';'])
+       nbpoints=numel(vec_X);
+       vec_X=reshape(vec_X,1,nbpoints);
+       vec_Y=reshape(vec_Y,1,nbpoints);
+       if testX_1 %unstructured coordinates for the second field
+            X_1_Name=Field_1.ListVarName{VarType_1.coord_x};
+            Y_1_Name=Field_1.ListVarName{VarType_1.coord_y};
+            eval(['vec_X_1=Field_1.' X_1_Name ';']) 
+            eval(['vec_Y_1=Field_1.' Y_1_Name ';'])
+            nbpoints_1=numel(vec_X_1);
+       else   %structured coordinates for the second field
+           y_1_Name=Field_1.ListVarName{VarType_1.coord(1)};
+           x_1_Name=Field_1.ListVarName{VarType_1.coord(2)};
+           eval(['y_1=Field_1.' y_1_Name ';']) 
+           eval(['x_1=Field_1.' x_1_Name ';'])  
+           npxy(1)=numel(y_1);
+           npxy(2)=numel(x_1);
+           nbpoints_1=npxy(1)*npxy(2);
+           [vec_X_1,vec_Y_1]=meshgrid(x_1,y_1);
+       end
+       vec_X_1=reshape(vec_X_1,1,nbpoints_1);
+       vec_Y_1=reshape(vec_Y_1,1,nbpoints_1);
+       if testfalse_1
+           FFName_1=Field_1.ListVarName{VarType_1.errorflag};          
+           eval(['vec_FF_1=Field_1.' FFName_1 ';']) 
+           vec_FF_1=reshape(vec_FF_1,1,nbpoints_1);
+           indsel=find(~vec_FF_1);
+           vec_X_1=vec_X_1(indsel);
+           vec_Y_1=vec_Y_1(indsel);
+       end
+       if testU % vector fields
+            U_1_Name=Field_1.ListVarName{VarType_1.vector_x};
+            V_1_Name=Field_1.ListVarName{VarType_1.vector_y};
+            eval(['vec_U_1=Field_1.' U_1_Name ';']) 
+            eval(['vec_V_1=Field_1.' V_1_Name ';'])
+            vec_U_1=reshape(vec_U_1,1,nbpoints_1);
+            vec_V_1=reshape(vec_V_1,1,nbpoints_1);
+            if testfalse_1
+                vec_U_1=vec_U_1(indsel);
+                vec_V_1=vec_V_1(indsel);
+            end            
+       else
+           A_1_Name=Field_1.ListVarName{ivar_C_1};
+           eval(['vec_A_1=Field_1.' A_1_Name ';'])
+           vec_A_1=reshape(vec_A_1,1,nbpoints_1);
+           if testfalse_1
+                vec_A_1=vec_A_1(indsel);
+           end
+       end
+       if ~isequal(vec_X_1,vec_X) && ~isequal(vec_Y_1,vec_Y) % if the unstructured positions are not the same
+           if testU
+               vec_U_1=griddata_uvmat(vec_X_1,vec_Y_1,vec_U_1,vec_X,vec_Y);  %interpolate vectors in the second field
+               vec_V_1=griddata_uvmat(vec_X_1,vec_Y_1,vec_V_1,vec_X,vec_Y);  %interpolate vectors in the second field   
+           else
+               vec_A_1=griddata_uvmat(vec_X_1,vec_Y_1,vec_A_1,vec_X,vec_Y);  %interpolate vectors in the second field
+           end
+       end 
+       if testU
+           UName=Field.ListVarName{VarType.vector_x};
+           VName=Field.ListVarName{VarType.vector_y};  
+           eval(['vec_U=Field.' UName ';']) 
+           eval(['vec_V=Field.' VName ';'])       
+           vec_U=reshape(vec_U,1,numel(vec_U));
+           vec_V=reshape(vec_V,1,numel(vec_V));
+           eval(['SubData.' UName '=vec_U-vec_U_1;'])
+           eval(['SubData.' VName '=vec_V-vec_V_1;'])
+       else
+           AName=Field.ListVarName{ivar_C};
+           eval(['SubData.' AName '=Field.' AName '-vec_A_1;'])
+       end
+   else  %structured coordiantes
+       XName=Field.ListVarName{VarType.coord(2)};
+       YName=Field.ListVarName{VarType.coord(1)};
+       eval(['x=Field.' XName ';']) 
+       eval(['y=Field.' YName ';'])
+       if testX_1 %unstructured coordinates for the second field
+           errormsg='the second input scalar is not on a regular grid: comparison option not implemented';
+           return
+       else
+           XName_1=Field.ListVarName{VarType_1.coord(2)};
+           YName_1=Field.ListVarName{VarType_1.coord(1)};
+           eval(['x_1=Field_1.' XName_1 ';']) 
+           eval(['y_1=Field_1.' YName_1 ';'])
+       end
+       if testU % vector fields
+           UName=Field.ListVarName{VarType.vector_x};
+           VName=Field.ListVarName{VarType.vector_y};
+           U_1_Name=Field_1.ListVarName{VarType_1.vector_x};
+           V_1_Name=Field_1.ListVarName{VarType_1.vector_y};
+           eval(['U_1=Field_1.' U_1_Name ';']) 
+           eval(['V_1=Field_1.' V_1_Name ';'])
+           if ~isequal(x_1,x)||~isequal(y_1,y)
+                [X_1,Y_1]=meshgrid(x_1,y_1);
+                U_1 =interp2(X_1,Y_1,U_1,x,y');
+                V_1 =interp2(X_1,Y_1,V_1,x,y');
+           end
+           val(['SubData.' UName '=Field.' UName '-U_1;'])
+           val(['SubData.' VName '=Field.' VName '-V_1;'])
+       else
+           AName=Field.ListVarName{ivar_C};
+           A_1_Name=Field_1.ListVarName{ivar_C_1};
+           eval(['A_1=double(Field_1.' A_1_Name ');'])
+           if ~isequal(x_1,x)||~isequal(y_1,y)
+                [X_1,Y_1]=meshgrid(x_1,y_1);
+                A_1 =interp2(X_1,Y_1,A_1,x,y');
+           end
+           eval(['SubData.' AName '=double(Field.' AName ')-A_1;'])
+       end
+   end
+end
+
+% merge a vector field and a scalar as second input
+if testU && ~testU_1
+    AName_1=Field_1.ListVarName{ivar_C_1};
+    if isfield(Field_1,'VarAttribute') && numel(Field_1.VarAttribute)>=ivar_C_1
+        AAttr=Field_1.VarAttribute{ivar_C_1} ;
+    else
+        AAttr=[];
+    end
+    if testX_1 %unstructured coordinate
+       XName_1=Field_1.ListVarName{VarType_1.coord_x};
+       YName_1=Field_1.ListVarName{VarType_1.coord_y};
+       SubData.ListVarName=[SubData.ListVarName {XName_1} {YName_1}];
+       DimCell=Field_1.VarDimName([VarType_1.coord_x VarType_1.coord_y ]);
+       if isfield(Field_1,'VarAttribute') 
+           if numel(Field_1.VarAttribute)>=VarType_1.coord_x
+                XAttr=Field_1.VarAttribute{VarType_1.coord_x} ;
+           else
+                XAttr=[];
+           end
+           if numel(Field_1.VarAttribute)>=VarType_1.coord_y
+               YAttr=Field_1.VarAttribute{VarType_1.coord_y} ;
+           else
+               YAttr=[];
+           end
+           SubData.VarAttribute=[SubData.VarAttribute {XAttr} {YAttr}];
+       end
+    else
+       XName_1=Field_1.ListVarName{VarType_1.coord(2)};
+       YName_1=Field_1.ListVarName{VarType_1.coord(1)};
+%        DimCell=[{YName_1} {XName_1}];
+       if isfield(Field_1,'VarAttribute') 
+           if numel(Field_1.VarAttribute)>=VarType_1.coord(2)
+                XAttr=Field_1.VarAttribute{VarType_1.coord(2)} ;
+           else
+                XAttr=[];
+           end
+           if numel(Field_1.VarAttribute)>=VarType_1.coord(1)
+               YAttr=Field_1.VarAttribute{VarType_1.coord(1)} ;
+           else
+               YAttr=[];
+           end
+           SubData.VarAttribute=[SubData.VarAttribute {YAttr} {XAttr}];
+       end
+    end  
+    %look for previously used variable names
+    XName_1_1=XName_1;%default
+    YName_1_1=YName_1;%default
+    AName_1_1=AName_1;%default
+    for iprev=1:numel(SubData.ListVarName)
+        switch SubData.ListVarName{iprev}
+            case XName_1
+                XName_1_1=[XName_1 '_1'];
+            case YName_1
+                YName_1_1=[YName_1 '_1'];
+            case AName_1
+                AName_1_1=[AName_1 '_1']; 
+        end
+    end     
+    if ~testX_1
+          DimCell=[{XName_1_1} {YName_1_1}];
+    end
+    SubData.ListVarName=[SubData.ListVarName {XName_1_1} {YName_1_1} {AName_1_1}];
+    DimCell=[DimCell Field_1.VarDimName(ivar_C_1)]; %(TODO: check for dimension names)
+    SubData.VarDimName=[SubData.VarDimName DimCell];
+    if isfield(Field_1,'VarAttribute')
+        SubData.VarAttribute=[SubData.VarAttribute {AAttr}];
+    end
+    eval(['SubData.' XName_1_1 '=Field_1.' XName_1 ';'])
+    eval(['SubData.' YName_1_1 '=Field_1.' YName_1 ';'])
+    eval(['SubData.' AName_1_1 '=Field_1.' AName_1 ';'])
+end
+
+%merge a scalar as the first input and a vector field as second input
+if ~testU && testU_1
+    UName_1=Field_1.ListVarName{VarType_1.vector_x};
+    VName_1=Field_1.ListVarName{VarType_1.vector_y};
+    UAttr=Field_1.VarAttribute{VarType_1.vector_x};
+    VAttr=Field_1.VarAttribute{VarType_1.vector_y};
+    if testX_1 %unstructured coordinate for the second field
+       XName_1=Field_1.ListVarName{VarType_1.coord_x};
+       YName_1=Field_1.ListVarName{VarType_1.coord_y};
+       
+       XAttr=Field_1.VarAttribute{VarType_1.coord_x};
+       YAttr=Field_1.VarAttribute{VarType_1.coord_y};
+%        SubData.ListVarName=[SubData.ListVarName {XName_1} {YName_1}];
+       DimCell=Field_1.VarDimName([VarType_1.coord_x VarType_1.coord_y ]);
+    else
+       XName_1=Field_1.ListVarName{VarType_1.coord(2)};
+       YName_1=Field_1.ListVarName{VarType_1.coord(1)};
+       if numel(Field_1.VarAttribute)>=VarType_1.coord(2)
+           XAttr=Field_1.VarAttribute{VarType_1.coord(2)};
+       else
+           XAttr=[];
+       end
+       if numel(Field_1.VarAttribute)>=VarType_1.coord(1)
+           YAttr=Field_1.VarAttribute{VarType_1.coord(1)};
+       else
+           YAttr=[];
+       end     
+    end  
+    %check for the existence of the same  variable name
+    XName_1_1=XName_1; %default
+    YName_1_1=YName_1; %default
+    UName_1_1=UName_1; %default
+    VName_1_1=VName_1; %default
+    for iprev=1:numel(SubData.ListVarName)
+        switch SubData.ListVarName{iprev}
+            case XName_1
+                XName_1_1=[XName_1 '_1'];
+            case YName_1
+                YName_1_1=[YName_1 '_1'];
+            case UName_1
+                UName_1_1=[UName_1 '_1'];
+            case VName_1
+                VName_1_1=[VName_1 '_1']; 
+        end
+    end     
+    if ~testX_1
+          DimCell=[{XName_1_1} {YName_1_1}];
+    end
+    SubData.ListVarName=[SubData.ListVarName {XName_1_1} {YName_1_1} {UName_1_1} {VName_1_1}];
+    DimCell=[DimCell Field_1.VarDimName([VarType_1.vector_x VarType_1.vector_y ])];
+    SubData.VarDimName=[SubData.VarDimName DimCell];
+    if ~(isfield(SubData,'VarAttribute') && numel(SubData.VarAttribute)==numel(SubData.ListVarName))
+        for ivar=numel(SubData.VarAttribute)+1:numel(SubData.ListVarName)-4
+             SubData.VarAttribute{ivar}=[];
+        end
+    end
+    SubData.VarAttribute=[SubData.VarAttribute {XAttr} {YAttr} {UAttr} {VAttr}];
+    eval(['SubData.' XName_1_1 '=Field_1.' XName_1 ';'])
+    eval(['SubData.' YName_1_1 '=Field_1.' YName_1 ';'])
+    eval(['SubData.' UName_1_1 '=Field_1.' UName_1 ';'])
+    eval(['SubData.' VName_1_1 '=Field_1.' VName_1 ';'])  
+end
+
+  
Index: /trunk/src/private/update_menu.m
===================================================================
--- /trunk/src/private/update_menu.m	(revision 8)
+++ /trunk/src/private/update_menu.m	(revision 8)
@@ -0,0 +1,27 @@
+%'update_menu': find an input string in a menu, add it to the menu at the penultimate position if it does not exist
+%-----------------------------------------------
+% function menu_str=update_menu(handle,strinput)
+%
+% OUTPUT:
+% menu_str: new menu; cell of strings
+%
+% INPUT:
+% handle: handle of the menu to modify (listbox uicontrol)
+% strinput: char string to detect or add in the menu
+
+function menu_str=update_menu(handle,strinput)
+menu_str=get(handle,'String');
+nbmenu=length(menu_str);
+ichoice=0;%default
+for imenu=1:nbmenu
+    if isequal(menu_str{imenu},strinput)
+       ichoice=imenu;
+    end
+end
+if ichoice==0%the input string does not exist in the menu
+    menu_str{nbmenu+1}=menu_str{nbmenu};%shift  the last item ('more...')
+    menu_str{nbmenu}=strinput;
+    set(handle,'String',menu_str)
+    ichoice=nbmenu;
+end
+set(handle,'Value',ichoice)
Index: /trunk/src/private/update_obj.m
===================================================================
--- /trunk/src/private/update_obj.m	(revision 8)
+++ /trunk/src/private/update_obj.m	(revision 8)
@@ -0,0 +1,75 @@
+%'update_obj': update the object graph representation and its projection field, record it in the uvmat interface
+%-------------------------------------------------------------------
+%Object=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
+%
+%OUTPUT:
+%UvData: data to be stored as 'Userdata' on the uvmat interface
+%IndexObj: object index for a new object added to the list in UvData
+%   the function updates UvData.Object{IndexObj}, and possibly adds a new plot (UvData.Plane or Line) in the list atached to the interface
+%
+%INPUT:
+%UvIn: structure stored as 'Userdata' on the uvmat interface
+%IndexObjIn: object index for an existing objects stored in UvData
+%ObjectData: structure containing the input object properties
+%PlotHandles: structure containing the handles of the plotting parameter buttons on the uvmat interface (obtained by get_plot_handles.m)
+%-------------------------------------
+
+function Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles)
+
+%default input and output
+Object_out=ObjectData;%default
+if  isfield(UvData,'Object') 
+    Object_set=UvData.Object;
+else
+    Object_set={};%create the object
+end
+
+% object representation in the different projected field plots
+for iview=1:length(Object_set) %loop on projection planes iview
+      if isfield(Object_set{iview},'plotaxes')
+         haxes=Object_set{iview}.plotaxes;% axes for the field plot
+         if ishandle(haxes) & isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists
+             testupdate=0;
+             HandlesDisplay=[];%default
+             if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay')
+                 HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations
+             end
+             hplot_list=findobj(haxes,'Tag','proj_object');
+             for ih=1:length(HandlesDisplay)
+                 plot_detect=find(hplot_list==HandlesDisplay(ih));
+                 if ~isempty(plot_detect)
+                     Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iview},HandlesDisplay(ih),'m');%update the the object representation
+                     testupdate=1;
+                     break
+                 end
+             end
+             if ~testupdate% draw new object plot
+                hh=plot_object(ObjectData,Object_set{iview},haxes,'m');%draw the object with the new object data
+                Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh];
+                PlotData=get(hh,'UserData');
+                PlotData.IndexObj=IndexObj;
+                set(hh,'UserData',PlotData); %record the object index in the graph
+             end
+         end
+      end
+end
+
+% plot the field projected on the object
+if ~isempty(PlotHandles) %&& ~testmask
+    ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
+    if ~isempty(ProjData)   
+        plotaxes=[];%default
+        if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
+            plotaxes=Object_set{IndexObj}.plotaxes;
+        end
+        [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
+        Object_out.plotaxes=plotaxes;
+        plotfig=get(plotaxes,'parent');
+        name_str=get(plotfig,'Name');
+        if ~isequal(name_str,'uvmat')
+            set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' set_title(ObjectData.Style,ObjectData.ProjMode)]);
+        end
+    end
+end
+
+
Index: /trunk/src/private/update_waitbar.m
===================================================================
--- /trunk/src/private/update_waitbar.m	(revision 8)
+++ /trunk/src/private/update_waitbar.m	(revision 8)
@@ -0,0 +1,14 @@
+%'update_waitbar': update the waitbar display, used for ACTION functions in the GUI 'series'
+%------------------------------------------------------------------
+%INPUT:
+% hwaitbar:  handles of the waitbar to update
+% bar_size: vector with 4 elements, representing the abscissa, ordinate, width, height of the waitbar relative to the GUI  
+% advance_ratio: number between 0 and 1 representing the advancement of the calculation (loop index relative to the total length)
+
+function update_waitbar(hwaitbar,bar_size,advance_ratio)
+waitbarpos(1)=bar_size(1);
+waitbarpos(3)=bar_size(3);
+waitbarpos(4)=advance_ratio*bar_size(4);
+waitbarpos(2)=bar_size(4)+bar_size(2)-waitbarpos(4);
+set(hwaitbar,'Position',waitbarpos)
+drawnow
Index: /trunk/src/private/write_plot_param.m
===================================================================
--- /trunk/src/private/write_plot_param.m	(revision 8)
+++ /trunk/src/private/write_plot_param.m	(revision 8)
@@ -0,0 +1,109 @@
+%'write_plot_param': update the plotting parameters on the uvmat interface after a plotting operation
+function write_plot_param(handles,PlotParam)
+
+%scalar or image parameters
+if isfield(PlotParam,'Scalar')
+    set_scal_display(handles,'on')
+    if isfield(PlotParam.Scalar,'MaxA')
+        set(handles.MaxA,'String',num2str(PlotParam.Scalar.MaxA,3));
+    end
+    if isfield(PlotParam.Scalar,'MinA')
+        set(handles.MinA,'String',num2str(PlotParam.Scalar.MinA,3));
+    end
+
+    if isfield(PlotParam.Scalar,'IncrA')
+        set(handles.IncrA,'String',num2str(PlotParam.Scalar.IncrA,3))
+    end
+else
+    set_scal_display(handles,'off')
+end
+
+% parameter for vector field
+if isfield(PlotParam,'Vectors')
+    set_vect_display(handles,'on')
+    if isfield(PlotParam.Vectors,'VecScale')
+        set(handles.VecScale,'String',num2str(PlotParam.Vectors.VecScale,3))
+    end
+    if isfield(PlotParam.Vectors,'MinC')&& isfield(PlotParam.Vectors,'MaxC')
+        MinC=PlotParam.Vectors.MinC;
+        MaxC=PlotParam.Vectors.MaxC;
+        set(handles.min_vec,'String', num2str(MinC,3));
+        set(handles.max_vec,'String',num2str(MaxC,3));
+        list=get(handles.color_code,'String');
+        ichoice=get(handles.color_code,'Value');
+    	color_option=list{ichoice};
+        test3color=strcmp(color_option,'rgb')||strcmp(color_option,'bgr');
+        if test3color% need to update color thresholds
+            set(handles.colcode1,'Visible','on')
+            set(handles.colcode2,'Visible','on')
+            set(handles.slider1,'Visible','on')
+            set(handles.slider2,'Visible','on')
+%             slider1=get(handles.slider1,'Value');
+%             slider2=get(handles.slider2,'Value');
+             colcode1=MinC+(MaxC-MinC)*PlotParam.Vectors.colcode1;
+             colcode2=MinC+(MaxC-MinC)*PlotParam.Vectors.colcode2;
+            set(handles.colcode1,'String',num2str(colcode1,3))
+            set(handles.colcode2,'String',num2str(colcode2,3))
+            set(handles.slider1,'Value',PlotParam.Vectors.colcode1)
+            set(handles.slider2,'Value',PlotParam.Vectors.colcode2)
+        else
+            set(handles.colcode1,'Visible','off')
+            set(handles.colcode2,'Visible','off')
+            set(handles.slider1,'Visible','off')
+            set(handles.slider2,'Visible','off')
+        end
+    end
+else
+    set_vect_display(handles,'off')
+    set(handles.edit_vect,'Visible','off')
+end
+
+%------------------------------------------------------------------
+%prepare interface for scalar display: state ='on' or 'off'
+function set_scal_display(handles,state)
+%------------------------------------------------------------------
+set(handles.SCALAR_title,'Visible',state)
+set(handles.MaxA,'Visible',state)
+set(handles.MinA,'Visible',state)
+%set(handles.IncrA,'Visible',state)
+set(handles.AutoScal,'Visible',state)
+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)
+set(handles.frame_scal,'Visible',state)
+set(handles.npx,'Visible',state)
+set(handles.npy,'Visible',state)
+set(handles.npx_title,'Visible',state)
+set(handles.npy_title,'Visible',state)
+%set(handles.makemask,'Visible',state)
+
+%---------------------------------------------
+%prepare interface for vector display: state ='on' or 'off'
+function set_vect_display(handles,state)
+%------------------------------------------------------------------
+set(handles.frame_vect,'Visible',state)
+set(handles.VECT_title,'Visible',state)
+set(handles.VecScale,'Visible',state)
+set(handles.AutoVec,'Visible',state)
+set(handles.HideFalse,'Visible',state)
+set(handles.HideWarning,'Visible',state)
+set(handles.record,'Visible',state)
+set(handles.colcode1,'Visible',state)
+set(handles.colcode2,'Visible',state)
+set(handles.min_vec,'Visible',state)
+set(handles.max_vec,'Visible',state)
+set(handles.scale_title,'Visible',state)
+set(handles.slider1,'Visible',state)
+set(handles.slider2,'Visible',state)
+set(handles.col_vec,'Visible',state)
+set(handles.Color_title,'Visible',state)
+set(handles.color_code,'Visible',state)
+set(handles.vec_col_bar,'Visible',state)
+set(handles.record,'Visible',state)
+set(handles.AutoVecColor,'Visible',state)
+set(handles.decimate4,'Visible',state)
+set(handles.min_C_title,'Visible',state)
+set(handles.max_C_title,'Visible',state)
+set(handles.MenuEditVectors,'Enable',state)
Index: unk/src/probe_calib.m
===================================================================
--- /trunk/src/probe_calib.m	(revision 7)
+++ 	(revision )
@@ -1,877 +1,0 @@
-%'probe_calib': performs geometric calibration from a set of reference points
-function varargout = probe_calib(varargin)
-% PROBE_CALIB M-file for probe_calib.fig
-%      PROBE_CALIB, by itself, creates a MenuCoord PROBE_CALIB or raises the existing
-%      singleton*.
-%
-%      H = PROBE_CALIB returns the handle to a MenuCoord PROBE_CALIB or the handle to
-%      the existing singleton*.
-%
-%      PROBE_CALIB('CALLBACK',hObject,eventData,handles,...) calls the local
-%      function named CALLBACK in PROBE_CALIB.M with the given input arguments.
-%
-%      PROBE_CALIB('Property','Value',...) creates a MenuCoord PROBE_CALIB or raises the
-%      existing singleton*.  Starting from the left, property value pairs are
-%      applied to the GUI before probe_calib_OpeningFunction gets called.  An
-%      unrecognized property name or invalid value makes property application
-%      stop.  All inputs are passed to probe_calib_OpeningFcn via varargin.
-%
-%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
-%      instance to run (singleton)".
-%
-% See also: GUIDE, GUIDATA, GUIHANDLES
-
-% Edit the above text to modify the response to help probe_calib
-
-% Last Modified by GUIDE v2.5 04-Feb-2008 15:46:42
-
-% Begin initialization code - DO NOT EDIT
-gui_Singleton = 1;
-gui_State = struct('gui_Name',       mfilename, ...
-                   'gui_Singleton',  gui_Singleton, ...
-                   'gui_OpeningFcn', @probe_calib_OpeningFcn, ...
-                   'gui_OutputFcn',  @probe_calib_OutputFcn, ...
-                   'gui_LayoutFcn',  [] , ...
-                   'gui_Callback',   []);
-if nargin & isstr(varargin{1})
-    gui_State.gui_Callback = str2func(varargin{1});
-end
-
-if nargout
-    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
-else
-    gui_mainfcn(gui_State, varargin{:});
-end
-% End initialization code - DO NOT EDIT
-
-
-% --- Executes just before probe_calib is made visible.
-%INPUT: 
-%handles: handles of the probe_calib interface elements
-% PlotHandles: set of handles of the elements contolling the plotting
-% parameters on the uvmat interface (obtained by 'get_plot_handle.m')
-function probe_calib_OpeningFcn(hObject, eventdata, handles, data,pos,inputfile)
-
-% Choose default command line output for probe_calib
-handles.output = hObject;
-
-% Update handles structure
-guidata(hObject, handles);
-
-%default
-% set(hObject,'Unit','Normalized')% set the unit normalized to the screen size
-% set(hObject,'Position',[0.7 0.1 0.25 0.5])%set the position of the probe_calib interface 
-set(hObject,'DeleteFcn',@closefcn)
-
-%set the position of the interface
-if exist('pos','var')& length(pos)>2
-    pos_gui=get(hObject,'Position');
-    pos_gui(1)=pos(1);
-    pos_gui(2)=pos(2);
-    set(hObject,'Position',pos_gui);
-end
-% set(handles.XImage,'String','')
-% set(handles.YImage,'String','')
-% set(handles.XObject,'String','')
-% set(handles.YObject,'String','')
-% set(handles.ZObject,'String','')
-inputxml='';
-if exist('inputfile','var')& ~isempty(inputfile)
-    [Path,Name,ext]=fileparts(inputfile);
-    if isequal(ext,'.png')
-        set(hObject,'UserData',inputfile)
-        [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(inputfile);
-        inputxml=[fullfile(Pathsub,RootFile) '.xml'];
-    end   
-end
-if exist(inputxml,'file')
-    loadfile(handles,inputxml)
-end
-set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
-
-
-% --- Outputs from this function are returned to the command line.
-function varargout = probe_calib_OutputFcn(hObject, eventdata, handles)
-% varargout  cell array for returning output args (see VARARGOUT);
-% hObject    handle to figure
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Get default command line output from handles structure
-varargout{1} = handles.output;
-varargout{2}=handles;
-
-%------------
-function Phi_Callback(hObject, eventdata, handles)
-
-
-%-----------------------------------------------------
-% --- Executes on button press in import.
-function import_Callback(hObject, eventdata, handles)
-%get the object file 
-huvmat=findobj('Tag','uvmat');
-UvData=get(huvmat,'UserData');
-hchild=get(huvmat,'Children');
-hrootpath=findobj(hchild,'Tag','RootPath');
-oldfile=get(hrootpath,'String');
-if isempty(oldfile)
-    oldfile='';
-end
-%[FileName,PathName] = uigetfile('*.civ','Select a .civ file',oldfile)
-[FileName, PathName, filterindex] = uigetfile( ...
-       {'*.xml;*.mat', ' (*.xml,*.mat)';
-       '*.xml',  '.xml files '; ...
-        '*.mat',  '.mat matlab files '}, ...
-        'Pick a file',oldfile);
-fileinput=[PathName FileName];%complete file name 
-testblank=findstr(fileinput,' ');%look for blanks
-if ~isempty(testblank)
-    warndlg_uvmat('forbidden input file name or path: no blank character allowed','ERROR')
-    return
-end
-sizf=size(fileinput);
-if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
-loadfile(handles,fileinput)
-
-%--------------------------------------------------
-%read input xml file and update the edit boxes
-function loadfile(handles,fileinput)
-
-%read the input xml file
-t=xmltree(fileinput);
-s=convert(t);%convert to matlab structure
-
-%read data currently displayed on the interface
-PointCoord=[];
-data=read_probe_calib(handles);
-Coord=[]; %default
-if isfield(data,'Coord')
-    Coord=data.Coord;
-end
-TabChar_0=get(handles.ListCoord,'String');
-nbcoord_0=size(TabChar_0,1);
-if isequal(get(handles.edit_append,'Value'),1) %edit mode
-    val=get(handles.ListCoord,'Value')-1;
-else
-   val=length(TabChar_0); 
-end
-nbcoord=0;
-
-%case of calibration (ImaDoc) input file
-if isfield(s,'GeometryCalib')
-    Calib=s.GeometryCalib;
-    if isfield(Calib,'SourceCalib')
-        if isfield(Calib.SourceCalib,'PointCoord')
-            PointCoord=Calib.SourceCalib.PointCoord;
-        end
-        if isfield(Calib.SourceCalib,'ImageCalib')
-            hcalib=get(handles.import,'parent');
-            set(hcalib,'UserData',Calib.SourceCalib.ImageCalib);%store the source image name in the interface 'UserData'
-        end
-    end
-    nbcoord=length(PointCoord);
-    if ~isfield(Calib,'ErrorRms')&~isfield(Calib,'ErrorMax') %old convention of Gauthier (cord in mm)
-        for i=1:length(PointCoord)
-          line=str2num(PointCoord{i});
-          Coord(i+val,4:5)=line(4:5);%px x
-          Coord(i+val,1:3)=line(1:3)/10;%phys x
-        end
-    else
-        for i=1:length(PointCoord)
-          line=str2num(PointCoord{i});
-          Coord(i,4:5)=line(4:5);%px x
-          Coord(i,1:3)=line(1:3);%phys x
-       end
-    end
-end
-
-%case of xml files of points 
-if isfield(s,'Coord')
-    PointCoord=s.Coord;
-    nbcoord=length(PointCoord);
-     %case of image coordinates
-    if isfield(s,'CoordType')& isequal(s.CoordType,'px')
-        for i=1:nbcoord
-           line=str2num(PointCoord{i});
-           Coord(i+val,4:5)=line(1:2);
-        end
-     %case of  physical coordinates
-    else
-        for i=1:nbcoord
-           line=str2num(PointCoord{i})
-           Coord(i+val,1:3)=line(1:3);
-           nbcolumn=size(Coord,2);
-           if nbcolumn<5
-               Coord(i+val,nbcolumn+1:5)=zeros(1,5-nbcolumn);
-           end
-        end
-     end
-end
-CoordCell={};
-for iline=1:size(Coord,1)
-    for j=1:5
-        CoordCell{iline,j}=num2str(Coord(iline,j));
-    end
-end
-        
-Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
-set(handles.ListCoord,'Value',1)
-set(handles.ListCoord,'String',Tabchar)
-
-
-%----------------------------------------------------
-% executed when closing: set the parent interface button to value 0
-function closefcn(gcbo,eventdata)
-SetData=get(gcbf,'UserData');
-if isfield(SetData,'ParentButton') & ishandle(SetData.ParentButton)
-    set(SetData.ParentButton, 'Value',0)
-end
-
-%-----------------------------------------------------------------------
-% --- Executes on button press in edit: PLOT the defined object and its projected field
-function edit_Callback(hObject, eventdata, handles)
-%hsetobject=get(hObject,'parent');
-%SetData=get(hsetobject,'UserData');%get the hidden interface data
-%IndexObj=SetData.IndexObj;%index of the current projection object in the list of projection objects (UvData.ProjObject)
-huvmat=findobj(allchild(0),'name','uvmat');%find the current uvmat interface handle
-UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
-hplot=findobj(huvmat,'Tag','axes3');
-h_menu_coord=findobj(huvmat,'Tag','menu_coord');
-menu=get(h_menu_coord,'String');
-choice=get(h_menu_coord,'Value');
-if iscell(menu)
-    option=menu{choice};
-else
-    option='px'; %default
-end
-%get axis
-%get CoordType
-ObjectData=read_probe_calib(handles);%read the interface input parameters defining the object
-if isequal(option,'phys')
-    ObjectData.Coord=ObjectData.Coord(:,[1:3]);
-elseif isequal(option,'px')
-    ObjectData.Coord=ObjectData.Coord(:,[4:5]);
-else
-    errordlg('the choice in coord_coord must be px or phys ')
-end
-% [UvData,IndexObj]=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles);
-% SetData.IndexObj=IndexObj;
-% set(gcbf,'UserData',SetData)%update object index in the probe_calib interface
-% set(huvmat,'UserData',UvData)%update the data in the uvmat interface
-ObjectData.ProjMode='none';
-plot_object(ObjectData,[],hplot,'b');
-
-
-% --- Executes on button press in MenuCoord.
-function MenuCoord_Callback(hObject, eventdata, handles)
-
-
-% --- Executes on button press in delete.
-function delete_Callback(hObject, eventdata, handles)
-SetData=get(gcbf,'UserData');%get the interface data
-IndexObj=SetData.IndexObj;
-delete_object(IndexObj);
-
-% --- Executes on button press in calibrate_lin.
-function calib_offset_Callback(hObject, eventdata, handles)
-Object=read_probe_calib(handles);
-
-%make linear calibration
-% 'calibration_lin' provides a linear transform on coordinates, 
-X=Object.Coord(:,1);
-Y=Object.Coord(:,2);
-x_ima=Object.Coord(:,4);
-y_ima=Object.Coord(:,5);
-[px,sx]=polyfit(X,x_ima,1);
-[py,sy]=polyfit(Y,y_ima,1);
-%err_X1=max(abs(x1-x_ima));%error
-%err_Y1=max(abs(y1-y_ima));%error
-T_x=px(2);
-T_y=py(2);
-GeometryCalib.focal=1;
-GeometryCalib.Tx_Ty_Tz=[T_x T_y 1];
-GeometryCalib.R=[px(1),0,0;0,py(1),0;0,0,1];
-%check error
-Calib.dpx=1;
-Calib.dpy=1;
-Calib.sx=1;
-Calib.Cx=0;
-Calib.Cy=0;
-Calib.Tz=1;
-Calib.kappa1=0;
-Calib.f=GeometryCalib.focal;
-Calib.Tx=T_x;
-Calib.Ty=T_y;
-Calib.R=GeometryCalib.R;
-[Xpoints,Ypoints]=px_XYZ(Calib,X,Y,0);
-GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));
-GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima));
-GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
-GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima))
-%calibrate_lin calibration results and point coordinates
-huvmat=findobj('Tag','uvmat');
-hchild=get(huvmat,'Children');
-hrootpath=findobj(hchild,'Tag','RootPath');
-hrootfile=findobj(hchild,'Tag','RootFile');
-RootPath='';
-RootFile='';
-if ~isempty(hrootpath)& ~isempty(hrootfile)
-    testhandle=1;
-    RootPath=get(hrootpath,'String');
-    RootFile=get(hrootfile,'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
-testappend=0;
-if exist(outputfile,'file');%=1 if the output file already exists, 0 else  
-    t=xmltree(outputfile); %read the file
-    uid=find(t,'ImaDoc');
-    if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup)
-        backupfile=outputfile;
-        testexist=2;
-        while testexist==2
-            backupfile=[backupfile '~'];
-            testexist=exist(backupfile,'file');       
-        end
-        [success,message]=copyfile(outputfile,backupfile);%make backup
-        if isequal(success,1)
-            delete(outputfile)
-        else
-            return
-        end
-    else
-        uid_calib=find(t,'ImaDoc/GeometryCalib');
-        if ~isempty(uid) %if GeometryCalib already exists, delete its content
-            backupfile=outputfile;
-            testexist=2;
-            while testexist==2
-                backupfile=[backupfile '~'];
-                testexist=exist(backupfile,'file');      
-            end
-            [success,message]=copyfile(outputfile,backupfile)%make backup
-            if isequal(success,1)
-                delete(outputfile)
-            else
-                return
-            end
-            uid_child=children(t,uid_calib);
-            t=delete(t,uid_child);
-            testappend=1;
-        end
-    end
-end
-if ~testappend
-    t=xmltree;
-    t=set(t,1,'name','ImaDoc');
-    [t,uid_calib]=add(t,1,'element','GeometryCalib');
-%     t=struct2xml(GeometryCalib,t,uid_calib);
-end
-Object.Coord(:,[1:3])=Object.Coord(:,[1:3])*10; %transform in
-GeometryCalib.SourceCalib.PointCoord=Object.Coord;
-t=struct2xml(GeometryCalib,t,uid_calib); 
-save(t,outputfile)
-
-warndlg_uvmat([outputfile 'updated with linear calibration data'],'CONFIRMATION')
-
-%display image with new calibration in the currently opened uvmat interface
-Indices=get(findobj(hchild,'Tag','FileIndex'),'String');
-Ext=get(findobj(hchild,'Tag','FileExt'),'String');
-imagename=[fullfile(RootPath,RootFile) Indices Ext];
-% input.menu_coord=1;
-huvmat=uvmat(imagename,1);%open uvmat, set phys coord (Value 1)
-
-
-
-% --- Executes on button press in calibrate_lin.
-function calib_lin_Callback(hObject, eventdata, handles)
-Object=read_probe_calib(handles);
-
-%make linear calibration
-% 'calibration_lin' provides a linear transform on coordinates, 
-X=Object.Coord(:,1);
-Y=Object.Coord(:,2);
-x_ima=Object.Coord(:,4);
-y_ima=Object.Coord(:,5);
-XY_mat=[ones(size(X)) X Y];
-a_X1=XY_mat\x_ima; %transformation matrix for X
-x1=XY_mat*a_X1;%reconstruction
-err_X1=max(abs(x1-x_ima));%error
-a_Y1=XY_mat\y_ima;%transformation matrix for X
-y1=XY_mat*a_Y1;
-err_Y1=max(abs(y1-y_ima));%error
-T_x=a_X1(1);
-T_y=a_Y1(1);
-GeometryCalib.focal=1;
-GeometryCalib.Tx_Ty_Tz=[T_x T_y 1];
-GeometryCalib.R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,1];
-
-%check error
-GeometryCalib.ErrorRms(1)=sqrt(mean((x1-x_ima).*(x1-x_ima)));
-GeometryCalib.ErrorMax(1)=max(abs(x1-x_ima));
-GeometryCalib.ErrorRms(2)=sqrt(mean((y1-y_ima).*(y1-y_ima)));
-GeometryCalib.ErrorMax(2)=max(abs(y1-y_ima))
-
-%calibrate_lin calibration results and point coordinates
-huvmat=findobj('Tag','uvmat');
-hchild=get(huvmat,'Children');
-hrootpath=findobj(hchild,'Tag','RootPath');
-hrootfile=findobj(hchild,'Tag','RootFile');
-RootPath='';
-RootFile='';
-if ~isempty(hrootpath)& ~isempty(hrootfile)
-    testhandle=1;
-    RootPath=get(hrootpath,'String');
-    RootFile=get(hrootfile,'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
-testappend=0;
-if exist(outputfile,'file');%=1 if the output file already exists, 0 else  
-    t=xmltree(outputfile); %read the file
-    uid=find(t,'ImaDoc');
-    if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup)
-        backupfile=outputfile;
-        testexist=2;
-        while testexist==2
-            backupfile=[backupfile '~'];
-            testexist=exist(backupfile,'file');       
-        end
-        [success,message]=copyfile(outputfile,backupfile)%make backup
-        if isequal(success,1);
-            delete(outputfile)
-        else
-            return
-        end
-    else
-        uid_calib=find(t,'ImaDoc/GeometryCalib');
-        if ~isempty(uid) %if GeometryCalib already exists, delete its content
-            backupfile=outputfile;
-            testexist=2;
-            while testexist==2
-                backupfile=[backupfile '~'];
-                testexist=exist(backupfile,'file');      
-            end
-            [success,message]=copyfile(outputfile,backupfile)%make backup
-            if isequal(success,1)
-                delete(outputfile)
-            else
-                return
-            end
-            uid_child=children(t,uid_calib);
-            t=delete(t,uid_child);
-            testappend=1;
-        end
-    end
-end
-if ~testappend
-    t=xmltree;
-    t=set(t,1,'name','ImaDoc');
-    [t,uid_calib]=add(t,1,'element','GeometryCalib');
-%     t=struct2xml(GeometryCalib,t,uid_calib);
-end
-% Object.Coord(:,[1:3])=Object.Coord(:,[1:3]); %transform in
-GeometryCalib.SourceCalib.PointCoord=Object.Coord;
-t=struct2xml(GeometryCalib,t,uid_calib); 
-save(t,outputfile)
-
-warndlg_uvmat([outputfile 'updated with linear calibration data'],'CONFIRMATION')
-
-%display image with new calibration in the currently opened uvmat interface
-Indices=get(findobj(hchild,'Tag','FileIndex'),'String');
-Ext=get(findobj(hchild,'Tag','FileExt'),'String');
-imagename=[fullfile(RootPath,RootFile) Indices Ext];
-% input.menu_coord=1;
-if exist(imagename,'file')
-    huvmat=uvmat(imagename,1);%open uvmat, set phys coord (Value 1)
-else
-    huvmat=uvmat;
-end
-
-
-% --- Executes on button press in translation.
-function translation_Callback(hObject, eventdata, handles)
-
-
-function T_x_Callback(hObject, eventdata, handles)
-% hObject    handle to T_x (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of T_x as text
-%        str2double(get(hObject,'String')) returns contents of T_x as a double
-
-
-
-
-
-function T_y_Callback(hObject, eventdata, handles)
-% hObject    handle to T_y (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of T_y as text
-%        str2double(get(hObject,'String')) returns contents of T_y as a double
-
-
-function T_z_Callback(hObject, eventdata, handles)
-% hObject    handle to T_z (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of T_z as text
-%        str2double(get(hObject,'String')) returns contents of T_z as a double
-
-
-% --- Executes on button press in rotation.
-function rotation_Callback(hObject, eventdata, handles)
-angle_rot=(pi/180)*str2num(get(handles.Phi,'String'))
-data=read_probe_calib(handles)
-data.Coord(:,1)=cos(angle_rot)*data.Coord(:,1)+sin(angle_rot)*data.Coord(:,2);
-data.Coord(:,1)=-sin(angle_rot)*data.Coord(:,1)+cos(angle_rot)*data.Coord(:,2);
-set(handles.XObject,'String',num2str(data.Coord(:,1)));
-set(handles.YObject,'String',num2str(data.Coord(:,2)));
-
-
-function XImage_Callback(hObject, eventdata, handles)
-update_list(hObject, eventdata,handles)
-
-function YImage_Callback(hObject, eventdata, handles)
-update_list(hObject, eventdata,handles)
-
-function XObject_Callback(hObject, eventdata, handles)
-update_list(hObject, eventdata,handles)
-
-function YObject_Callback(hObject, eventdata, handles)
-update_list(hObject, eventdata,handles)
-
-function ZObject_Callback(hObject, eventdata, handles)
-update_list(hObject, eventdata,handles)
-
-function update_list(hObject, eventdata, handles)
-str4=get(handles.XImage,'String');
-str5=get(handles.YImage,'String');
-str1=get(handles.XObject,'String');
-tt=double(str1);
-str2=get(handles.YObject,'String');
-str3=get(handles.ZObject,'String');
-if ~isempty(str1) & ~isequal(double(str1),32) & (isempty(str3)|isequal(double(str3),32))
-    str3='0';%put z to 0 by default
-end
-strline=[str1 '    |    ' str2 '    |    ' str3 '    |    ' str4 '    |    ' str5];
-Coord=get(handles.ListCoord,'String');
-testappend=get(handles.edit_append,'Value');
-if isequal(testappend,1); %edit mode  
-    val=get(handles.ListCoord,'Value');
-    Coord{val}=strline;
-else
-    val=length(get(handles.ListCoord,'String'));
-    Coord{val+1}=strline;
-    set(handles.ListCoord,'Value',val+1)
-% if val+1<=length(Coord)
-%     set(handles.ListCoord,'Value',val+1)
-%     ListCoord_Callback(hObject, eventdata, handles)
-end
-set(handles.ListCoord,'String',Coord)
-%set(handles.ListCoord,'Value',val+1)
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function data=read_probe_calib(handles)
-data_XIma=[];
-data_YIma=[];
-data_XObject=[];
-data_YObject=[];
-data_ZObject=[];
-Coord=get(handles.ListCoord,'String');
-% XImage=get(handles.XImage,'String');
-% YImage=get(handles.YImage,'String');
-% XObject=get(handles.XObject,'String');
-% YObject=get(handles.YObject,'String');
-% ZObject=get(handles.ZObject,'String');
-% if ischar(Xcolumn)
-%     Xcolumn={Xcolumn};
-% end
-nb_defining_points=length(Coord);
-iline=0;
-for i=1:nb_defining_points
-    coord_str=Coord{i};%character string of line number i
-    k=findstr('|',coord_str);%find 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)
-        iline=iline+1;
-        if ~isempty(data1)
-            data.Coord(iline,1)=data1;
-        end    
-        if ~isempty(data2)
-            data.Coord(iline,2)=data2;
-        end
-        if ~isempty(data3)
-            data.Coord(iline,3)=data3;
-        end
-        if ~isempty(data4)
-            data.Coord(iline,4)=data4;
-        end
-        if isempty(data5)
-            data.Coord(iline,5)=0;
-        else
-            data.Coord(iline,5)=data5;
-        end
-    end
-end
-data.Style='points';
-
-
-% --- Executes on selection change in ListCoord.
-function ListCoord_Callback(hObject, eventdata, handles)
-% hObject    handle to ListCoord (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: contents = get(hObject,'String') returns ListCoord contents as cell array
-%        contents{get(hObject,'Value')} returns selected item from ListCoord
-set(handles.edit_append,'Value',1); %set to edit mode
-Coord=get(handles.ListCoord,'String');
-val=get(handles.ListCoord,'Value');
-if length(Coord)>0
-coord_str=Coord{val};
-k=findstr('|',coord_str);
-set(handles.XObject,'String',coord_str(1:k(1)-5))
-set(handles.YObject,'String',coord_str(k(1)+5:k(2)-5))
-set(handles.ZObject,'String',coord_str(k(2)+5:k(3)-5))
-set(handles.XImage,'String',coord_str(k(3)+5:k(4)-5))
-set(handles.YImage,'String',coord_str(k(4)+5:end))
-end
-
-%------------------------------------------------------
-% --- Executes on button press in translation_plus.
-function translation_plus_Callback(hObject, eventdata, handles)
-
-T=[0 0 0];
-T_x=get(handles.T_x,'String')
-T_y=get(handles.T_y,'String')
-T_z=get(handles.T_z,'String')
-if ~isempty(T_x)
-    T(1)=str2num(T_x);
-end
-if ~isempty(T_y)
-    T(2)=str2num(T_y);
-end
-if ~isempty(T_z)
-    T(3)=str2num(T_z);
-end
-translation(handles,T)
-
-
-
-% --- Executes on button press in translation_minus.
-function translation_minus_Callback(hObject, eventdata, handles)
-
-T=[0 0 0];
-T_x=get(handles.T_x,'String')
-T_y=get(handles.T_y,'String')
-T_z=get(handles.T_z,'String')
-if ~isempty(T_x)
-    T(1)=-str2num(T_x);
-end
-if ~isempty(T_y)
-    T(2)=-str2num(T_y);
-end
-if ~isempty(T_z)
-    T(3)=-str2num(T_z);
-end
-translation(handles,T)
-
-
-%%%--------------------------------------
-function translation(handles,T)
-data=read_probe_calib(handles);
-data.Coord(:,1)=T(1)+data.Coord(:,1);
-data.Coord(:,2)=T(2)+data.Coord(:,2);
-data.Coord(:,3)=T(3)+data.Coord(:,3);
-data.Coord(:,[4 5])=data.Coord(:,[4 5]);
-for i=1:size(data.Coord,1)
-    for j=1:5
-          Coord{i,j}=num2str(data.Coord(i,j));%phys x,y,z
-   end
-end
-Tabchar=cell2tab(Coord,'    |    ');
-set(handles.ListCoord,'String',Tabchar)
-
-%----------------------------------------------------
-% --- Executes on button press in rotation_plus.
-function rotation_plus_Callback(hObject, eventdata, handles)
-Phi=0;
-Phi=get(handles.Phi,'String')
-if ~isempty(Phi)
-    Phi=str2num(Phi);
-end
-rotation(handles,Phi)
-
-%-------------------------------------------------
-% --- Executes on button press in rotation_minus.
-function rotation_minus_Callback(hObject, eventdata, handles)
-Phi=0;
-Phi=get(handles.Phi,'String')
-if ~isempty(Phi)
-    Phi=-str2num(Phi);
-end
-rotation(handles,Phi)
-
-%-----------------------------------------------------
-%rotation
-function rotation(handles,Phi)
-O_x=str2num(get(handles.O_x,'String'));
-O_y=str2num(get(handles.O_y,'String'));
-if isempty(O_x)
-    O_x=0;%default
-end
-if isempty(O_y)
-    O_y=0;%default
-end
-data=read_probe_calib(handles);
-r1=cos(pi*Phi/180);
-r2=-sin(pi*Phi/180);
-r3=sin(pi*Phi/180);
-r4=cos(pi*Phi/180);
-data.Coord(:,1)=r1*data.Coord(:,1)+r2*data.Coord(:,2);
-data.Coord(:,2)=r3*data.Coord(:,1)+r4*data.Coord(:,2);
-% data.Coord(:,[4 5])=data.Coord(:,[4 5]);
-for i=1:size(data.Coord,1)
-    for j=1:5
-          Coord{i,j}=num2str(data.Coord(i,j));%phys x,y,z
-   end
-end
-Tabchar=cell2tab(Coord,'    |    ');
-set(handles.ListCoord,'String',Tabchar)
-
-function O_x_Callback(hObject, eventdata, handles)
-% hObject    handle to O_x (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of O_x as text
-%        str2double(get(hObject,'String')) returns contents of O_x as a double
-
-
-
-function O_y_Callback(hObject, eventdata, handles)
-% hObject    handle to O_y (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of O_y as text
-%        str2double(get(hObject,'String')) returns contents of O_y as a double
-
-
-function O_z_Callback(hObject, eventdata, handles)
-% hObject    handle to O_z (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of O_z as text
-%        str2double(get(hObject,'String')) returns contents of O_z as a double
-
-
-
-
-
-
-
-% --- Executes on selection change in edit_append.
-function edit_append_Callback(hObject, eventdata, handles)
-val=get(handles.edit_append,'Value');
-if isequal(val,2); %append mode
-    %appeler mouse
-end
-
-
-function NEW_Callback(hObject, eventdata, handles)
-%A METTRE SOUS UN BOUTON
-huvmat=findobj('name','uvmat');
-hchild=get(huvmat,'children');
-hcoord=findobj(hchild,'Tag','menu_coord')
-coordtype=get(hcoord,'Value')
-haxes=findobj(hchild,'Tag','axes3');
-AxeData=get(haxes,'UserData');
-if ~isequal(hcoord,2)
-    set(hcoord,'Value',2)
-    huvmat=uvmat(AxeData)
-    'relancer uvmat'
-end
-if ~isfield(AxeData,'ZoomAxes')
-    warndlg_uvmat('first draw a window around a grid marker','ERRROR')
-    return
-end 
-XLim=get(AxeData.ZoomAxes,'XLim');
-YLim=get(AxeData.ZoomAxes,'YLim');
-np=size(AxeData.A);
-ind_sub_x=round(XLim)
-ind_sub_y=np(1)-round(YLim)
-Mfiltre=AxeData.A([ind_sub_y(2):ind_sub_y(1)] ,ind_sub_x,:);
-Mfiltre_norm=double(Mfiltre);
-Mfiltre_norm=Mfiltre_norm/sum(sum(Mfiltre_norm));
-Mfiltre_norm=100*(Mfiltre_norm-mean(mean(Mfiltre_norm)));
-Atype=class(AxeData.A)
-Data.NbDim=2;
-Data.A=filter2(Mfiltre_norm,double(AxeData.A)); 
-Data.A=feval(Atype,Data.A);
-Data.AName='image';
-Data.AX=AxeData.AX;
-Data.AY=AxeData.AY;
-Data.CoordType='px';
-plot_field(Data)
- 
-
-% --- Executes on button press in HELP.
-function HELP_Callback(hObject, eventdata, handles)
-% hObject    handle to HELP (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-path_to_uvmat=which ('uvmat');% check the path of uvmat
-pathelp=fileparts(path_to_uvmat);
-helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
-if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
-else
-   web([helpfile '#probe_calib'])
-end
-
-%'move_key:' function activated when a key is pressed on the keyboard
-%-----------------------------------
-function key_press_fcn(hObject,eventdata,handles)
-hh=get(hObject,'parent')
-xx=double(get(hh,'CurrentCharacter')) %get the keyboard character
-
-if isequal(xx,8)%move arrow right
-   data=read_probe_calib(handles);
-    Coord=[]; %default
-    if isfield(data,'Coord')
-        Coord=data.Coord
-    end
-    val=get(handles.ListCoord,'Value');
-    Coord(val,:)=[];
-    CoordCell={};
-    for iline=1:size(Coord,1)
-        for j=1:5
-            CoordCell{iline,j}=num2str(Coord(iline,j));
-        end
-    end
-    Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
-    val=min(size(Coord,1),val);
-    set(handles.ListCoord,'Value',max(val,1))
-    set(handles.ListCoord,'String',Tabchar)  
-end
Index: unk/src/proj_field.m
===================================================================
--- /trunk/src/proj_field.m	(revision 7)
+++ 	(revision )
@@ -1,1617 +1,0 @@
-%'proj_field': projects the field on a projection object
-%--------------------------------------------------------------------------
-%  function [ProjData,errormsg]=proj_field(FieldData,ObjectData,IndexObj)
-%
-% OUTPUT:
-% ProjData structure containing the fields of the input field FieldData,
-% transmitted or projected on the object, plus the additional fields
-%    .UMax, .UMin, .VMax, .VMin: min and max of velocity components in a domain
-%    .UMean,VMean: mean of the velocity components in a domain
-%    .AMin, AMax: min and max of a scalar
-%    .AMean: mean of a scalar in a domain  
-%  .NbPix;
-%  .DimName=  names of the matrix dimensions (matlab cell)
-%  .DimValue= values of the matricx dimensions (matlab vector, same length as .DimName);
-%  .VarName= names of the variables [ProjData.VarName {'A','AMean','AMin','AMax'}];
-%  .VarDimNameIndex= dimensions of the variables, indicated by indices in the list .DimName;
-%
-%INPUT
-% ObjectData: structure characterizing the projection object
-%    .Style : style of projection object
-%    .ProjMode=type of projection ;
-%    .CoordType: 'px' or 'phys' type of coordinates defining the object position
-%    .Phi  angle of rotation (=0 by default)
-%    .ProjAngle=angle of projection;
-%    .DX,.DY,.DZ=increments along each coordinate
-%    .Coord(nbpoints,3): set of coordinates defining the object position;
-
-%FieldData: data of the field to be projected on the projection object, with optional fields
-%    .Txt: error message, transmitted to the projection
-%    .CoordType: 'px' or 'phys' type of coordinates of the field, must be the same as for the projection object, transmitted
-%    .Mesh: typical distance between data points (used for mouse action or display), transmitted
-%    .CoordUnit, .TimeUnit, .dt: transmitted
-% standardised description of fields, nc-formated Matlab structure with fields:
-%         .ListGlobalAttribute: cell listing the names of the global attributes
-%        .Att_1,Att_2... : values of the global attributes
-%            .ListDimName: cell listing the names of the array dimensions
-%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
-%            .ListVarName: cell listing the names of the variables
-%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
-%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
-%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
-% The variables are grouped in 'fields', made of a set of variables with common dimensions (using the function find_field_indices)
-% The variable attribute 'Role' is used to define the role for plotting:
-%       Role = 'scalar':  (default) represents a scalar field
-%            = 'coord':  represents a set of unstructured coordinates, whose
-%                     space dimension is given by the last array dimension (called 'nb_dim').
-%            = 'coord_x', 'coord_y',  'coord_z': represents a separate set of
-%                        unstructured coordinate x, y  or z
-%            = 'vector': represents a vector field whose number of components
-%                is given by the last dimension (called 'nb_dim')
-%            = 'vector_x', 'vector_y', 'vector_z'  :represents the x, y or z  component of a vector  
-%            = 'warnflag' : provides a warning flag about the quality of data in a 'Field', default=0, no warning
-%            = 'errorflag': provides an error flag marking false data,
-%                   default=0, no error. Different non zero values can represent different criteria of elimination.
-%
-% Default role of variables (by name)
-%  vector field:
-%    .X,.Y: position of the velocity vectors, projected on the object
-%    .U, .V, .W: velocity components, projected on the object
-%    .C, .CName: scalar associated to the vector
-%    .F : equivalent to 'warnflag'
-%    .FF: equivalent to 'errorflag'
-%  scalar field or image:
-%    .AName: name of a scalar (to be calculated from velocity fields after projection), transmitted 
-%    .A: scalar, projected on the object
-%    .AX, .AY: positions for the scalar
-%     case of a structured grid: A is a dim 2 matrix and .AX=[first last] (length 2 vector) represents the first and last abscissa of the grid
-%     case of an unstructured scalar: A is a vector, AX and AY the corresponding coordinates 
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function [ProjData,errormsg]=proj_field(FieldData,ObjectData,IndexObj)
-
-if isfield(ObjectData,'ProjMode') && (isequal(ObjectData.ProjMode,'none')||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'))
-    ProjData=[];
-    return
-end
-%introduce default field properties (reading old standards)
-if ~isfield(ObjectData,'Style')||~isfield(ObjectData,'Coord')||~isfield(ObjectData,'ProjMode')
-    ProjData=FieldData;
-    return
-end
-
-% OBSOLETE
-if isfield(ObjectData,'XMax') && ~isempty(ObjectData.XMax)
-    ObjectData.RangeX(1)=ObjectData.XMax;
-end
-if isfield(ObjectData,'XMin') && ~isempty(ObjectData.XMin)
-    ObjectData.RangeX(2)=ObjectData.XMin;
-end
-if isfield(ObjectData,'YMax') && ~isempty(ObjectData.YMax)
-    ObjectData.RangeY(1)=ObjectData.YMax;
-end
-if isfield(ObjectData,'YMin') && ~isempty(ObjectData.YMin)
-    ObjectData.RangeY(2)=ObjectData.YMin;
-end
-if isfield(ObjectData,'ZMax') && ~isempty(ObjectData.ZMax)
-    ObjectData.RangeZ(1)=ObjectData.ZMax;
-end
-if isfield(ObjectData,'ZMin') && ~isempty(ObjectData.ZMin)
-    ObjectData.RangeZ(2)=ObjectData.ZMin;
-end
-%%%%%%%%%%
-
-% FieldData=document_field(FieldData);%transform FieldData to the standard format
-% if ~isfield(FieldData,'VarAttribute')
-%     FieldData.VarAttribute={};
-% end
-
-if isequal(ObjectData.Style,'points')
-    [ProjData,errormsg]=proj_points(FieldData,ObjectData);
-elseif isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')
-     [ProjData,errormsg] = proj_line(FieldData,ObjectData);
-elseif isequal(ObjectData.Style,'polygon')|isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'ellipse')
-    if isequal(ObjectData.ProjMode,'inside')|isequal(ObjectData.ProjMode,'outside')
-        [ProjData,errormsg] = proj_patch(FieldData,ObjectData);
-    else
-        [ProjData,errormsg] = proj_line(FieldData,ObjectData);
-    end
-     %A FAIRE : GERER MASK
-elseif isequal(ObjectData.Style,'plane')
-%         if isfield(FieldData,'NbDim') & isequal(FieldData.NbDim,3)
-%             ProjData= proj_plane3D(FieldData,ObjectData);%
-%         else
-            [ProjData,errormsg] = proj_plane(FieldData,ObjectData);
-%         end
-end
-if exist('IndexObj','var')
-    ProjData.IndexObj=IndexObj;%transfer object index
-end
-
-%-----------------------------------------------------------------
-%project on a set of points
-function  [ProjData,errormsg]=proj_points(FieldData,ObjectData)%%
-%-------------------------------------------------------------------
-
-siz=size(ObjectData.Coord);
-width=0;
-if isfield(ObjectData,'Range')
-    width=ObjectData.Range(1,2);
-end
-if isfield(ObjectData,'RangeX')&~isempty(ObjectData.RangeX)
-    width=max(ObjectData.RangeX);
-end
-if isfield(ObjectData,'RangeY')&~isempty(ObjectData.RangeY)
-    width=max(width,max(ObjectData.RangeY));
-end
-if isfield(ObjectData,'RangeZ')&~isempty(ObjectData.RangeZ)
-    width=max(width,max(ObjectData.RangeZ));
-end
-if isequal(ObjectData.ProjMode,'projection') 
-    if width==0
-        errormsg='projection range around points needed';
-        return
-    end
-elseif  ~isequal(ObjectData.ProjMode,'interp')
-    errormsg=(['ProjMode option ' ObjectData.ProjMode ' not available in proj_field']);
-        return
-end
-ProjData=proj_heading(FieldData,ObjectData);
-ProjData.NbDim=0;
-%ProjData.ListDimName= {'nb_points'};
-%ProjData.DimValue=siz(1);  %nbre of projection points  
-
-
-% idimvar=0;
-[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
-if ~isempty(errormsg)
-    errormsg=['error in proj_field/proj_points:' errormsg];
-    return
-end
-%LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
-% CellVarIndex=cells of variable index arrays
-% ivar_new=0; % index of the current variable in the projected field
-% icoord=0;
-for icell=1:length(CellVarIndex)
-    if NbDim(icell)==1
-        continue
-    end
-    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
-    VarType=VarTypeCell{icell};
-    ivar_X=VarType.coord_x;
-    ivar_Y=VarType.coord_y;
-    ivar_Z=VarType.coord_z;
-%     ivar_U=VarType.vector_x;
-%     ivar_V=VarType.vector_y;
-%     ivar_W=VarType.vector_z;
-%     ivar_C=VarType.scalar ;
-    ivar_Anc=VarType.ancillary;
-%     test_anc=zeros(size(VarIndex));
-    test_anc(ivar_Anc)=ones(size(ivar_Anc));
-    ivar_F=VarType.warnflag;
-    ivar_FF=VarType.errorflag;
-    VarIndex([ivar_X ivar_Y ivar_Z ivar_Anc ivar_F ivar_FF])=[];% not projected variables removed frlom list
-    if isempty(ivar_X)
-        test_grid=1;%test for input data on regular grid (e.g. image)coordinates
-      
-    else
-        if length(ivar_X)>1 | length(ivar_Y)>1 | length(ivar_Z)>1
-                 errormsg='multiple coordinate input in proj_field.m';
-                    return
-        end
-        if length(ivar_Y)~=1
-                errormsg='y coordinate not defined in proj_field.m';
-                return
-        end
-        test_grid=0;
-    end
-    ProjData.ListVarName={'Y','X','NbVal'};
-    ProjData.VarDimName={'nb_points','nb_points','nb_points'};
-    %ProjData.VarDimIndex={[1],[1],[1]}; 
-    ProjData.VarAttribute{1}.Role='ancillary';
-    ProjData.VarAttribute{2}.Role='ancillary';
-    ProjData.VarAttribute{3}.Role='ancillary';
-    for ivar=VarIndex        
-        VarName=FieldData.ListVarName{ivar};
-        ProjData.ListVarName=[ProjData.ListVarName {VarName}];
-        %ProjData.VarDimIndex=[ProjData.VarDimIndex {[1]}];
-        ProjData.VarDimName=[ProjData.VarDimName {'nb_points'}];
-    end
-    if ~test_grid
-        eval(['coord_x=FieldData.' FieldData.ListVarName{ivar_X} ';'])
-        eval(['coord_y=FieldData.' FieldData.ListVarName{ivar_Y} ';'])
-        test3D=0;% TEST 3D CASE : NOT COMPLETED ,  3D CASE : NOT COMPLETED 
-        if length(ivar_Z)==1
-            eval(['coord_z=FieldData.' FieldData.ListVarName{ivar_Z} ';'])
-            test3D=1;
-        end
-%         if length(ivar_U)>1 | length(ivar_V)>1 | length(ivar_W)>1
-%                  warndlg_uvmat('multiple vector input in proj_field.m','ERROR')
-%                     return
-%         end
-        if length(ivar_F)>1 | length(ivar_FF)>1 
-                 warndlg_uvmat('multiple flag input in proj_field.m','ERROR')
-                    return
-        end
-       
-        for ipoint=1:siz(1)
-           Xpoint=ObjectData.Coord(ipoint,:);
-           distX=coord_x-Xpoint(1);
-           distY=coord_y-Xpoint(2);          
-           dist=distX.*distX+distY.*distY;
-           indsel=find(dist<width*width);
-           ProjData.X(ipoint,1)=Xpoint(1);
-           ProjData.Y(ipoint,1)=Xpoint(2);
-           if isequal(length(ivar_FF),1)
-               FFName=FieldData.ListVarName{ivar_FF};
-               eval(['FF=FieldData.' FFName '(indsel);'])
-               ind_indsel=find(~FF);
-               indsel=indsel(ind_indsel);
-           end
-           ProjData.NbVal(ipoint,1)=length(indsel);
-            for ivar=VarIndex 
-               VarName=FieldData.ListVarName{ivar};
-               if isempty(indsel)
-                    eval(['ProjData.' VarName '(ipoint,1)=NaN;'])
-               else
-                    eval(['Var=FieldData.' VarName '(indsel);'])
-                    eval(['ProjData.' VarName '(ipoint,1)=mean(Var);'])
-                    if isequal(ObjectData.ProjMode,'interp')
-                         eval(['ProjData.' VarName '(ipoint,1)=griddata_uvmat(coord_x(indsel),coord_y(indsel),Var,Xpoint(1),Xpoint(2)))';])
-                    end
-               end
-            end
-        end
-    else 
-        %DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
-        %case of structured coordinates
-        if  numel(VarType.coord)>=2 & VarType.coord(1:2) > 0;
-            AYName=FieldData.ListVarName{VarType.coord(1)};
-            AXName=FieldData.ListVarName{VarType.coord(2)};
-            eval(['AX=FieldData.' AXName ';']);% set of x positions
-            eval(['AY=FieldData.' AYName ';']);% set of y positions  
-            AName=FieldData.ListVarName{VarIndex(1)};
-            eval(['A=FieldData.' AName ';']);% scalar
-            npxy=size(A);
-
-% %             nbcolor=1; %default
-%             for idim=1:length(ListDimName)
-%                 DimName=ListDimName{idim};
-%                 if isequal(DimName,'rgb')|isequal(DimName,'nb_coord')|isequal(DimName,'nb_coord_i')
-%                    nbcolor=npxy(idim);
-%                    DimIndices(idim)=[];
-%                    npxy(idim)=[];
-%                 end
-%                 if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED
-%                     DimIndices(idim)=[];
-%                     npxy(idim)=[];
-%                 end
-%             end  
-            ind_1=find(npxy==1);
-            %DimIndices(ind_1)=[]; %suppress singleton dimensions 
-%             indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero)
-            %nb_dim=length(DimIndices)%number of space dimensions
-            nb_dim=numel(VarType.coord);
-            Coord_z=[];
-            Coord_y=[];
-            Coord_x=[];   
-            for idim=1:nb_dim %loop on space dimensions
-                test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
-                test_coord(idim)=0;%test for defined coordinates, =0 by default
-                %ivar=DimVarIndex(DimIndices(idim));% index of the variable corresponding to the current dimension
-                ivar=VarType.coord(idim);
-%                 if ~isequal(ivar,0)%  a variable corresponds to the current dimension
-                    eval(['Coord{idim}=FieldData.' FieldData.ListVarName{ivar} ';']) ;% position for the first index
-                    if numel(Coord{idim})==2
-                       DCoord_min(idim)= (Coord{idim}(2)-Coord{idim}(1))/(npxy(idim)-1);
-                    else
-                        DCoord=diff(Coord{idim});
-                        DCoord_min(idim)=min(DCoord);
-                        DCoord_max=max(DCoord);
-                        test_direct(idim)=DCoord_max>0;% =1 for increasing values, 0 otherwise
-                        test_direct_min=DCoord_min(idim)>0;% =1 for increasing values, 0 otherwise
-                        if ~isequal(test_direct(idim),test_direct_min)
-                            errormsg=['non monotonic dimension variable # ' num2str(idim)  ' in proj_field.m'];
-                                    return
-                        end               
-                        test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity
-                        test_coord(idim)=1;
-                    end
-%                 else  % no variable associated with the first dimension, look fo variable  attributes Coord_1, _2 or _3
-%                     Coord_i_str=['Coord_' num2str(idim)];
-%                     DCoord_min(idim)=1;%default
-%                     Coord{idim}=[0.5 npxy(idim)];
-%                     test_direct(idim)=1;
-%                 end
-            end
-            DX=DCoord_min(2);
-            DY=DCoord_min(1);
-            for ipoint=1:siz(1)
-                xwidth=width/(abs(DX));
-                ywidth=width/(abs(DY));
-                i_min=round((ObjectData.Coord(ipoint,1)-Coord{2}(1))/DX+0.5-xwidth); %minimum index of the selected region
-                i_min=max(1,i_min);%restrict to field limit
-                i_plus=round((ObjectData.Coord(ipoint,1)-Coord{2}(1))/DX+0.5+xwidth);
-                i_plus=min(npxy(2),i_plus); %restrict to field limit
-                j_min=round((ObjectData.Coord(ipoint,2)-Coord{1}(1))/DY-ywidth+0.5);
-                j_min=max(1,j_min);
-                j_plus=round((ObjectData.Coord(ipoint,2)-Coord{1}(1))/DY+ywidth+0.5);
-                j_plus=min(npxy(1),j_plus);
-                ProjData.X(ipoint,1)=ObjectData.Coord(ipoint,1);
-                ProjData.Y(ipoint,1)=ObjectData.Coord(ipoint,2);
-                i_int=[i_min:i_plus];
-                j_int=[j_min:j_plus];
-                ProjData.NbVal(ipoint,1)=length(j_int)*length(i_int);
-                if isempty(i_int) | isempty(j_int)
-                   for ivar=VarIndex   
-                        eval(['ProjData.' FieldData.ListVarName{ivar} '(ipoint,:)=NaN;']);
-                   end
-                   errormsg=['no data points in the selected projection range ' num2str(width) ];
-                else
-                    %TODO: introduce circle in the selected subregion
-                    %[I,J]=meshgrid([1:j_int],[1:i_int]);
-                    for ivar=VarIndex   
-                        eval(['Avalue=FieldData.' FieldData.ListVarName{ivar} '(j_int,i_int,:);']);
-                        eval(['ProjData.' FieldData.ListVarName{ivar} '(ipoint,:)=mean(mean(Avalue));']);
-                    end
-                end
-            end
-        end
-   end
-end
-
-%-----------------------------------------------------------------
-%project in a patch
-function  [ProjData,errormsg]=proj_patch(FieldData,ObjectData)%%
-%-------------------------------------------------------------------
-ProjData=proj_heading(FieldData,ObjectData);
-
-objectfield=fieldnames(ObjectData);
-widthx=0;
-widthy=0;
-if isfield(ObjectData,'RangeX')&~isempty(ObjectData.RangeX)
-    widthx=max(ObjectData.RangeX);
-end
-if isfield(ObjectData,'RangeY')&~isempty(ObjectData.RangeY)
-    widthy=max(ObjectData.RangeY);
-end
-
-%A REVOIR, GENERALISER: UTILISER proj_line
-ProjData.NbDim=1;
-ProjData.ListDimName={};%name of dimension 
-ProjData.DimValue=[];%values of dimension (nbre of vectors)
-ProjData.ListVarName={};
-%ProjData.VarDimIndex={};
-ProjData.VarDimName={};
-if isfield (FieldData,'ListVarAttribute')
-    ProjData.ListVarAttribute=FieldData.ListVarAttribute;%list of variable attribute names
-    for iattr=1:length(ProjData.ListVarAttribute)%initialization of variable attribute values
-        AttrName=ProjData.ListVarAttribute{iattr};
-        eval(['ProjData.' AttrName '={};'])
-    end;
-end
-
-%group the variables (fields of 'FieldData') in cells of variables with the same dimensions
-testfalse=0;
-ListIndex={};
-% DimVarIndex=0;%initilise list of indices for dimension variables
-idimvar=0;
-[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
-if ~isempty(errormsg)
-    errormsg=['error in proj_field/proj_patch:' errormsg];
-    return
-end
-
-%LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
-dimcounter=0;
-for icell=1:length(CellVarIndex)
-    testX=0;
-    testY=0;
-    test_Amat=0;
-    testfalse=0;
-    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
-    VarType=VarTypeCell{icell};
-  %  DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
-    if NbDim(icell)~=2% proj_patch acts only on fields of space dimension 2
-        continue
-    end
-    testX=~isempty(VarType.coord_x) && ~isempty(VarType.coord_y);
-    testfalse=~isempty(VarType.errorflag);
-    testproj(VarIndex)=zeros(size(VarIndex));%default
-    testproj(VarType.scalar)=1;
-    testproj(VarType.vector_x)=1;
-    testproj(VarType.vector_y)=1;
-    testproj(VarType.vector_z)=1;
-    testproj(VarType.image)=1;
-    testproj(VarType.color)=1;
-    VarIndex=VarIndex(find(testproj(VarIndex)));%select only the projected variables
-    if testX %case of unstructured coordinates
-         eval(['nbpoint=numel(FieldData.' FieldData.ListVarName{VarIndex(1)} ');'])
-         for ivar=[VarIndex VarType.coord_x VarType.coord_y VarType.errorflag]
-               VarName=FieldData.ListVarName{ivar};
-            eval(['FieldData.' VarName '=reshape(FieldData.' VarName ',nbpoint,1);'])
-         end
-         XName=FieldData.ListVarName{VarType.coord_x};
-         YName=FieldData.ListVarName{VarType.coord_y};
-         eval(['coord_x=FieldData.' XName ';'])
-         eval(['coord_y=FieldData.' YName ';'])
-    end
-    if testfalse
-        FFName=FieldData.ListVarName{VarType.errorflag};
-        eval(['errorflag=FieldData.' FFName ';'])
-    end
-    % image or 2D matrix
-    if numel(VarType.coord)>=2 & VarType.coord(1:2) > 0;
-        test_Amat=1;%image or 2D matrix
-        AYName=FieldData.ListVarName{VarType.coord(1)};
-        AXName=FieldData.ListVarName{VarType.coord(2)};
-        eval(['AX=FieldData.' AXName ';'])% x coordinate
-        eval(['AY=FieldData.' AYName ';'])% y coordinate
-        VarName=FieldData.ListVarName{VarIndex(1)};
-        eval(['DimValue=size(FieldData.' VarName ');'])
-        testcolor=find(numel(DimValue)==3);
-%                     errormsg='multicomponent field not projected';
-
-        for idim=1:length(DimValue)        
-            Coord_i_str=['Coord_' num2str(idim)];
-            DCoord_min(idim)=1;%default
-            Coord{idim}=[0.5 DimValue(idim)];
-            test_direct(idim)=1;
-%             if isfield(FieldData,'VarAttribute')
-%                 for ivar=VarIndex
-%                     if length(FieldData.VarAttribute)>=ivar & isfield(FieldData.VarAttribute{ivar},Coord_i_str)% if there is a variable  attribute named Coord_1, _2 or _3
-%                         eval(['Coord_i=FieldData.VarAttribute{ivar}.' Coord_i_str ';']);%'range x 
-%                         if isnumeric(Coord_i)
-%                              if length(Coord_i)>=2
-%                                 Coord{idim}=[Coord_i(1) Coord_i(end)];
-%                                 %test_direct(idim)=(Coord{idim}(2)>Coord{idim}(1));
-%                              else 
-%                                 warndlg_uvmat(['two values needed for ' Coord_i_str 'in proj_field.m'],'ERROR')
-%                                 return
-%                              end
-%                          else
-%                             warndlg_uvmat(['non numerical coordinate attributes' Coord_i_str 'in proj_field.m'],'ERROR')
-%                             return
-%                          end
-%                          %test_coord(idim)=1;
-%                          DCoord_min(idim)=(Coord{idim}(end)-Coord{idim}(1))/(DimValue(idim)-1);
-%                     end
-%                 end
-%             end
-        end
-        AX=linspace(Coord{2}(1),Coord{2}(2),DimValue(2));
-        AY=linspace(Coord{1}(1),Coord{1}(2),DimValue(1));  %TODO : 3D case 
-        if length(DimValue)==3
-            testcolor=1;
-            npxy(3)=3;
-        else
-            testcolor=0;
-            npxy(3)=1;
-        end
-        [Xi,Yi]=meshgrid(AX,AY);
-        npxy(1)=length(AY);
-        npxy(2)=length(AX);
-        Xi=reshape(Xi,npxy(1)*npxy(2),1);
-        Yi=reshape(Yi,npxy(1)*npxy(2),1);
-        for ivar=1:length(VarIndex)
-            VarName=FieldData.ListVarName{VarIndex(ivar)};
-            eval(['FieldData.' VarName '=reshape(FieldData.' VarName ',npxy(1)*npxy(2),npxy(3));']); % keep only non false vectors 
-        end
-    end
-%select the indices in the range of action
-    testin=[];%default
-    if isequal(ObjectData.Style,'rectangle')
-%            if ~isfield(ObjectData,'RangeX')|~isfield(ObjectData,'RangeY')
-%                 errormsg='rectangle half sides RangeX and RangeY needed'
-%                 return
-%            end
-       if testX
-            distX=abs(coord_x-ObjectData.Coord(1,1));
-            distY=abs(coord_y-ObjectData.Coord(1,2));
-            testin=distX<widthx & distY<widthy;
-       elseif test_Amat
-           distX=abs(Xi-ObjectData.Coord(1,1));
-           distY=abs(Yi-ObjectData.Coord(1,2));
-           testin=distX<widthx & distY<widthy;
-       end
-    elseif isequal(ObjectData.Style,'polygon')
-        if testX
-            testin=inpolygon(coord_x,coord_y,ObjectData.Coord(:,1),ObjectData.Coord(:,2));
-        elseif test_Amat
-           testin=inpolygon(Xi,Yi,ObjectData.Coord(:,1),ObjectData.Coord(:,2));
-       else%calculate the scalar
-           testin=[]; %A REVOIR
-       end
-    elseif isequal(ObjectData.Style,'ellipse')
-       X2Max=widthx*widthx;
-       Y2Max=(widthy)*(widthy);
-       if testX
-            distX=(coord_x-ObjectData.Coord(1,1));
-            distY=(coord_y-ObjectData.Coord(1,2));
-            testin=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;
-       elseif test_Amat %case of usual 2x2 matrix
-           distX=(Xi-ObjectData.Coord(1,1));
-           distY=(Yi-ObjectData.Coord(1,2));
-           testin=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;
-       end
-    end
-    %selected indices
-    if isequal(ObjectData.ProjMode,'outside')
-            testin=~testin;
-    end
-    if testfalse
-        testin=testin & (errorflag==0); % keep only non false vectors         
-    end
-    indsel=find(testin);
-    for ivar=VarIndex
-        if testproj(ivar)
-            VarName=FieldData.ListVarName{ivar};
-            eval(['ProjData.' VarName 'Mean=mean(mean(double(FieldData.' VarName '(indsel,:))));']); % keep only non false vectors
-            eval(['[ProjData.' VarName 'Histo,ProjData.' VarName ']=hist(double(FieldData.' VarName '(indsel,:)),100);']); % keep only non false vectors 
-            ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']}];
-            if test_Amat && testcolor
-                 ProjData.VarDimName=[ProjData.VarDimName  {VarName} {{VarName,'rgb'}} {'rgb'}];%{{'nb_point','rgb'}};
-            else
-               ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'nbpoint'}];
-            end
-        end
-    end 
-%     if test_Amat & testcolor
-%        %ProjData.ListDimName=[ProjData.ListDimName {'rgb'}];
-%       % ProjData.DimValue=[ProjData.DimValue 3];
-%       % ProjData.VarDimIndex={[1 2]};
-%        ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName,'rgb'}];%{{'nb_point','rgb'}};
-%        ProjData.VarDimName
-%     end
-end
-
-
-
-%-----------------------------------------------------------------
-%project on a line
-% AJOUTER flux,circul,error
-function  [ProjData,errormsg] = proj_line(FieldData, ObjectData)
-%-----------------------------------------------------------------
-ProjData=proj_heading(FieldData,ObjectData);%transfer global attributes
-ProjData.NbDim=1;
-
-%initialisation of the input parameters and defaultoutput
-ProjMode='projection';%direct projection on the line by default
-if isfield(ObjectData,'ProjMode'),ProjMode=ObjectData.ProjMode; end; 
-ProjAngle=90; %90 degrees projection by default
-if isfield(FieldData,'ProjAngle'),ProjAngle=ObjectData.ProjAngle; end; 
-width=0;%default width of the projection band
-if isfield(ObjectData,'Range')&size(ObjectData.Range,2)>=2
-    width=abs(ObjectData.Range(1,2));
-end
-if isfield(ObjectData,'RangeY')
-    width=max(ObjectData.RangeY);
-end
-
-% default output
-errormsg=[];%default
-Xline=[];
-flux=0;
-circul=0;
-liny=ObjectData.Coord(:,2);
-siz_line=size(ObjectData.Coord);
-if siz_line(1)<2
-    return% line needs at least 2 points to be defined
-end
-testfalse=0;
-ListIndex={};
-
-%angles of the polyline and boundaries of action
-dlinx=diff(ObjectData.Coord(:,1));
-dliny=diff(ObjectData.Coord(:,2));
-theta=angle(dlinx+i*dliny);%angle of each segment
-theta(siz_line(1))=theta(siz_line(1)-1);
-% determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'filter')
-if isequal(ProjMode,'projection') || isequal(ProjMode,'filter')
-    xsup(1)=ObjectData.Coord(1,1)-width*sin(theta(1));
-    xinf(1)=ObjectData.Coord(1,1)+width*sin(theta(1));
-    ysup(1)=ObjectData.Coord(1,2)+width*cos(theta(1));
-    yinf(1)=ObjectData.Coord(1,2)-width*cos(theta(1));
-    for ip=2:siz_line(1)
-        xsup(ip)=ObjectData.Coord(ip,1)-width*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
-        xinf(ip)=ObjectData.Coord(ip,1)+width*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
-        ysup(ip)=ObjectData.Coord(ip,2)+width*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
-        yinf(ip)=ObjectData.Coord(ip,2)-width*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
-    end
-end
-
-%group the variables (fields of 'FieldData') in cells of variables with the same dimensions
-[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
-if ~isempty(errormsg)
-    errormsg=['error in proj_field/proj_line:' errormsg];
-    return
-end
-
-% loop on variable cells with the same space dimension
-ProjData.ListVarName={};
-ProjData.VarDimName={};
-for icell=1:length(CellVarIndex)
-    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
-    VarType=VarTypeCell{icell}; %types of variables
-    if NbDim(icell)~=2% proj_line acts only on fields of space dimension 2, TODO: check 3D case
-        continue
-    end
-    testX=~isempty(VarType.coord_x) && ~isempty(VarType.coord_y);% test for unstructured coordinates
-    testU=~isempty(VarType.vector_x) && ~isempty(VarType.vector_y);% test for vectors
-    testfalse=~isempty(VarType.errorflag);% test for error flag
-    testproj(VarIndex)=zeros(size(VarIndex));% test =1 for simply projected variables, default =0
-                                             %=0 for vector components, treated separately
-    testproj(VarType.scalar)=1;
-    testproj(VarType.image)=1;
-    testproj(VarType.color)=1;
-    VarIndex=VarIndex(find(testproj(VarIndex)));%select only the projected variables
-    if testU
-         VarIndex=[VarIndex VarType.vector_x VarType.vector_y];%append u and v at the end of the list of variables
-    end
-    %identify vector components   
-    if testU
-        UName=FieldData.ListVarName{VarType.vector_x};
-        VName=FieldData.ListVarName{VarType.vector_y};
-        eval(['vector_x=FieldData.' UName ';'])
-        eval(['vector_y=FieldData.' VName ';'])
-    end  
-    %identify error flag
-    if testfalse
-        FFName=FieldData.ListVarName{VarType.errorflag};
-        eval(['errorflag=FieldData.' FFName ';'])
-    end   
-    % check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y
-    if testX
-        if  ~isequal(ProjMode,'interp')
-            if width==0
-                errormsg='range of the projection object is missing';
-                return      
-            else
-                lambda=2/(width*width); %smoothing factor used for filter: weight exp(-2) at distance width from the line
-            end
-        end
-        if ~isequal(ProjMode,'projection')
-            if isfield(ObjectData,'DX')&~isempty(ObjectData.DX)
-                DX=abs(ObjectData.DX);%mesh of interpolation points along the line
-            else
-                errormsg='DX missing';
-                return
-            end
-        end
-        XName= FieldData.ListVarName{VarType.coord_x};
-        YName= FieldData.ListVarName{VarType.coord_y};
-        eval(['coord_x=FieldData.' XName ';'])    
-        eval(['coord_y=FieldData.' YName ';'])
-    end   
-    %initiate projection
-    for ivar=1:length(VarIndex)
-        ProjLine{ivar}=[];
-    end
-    XLine=[];
-    linelengthtot=0;
-
-%         circul=0;
-%         flux=0;
-  %%%%%%%  % A FAIRE CALCULER MEAN DES QUANTITES    %%%%%%
-   %case of unstructured coordinates
-    if testX   
-        for ip=1:siz_line(1)-1     %Loop on the segments of the polyline
-            linelength=sqrt(dlinx(ip)*dlinx(ip)+dliny(ip)*dliny(ip));  
-            %select the vector indices in the range of action
-            if testfalse
-                flagsel=(errorflag==0); % keep only non false vectors
-            else
-                flagsel=ones(size(coord_x));
-            end
-            if isequal(ProjMode,'projection') | isequal(ProjMode,'filter')
-                flagsel=flagsel & ((coord_y -yinf(ip))*(xinf(ip+1)-xinf(ip))>(coord_x-xinf(ip))*(yinf(ip+1)-yinf(ip))) ...
-                & ((coord_y -ysup(ip))*(xsup(ip+1)-xsup(ip))<(coord_x-xsup(ip))*(ysup(ip+1)-ysup(ip))) ...
-                & ((coord_y -yinf(ip+1))*(xsup(ip+1)-xinf(ip+1))>(coord_x-xinf(ip+1))*(ysup(ip+1)-yinf(ip+1))) ...
-                & ((coord_y -yinf(ip))*(xsup(ip)-xinf(ip))<(coord_x-xinf(ip))*(ysup(ip)-yinf(ip)));
-            end
-            indsel=find(flagsel);%indsel =indices of good vectors 
-            X_sel=coord_x(indsel);
-            Y_sel=coord_y(indsel);
-            nbvar=0;
-            for iselect=1:numel(VarIndex)-2*testU
-                VarName=FieldData.ListVarName{VarIndex(iselect)};
-                eval(['ProjVar{iselect}=FieldData.' VarName '(indsel);']);%scalar value
-            end   
-            if testU
-                ProjVar{numel(VarIndex)-1}=cos(theta(ip))*vector_x(indsel)+sin(theta(ip))*vector_y(indsel);% longitudinal component
-                ProjVar{numel(VarIndex)}=-sin(theta(ip))*vector_x(indsel)+cos(theta(ip))*vector_y(indsel);%transverse component         
-            end
-            if isequal(ProjMode,'projection')
-                sintheta=sin(theta(ip));
-                costheta=cos(theta(ip));
-                Xproj=(X_sel-ObjectData.Coord(ip,1))*costheta + (Y_sel-ObjectData.Coord(ip,2))*sintheta; %projection on the line
-                [Xproj,indsort]=sort(Xproj);
-                for ivar=1:numel(ProjVar)
-                    if ~isempty(ProjVar{ivar})
-                        ProjVar{ivar}=ProjVar{ivar}(indsort);
-                     end
-                end
-            elseif isequal(ProjMode,'interp') %linear interpolation:
-                npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX)
-                Xproj=[linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint)];
-                xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1);
-                yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2);
-                for ivar=1:numel(ProjVar)
-                     if ~isempty(ProjVar{ivar})
-                        ProjVar{ivar}=griddata_uvmat(X_sel,Y_sel,ProjVar{ivar},xreg,yreg);
-                     end
-                end
-            elseif isequal(ProjMode,'filter') %filtering
-                npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX)
-                Xproj=[linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint)];
-                siz=size(X_sel);
-                xregij=cos(theta(ip))*Xproj'*ones(1,siz(2))+ObjectData.Coord(ip,1);
-                yregij=sin(theta(ip))*Xproj'*ones(1,siz(2))+ObjectData.Coord(ip,2);
-                xij=ones(npoint,1)*X_sel;
-                yij=ones(npoint,1)*Y_sel;
-                Aij=exp(-lambda*((xij-xregij).*(xij-xregij)+(yij-yregij).*(yij-yregij)));
-                norm=ones(1,siz(2))*Aij';
-                for ivar=1:numel(ProjVar)
-                     if ~isempty(ProjVar{ivar})
-                        ProjVar{ivar}=ProjVar{ivar}*Aij'./norm;
-                     end
-                end              
-            end
-            %prolongate the total record
-            for ivar=1:numel(ProjVar)
-                  if ~isempty(ProjVar{ivar})
-                     ProjLine{ivar}=[ProjLine{ivar}; ProjVar{ivar}];
-                  end
-            end
-            XLine=[XLine ;(Xproj+linelengthtot)];%along line abscissa
-            linelengthtot=linelengthtot+linelength;
-            %     circul=circul+(sum(U_sel))*linelength/npoint;
-            %     flux=flux+(sum(V_sel))*linelength/npoint;
-        end
-        ProjData.X=XLine';
-        cur_index=1;
-        ProjData.ListVarName=[ProjData.ListVarName {XName}];
-        ProjData.VarDimName=[ProjData.VarDimName {XName}];
-        ProjData.VarAttribute{1}.long_name='abscissa along line';
-        for iselect=1:numel(VarIndex)
-            VarName=FieldData.ListVarName{VarIndex(iselect)};
-            eval(['ProjData.' VarName '=ProjLine{iselect};'])
-            ProjData.ListVarName=[ProjData.ListVarName {VarName}];
-            ProjData.VarDimName=[ProjData.VarDimName {XName}];
-            ProjData.VarAttribute{iselect}=FieldData.VarAttribute{VarIndex(iselect)};
-        end
-    
-    %case of structured coordinates
-    elseif  numel(VarType.coord)>=2 & VarType.coord(1:2) > 0;
-        if ~isequal(ObjectData.Style,'line')% exclude polyline
-            errormsg=['no  projection available on ' ObjectData.Style 'for structured coordinates']; % 
-        else
-            test_Amat=1;%image or 2D matrix
-            test_interp2=0;%default
-%             if ~isempty(VarType.coord_y)  
-            AYName=FieldData.ListVarName{VarType.coord(1)};
-            AXName=FieldData.ListVarName{VarType.coord(2)};
-            eval(['AX=FieldData.' AXName ';']);% set of x positions
-            eval(['AY=FieldData.' AYName ';']);% set of y positions  
-            AName=FieldData.ListVarName{VarIndex(1)};
-            eval(['A=FieldData.' AName ';']);% scalar
-            npxy=size(A);
-            npx=npxy(2);
-            npy=npxy(1); 
-            if numel(AX)==2
-                DX=(AX(2)-AX(1))/(npx-1);
-            else
-                DX_vec=diff(AX);
-                DX=max(DX_vec);
-                DX_min=min(DX_vec);
-                if (DX-DX_min)>0.0001*abs(DX) 
-                    test_interp2=1;
-                    DX=DX_min;
-                end    
-            end
-            if numel(AY)==2
-                DY=(AY(2)-AY(1))/(npy-1);
-            else
-                DY_vec=diff(AY);
-                DY=max(DY_vec);
-                DY_min=min(DY_vec);
-                if (DY-DY_min)>0.0001*abs(DY)
-                   test_interp2=1;
-                    DY=DY_min;
-                end     
-            end              
-            AXI=linspace(AX(1),AX(end), npx);%set of  x  positions for the interpolated input data
-            AYI=linspace(AY(1),AY(end), npy);%set of  x  positions for the interpolated input data
-            if isfield(ObjectData,'DX')
-                DXY_line=ObjectData.DX;%mesh on the projection line
-            else
-                DXY_line=sqrt(abs(DX*DY));% mesh on the projection line
-            end
-            dlinx=ObjectData.Coord(2,1)-ObjectData.Coord(1,1);
-            dliny=ObjectData.Coord(2,2)-ObjectData.Coord(1,2);
-            linelength=sqrt(dlinx*dlinx+dliny*dliny);
-            theta=angle(dlinx+i*dliny);%angle of the line   
-            if isfield(FieldData,'RangeX')
-                XMin=min(FieldData.RangeX);%shift of the origin on the line
-            else
-                XMin=0;
-            end
-            eval(['ProjData.' AXName '=linspace(XMin,XMin+linelength,linelength/DXY_line+1);'])%abscissa of the new pixels along the line
-            y=linspace(-width,width,2*width/DXY_line+1);%ordintes of the new pixels (coordinate across the line)
-            eval(['npX=length(ProjData.' AXName ');'])
-            npY=length(y); %TODO: utiliser proj_grid
-            eval(['[X,Y]=meshgrid(ProjData.' AXName ',y);'])%grid in the line coordinates
-            XIMA=ObjectData.Coord(1,1)+(X-XMin)*cos(theta)-Y*sin(theta);
-            YIMA=ObjectData.Coord(1,2)+(X-XMin)*sin(theta)+Y*cos(theta);
-            XIMA=(XIMA-AX(1))/DX+1;%  index of the original image along x
-            YIMA=(YIMA-AY(1))/DY+1;% index of the original image along y
-            XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line'
-            YIMA=reshape(round(YIMA),1,npX*npY);
-            flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
-            ind_in=find(flagin);
-            ind_out=find(~flagin);
-            ICOMB=(XIMA-1)*npy+YIMA;
-            ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
-            nbcolor=1; %color images
-            if numel(npxy)==2
-                nbcolor=1;
-            elseif length(npxy)==3
-                nbcolor=npxy(3);
-            else
-                errormsg='multicomponent field not projected';
-                display(errormsg)
-                return
-            end 
-            nbvar=length(ProjData.ListVarName);% number of var from previous cells
-            ProjData.ListVarName=[ProjData.ListVarName {AXName}];
-            ProjData.VarDimName=[ProjData.VarDimName {AXName}];
-            for ivar=VarIndex
-                VarName{ivar}=FieldData.ListVarName{ivar};
-                if test_interp2% interpolate on new grid
-                    eval(['FieldData.' VarName{ivar} '=interp2(FieldData.' AXName ',FieldData.' AYName ',FieldData.' VarName{ivar} ',AXI,AYI'');']) %TO TEST
-                end
-                eval(['vec_A=reshape(squeeze(FieldData.' VarName{ivar} '),npx*npy,nbcolor);']) %put the original image in colum
-                if nbcolor==1
-                    vec_B(ind_in)=vec_A(ICOMB);
-                    vec_B(ind_out)=zeros(size(ind_out));
-                    A_out=reshape(vec_B,npY,npX);
-                    eval(['ProjData.' VarName{ivar} '=((sum(A_out,1)/npY))'';']);
-                elseif nbcolor==3
-                    vec_B(ind_in,[1:3])=vec_A(ICOMB,:);
-                    vec_B(ind_out,1)=zeros(size(ind_out));
-                    vec_B(ind_out,2)=zeros(size(ind_out));
-                    vec_B(ind_out,3)=zeros(size(ind_out));
-                    A_out=reshape(vec_B,npY,npX,nbcolor);
-                    eval(['ProjData.' VarName{ivar} '=squeeze(sum(A_out,1)/npY);']);
-                end  
-                ProjData.ListVarName=[ProjData.ListVarName VarName{ivar} ];
-                ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate
-            end
-            if testU
-                 eval(['vector_x =ProjData.' VarName{VarType.vector_x} ';'])
-                 eval(['vector_y =ProjData.' VarName{VarType.vector_y} ';'])
-                 eval(['ProjData.' VarName{VarType.vector_x} '=cos(theta)*vector_x+sin(theta)*vector_y;'])
-                 eval(['ProjData.' VarName{VarType.vector_y} '=-sin(theta)*vector_x+cos(theta)*vector_y;'])
-            end
-            ProjData.VarAttribute{nbvar+1}.long_name='abscissa along line';
-            if nbcolor==3
-                ProjData.VarDimName{end}={XName,'rgb'};
-            end
-        end      
-    end
-end
-
-% %shotarter case for horizontal or vertical line (A FAIRE 
-% %     Rangx=[0.5 npx-0.5];%image coordiantes of corners
-% %     Rangy=[npy-0.5 0.5];
-% %     if isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib
-% %         Rangx=Rangx/Calib.Pxcmx;
-% %         Rangy=Rangy/Calib.Pxcmy;
-% %     else
-% %         [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],[0 0]);%case of translations without rotation and quadratic deformation
-% %         [xx,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,[0 0]);
-% %     end 
-% 
-% %     test_scal=0;%default% 3- 'UserData':(get(handles.Tag,'UserData')
-
-
-%-----------------------------------------------------------------
-%project on a plane 
-% AJOUTER flux,circul,error
- function  [ProjData,errormsg] = proj_plane(FieldData, ObjectData)
-%-----------------------------------------------------------------
-
-%initialisation of the input parameters of the projection plane
-%-----------------------------------------------------------------
-ProjMode='projection';%direct projection by default
-if isfield(ObjectData,'ProjMode'),ProjMode=ObjectData.ProjMode; end;
-
-%axis origin
-if isempty(ObjectData.Coord)
-    ObjectData.Coord(1,1)=0;%origin of the plane set to [0 0] by default
-    ObjectData.Coord(1,2)=0;
-    ObjectData.Coord(1,3)=0;
-end
-
-%rotation angles 
-Phi=0;%default
-Theta=0;
-Psi=0;
-if isfield(ObjectData,'Phi')&& ~isempty(ObjectData.Phi)
-    Phi=(pi/180)*ObjectData.Phi;%first Euler angle in radian
-end
-if isfield(ObjectData,'Theta')&& ~isempty(ObjectData.Theta)
-    Theta=(pi/180)*ObjectData.Theta;%second Euler angle in radian
-end
-if isfield(ObjectData,'Psi')&& ~isempty(ObjectData.Psi)
-    Psi=(pi/180)*ObjectData.Psi;%third Euler angle in radian
-end
-
-%components of the unity vector normal to the projection plane
-NormVec_X=-sin(Phi)*sin(Theta);
-NormVec_Y=cos(Phi)*sin(Theta);
-NormVec_Z=cos(Theta);
-
-% test for 3D fields
-test3D=0;
-if isfield(FieldData,'NbDim')
-    test3D=isequal(FieldData.NbDim,3);
-end
-test3C=test3D; %default 3 vel components
-
-%mesh sizes DX and DY
-DX=0;
-DY=0; %default 
-if isfield(ObjectData,'DX')&~isempty(ObjectData.DX)
-     DX=abs(ObjectData.DX);%mesh of interpolation points 
-end
-if isfield(ObjectData,'DY')&~isempty(ObjectData.DY)
-     DY=abs(ObjectData.DY);%mesh of interpolation points 
-end
-if  ~isequal(ProjMode,'projection') & (DX==0|DY==0)
-        errormsg='DX or DY missing';
-        display(errormsg)
-        return
-end
-
-%extrema along each axis
-testXMin=0;
-testXMax=0;
-testYMin=0;
-testYMax=0;
-if isfield(ObjectData,'RangeX')
-        XMin=min(ObjectData.RangeX);
-        XMax=max(ObjectData.RangeX);
-        testXMin=XMax>XMin;
-        testXMax=1;
-end
-if isfield(ObjectData,'RangeY')
-        YMin=min(ObjectData.RangeY);
-        YMax=max(ObjectData.RangeY);
-        testYMin=YMax>YMin;
-        testYMax=1;
-end
-width=0;%default width of the projection band
-if isfield(ObjectData,'RangeZ')
-        width=max(ObjectData.RangeZ);
-end
-
-% initiate Matlab  structure for physical field
-ProjData=proj_heading(FieldData,ObjectData);
-ProjData.NbDim=2;
-ProjData.ListDimName={};%name of dimension 
-ProjData.DimValue=[];%values of dimension (nbre of vectors)
-ProjData.ListVarName={};
-ProjData.VarDimName={};
-
-error=0;%default
-flux=0;
-testfalse=0;
-ListIndex={};
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%group the variables (fields of 'FieldData') in cells of variables with the same dimensions
-%-----------------------------------------------------------------
-idimvar=0;
-[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
-if ~isempty(errormsg)
-    errormsg=['error in proj_field/proj_plane:' errormsg];
-    return
-end
-%LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
-% CellVarIndex=cells of variable index arrays
-ivar_new=0; % index of the current variable in the projected field
-icoord=0;
-nbcoord=0;%number of added coordinate variables brought by projection
-for icell=1:length(CellVarIndex)
-    if NbDim(icell)<2
-        continue
-    end
-    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list FieldData.ListVarName
-    VarType=VarTypeCell{icell};
-    ivar_X=VarType.coord_x;
-    ivar_Y=VarType.coord_y;
-    ivar_Z=VarType.coord_z;
-    ivar_U=VarType.vector_x;
-    ivar_V=VarType.vector_y;
-    ivar_W=VarType.vector_z;
-    ivar_C=VarType.scalar ;
-    ivar_Anc=VarType.ancillary;
-    test_anc=zeros(size(VarIndex));
-    test_anc(ivar_Anc)=ones(size(ivar_Anc));
-    ivar_F=VarType.warnflag;
-    ivar_FF=VarType.errorflag;
-    testX=~isempty(ivar_X) && ~isempty(ivar_Y);
-    %DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
-    DimCell=FieldData.VarDimName{VarIndex(1)};
-    if ischar(DimCell)
-        DimCell={DimCell};%name of dimensions
-    end
-    
-%case of input fields with unstructured coordinates
-    if testX
-        XName=FieldData.ListVarName{ivar_X};
-        YName=FieldData.ListVarName{ivar_Y};
-        eval(['coord_x=FieldData.' XName ';'])
-        eval(['coord_y=FieldData.' YName ';'])
-        if length(ivar_Z)==1
-            ZName=FieldData.ListVarName{ivar_X};
-            eval(['coord_z=FieldData.' ZName ';'])
-        end
-
-        % translate  initial coordinates
-        coord_x=coord_x-ObjectData.Coord(1,1);
-        coord_y=coord_y-ObjectData.Coord(1,2);
-        if ~isempty(ivar_Z)
-            coord_z=coord_z-ObjectData.Coord(1,3);
-        end
-        
-        % selection of the vectors in the projection range (3D case)
-        if length(ivar_Z)==1 &&  width > 0
-            %components of the unitiy vector normal to the projection plane
-            fieldZ=NormVec_X*coord_x + NormVec_Y*coord_y+ NormVec_Z*coord_z;% distance to the plane            
-            indcut=find(abs(fieldZ) <= width);
-            for ivar=VarIndex
-                VarName=FieldData.ListVarName{ivar};
-                eval(['FieldData.' VarName '=FieldData.' VarName '(indcut);'])
-%                 end      
-                    % A VOIR : CAS DE VAR STRUCTUREE MAIS PAS GRILLE REGULIERE : INTERPOLER SUR GRILLE REGULIERE              
-            end
-            coord_x=coord_x(indcut);
-            coord_y=coord_y(indcut);
-            coord_z=coord_z(indcut);
-        end
-
-       %rotate coordinates if needed
-        if isequal(Phi,0)
-            coord_X=coord_x;
-            coord_Y=coord_y;
-            if ~isequal(Theta,0)
-                coord_Y=coord_Y *cos(Theta);
-            end
-        else
-            coord_X=(coord_x *cos(Phi) + coord_y* sin(Phi));
-            coord_Y=(-coord_x *sin(Phi) + coord_y *cos(Phi))*cos(Theta);
-        end
-        if ~isempty(ivar_Z)
-            coord_Y=coord_Y+coord_z *sin(Theta);
-        end
-        if ~isequal(Psi,0)
-                coord_X=(coord_X *cos(Psi) - coord_Y* sin(Psi));%A VERIFIER
-                coord_Y=(coord_X *sin(Psi) + coord_Y* cos(Psi));
-        end
-        
-        %restriction to the range of x and y if imposed
-        testin=ones(size(coord_X)); %default
-        testbound=0;
-        if testXMin
-            testin=testin & (coord_X >= XMin);
-            testbound=1;
-        end
-        if testXMax
-            testin=testin & (coord_X <= XMax);
-            testbound=1;
-        end
-        if testYMin
-            testin=testin & (coord_Y >= YMin);
-            testbound=1;
-        end
-        if testYMin
-            testin=testin & (coord_Y <= YMax);
-            testbound=1;
-        end
-        if testbound
-            indcut=find(testin);
-            for ivar=VarIndex
-                VarName=FieldData.ListVarName{ivar};
-                eval(['FieldData.' VarName '=FieldData.' VarName '(indcut);'])            
-            end
-            coord_X=coord_X(indcut);
-            coord_Y=coord_Y(indcut);
-            if length(ivar_Z)==1
-                coord_Z=coord_Z(indcut);
-            end
-        end
-        % different cases of projection
-        if isequal(ObjectData.ProjMode,'projection')
-            ProjData.ListDimName=[ProjData.ListDimName FieldData.ListDimName(DimIndices(1))];%add the point index to the list of dimensions
-            ProjData.DimValue=[ProjData.DimValue length(coord_X)];
-            nbvar=0;
-            for ivar=VarIndex %transfer variables to the projection plane
-                VarName=FieldData.ListVarName{ivar};
-                if ivar==ivar_X %x coordinate
-                    eval(['ProjData.' VarName '=coord_X;'])
-                elseif ivar==ivar_Y % y coordinate
-                    eval(['ProjData.' VarName '=coord_Y;'])
-                elseif isempty(ivar_Z) || ivar~=ivar_Z % other variables (except Z coordinate wyhich is not reproduced)
-                    eval(['ProjData.' VarName '=FieldData.' VarName ';'])
-                end
-                if isempty(ivar_Z) || ivar~=ivar_Z 
-                    ProjData.ListVarName=[ProjData.ListVarName VarName];
-                    ProjData.VarDimIndex=[ProjData.VarDimIndex DimIndices(1)];
-                    nbvar=nbvar+1;
-                    if isfield(FieldData,'VarAttribute') & length(FieldData.VarAttribute) >=ivar
-                        ProjData.VarAttribute{nbvar}=FieldData.VarAttribute{ivar};
-                    end
-                end
-            end  
-        elseif isequal(ObjectData.ProjMode,'interp')||isequal(ObjectData.ProjMode,'filter')%interpolate data on a regular grid
-            coord_x_proj=[XMin:DX:XMax];
-            coord_y_proj=[YMin:DY:YMax];
-            DimCell={'coord_y','coord_x'};
-            %ProjData.DimValue=[length(coord_y_proj) length(coord_x_proj)];
-            ProjData.ListVarName={'coord_y','coord_x'};
-            ProjData.VarDimName={'coord_y','coord_x'};   
-            nbcoord=2;
-            %ProjData.VarDimIndex={};   
-            ProjData.coord_y=[YMin YMax];
-            ProjData.coord_x=[XMin XMax];
-            if isempty(ivar_X), ivar_X=0; end;
-            if isempty(ivar_Y), ivar_Y=0; end;
-            if isempty(ivar_Z), ivar_Z=0; end;
-            if isempty(ivar_U), ivar_U=0; end;
-            if isempty(ivar_V), ivar_V=0; end;
-            if isempty(ivar_W), ivar_W=0; end;
-            if isempty(ivar_F), ivar_F=0; end;
-            if isempty(ivar_FF), ivar_FF=0; end;
-            if ~isequal(ivar_FF,0)
-                VarName_FF=FieldData.ListVarName{ivar_FF};
-                eval(['indsel=find(FieldData.' VarName_FF '==0);'])
-                coord_X=coord_X(indsel);
-                coord_Y=coord_Y(indsel);
-            end
-            FF=zeros(1,length(coord_y_proj)*length(coord_x_proj));
-            testFF=0;
-            for ivar=VarIndex
-                VarName=FieldData.ListVarName{ivar}; 
-                if ~( ivar==ivar_X | ivar==ivar_Y | ivar==ivar_Z | ivar==ivar_F | ivar==ivar_FF | test_anc(ivar)==1)                 
-                    ivar_new=ivar_new+1;
-                    ProjData.ListVarName=[ProjData.ListVarName {VarName}];
-                    ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
-                    %ProjData.VarDimIndex=[ProjData.VarDimIndex {[1 2]}];
-                    if isfield(FieldData,'VarAttribute') & length(FieldData.VarAttribute) >=ivar
-                        ProjData.VarAttribute{ivar_new+nbcoord}=FieldData.VarAttribute{ivar};
-                    end
-%                     ProjData.VarAttribute{ivar_new}.Coord_2=[XMin XMax];
-%                     ProjData.VarAttribute{ivar_new}.Coord_1=[YMin YMax];
-                    if  ~isequal(ivar_FF,0)
-                        eval(['FieldData.' VarName '=FieldData.' VarName '(indsel);'])
-                    end
-                    eval(['ProjData.' VarName '=griddata_uvmat(coord_X,coord_Y,FieldData.' VarName ',coord_x_proj,coord_y_proj'');'])
-                    eval(['varline=reshape(ProjData.' VarName ',1,length(coord_y_proj)*length(coord_x_proj));'])
-                    FFlag= isnan(varline); %detect undefined values NaN
-                    indnan=find(FFlag);
-                    if~isempty(indnan)
-                        varline(indnan)=zeros(size(indnan));
-                        eval(['ProjData.' VarName '=reshape(varline,length(coord_y_proj),length(coord_x_proj));'])
-                        FF(indnan)=ones(size(indnan));
-%                         eval(['ProjData.' VarName '(indnan)=zeros(size(indnan));'])%put NaN to 0
-%                         FF=FF|FFlag;
-                        testFF=1;
-                    end
-                    if ivar==ivar_U
-                        ivar_U=ivar_new;
-                    end
-                    if ivar==ivar_V
-                        ivar_V=ivar_new;
-                    end
-                    if ivar==ivar_W
-                        ivar_W=ivar_new;
-                    end
-                end
-            end
-            if testFF
-                ProjData.FF=reshape(FF,length(coord_y_proj),length(coord_x_proj));
-                ProjData.ListVarName=[ProjData.ListVarName {'FF'}];
-              %  ProjData.VarDimIndex=[ProjData.VarDimIndex {[1 2]}];
-               ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
-                ProjData.VarAttribute{ivar_new+1+nbcoord}.Role='errorflag';
-            end
-        end
-%case of fields defined on a structured  grid 
-    else  
-        AYName=FieldData.ListVarName{VarType.coord(1)};
-        AXName=FieldData.ListVarName{VarType.coord(2)};
-        eval(['AX=FieldData.' AXName ';'])
-        eval(['AY=FieldData.' AYName ';'])
-        VarName=FieldData.ListVarName{VarIndex(1)};
-        eval(['DimValue=size(FieldData.' VarName ');'])
-        ListDimName=FieldData.ListDimName(DimIndices);
-        ProjData.ListVarName=[{AYName} {AXName} ProjData.ListVarName]; %TODO: check if it already exists in Projdata (several cells)
-        ProjData.VarDimName=[{AYName} {AXName} ProjData.VarDimName];
-        nbcolor=1; %default
-        for idim=1:length(ListDimName)
-            DimName=ListDimName{idim};
-            if isequal(DimName,'rgb')|isequal(DimName,'nb_coord')|isequal(DimName,'nb_coord_i')
-               nbcolor=DimValue(idim);
-               DimIndices(idim)=[];
-               DimValue(idim)=[];
-            end
-            if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED
-                DimIndices(idim)=[];
-                DimValue(idim)=[];
-            end
-        end  
-        ind_1=find(DimValue==1);
-        DimIndices(ind_1)=[]; %suppress singleton dimensions 
-%         indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero)
-        nb_dim=length(DimIndices);%number of space dimensions
-        Coord_z=[];
-        Coord_y=[];
-        Coord_x=[];   
-    
-        for idim=1:nb_dim %loop on space dimensions
-            test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
-            test_coord(idim)=0;%test for defined coordinates, =0 by default
-            ivar=DimVarIndex(DimIndices(idim));% index of the variable corresponding to the current dimension
-            if ~isequal(ivar,0)%  a variable corresponds to the current dimension
-                eval(['Coord{idim}=FieldData.' FieldData.ListVarName{ivar} ';']) ;% position for the first index
-                DCoord=diff(Coord{idim});
-                DCoord_min(idim)=min(DCoord);
-                DCoord_max=max(DCoord);
-                test_direct(idim)=DCoord_max>0;% =1 for increasing values, 0 otherwise
-                test_direct_min=DCoord_min(idim)>0;% =1 for increasing values, 0 otherwise
-                if ~isequal(test_direct(idim),test_direct_min)
-                     warndlg_uvmat(['non monotonic dimension variable # ' num2str(idim)  ' in proj_field.m'],'ERROR')
-                                return
-                end               
-                test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity
-                test_coord(idim)=1;
-
-            else  % no variable associated with the first dimension, look for variable  attributes Coord_1, _2 or _3
-                Coord_i_str=['Coord_' num2str(idim)];
-                DCoord_min(idim)=1;%default
-                Coord{idim}=[0.5 DimValue(idim)-0.5];
-                test_direct(idim)=1;
-%                 for ivar=VarIndex
-%                     if  isfield(FieldData.VarAttribute{ivar},Coord_i_str)% if there is a variable  attribute named Coord_1, _2 or _3
-%                          eval(['Coord{idim}=FieldData.VarAttribute{ivar}.' Coord_i_str ';']);%'range x 
-%                          if isnumeric(Coord{idim})
-%                              if length(Coord{idim})>=2
-%                                 test_direct(idim)=(Coord{idim}(2)>Coord{idim}(1));
-%                              else 
-%                                 warndlg_uvmat(['two values needed for ' Coord_i_str 'in proj_field.m'],'ERROR')
-%                                 return
-%                              end
-%                          else
-%                             warndlg_uvmat(['non numerical coordinate attributes' Coord_i_str 'in proj_field.m'],'ERROR')
-%                             return
-%                          end
-%                          DCoord_min(idim)=(Coord{idim}(end)-Coord{idim}(1))/(DimValue(idim)-1);
-%                     end
-%                 end
-            end
-        end
-        if nb_dim==2
-            if DY==0
-                DY=abs(DCoord_min(1));
-            end
-            npY=1+round(abs(Coord{1}(end)-Coord{1}(1))/DY);%nbre of points after interpolation 
-            npy=1+round(abs(Coord{1}(end)-Coord{1}(1))/abs(DCoord_min(1)));%nbre of points after possible interpolation on a regular grid
-            if DX==0
-                DX=abs(DCoord_min(2));
-            end
-            npX=1+round(abs(Coord{2}(end)-Coord{2}(1))/DX);%nbre of points after interpol  
-            npx=1+round(abs(Coord{2}(end)-Coord{2}(1))/abs(DCoord_min(2)));%nbre of points after possible interpolation on a regular grid 
-            Coord_y=linspace(Coord{1}(1),Coord{1}(end),npY);
-            test_direct_y=test_direct(1);
-            Coord_x=linspace(Coord{2}(1),Coord{2}(end),npX);
-            test_direct_x=test_direct(2);
-            DAX=DCoord_min(2);
-            DAY=DCoord_min(1);
-        elseif nb_dim==3
-            DZ=abs(DCoord_min(1));
-            npz=1+round(abs(Coord{1}(end)-Coord{1}(1))/DZ);%nbre of points after interpolation
-            if DY==0
-                DY=abs(DCoord_min(2));
-            end
-            npY=1+round(abs(Coord{2}(end)-Coord{2}(1))/DY);%nbre of points after interpol 
-            npy=1+round(abs(Coord{2}(end)-Coord{2}(1))/abs(DCoord_min(2)));%nbre of points before interpol 
-            if DX==0
-                DX=abs(DCoord_min(3));
-            end
-            npX=1+round(abs(Coord{3}(end)-Coord{3}(1))/DX);%nbre of points after interpol
-            npx=1+round(abs(Coord{3}(end)-Coord{3}(1))/abs(DCoord_min(3)));%nbre of points before interpol 
-            Coord_z=linspace(Coord{1}(1),Coord{1}(end),npz);
-            test_direct_z=test_direct(1);
-            Coord_y=linspace(Coord{2}(1),Coord{2}(end),npY);
-            test_direct_y=test_direct(2);
-            Coord_x=linspace(Coord{3}(1),Coord{3}(end),npX);
-            test_direct_x=test_direct(3);
-        end  
-        minAX=min(Coord_x);
-        maxAX=max(Coord_x);
-        minAY=min(Coord_y);
-        maxAY=max(Coord_y);
-        xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);
-        ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);
-        xcor_new=xcorner*cos(Phi)+ycorner*sin(Phi);%coord new frame
-        ycor_new=-xcorner*sin(Phi)+ycorner*cos(Phi);
-        if ~testXMax
-            XMax=max(xcor_new);
-        end
-        if ~testXMin
-            XMin=min(xcor_new);
-        end
-        if ~testYMax
-            YMax=max(ycor_new);
-        end
-        if ~testYMin
-            YMin=min(ycor_new);
-        end
-        DXinit=(maxAX-minAX)/(npx-1);
-        DYinit=(maxAY-minAY)/(npy-1);
-        if DX==0
-            DX=DXinit;
-        end
-        if DY==0
-            DY=DYinit;
-        end
-        npX=floor((XMax-XMin)/DX+1);
-        npY=floor((YMax-YMin)/DY+1);    
-        if test_direct_y
-            coord_y_proj=linspace(YMin,YMax,npY);%abscissa of the new pixels along the line
-        else
-            coord_y_proj=linspace(YMax,YMin,npY);%abscissa of the new pixels along the line
-        end
-        if test_direct_x
-            coord_x_proj=linspace(XMin,XMax,npX);%abscissa of the new pixels along the line
-        else
-            coord_x_proj=linspace(XMax,XMin,npX);%abscissa of the new pixels along the line
-        end 
-        
-        % case with no rotation and interpolation
-        if isequal(ProjMode,'projection') && isequal(Phi,0) && isequal(Theta,0) && isequal(Psi,0)
-            if test_direct(1)
-                min_ind1=ceil((YMin-Coord{1}(1))/DYinit)+1;
-                max_ind1=floor((YMax-Coord{1}(1))/DYinit)+1;
-                Ybound(1)=Coord{1}(1)+DYinit*(min_ind1-1);
-                Ybound(2)=Coord{1}(1)+DYinit*(max_ind1-1);
-            else
-                min_ind1=ceil((Coord{1}(1)-YMax)/DYinit)+1;
-                max_ind1=floor((Coord{1}(1)-YMin)/DYinit)+1;
-                Ybound(2)=Coord{1}(1)-DYinit*(max_ind1-1);
-                Ybound(1)=Coord{1}(1)-DYinit*(min_ind1-1);
-            end              
-            if test_direct(2)==1
-                min_ind2=ceil((XMin-Coord{2}(1))/DXinit)+1;
-                max_ind2=floor((XMax-Coord{2}(1))/DXinit)+1;
-                Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
-                Xbound(2)=Coord{2}(1)+DXinit*(max_ind2-1);
-            else
-                min_ind2=ceil((Coord{2}(1)-XMax)/DXinit)+1;
-                max_ind2=floor((Coord{2}(1)-XMin)/DXinit)+1;
-                Xbound(2)=Coord{2}(1)+DXinit*(max_ind2-1);
-                Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
-            end 
-            min_ind1=max(min_ind1,1);% deals with margin (bound lower than the first index)
-            min_ind2=max(min_ind2,1);
-            max_ind1=min(max_ind1,npy);
-            max_ind2=min(max_ind2,npx);
-            for ivar=VarIndex
-                VarName=FieldData.ListVarName{ivar}; 
-%                 if isequal(ObjectData.ProjMode,'interp')||isequal(ObjectData.ProjMode,'filter')% coordinates common to all fields
-%                     ProjData.ListDimName={'coord_y','coord_x'};
-%                     ProjData.DimValue=[length(coord_y_proj) length(coord_x_proj)];
-%                 else
-%                     icoord=icoord+1;
-%                     ProjData.ListDimName=[ProjData.ListDimName {['coord_y_' num2str(icoord)],['coord_x_' num2str(icoord)]}];
-%                     ProjData.DimValue=[ProjData.DimValue length(coord_y_proj) length(coord_x_proj)];
-%                 end
-                ProjData.ListVarName=[ProjData.ListVarName VarName];
-                ProjData.VarDimIndex=[ProjData.VarDimIndex [nb_dim-1 nb_dim]];
-                if length(FieldData.VarAttribute)>=ivar
-                    ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar};
-                end
-%                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=Xbound;
-%                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=Ybound;
-                eval(['ProjData.' VarName '=FieldData.' VarName '(min_ind1:max_ind1,min_ind2:max_ind2) ;']);
-            end         
-        else
-        % case with rotation and/or interpolation
-            if isempty(Coord_z) %2D case
-                [X,Y]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
-                XIMA=ObjectData.Coord(1,1)+(X)*cos(Phi)-Y*sin(Phi);%corresponding coordinates in the original image
-                YIMA=ObjectData.Coord(1,2)+(X)*sin(Phi)+Y*cos(Phi);
-                XIMA=(XIMA-minAX)/DXinit+1;% image index along x
-                YIMA=(-YIMA+maxAY)/DYinit+1;% image index along y
-                XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line'
-                YIMA=reshape(round(YIMA),1,npX*npY);
-                flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image 
-                if isequal(ObjectData.ProjMode,'filter')
-                    npx_filter=ceil(abs(DX/DAX));
-                    npy_filter=ceil(abs(DY/DAY));
-                    Mfilter=ones(npy_filter,npx_filter)/(npx_filter*npy_filter);
-                    test_filter=1;
-                else
-                    test_filter=0;
-                end
-                for ivar=VarIndex
-                    VarName=FieldData.ListVarName{ivar} ; 
-                    if test_interp(1) | test_interp(2)%interpolate on a regular grid         
-                          eval(['FieldData.' VarName '=interp2(Coord{2},Coord{1},FieldData.' VarName ',Coord_x,Coord_y'');']) %TO TEST
-                    end
-                    %filter the field (image) if option 'filter' is used
-                    if test_filter  
-                         Aclass=class(FieldData.A);
-                         eval(['FieldData.' VarName '=filter2(Mfilter,FieldData.' VarName ',''valid'');'])
-                         if ~isequal(Aclass,'double')
-                             eval(['FieldData.' VarName '=' Aclass '(FieldData.' VarName ');'])%revert to integer values
-                         end
-                    end
-                    eval(['vec_A=reshape(FieldData.' VarName ',npx*npy,nbcolor);'])%put the original image in line              
-                    ind_in=find(flagin);
-                    ind_out=find(~flagin);
-                    ICOMB=(XIMA-1)*npy+YIMA;
-                    ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
-                    vec_B(ind_in,[1:nbcolor])=vec_A(ICOMB,:); 
-                    for icolor=1:nbcolor
-                        vec_B(ind_out,icolor)=zeros(size(ind_out));
-                    end
-                    % TODO: A REVOIR:
-%                     if isequal(ObjectData.ProjMode,'interp') || isequal(ObjectData.ProjMode,'filter')% coordinates common to all fields
-%                         ProjData.ListDimName={'coord_y','coord_x'};
-%                         ProjData.DimValue=[length(coord_y_proj) length(coord_x_proj)];
-%                     else
-%                         icoord=icoord+1;
-%                         ProjData.ListDimName=[ProjData.ListDimName {['coord_y_' num2str(icoord)],['coord_x_' num2str(icoord)]}];
-%                         ProjData.DimValue=[ProjData.DimValue length(coord_y_proj) length(coord_x_proj)];
-%                     end
-                    ProjData.ListVarName=[ProjData.ListVarName VarName];                 
-                   % ProjData.VarDimIndex=[ProjData.VarDimIndex [nb_dim-1 nb_dim]];
-                    if length(FieldData.VarAttribute)>=ivar
-                        ProjData.VarAttribute{length(ProjData.ListVarName)+nbcoord}=FieldData.VarAttribute{ivar};
-                    end
-                    % A REVOIR:
-%                     if test_direct(2)==1
-%                         ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=[XMin XMax];
-%                     else
-%                         ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=[XMax XMin];
-%                     end
-%                     if test_direct(1)==1
-%                         ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=[YMin YMax];
-%                     else
-%                         ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=[YMax YMin];
-%                     end      
-                    eval(['ProjData.' VarName '=reshape(vec_B,npY,npX,nbcolor);']);
-                end
-                ProjData.FF=reshape(~flagin,npY,npX);%false flag A FAIRE: tenir compte d'un flga antérieur  
-                ProjData.ListVarName=[ProjData.ListVarName 'FF'];
-              %  ProjData.VarDimIndex=[ProjData.VarDimIndex [nb_dim-1 nb_dim]];
-                ProjData.VarAttribute{length(ProjData.ListVarName)}.Role='errorflag';
-            else %3D case
-                if isequal(Theta,0) & isequal(Phi,0)       
-                    test_sup=(Coord{1}>=ObjectData.Coord(1,3));
-                    iz_sup=find(test_sup);
-                    iz=iz_sup(1);
-                    if iz>=1 & iz<=npz
-                        ProjData.ListDimName=[ProjData.ListDimName ListDimName(2:end)];
-                        ProjData.DimValue=[ProjData.DimValue npY npX];
-                        for ivar=VarIndex
-                            VarName=FieldData.ListVarName{ivar}; 
-                            ProjData.ListVarName=[ProjData.ListVarName VarName];
-                          %  ProjData.VarDimIndex=[ProjData.VarDimIndex [nb_dim-2 nb_dim-1]];
-                            ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar}; %reproduce the variable attributes
-                            % A REVOIR
-%                             if test_direct_x==1
-%                                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=[XMin XMax];
-%                             else
-%                                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_2=[XMax XMin];
-%                             end
-%                             if test_direct_y==1
-%                                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=[YMin YMax];
-%                             else
-%                                 ProjData.VarAttribute{length(ProjData.ListVarName)}.Coord_1=[YMax YMin];
-%                             end      
-                            eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz
-                            %TODO : do a vertical average for a thick plane
-                            if test_interp(2) | test_interp(3)
-                                eval(['ProjData.' VarName '=interp2(Coord{3},Coord{2},ProjData.' VarName ',Coord_x,Coord_y'');']) 
-                            end
-                        end
-                    end
-                else
-                    errormsg='projection of structured coordinates on oblique plane not yet implemented';
-                    %TODO: use interp3
-                    return
-                end
-            end
-        end
-    end
-    %projection of  velocity components in the rotated coordinates
-    if ~isequal(Phi,0) & length(ivar_U)==1
-        if isempty(ivar_V)
-            warndlg_uvmat('v velocity component missing in proj_field.m','ERROR')
-            return
-        end
-        UName=FieldData.ListVarName{ivar_U};
-        VName=FieldData.ListVarName{ivar_V};    
-        eval(['ProjData.' UName  '=cos(Phi)*ProjData.' UName '+ sin(Phi)*ProjData.' VName ';'])
-        eval(['ProjData.' VName  '=cos(Theta)*(-sin(Phi)*ProjData.' UName '+ cos(Phi)*ProjData.' VName ');'])
-        if ~isempty(ivar_W)
-            WName=FieldData.ListVarName{ivar_W};
-            eval(['ProjData.' VName '=ProjData.' VName '+ ProjData.' WName '*sin(Theta);'])% 
-            eval(['ProjData.' WName '=NormVec_X*ProjData.' UName '+ NormVec_Y*ProjData.' VName '+ NormVec_Z* ProjData.' WName ';']);
-        end
-        if ~isequal(Psi,0)
-            eval(['ProjData.' UName '=cos(Psi)* ProjData.' UName '- sin(Psi)*ProjData.' VName ';']);
-            eval(['ProjData.' VName '=sin(Psi)* ProjData.' UName '+ cos(Psi)*ProjData.' VName ';']);
-        end
-    end
-end
-
-%-----------------------------------------------------------------
-%transmit the global attributes
-function [ProjData,errormsg]=proj_heading(FieldData,ObjectData)
-%-----------------------------------------------------------------
-% ProjData=FieldData;
-ProjData=[];%default
-if ~isfield(FieldData,'ListGlobalAttribute')
-    ProjData.ListGlobalAttribute={};
-else
-    ProjData.ListGlobalAttribute=FieldData.ListGlobalAttribute;
-end
-if isfield(FieldData,'Txt')
-    errormsg=FieldData.Txt; %transmit erreur message
-    return;
-end
-for iattr=1:length(ProjData.ListGlobalAttribute)
-    AttrName=ProjData.ListGlobalAttribute{iattr};
-    if isfield(FieldData,AttrName)
-        eval(['ProjData.' AttrName '=FieldData.' AttrName ';']);
-    end
-end
-if isfield(FieldData,'CoordType')
-    if isfield(ObjectData,'CoordType')&~isequal(FieldData.CoordType,ObjectData.CoordType)
-        errormsg=[ObjectData.Style ' in ' ObjectData.CoordType ' coordinates, while field in ' FieldData.CoordType ' coordinates'];
-        return
-    else
-         ProjData.CoordType=FieldData.CoordType;
-    end
-end
-
-ListObject={'Style','ProjMode','RangeX','RangeY','RangeZ','Phi','Theta','Psi','Coord'};
-for ilist=1:length(ListObject)
-    if isfield(ObjectData,ListObject{ilist})
-        eval(['val=ObjectData.' ListObject{ilist} ';'])
-        if ~isempty(val)
-            eval(['ProjData.Object' ListObject{ilist} '=val;']);
-            ProjData.ListGlobalAttribute=[ProjData.ListGlobalAttribute {['Object' ListObject{ilist}]}];
-        end
-    end   
-end
Index: unk/src/proj_grid.m
===================================================================
--- /trunk/src/proj_grid.m	(revision 7)
+++ 	(revision )
@@ -1,83 +1,0 @@
-%'proj_grid': project  fields with unstructured coordinantes on a regular grid
-% -------------------------------------------------------------------------
-% function [A,rangx,rangy]=proj_grid(vec_X,vec_Y,vec_A,rgx_in,rgy_in,npxy_in)
-
-
-function [A,rangx,rangy]=proj_grid(vec_X,vec_Y,vec_A,rgx_in,rgy_in,npxy_in)
-    if length(vec_Y)<2
-        warndlg_uvmat('less than 2 points in proj_grid.m','ERROR');
-        return; 
-    end
-    diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
-    index=find(diffy);% find the indices of vec_Y after wich a change of horizontal line occurs(diffy non zero)
-    if isempty(index); warndlg_uvmat('points aligned along abscissa in proj_grid.m','ERROR'); return; end;%points aligned% A FAIRE: switch to line plot.
-    diff2=diff(diffy(index));% diff2 = fluctuations of the detected vertical grid mesh dy 
-    if max(abs(diff2))>0.001*abs(diffy(index(1))) % if max(diff2) is larger than 1/1000 of the first mesh dy
-        % the data are not regularly spaced and must be interpolated  on a regular grid
-        if exist('rgx_in','var') & ~isempty (rgx_in) & isnumeric(rgx_in) & length(rgx_in)==2%  positions imposed from input
-            rangx=rgx_in; % first and last positions
-            rangy=rgy_in;
-%             npxy=npxy_in;
-            dxy(1)=1/(npxy_in(1)-1);%grid mesh in y
-            dxy(2)=1/(npxy_in(2)-1);%grid mesh in x
-            dxy(1)=(rangy(2)-rangy(1))/(npxy_in(1)-1);%grid mesh in y
-            dxy(2)=(rangx(2)-rangx(1))/(npxy_in(2)-1);%grid mesh in x
-        else % interpolation grid automatically determined
-            rangx(1)=min(vec_X);
-            rangx(2)=max(vec_X);
-            rangy(2)=min(vec_Y);
-            rangy(1)=max(vec_Y);
-            dxymod=sqrt((rangx(2)-rangx(1))*(rangy(1)-rangy(2))/length(vec_X));
-            dxy=[-dxymod/4 dxymod/4];% increase the resolution 4 times
-        end
-        xi=[rangx(1):dxy(2):rangx(2)];
-        yi=[rangy(1):dxy(1):rangy(2)];
-        [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
-        A=griddata_uvmat(vec_X,vec_Y,vec_A,xi,yi'); 
-        A=reshape(A,length(yi),length(xi));
-    else
-        x=vec_X(1:index(1));% the set of abscissa (obtained on the first line)
-        indexend=index(end);% last vector index of line change
-        ymax=vec_Y(indexend+1);% y coordinate AFTER line change
-        ymin=vec_Y(index(1));
-        %y=[vec_Y(index) ymax]; % the set of y ordinates including the last one
-        y=vec_Y(index);
-        y(length(y)+1)=ymax;
-        nx=length(x);   %number of grid points in x
-        ny=length(y);   % number of grid points in y
-        B=(reshape(vec_A,nx,ny))'; %vec_A reshaped as a rectangular matrix
-        [X,Y]=meshgrid(x,y);% positions X and Y also reshaped as matrix 
-        
-        %linear interpolation to improve the image resolution and/or adjust
-        %to prescribed positions 
-        test_interp=1;
-        if exist('rgx_in','var') & ~isempty (rgx_in) & isnumeric(rgx_in) & length(rgx_in)==2%  positions imposed from input
-            rangx=rgx_in; % first and last positions
-            rangy=rgy_in;
-            npxy=npxy_in;
-        else        
-            rangx=[vec_X(1) vec_X(nx)];% first and last position found for x
-%             rangy=[ymin ymax];
-              rangy=[max(ymax,ymin) min(ymax,ymin)];
-            if max(nx,ny) <= 64 & isequal(npxy_in,'np>256')
-                npxy=[8*ny 8*nx];% increase the resolution 8 times
-            elseif max(nx,ny) <= 128 & isequal(npxy_in,'np>256')
-                npxy=[4*ny 4*nx];% increase the resolution 4 times
-            elseif max(nx,ny) <= 256 & isequal(npxy_in,'np>256')
-                npxy=[2*ny 2*nx];% increase the resolution 2 times
-            else
-                npxy=[ny nx];
-                test_interp=0; % no interpolation done
-            end
-        end
-        if test_interp==1%if we interpolate
-            xi=[rangx(1):(rangx(2)-rangx(1))/(npxy(2)-1):rangx(2)];
-            yi=[rangy(1):(rangy(2)-rangy(1))/(npxy(1)-1):rangy(2)];
-            [XI,YI]=meshgrid(xi,yi);
-            A = interp2(X,Y,B,XI,YI);
-        else %no interpolation for a resolution higher than 256
-            A=B;
-            XI=X;
-            YI=Y;
-        end
-    end
Index: unk/src/px.m
===================================================================
--- /trunk/src/px.m	(revision 7)
+++ 	(revision )
@@ -1,87 +1,0 @@
-%'px': transform fields from physical coordinates (phys) to image (px) coordinates 
-
-% OUTPUT: 
-% DataOut:   structure of modified data (transforms DataIn)
-%       DataOut.CoordType='px': labels image coordinates
-%       DataOut.CoordUnit= 'px' : units of output coordinates
-%       DataOut.X and .Y arrays of image coordinates X, Y
-%       DataOut.U, .V velocity in pixel displacement on the image (unit=px), if velocity exists as input 
-%    
-%INPUT:
-% DataIn:  structure of possible input data (like UvData) or cell of structures (several fields):
-%      DataIn.CoordType='phys': allows transform to px, else no transform   (DataOut=DataIn)
-%      DataIn.X and .Y arrays of physical coordinates X, Y
-%      DataIn.Z corresponding array of Z coordinates (=0 by default)
-%      DataIn.U, V corresponding array of velocity components
-%      DataIn.W corresponding array of the third velocity component in 3D case
-%      DataIn.dt: time interval of the image pair used for velocity measurement (NEEDED TO GET OUTPUT RESULT))
-%      DataIn.A, AX, AY : image or scalar input -> EMPTY  CORRESPONDING OUTPUT (A REVOIR)
-%      Other fields in DataIn: copied to DataOut without modification
-% Calib: structure containing the calibration parameters (Tsai) or containing a subtree Calib.GeometryCalib with these parameters
-%
-% call the functions phys_XYZ or px_XYZ (case of images) for pointwise coordinate transforms
-
-function [DataOut,DataOut_1]=px(Data,CalibData,Data_1,CalibData_1)%DataIn,Calib)
-% A FAIRE: 1- verifier si DataIn est une 'field structure'(.ListVarName'):
-% chercher ListVarAttribute, for each field (cell of variables):
-%   .CoordType: 'phys' or 'px'   (default==px, no transform)
-%   .scale_factor: =dt (to transform displacement into velocity) default=1
-%   .covariance: 'scalar', 'coord', 'D_i': covariant (like velocity), 'D^i': contravariant (like gradient), 'D^jD_i' (like strain tensor)
-%   (default='coord' if .Role='coord_x,_y..., 
-%            'D_i' if '.Role='vector_x,...',
-%              'scalar', else (thenno change except scale factor)
-if  ~(exist('CalibData','var') && isfield(CalibData,'GeometryCalib'))
-    DataOut=Data;
-else
-    DataOut=px_1(Data,CalibData.GeometryCalib);
-end
-if exist('Data_1','var')
-    if ~(exist('CalibData_1','var') && isfield(CalibData_1,'GeometryCalib'))
-        DataOut_1=Data_1;
-    else
-        DataOut_1=px_1(Data_1,CalibData_1.GeometryCalib);
-    end
-else
-    DataOut_1=[];
-end
-
-
-%------------------------------------------------
-function DataOut=px_1(Data,Calib)
-DataOut=Data;%default
-
-%Act only if .CoordType=phys, and Calib defined
-if isfield(Data,'CoordType')& isequal(Data.CoordType,'phys')& ~isempty(Calib)
-    DataOut.CoordType='px'; %put flag for pixel coordinates
-    DataOut.CoordUnit='px';
-    %transform of X,Y coordinates
-    if isfield(Data,'Z')&~isempty(Data.Z)
-        Z=Data.Z;
-    else
-        Z=0;
-    end
-    if isfield(Data,'X') & isfield(Data,'Y')
-        [DataOut.X,DataOut.Y]=px_XYZ(Calib,Data.X,Data.Y,Z);
-        if isfield(Data,'U')&isfield(Data,'V')& isfield(Data,'dt')& ~isequal(Data.dt,0)
-            Data.U=Data.U*Data.dt;
-            Data.V=Data.V*Data.dt;
-            if isfield(Data,'W')
-                W=Data.W*Data.dt;
-            else
-                W=0;
-            end
-            [XOut_1,YOut_1]=px_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z-W/2);
-            [XOut_2,YOut_2]=px_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z+W/2);
-            DataOut.U=XOut_2-XOut_1;
-            DataOut.V=YOut_2-YOut_1;
-        end
-    end
-    %transform of an image
-    if isfield(Data,'A')&isfield(Data,'AX')&~isempty(Data.AX) & isfield(Data,'AY')&...
-                                   isfield(Data,'AY')&~isempty(Data.AY)&length(Data.A)>1
-%         if isfield(Data,'Field')&isequal(Data.Field,'images')
-          %NO TRANSFORM FROM phys to px for images
-            DataOut.A=[];% 
-    end
-end
-
Index: unk/src/px_XYZ.m
===================================================================
--- /trunk/src/px_XYZ.m	(revision 7)
+++ 	(revision )
@@ -1,50 +1,0 @@
-%'px_XYZ': transform phys coordinates to image coordinates (px)
-%
-% OUPUT:
-% X,Y: array of coordinates in the image cooresponding to the input physical positions 
-%                    (origin at lower leftcorner, unit=pixel)
-
-% INPUT:
-% Calib: structure containing the calibration parameters (read from the ImaDoc .xml file)
-% Xphys, Yphys: array of x,y physical coordinates
-% [Zphys]: corresponding array of z physical coordinates (0 by default)
-
-
-function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
-X=[];%default
-Y=[];
-% if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
-%     Zindex=Z;
-%     planepos=Calib.PlanePos{Zindex};
-%     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
-% else
-%     zphys=0;
-% end
-if ~exist('Zphys','var')
-    Zphys=0;
-end
-
-%%%%%%%%%%%%%
-if isfield(Calib,'R')
-    R=(Calib.R)';
-    xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
-    yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
-    zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
-%undistorted image coordinates
-    Xu=Calib.f*xc./zc;
-    Yu=Calib.f*yc./zc;
-%distorted image coordinates
-    distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
-% distortion=1;
-    Xd=Xu./distortion;
-    Yd=Yu./distortion;
-%pixel coordinates
-    X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
-    Y=Yd/Calib.dpy+Calib.Cy;
-
-elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib  
-        X=Xphys*Calib.Pxcmx;
-        Y=Yphys*Calib.Pxcmy;
-end
-
-
Index: unk/src/pxcm_tsai.m
===================================================================
--- /trunk/src/pxcm_tsai.m	(revision 7)
+++ 	(revision )
@@ -1,79 +1,0 @@
-%'pxcm_tsai': find differentials of the Tsai calibration
-%
-function [A11,A12,A13,A21,A22,A23]=pxcm_tsai(a,var_phys)
-a_read=a;
-
-R=(a.R)';
-
-x=var_phys(:,1);
-y=var_phys(:,2);
-
-if isfield(a,'PlanePos')
-    prompt={'Plane 1 Index','Plane 2 Index'};
-    Rep=inputdlg(prompt,'Target displacement test');
-    Z1=str2double(Rep(1));
-    Z2=str2double(Rep(2));
-    z=(a.PlanePos(Z2,3)+a.PlanePos(Z1,3))/2
-else
-    z=0;
-end
-
-%transform coeff for differentiels
-a.C11=R(1)*R(8)-R(2)*R(7);
-a.C12=R(2)*R(7)-R(1)*R(8);
-a.C21=R(4)*R(8)-R(5)*R(7);
-a.C22=R(5)*R(7)-R(4)*R(8);
-a.C1x=R(3)*R(7)-R(9)*R(1);
-a.C1y=R(3)*R(8)-R(9)*R(2);
-a.C2x=R(6)*R(7)-R(9)*R(4);
-a.C2y=R(6)*R(8)-R(9)*R(5);
-
-
-%dependence in x,y
-denom=(R(7)*x+R(8)*y+R(9)*z+a.Tz).*(R(7)*x+R(8)*y+R(9)*z+a.Tz);
-A11=(a.f*a.sx*(a.C11*y-a.C1x*z+R(1)*a.Tz-R(7)*a.Tx)./denom)/a.dpx;
-A12=(a.f*a.sx*(a.C12*x-a.C1y*z+R(2)*a.Tz-R(8)*a.Tx)./denom)/a.dpx;
-A21=(a.f*a.sx*(a.C21*y-a.C2x*z+R(4)*a.Tz-R(7)*a.Ty)./denom)/a.dpy;
-A22=(a.f*(a.C22*x-a.C2y*z+R(5)*a.Tz-R(8)*a.Ty)./denom)/a.dpy;
-A13=(a.f*(a.C1x*x+a.C1y*y+R(3)*a.Tz-R(9)*a.Tx)./denom)/a.dpx;
-A23=(a.f*(a.C2x*x+a.C2y*y+R(6)*a.Tz-R(9)*a.Ty)./denom)/a.dpy;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Old Version for z=0
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %'camera' coordinates
-% xc=R(1)*x+R(2)*y+a.Tx;
-% yc=R(4)*x+R(5)*y+a.Ty;
-% zc=R(7)*x+R(8)*y+a.Tz;
-% %undistorted image coordinates
-% Xu=a.f*xc./zc;
-% Yu=a.f*yc./zc;
-% %distorted image coordinates
-% distortion=(a.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %!! intégrer derivation kappa
-% % distortion=1;
-% Xd=Xu./distortion;
-% Yd=Yu./distortion;
-% %pixel coordinates
-% X=Xd*a.sx/a.dpx+a.Cx;
-% Y=Yd/a.dpy+a.Cy;
-% 
-% %transform coeff for differentiels
-% a.C11=R(1)*R(8)-R(2)*R(7);
-% a.C12=R(2)*R(7)-R(1)*R(8);
-% a.C21=R(4)*R(8)-R(5)*R(7);
-% a.C22=R(5)*R(7)-R(4)*R(8);
-% a.C1x=R(3)*R(7)-R(9)*R(1);
-% a.C1y=R(3)*R(8)-R(9)*R(2);
-% a.C2x=R(6)*R(7)-R(9)*R(4);
-% a.C2y=R(6)*R(8)-R(9)*R(5);
-% 
-% 
-% %dependence in x,y
-% denom=(R(7)*x+R(8)*y+a.Tz).*(R(7)*x+R(8)*y+a.Tz);
-% A11=(a.f*a.sx*(a.C11*y+R(1)*a.Tz-R(7)*a.Tx)./denom)/a.dpx;
-% A12=(a.f*a.sx*(a.C12*x+R(2)*a.Tz-R(8)*a.Tx)./denom)/a.dpx;
-% A21=(a.f*a.sx*(a.C21*y+R(4)*a.Tz-R(7)*a.Ty)./denom)/a.dpy;
-% A22=(a.f*(a.C22*x+R(5)*a.Tz-R(8)*a.Ty)./denom)/a.dpy;
-% A13=(a.f*(a.C1x*x+a.C1y*y+R(3)*a.Tz-R(9)*a.Tx)./denom)/a.dpx;
-% A23=(a.f*(a.C2x*x+a.C2y*y+R(6)*a.Tz-R(9)*a.Ty)./denom)/a.dpy;
-% 
Index: unk/src/raw2phys.m
===================================================================
--- /trunk/src/raw2phys.m	(revision 7)
+++ 	(revision )
@@ -1,151 +1,0 @@
-%'raw2phys': transform raw signal to physical values using different calibrations laws
-%
-function FieldPhys=raw2phys(Field)
-
-% do not transform if Field already in phys coordinates
-FieldPhys=Field;%default
-if isfield(Field,'CoordType') & isequal(Field.CoordType,'phys')
-    return %no transform if the data are already physical
-else
-    FieldPhys.CoordType='phys';
-end
-
-%Filtering of the initial data
-nbfilter=51;
-nbhalf=floor(nbfilter/2);
-for ivar=1:length(FieldPhys.ListVarName)
-    VarName=FieldPhys.ListVarName{ivar};
-    if ~isequal(VarName,'time')
-        eval(['FirstVal=FieldPhys.' VarName '(1);'])
-        eval(['LastVal=FieldPhys.' VarName '(end);'])
-        FirstVal=ones(nbhalf,1)*FirstVal;
-        LastVal=ones(nbhalf,1)*LastVal;    
-        eval(['FieldPhys.' VarName '=[FirstVal;FieldPhys.' VarName ';LastVal];'])
-        eval(['FieldPhys.' VarName '=conv(ones(1,nbfilter)/nbfilter,FieldPhys.' VarName ');']);
-         eval(['FieldPhys.' VarName '([1:nbfilter-1])=[];']);
-         eval(['FieldPhys.' VarName '([end-nbfilter+2:end])=[];']);
-    end
-end
-
-
-
-ScanRate=240; %data points per second
-VelTranslation=1; % 1 cm/s A VERIFIER
-test_Offset=0;
-test_Thermistance_B=0;
-test_Thermistance_M=0;
-if isfield(Field,'ListVarAttribute')
-    for ilist=1:length(Field.ListVarAttribute)
-        attr_name=Field.ListVarAttribute{ilist}
-        if isequal(attr_name,'PhysUnits')
-            FieldPhys.units =Field.PhysUnits;
-        end
-        if isequal(attr_name,'Offset')
-            test_Offset=1;
-        end
-        if isequal(attr_name,'ThermistanceCalib_B')
-            test_Thermistance_B=1;
-        end  
-        if isequal(attr_name,'ThermistanceCalib_M')
-            test_Thermistance_M=1;
-        end
-    end
-end
-
-
-
-% substract offset
-if test_Offset
-    for ivar=1:length(Field.ListVarName)
-        Val_Offset=Field.Offset{ivar};
-        if isnumeric(Val_Offset)&~isempty(Val_Offset)
-            VarName=Field.ListVarName{ivar};
-            eval(['FieldPhys.' VarName '=FieldPhys.' VarName '-Val_Offset;'])
-        end
-    end
-end
-
-%thermistance calibration
-if test_Thermistance_M & test_Thermistance_B
-    for ivar=1:length(Field.ListVarName)
-        Val_B=Field.ThermistanceCalib_B{ivar};
-        Val_M=Field.ThermistanceCalib_M{ivar};
-        if isnumeric(Val_B) & ~isempty(Val_B) & isnumeric(Val_M) & ~isempty(Val_M)
-            VarName=Field.ListVarName{ivar};
-            eval(['FieldPhys.' VarName '=(Val_M ./ (log( FieldPhys.' VarName ')-Val_B)) -273.15;'])
-        end
-    end
-end
-return
-
-%NON USED
-%density profile
-Density=(Conductivity-B)/A;%calibration
-Density=Density(find(Motor>1));%restrict the record to the time motor on
-Density=flipdim(Density,2)';
-%detect free surface
-[dmax,imax]=max(diff(Density));
-nbpoints=length(Density);
-Pos=linspace(0,nbpoints*VelTranslation/ScanRate,nbpoints);
-Pos=Pos-imax*VelTranslation/ScanRate;
-
-%[dmax,jmax]=max(diff(Conductivity))
-napoints=length(Conductivity);
-Pos1=linspace(0,napoints*VelTranslation/ScanRate,napoints);
-%Pos1=Pos1-jmax*VelTranslation/ScanRate;
-
-figure(2);
-clf
-plot(Pos1,Conductivity)
-grid on
-figure(3);
-size(Pos)
-size(Density)
-plot(Pos,Density)
-hold on
-grid on
-%determination of N
-PosCentr=Pos([floor(nbpoints/4):floor(3*nbpoints/4)]);
-DensityCentr=Density([floor(nbpoints/4):floor(3*nbpoints/4)]);
-p=polyfit(PosCentr,DensityCentr,1);
-LinDens=polyval(p,PosCentr);
-plot(PosCentr,LinDens,'r')
-grad=p(1)
-%find(Motor>1)
-
-% data.conductivity=flipdim(Conductivity(find(Motor>5)),1)';
-% data.deplacement=[100/size(data.conductivity,2):100/size(data.conductivity,2):100];
-% 
-% figure;plot(data.deplacement,data.conductivity);hold on;
-
-%data.density=flipdim(Conductivity(find(Motor>1)),1)'*3.4764+15.1367;
-%data.density=flipdim(Conductivity(find(Motor>1)),2)'*5+14.6090;
-%data.density=flipdim(Conductivity(find(Motor>1)),2)'*4.1525+19.50;
-% data.density=flipdim(Conductivity(find(Motor>1)),2)'
-% data.deplacement=[92/size(data.density,2):92/size(data.density,2):92];
-% figure(101)
-% plot(data.deplacement,data.density);hold on;
-
-% t=data.deplacement(find(data.deplacement>20&data.deplacement<80));
-%t=data.deplacement(find(data.deplacement>0&data.deplacement<90));
-% X=[ones(size(t,2),1)';t];
-% Y=data.density(find(data.deplacement>20&data.deplacement<80));
-% %Y=data.density(find(data.deplacement>0&data.deplacement<90));
-% coeff=Y/X;
-
-% plot(data.deplacement,data.deplacement*coeff(2)+coeff(1),'r');
-
-% grad=abs(coeff(2)*100)
-Tbv=2*pi/sqrt(981*0.001*grad)
-N=2*pi/Tbv
-title(strcat('',name,''))
-xpos=get(gca,'XLim')
-ypos=get(gca,'YLim')
-%xtext=xpos(1)+(xpos(2)-xpos(1))*3/4
-xtext=xpos(1)+(xpos(2)-xpos(1))/2
-ytext=ypos(1)+(ypos(2)-ypos(1))/4
-TabText={strcat('Tbv : ',num2str(Tbv),'s'); strcat('Stratification : ',num2str(grad)); strcat('N : ',num2str(2*pi/Tbv),'rad.s-1')}
-text(xtext,ytext,TabText)
-% text(xtext,13,strcat('Tbv : ',num2str(Tbv),'s'));
-% text(55,10,strcat('Stratification : ',num2str(grad)));
-% text(55,16,strcat('N : ',num2str(2*pi/Tbv),'rad.s-1'));
Index: unk/src/read_civxdata.m
===================================================================
--- /trunk/src/read_civxdata.m	(revision 7)
+++ 	(revision )
@@ -1,275 +1,0 @@
-%'read_civxdata': reads civx data from netcdf files
-%------------------------------------------------------------------
-% COMBINE ET REMPLACE read_ncfield, read_vel et read_scalar_new
-%------------------------------------------------------------------
-% OUTPUT:
-% nb_coord,nb_dim,
-% Civ: =0 or 1, indicates whether the data is civ (A SUPPRIMER ?)
-% CivStage: =0, ??? A UTILISER POUR REMPLACER civ
-%           =1, civ1 has been performed only
-%           =2, fix1 has been performed
-%           =3, pacth1 has been performed
-%           =4, civ2 has been performed 
-%           =5, fix2 has been performed
-%           =6, pacth2 has been performed
-% time: absolute time
-% Field
-%            .Txt: (char string) error message if any
-%            .NbDim: number of dimensions (=0 by default)
-%            .NbCoord: number of vector components
-%            .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
-%            .dt: time interval for the corresponding image pair
-%            .CivStage: =0, ??? A UTILISER POUR REMPLACER civ
-        %           =1, civ1 has been performed only
-        %           =2, fix1 has been performed
-        %           =3, pacth1 has been performed
-        %           =4, civ2 has been performed 
-        %           =5, fix2 has been performed
-        %           =6, pacth2 has been performed
-%            .X, .Y, .Z: set of vector coordinates 
-%            .U,.V,.W: corresponding set of vector components
-%            .F: warning flags
-%            .FF: error flag, =0 for good vectors
-%            .C: scalar associated with velocity (used for vector colors)
-%            .CoordType
-%            .DijU; matrix of spatial derivatives (DijU(1,1,:)=DUDX,
-%            DijU(1,2,:)=DUDY, Dij(2,1,:)=DVDX, DijU(2,2,:)=DVDY
-%            .A, .AX, .AY: additional scalar
-% dt:time interval of the image pair red from a single file, or vector with
- 
-% pixcmx,pixcmy: scaling factors (from the first file)
-% vel_type_out: string representing the selected velocity type (civ1,civ2,filter1...)
-%
-% INPUT:
-% filename: file name (string).
-% FieldNames =cell of field names to get, which can contain the strings:
-%             'ima_cor': image correlation, vec_c or vec2_C
-%             'vort','div','strain': requires velocity derivatives DUDX...
-%             'error': error estimate (vec_E or vec2_E)
-%             
-% VelType : character string indicating the types of velocity fields to read ('civ1','civ2'...)
-%            if vel_type=[] or'*', a  priority choice, given by vel_type_out{1,2}, is done depending 
-%            if vel_type='filter'; a structured field is sought (filter2 in priority, then filter1)
-
-
-% FUNCTIONS called: 
-% 'varcivx_generator':, sets the names of vaiables to read in the netcdf file 
-% 'nc2struct': reads a netcdf file 
-
-function [Field,VelTypeOut]=read_civxdata(filename,FieldNames,VelType)
-
-if ~exist('VelType','var')
-    VelType=[];
-end
-if isequal(VelType,'*')
-    VelType=[];
-end
-if ~exist('FieldNames','var') 
-    FieldNames=[]; %default
-end
-
-VelTypeOut=VelType;%default
-[var,role,units,vel_type_out_cell]=varcivx_generator(FieldNames,VelType);%determine the names of constants and variables to read
-[Field,vardetect,ichoice]=nc2struct(filename,var);
-if isfield(Field,'Txt')
-    return % error in file reading
-end
-if isequal(vardetect,0)
-     Field.Txt=[FieldNames ' not accessible in ' filename '/' VelType];
-     return
-end
-var_ind=find(vardetect);
-for ivar=1:length(var_ind)
-    Field.VarAttribute{ivar}.Role=role{var_ind(ivar)};
-%     Field.VarAttribute{ivar}.units=units{var_ind(ivar)};% not necessary: set with calc_field
-end
-VelTypeOut=VelType;
-if ~isempty(ichoice)
-    VelTypeOut=vel_type_out_cell{ichoice};
-end
-
-%adjust for Djui:
-if isfield(Field,'DjUi')
-    Field.ListVarName(end-2:end)=[];
-    Field.ListVarName{end}='DjUi';
-    Field.VarDimIndex(end-2:end)=[];
-    Field.VarAttribute(end-2:end)=[];
-end
-
-%determine the appropriate constant for time and dt for the PIV pair
-test_civ1=isequal(VelTypeOut,'civ1')||isequal(VelTypeOut,'interp1')||isequal(VelTypeOut,'filter1');
-test_civ2=isequal(VelTypeOut,'civ2')||isequal(VelTypeOut,'interp2')||isequal(VelTypeOut,'filter2');
-if test_civ1
-    Field.Time=Field.absolut_time_T0;
-elseif test_civ2
-    Field.Time=Field.absolut_time_T0_2;
-    Field.dt=Field.dt2;
-else
-    Field.Txt='the input file is not civx';
-    display(Field.Txt)
-end
-
-% CivStage
-if isfield(Field,'patch2')&& isequal(Field.patch2,1)
-    Field.CivStage=6;
-elseif isfield(Field,'fix2')&& isequal(Field.fix2,1)
-    Field.CivStage=5;
-elseif isfield(Field,'civ2')&& isequal(Field.civ2,1)
-    Field.CivStage=4; 
-elseif isfield(Field,'patch')&& isequal(Field.patch,1)
-    Field.CivStage=3; 
-elseif isfield(Field,'fix')&& isequal(Field.fix,1)
-    Field.CivStage=2;
-else
-    Field.CivStage=1;
-end 
-
-%update list of global attributes
-List=Field.ListGlobalAttribute;
-ind_remove=[];
-for ilist=1:length(List)
-    switch(List{ilist})
-        case {'patch2','fix2','civ2','patch','fix','dt2','absolut_time_T0','absolut_time_T0_2'}
-            ind_remove=[ind_remove ilist];
-            Field=rmfield(Field,List{ilist});
-    end
-end
-List(ind_remove)=[];
-Field.ListGlobalAttribute=[List {'Time','CivStage','CoordUnit'}];
-
-% rescale to pixel coordiantes
-if isfield(Field,'pixcmx')
-Field.U=Field.U*Field.pixcmx;
-Field.V=Field.V*Field.pixcmy;
-Field.X=Field.X*Field.pixcmx;
-Field.Y=Field.Y*Field.pixcmy; 
-end
-if ~isequal(Field.dt,0)
-    Field.U=Field.U*Field.dt;%translate in px displacement
-    Field.V=Field.V*Field.dt;
-    if isfield(Field,'DjUi')
-       Field.DjUi(:,1,1)=Field.dt*Field.DjUi(:,1,1);
-       Field.DjUi(:,2,2)=Field.dt*Field.DjUi(:,2,2);
-       Field.DjUi(:,1,2)=(Field.pixcmy/Field.pixcmx)*Field.dt*Field.DjUi(:,1,2);
-       Field.DjUi(:,2,1)=(Field.pixcmx/Field.pixcmy)*Field.dt*Field.DjUi(:,2,1);
-    end
-end
-Field.CoordType='px';% TODO: abandon, use COORdUnit instead ? (to adapt 'px' and 'phys')
-Field.CoordUnit='pixel';
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type) 
-%INPUT:
-% FieldNames =cell of field names to get, which can contain the strings:
-%             'ima_cor': image correlation, vec_c or vec2_C
-%             'vort','div','strain': requires velocity derivatives DUDX...
-%             'error': error estimate (vec_E or vec2_E)
-%             
-% vel_type: character string indicating the types of velocity fields to read ('civ1','civ2'...)
-%            if vel_type=[] or'*', a  priority choice, given by vel_type_out{1,2}, is done depending 
-%            if vel_type='filter'; a structured field is sought (filter2 in priority, then filter1)
-
-function [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type) 
-
-%default input values
-if ~exist('vel_type','var'),vel_type=[];end;
-if iscell(vel_type),vel_type=vel_type{1}; end;%transform cell to string if needed
-% if ~exist('display','var'),display=[];end;
-if ~exist('FieldNames','var'),FieldNames={'ima_cor'};end;%default scalar 
-if ischar(FieldNames), FieldNames={FieldNames}; end;
-
-%select the priority order for automatic vel_type selection
-testder=0;
-for ilist=1:length(FieldNames)
-    if ~isempty(FieldNames{ilist})
-    switch FieldNames{ilist}
-        case {'vort','div','strain'}
-            testder=1;
-    end
-    end
-end      
-if isempty(vel_type) || isequal(vel_type,'*') %undefined velocity type (civ1,civ2...)
-    if testder
-         vel_type_out{1}='filter2'; %priority to filter2 for scalar reading, filter1 as second
-        vel_type_out{2}='filter1';
-    else
-        vel_type_out{1}='civ2'; %priority to civ2 for vector reading, civ1 as second priority      
-        vel_type_out{2}='civ1';
-    end
-elseif isequal(vel_type,'filter')
-        vel_type_out{1}='filter2'; %priority to filter2 for scalar reading, filter1 as second
-        vel_type_out{2}='filter1';
-        if ~testder
-            vel_type_out{3}='civ1';%civ1 as third priority if derivatives are not needed
-        end
-elseif testder
-    test_civ1=isequal(vel_type,'civ1')||isequal(vel_type,'interp1')||isequal(vel_type,'filter1');
-    if test_civ1
-        vel_type_out{1}='filter1'; %switch to filter for reading spatial derivatives
-    else
-        vel_type_out{1}='filter2';
-    end
-else   
-    vel_type_out{1}=vel_type;%imposed velocity field 
-end
-vel_type_out=vel_type_out';
-
-%determine names of netcdf variables to read
-var={'X','Y','Z','U','V','W','C','F','FF'};
-role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
-units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
-if testder
-    var=[var {'DjUi(:,1,1)','DjUi(:,1,2)','DjUi(:,2,1)','DjUi(:,2,2)'}];
-    role=[role {'tensor','tensor','tensor','tensor'}];
-    units=[units {'pixel','pixel','pixel','pixel'}];
-end
-for ilist=1:length(vel_type_out)
-    var=[var;varname1(vel_type_out{ilist},FieldNames)];
-end
-
-  
-%-------------------------
-%determine  var names to read
-%--------------------------------------
-function varin=varname1(vel_type,FieldNames)
-
-testder=0;
-C1='';
-C2='';
-for ilist=1:length(FieldNames)
-    if ~isempty(FieldNames{ilist})
-    switch FieldNames{ilist}
-        case 'ima_cor' %image correlation corresponding to a vel vector
-            C1='vec_C';
-            C2='vec2_C';
-        case 'error'
-            C1='vec_E';
-            C2='vec2_E';
-        case {'vort','div','strain'}
-            testder=1;
-    end
-    end
-end      
-switch vel_type
-    case 'civ1'
-        varin={'vec_X','vec_Y','vec_Z','vec_U','vec_V','vec_W',C1,'vec_F','vec_FixFlag'};
-    case 'interp1'
-        varin={'vec_patch_X','vec_patch_Y','','vec_patch0_U','vec_patch0_V','','','',''};
-    case 'filter1'
-        varin={'vec_patch_X','vec_patch_Y','','vec_patch_U','vec_patch_V','','','',''};
-    case 'civ2'
-        varin={'vec2_X','vec2_Y','vec2_Z','vec2_U','vec2_V','vec2_W',C2,'vec2_F','vec2_FixFlag'};
-    case 'interp2'
-        varin={'vec2_patch_X','vec2_patch_Y','vec2_patch_Z','vec2_patch0_U','vec2_patch0_V','vec2_patch0_W','','',''};
-    case 'filter2'
-        varin={'vec2_patch_X','vec2_patch_Y','vec2_patch_Z','vec2_patch_U','vec2_patch_V','vec2_patch0_W','','',''};
-end
-if testder
-     switch vel_type
-        case 'filter1'
-            varin=[varin {'vec_patch_DUDX','vec_patch_DVDX','vec_patch_DUDY','vec_patch_DVDY'}];
-        case 'filter2'
-            varin=[varin {'vec2_patch_DUDX','vec2_patch_DVDX','vec2_patch_DUDY','vec2_patch_DVDY'}];
-    end   
-end
Index: unk/src/read_geometry_calib.m
===================================================================
--- /trunk/src/read_geometry_calib.m	(revision 7)
+++ 	(revision )
@@ -1,51 +1,0 @@
-%'read_geometry_calib': read data on the GUI geometry_calib
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function data=read_geometry_calib(Coord_cell)
-data_XIma=[];
-data_YIma=[];
-data_XObject=[];
-data_YObject=[];
-data_ZObject=[];
-%Coord=get(handles.ListCoord,'String');
-% XImage=get(handles.XImage,'String');
-% YImage=get(handles.YImage,'String');
-% XObject=get(handles.XObject,'String');
-% YObject=get(handles.YObject,'String');
-% ZObject=get(handles.ZObject,'String');
-% if ischar(Xcolumn)
-%     Xcolumn={Xcolumn};
-% end
-nb_defining_points=length(Coord_cell);
-iline=0;
-for i=1:nb_defining_points
-    coord_str=Coord_cell{i};%character string of line number i
-    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)
-            iline=iline+1;
-            if ~isempty(data1)
-                data.Coord(iline,1)=data1;
-            end    
-            if ~isempty(data2)
-                data.Coord(iline,2)=data2;
-            end
-            if ~isempty(data3)
-                data.Coord(iline,3)=data3;
-            end
-            if ~isempty(data4)
-                data.Coord(iline,4)=data4;
-            end
-            if isempty(data5)
-                data.Coord(iline,5)=0;
-            else
-                data.Coord(iline,5)=data5;
-            end
-        end
-    end
-end
-data.Style='points';
Index: unk/src/read_get_field.m
===================================================================
--- /trunk/src/read_get_field.m	(revision 7)
+++ 	(revision )
@@ -1,743 +1,0 @@
-%'read_get_field': read the list of selected variables from the GUI get_field (SAME AS THE FIRST
-% INPUT: 
-% hget_field: handles of the GUI get_field
-
-function [SubField,errormsg]=read_get_field(hget_field)
-%---------------------------------------------------------
-SubField=[];%default
-errormsg=[]; %default
-handles=guidata(hget_field);%handles of GUI elements in get_field
-Field=get(hget_field,'UserData');% read the current field Structure in the get_field interface
-if isfield(Field,'VarAttribute')
-    VarAttribute=Field.VarAttribute;
-else
-    VarAttribute={};
-end
-
-% select the indices of field variables for 2D plots
-test_1Dplot=get(handles.check_1Dplot,'Value');
-test_scalar=get(handles.check_scalar,'Value');
-test_vector=get(handles.check_vector,'Value');
-
-nbvar=0;
-empty_coord_x=0;
-empty_coord_y=0;
-dimname_y={};
-ListVarName={};
-VarDimName={};
-SubVarAttribute={};
-dim_x=0;
-dim_y=0;
-dim_z=0;
-dim_vec_x=0;
-dim_vec_y=0;
-dim_vec_z=0;
-c_index=[];
-if test_1Dplot
-     % select ordinate variable(s)
-    inputlist=get(handles.ordinate,'String'); 
-    val=get(handles.ordinate,'Value');% selection(s) for ordinate
-    VarNameCell=inputlist(val); %names of the variable(s) in the list
-    for ilist=1:length(VarNameCell)
-        VarIndex_y(ilist)=name2index(VarNameCell{ilist},Field.ListVarName);%index of the variable in ListVarName
-        dim_ordinate{ilist}=Field.VarDimName{VarIndex_y(ilist)};% name of the corresponding dimension
-%         if iscell(dim_ordinate{ilist})
-%             dim_ordinate{ilist}=dim_ordinate{ilist}{1};%take the first dimension name (char chain) in case of a matrix
-%         end
-        testpermute(ilist)=0;%default
-        nbvar=nbvar+1;
-        ListVarName{nbvar}=Field.ListVarName{VarIndex_y(ilist)};
-        VarDimName{nbvar}=Field.VarDimName{VarIndex_y(ilist)};
-        subvarindex(ilist)=nbvar;
-        if numel(VarAttribute)>=VarIndex_y(ilist)
-            SubVarAttribute{nbvar}=VarAttribute{VarIndex_y(ilist)};
-        end
-        SubVarAttribute{nbvar}.Role='scalar';           
-    end
-    
-        % select abscissa variable
-    inputlist=get(handles.abscissa,'String'); 
-    val=get(handles.abscissa,'Value');% a single selection is expected for abscissa
-    VarName=inputlist{val}; %name of the variable in the list
-    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
-    if isempty(VarIndex)% default abscissa = matrix index
-        coord_x_name=dim_ordinate{1};% name of the x coordinate = dimension of the plotted quantity
-        if iscell(coord_x_name)
-            coord_x_name=coord_x_name{1};
-        end
-        empty_coord_x=1;
-    else
-        dimname_x=Field.VarDimName{VarIndex};
-        if numel(dimname_x)~=1
-            errormsg='abscissa must be a one-dimensional variable';
-            return
-        end
-        nbvar=nbvar+1; 
-        ListVarName{nbvar}=Field.ListVarName{VarIndex};
-        VarDimName{nbvar}=Field.VarDimName{VarIndex};
-        if numel(VarAttribute)>=VarIndex
-            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
-        end
-        SubVarAttribute{nbvar}.Role='coord_x';
-         %check consistency of ordinate dimensions
-        for ilist=1:length(VarNameCell)
-            if iscell(dim_ordinate{ilist})
-                if ~strcmp(dim_ordinate{ilist}{1},dimname_x)
-                    if strcmp(dim_ordinate{ilist}{2},dimname_x)
-                        testpermute(ilist)=1;
-                    else
-                        errormsg='inconsistent dimensions for ordinate and abscissa';
-                        return
-                    end
-                end
-            end
-        end
-    end
-end
-
-test3D=strcmp(get(handles.coord_z_scalar,'Visible'),'on')||strcmp(get(handles.coord_z_vectors,'Visible'),'on');
-VarSubIndexA=[];
-
-%scalar variable
-test_xdimvar=0;%default
-test_ydimvar=0;%default
-test_zdimvar=0;%defaul
-dimname_x=[];
-dimname_y=[];
-dimname_z=[];
-if test_scalar
-    inputlist=get(handles.scalar,'String');
-    if isempty(inputlist)
-        errormsg='empty input field';
-        return
-    end
-    val=get(handles.scalar,'Value');%selected indices in the ordinate listbox
-    VarNameScalar=inputlist{val}; %name of the variable in the list
-    VarIndexA=name2index(VarNameScalar,Field.ListVarName);%index of the variable in ListVarName
-    dimname_A=Field.VarDimName{VarIndexA};
-    nbvar=nbvar+1;
-    ListVarName{nbvar}=Field.ListVarName{VarIndexA};
-    VarSubIndexA=nbvar;
-    VarDimName{nbvar}=dimname_A;
-    if numel(VarAttribute)>=VarIndexA
-        SubVarAttribute{nbvar}=VarAttribute{VarIndexA};
-    end
-    SubVarAttribute{nbvar}.Role='scalar';
-    field_var_index=VarIndexA; %store the last variable index to determine the absissa dimension if not defiend
-
-     % select x variable 
-    inputlist=get(handles.coord_x_scalar,'String'); 
-    val=get(handles.coord_x_scalar,'Value');% a single selection is expected for abscissa
-    VarName=inputlist{val}; %name of the variable in the list
-    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
-    if isempty(VarIndex)% default abscissa = matrix index
-        empty_coord_x=1;
-    else
-        dimname_x=Field.VarDimName{VarIndex};
-        nbvar=nbvar+1;
-        ListVarName{nbvar}=Field.ListVarName{VarIndex};
-        VarDimName{nbvar}=dimname_x;
-        if numel(VarAttribute)>=VarIndex
-            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
-        end
-         %check consistency of dimensions
-        if ~isequal(dimname_x,dimname_A)% case of dimension variables
-            if iscell(dimname_x)
-                if numel(dimname_x)==1
-                    dimname_x=dimname_x{1};%transform to char chain
-                else
-                    errormsg='invalid x coordinate selection in get_field';
-                    return
-                end
-            end
-            test_xdimvar=1;
-            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
-        else
-            SubVarAttribute{nbvar}.Role='coord_x';%abcissa with unstructured coordinates
-        end
-    end
-    
-    % select y variable
-    inputlist=get(handles.coord_y_scalar,'String'); 
-    val=get(handles.coord_y_scalar,'Value');% a single selection is expected for abscissa
-    VarName=inputlist{val}; %name of the variable in the list    
-    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
-    if isempty(VarIndex)% default abscissa = matrix index
-        empty_coord_y=1;
-    else
-        dimname_y=Field.VarDimName{VarIndex};
-         %check consistency of dimensions
-        nbvar=nbvar+1;
-        ListVarName{nbvar}=Field.ListVarName{VarIndex};
-        VarDimName{nbvar}=dimname_y;
-        if numel(VarAttribute)>=VarIndex
-            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
-        end
-         %check consistency of dimensions
-        if ~isequal(dimname_y,dimname_A)% case of dimension variables
-             if iscell(dimname_y)
-                if numel(dimname_y)==1
-                    dimname_y=dimname_y{1};%transform to char chain
-                else
-                    errormsg='invalid y coordinate selection in get_field';
-                    return
-                end
-             end
-            test_ydimvar=1;
-            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
-        else
-            SubVarAttribute{nbvar}.Role='coord_y';%abcissa with unstructured coordinates
-        end
-        if isequal(dimname_y,dimname_x)
-            errormsg='identical x and y coordinates selected in get_field';
-            return
-        end
-    end
-
-        % select z variable
-   if test3D % TODO: Lire z comme x et y
-        inputlist=get(handles.coord_z_scalar,'String'); 
-        val=get(handles.coord_z_scalar,'Value');% a single selection is expected for abscissa
-        VarName=inputlist{val}; %name of the variable in the list    
-        VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
-        if isempty(VarIndex)% default abscissa = matrix index
-%             coord_z_name=dimname_A{1};% name of the x coordinate = dimension of the plotted quantity
-            empty_coord_z=1;
-        else
-            dimname_z=Field.VarDimName{VarIndex};
-             %check consistency of dimensions
-            if ~isequal(dimname_z,dimname_A)
-                for icoord=1:numel(dimname_A)
-                    if strcmp(dimname_z,dimname_A{icoord})%  a dimension variable
-                         dim_z=icoord;
-                        break
-                    end
-                end
-                if ~dim_z
-                    errormsg='inconsistent dimensions for coordinate z';
-                    return
-                end
-            end
-            nbvar=nbvar+1;
-            ListVarName{nbvar}=Field.ListVarName{VarIndex};
-            VarDimName{nbvar}=dimname_z;
-            if numel(VarAttribute)>=VarIndex
-                SubVarAttribute{nbvar}=VarAttribute{VarIndex};
-            end
-            if dim_z
-                SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
-            else
-                SubVarAttribute{nbvar}.Role='coord_z';%z coordinate with unstructured coordinates
-            end
-        end
-   end
-end
-test_vec_x_dimvar=0;%default
-test_vec_y_dimvar=0;%default
-test_vec_z_dimvar=0;%defaul
-dimname_vec_x=[];
-dimname_vec_y=[];
-dimname_vec_z=[];
-if test_vector 
-    %select u variable
-    inputlist=get(handles.vector_x,'String');
-    if isempty(inputlist)
-        errormsg='empty input field';
-        return
-    end
-    val=get(handles.vector_x,'Value');%selected indices in the ordinate listbox
-    VarNameU=inputlist{val}; %name of the variable in the list
-    VarIndexU=name2index(VarNameU,Field.ListVarName);%index of the variable in ListVarName
-    nbvar=nbvar+1;
-    VarSubIndexU=nbvar;
-    ListVarName{nbvar}=Field.ListVarName{VarIndexU};
-    dimname_u=Field.VarDimName{VarIndexU};
-    VarDimName{nbvar}=dimname_u;
-    if numel(VarAttribute)>=VarIndexU
-        SubVarAttribute{nbvar}=VarAttribute{VarIndexU};
-    end
-    SubVarAttribute{nbvar}.Role='vector_x';
-    field_var_index=VarIndexU; %store the last variable index to determine the absissa dimension if not defiend
-    
-    %scalar v variable
-    inputlist=get(handles.vector_y,'String');
-    val=get(handles.vector_y,'Value');%selected indices in the ordinate listbox
-    VarNameV=inputlist{val}; %name of the variable in the list
-    VarIndexV=name2index(VarNameV,Field.ListVarName);%index of the variable in ListVarName 
-     %check consistency of dimensions with u
-    dimname_v=Field.VarDimName{VarIndexV};
-    if ~isequal(dimname_v,dimname_u)
-       errormsg='inconsistent dimensions for u and v';
-        return
-    end
-    nbvar=nbvar+1;
-    VarSubIndexV=nbvar;
-    ListVarName{nbvar}=Field.ListVarName{VarIndexV};
-    VarDimName{nbvar}=dimname_u;
-    if numel(VarAttribute)>=VarIndexV
-        SubVarAttribute{nbvar}=VarAttribute{VarIndexV};
-    end
-    SubVarAttribute{nbvar}.Role='vector_y';
-    
- 
-     % select x variable for vector
-    inputlist=get(handles.coord_x_vectors,'String'); 
-    val=get(handles.coord_x_vectors,'Value');% a single selection is expected for abscissa
-    VarName=inputlist{val}; %name of the variable in the list
-    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
-    if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
-%         coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity
-        empty_coord_vec_x=1;
-    else
-        empty_coord_vec_x=0;
-        dimname_vec_x=Field.VarDimName{VarIndex};
-        nbvar=nbvar+1;
-        ListVarName{nbvar}=Field.ListVarName{VarIndex};
-        VarDimName{nbvar}=dimname_vec_x;
-        if numel(VarAttribute)>=VarIndex
-            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
-        end
-         %check consistency of dimensions
-        if ~isequal(dimname_vec_x,dimname_u)% case of dimension variables
-            if iscell(dimname_vec_x)
-                if numel(dimname_vec_x)==1
-                    dimname_vec_x=dimname_vec_x{1};%transform to char chain
-                else
-                    errormsg='invalid x coordinate selection in get_field';
-                    return
-                end
-            end
-            test_vec_x_dimvar=1;
-            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
-        else
-            SubVarAttribute{nbvar}.Role='coord_x';%abcissa with unstructured coordinates
-        end
-    end
-        
-         % select y variable for vector
-    inputlist=get(handles.coord_y_vectors,'String'); 
-    val=get(handles.coord_y_vectors,'Value');% a single selection is expected for abscissa
-    VarName=inputlist{val}; %name of the variable in the list
-    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
-    if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
-%         coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity
-        empty_coord_vec_y=1;
-    else
-        empty_coord_vec_y=0;
-        dimname_vec_y=Field.VarDimName{VarIndex};
-        nbvar=nbvar+1;
-        ListVarName{nbvar}=Field.ListVarName{VarIndex};
-        VarDimName{nbvar}=dimname_vec_y;
-        if numel(VarAttribute)>=VarIndex
-            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
-        end
-         %check consistency of dimensions
-        if ~isequal(dimname_vec_y,dimname_u)% case of dimension variables
-            if iscell(dimname_vec_y)
-                if numel(dimname_vec_y)==1
-                    dimname_vec_y=dimname_vec_y{1};%transform to char chain
-                else
-                    errormsg='invalid y coordinate selection in get_field';
-                    return
-                end
-            end
-            test_vec_y_dimvar=1;
-            SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
-        else
-            SubVarAttribute{nbvar}.Role='coord_y';%abcissa with unstructured coordinates
-        end
-    end    
-        
-     % select z variable for vector
-    if test3D
-        inputlist=get(handles.coord_z_vectors,'String'); 
-        val=get(handles.coord_z_vectors,'Value');% a single selection is expected for abscissa
-        VarName=inputlist{val}; %name of the variable in the list
-        VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
-        if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
-    %         coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity
-            empty_coord_vec_z=1;
-        else
-            dimname_vec_z=Field.VarDimName{VarIndex};
-            nbvar=nbvar+1;
-            ListVarName{nbvar}=Field.ListVarName{VarIndex};
-            VarDimName{nbvar}=dimname_vec_z;
-            if numel(VarAttribute)>=VarIndex
-                SubVarAttribute{nbvar}=VarAttribute{VarIndex};
-            end
-             %check consistency of dimensions
-            if ~isequal(dimname_vec_z,dimname_u)% case of dimension variables
-                if iscell(dimname_vec_z)
-                    if numel(dimname_vec_z)==1
-                        dimname_vec_z=dimname_vec_y{1};%transform to char chain
-                    else
-                        errormsg='invalid y coordinate selection in get_field';
-                        return
-                    end
-                end
-                test_vec_z_dimvar=1;
-                SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
-            else
-                SubVarAttribute{nbvar}.Role='coord_z';%abcissa with unstructured coordinates
-            end
-        end        
-    end   
-        
-      
-     if test3D %  (a revoir)  
-         %scalar w variable
-        inputlist=get(handles.vector_z,'String');
-        val=get(handles.vector_z,'Value');%selected indices in the ordinate listbox
-        VarNameW=inputlist{val}; %name of the variable in the list
-        VarIndex=name2index(VarNameW,Field.ListVarName);%index of the variable in ListVarName 
-         %check consistency of dimensions with u
-        dimname_w=Field.VarDimName{VarIndex};
-        if ~isequal(dimname_w,dimname_u)
-           errormsg='inconsistent dimensions for u and v';
-            return
-        end
-        nbvar=nbvar+1;
-        w_index=nbvar;
-        ListVarName{nbvar}=Field.ListVarName{VarIndex};
-        VarDimName{nbvar}=dimname_u;
-        if numel(VarAttribute)>=VarIndex
-            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
-        end
-        SubVarAttribute{nbvar}.Role='vector_z';
-    end  
-    
-    % select color variable
-    inputlist=get(handles.vec_color,'String'); 
-    val=get(handles.vec_color,'Value');% a single selection is expected for abscissa
-    VarNameC=inputlist{val}; %name of the variable in the list
-    VarIndex=name2index(VarNameC,Field.ListVarName);%index of the variable in ListVarName
-       %check consistency of dimensions with u
-    if ~isempty(VarIndex)
-        if ~isequal(Field.VarDimName{VarIndex},dimname_u)
-            errormsg='inconsistent dimensions for u and v';
-            return
-        end
-        nbvar=nbvar+1;
-        c_index=nbvar;
-        ListVarName{nbvar}=Field.ListVarName{VarIndex};
-        VarDimName{nbvar}=Field.VarDimName{VarIndex};
-        if numel(VarAttribute)>=VarIndex
-            SubVarAttribute{nbvar}=VarAttribute{VarIndex};
-        end
-        SubVarAttribute{nbvar}.Role='scalar';
-    end
-end 
-
-% get the input field
-inputfield=get(handles.inputfile,'String');
-if exist(inputfield,'file')% read the input data corresponding to the list of selected varaibles
-    SubField=nc2struct(inputfield,ListVarName);
-else  % subfield stored in memory
-    SubField.ListVarName=ListVarName;
-    SubField.VarDimName=VarDimName;
-end
-SubField.ListGlobalAttribute=['InputFile' SubField.ListGlobalAttribute];
-SubField.InputFile=get(handles.inputfile,'String');
-SubField.VarAttribute=SubVarAttribute;
-
-%permute indices if coord_y is not the first matrix index
-if test_scalar
-    VarNameA=Field.ListVarName{VarIndexA};
-    DimCellA=Field.VarDimName{VarIndexA};   
-    eval(['npxy=size(SubField.' VarNameA ')'])
-    SingleCellA={};
-    if numel(npxy) < numel(DimCellA)
-        SingleCellA=DimCellA(1:end-numel(npxy));
-        DimCellA=DimCellA(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
-    end
-    ind_single=find(npxy==1);
-    SingleCellA=[SingleCellA DimCellA(ind_single)];
-    ind_select=find(npxy~=1);%look for non singleton dimensions
-    DimCellA=DimCellA(ind_select);
-    npxy=npxy(ind_select);
-    dimA=[];
-    if test_zdimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
-        for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
-            if strcmp(dimname_z,SingleCellA{icoord})% a singleton dimension
-                errormsg=['the singleton dimension ' dimname_z ' has been selected for z'];
-                return
-            end
-        end
-        for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
-             if strcmp(dimname_z,DimCellA{icoord})% a dimension variable
-                 dimA=[dimA icoord];
-                 break
-             end
-        end
-    end
-    if test_ydimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
-        for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
-            if strcmp(dimname_y,SingleCellA{icoord})% a singleton dimension
-                errormsg=['the singleton dimension ' dimname_y ' has been selected for ordiante'];
-                return
-            end
-        end
-        for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
-             if strcmp(dimname_y,DimCellA{icoord})% a dimension variable
-                 dimA=[dimA icoord];
-                 break
-             end
-        end
-    end
-    if test_xdimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
-        for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar
-            if strcmp(dimname_x,SingleCellA{icoord})% a singleton dimension
-                errormsg=['the singleton dimension ' dimname_x ' has been selected for abscissa'];
-                return
-            end
-        end
-        for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
-             if strcmp(dimname_x,DimCellA{icoord})% a dimension variable
-                 dimA=[dimA icoord];
-                 break
-             end
-        end
-    end
-    dimextra=(1:numel(DimCellA));
-    dimextra(dimA)=[]; %list of unselected dimension indices
-    DimCellA=DimCellA([dimA dimextra]);
-    eval(['SubField.' VarNameA '=permute(squeeze(SubField.' VarNameA '),[dimA dimextra]);'])
-    SubField.VarDimName{VarSubIndexA}=DimCellA;  
-    %add default coord_x and/or coord_y if empty
-    if empty_coord_x || empty_coord_y
-        VarName=Field.ListVarName{field_var_index};
-        DimCell=Field.VarDimName{field_var_index};    
-        eval(['npxy=size(SubField.' VarName ')'])
-        if numel(npxy) < numel(DimCell)
-            DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 
-        end
-        ind_select=find(npxy~=1) ;%look for non singleton dimensions
-        DimCell=DimCell(ind_select);
-        npxy=npxy(ind_select);
-        testold=0;
-    %old convention; use of coord_1 and Coord_2
-        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
-            if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1')
-                Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
-                Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
-                testold=1;
-            end
-        end
-        if empty_coord_x        
-                coord_x_name=DimCell{2};
-                SubField.ListVarName=[{coord_x_name} SubField.ListVarName];
-                SubField.VarDimName=[{coord_x_name} SubField.VarDimName];  
-                if testold
-                    eval(['SubField.' coord_x_name '=linspace(Coord_2(1),Coord_2(end),npxy(2));'])
-                else
-                    eval(['SubField.' coord_x_name '=[0.5 npxy(2)-0.5];'])
-                end
-            
-            if ~testold
-                coord_x_attr.units='index';
-            else
-                coord_x_attr.units='cm';
-            end
-            SubField.VarAttribute=[{coord_x_attr} SubField.VarAttribute];  
-        end
-        if empty_coord_y 
-            coord_y_name=DimCell{1};
-            SubField.ListVarName=[{coord_y_name} SubField.ListVarName];
-            SubField.VarDimName=[{coord_y_name} SubField.VarDimName];
-            if testold
-                eval(['SubField.' coord_y_name '=linspace(Coord_1(1),Coord_1(end),npxy(1));']) 
-            else
-                eval(['SubField.' coord_y_name '=[npxy(1)-0.5 0.5];'])
-            end
-            if ~testold
-                coord_y_attr.units='index';
-            else
-                coord_y_attr.units='cm';
-            end
-            SubField.VarAttribute=[{coord_y_attr} SubField.VarAttribute];       
-        end
-    end
-end
-
-%permute indices if coord_y is not the first matrix index
-if test_vector
-    VarNameU=Field.ListVarName{VarIndexU};
-    DimCellU=Field.VarDimName{VarIndexU};   
-    eval(['npxy=size(SubField.' VarNameU ')'])
-    SingleCellU={};
-    if numel(npxy) < numel(DimCellU)
-        SingleCellU=DimCellU(1:end-numel(npxy));
-        DimCellU=DimCellU(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
-    end
-    ind_single=find(npxy==1);
-    SingleCellU=[SingleCellU DimCellU(ind_single)];
-    ind_select=find(npxy~=1);%look for non singleton dimensions
-    DimCellU=DimCellU(ind_select);
-    npxy=npxy(ind_select);
-    dimU=[];
-    if test_zdimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
-        for icoord=1:numel(SingleCellU)% look for coincidence of dimension with one of the dimensions of the scalar 
-            if strcmp(dimname_vec_z,SingleCellU{icoord})% a singleton dimension
-                errormsg=['the singleton dimension ' dimname_vec_z ' has been selected for z'];
-                return
-            end
-        end
-        for icoord=1:numel(DimCellU)% look for coincidence of dimension with one of the dimensions of the scalar 
-             if strcmp(dimname_vec_z,DimCellU{icoord})% a dimension variable
-                 dimU=[dimU icoord];
-                 break
-             end
-        end
-    end
-    if test_ydimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
-        for icoord=1:numel(SingleCellU)% look for coincidence of dimension with one of the dimensions of the scalar 
-            if strcmp(dimname_vec_y,SingleCellU{icoord})% a singleton dimension
-                errormsg=['the singleton dimension ' dimname_vec_y ' has been selected for ordinate'];
-                return
-            end
-        end
-        for icoord=1:numel(DimCellU)% look for coincidence of dimension with one of the dimensions of the scalar 
-             if strcmp(dimname_vec_y,DimCellU{icoord})% a dimension variable
-                 dimU=[dimU icoord];
-                 break
-             end
-        end
-    end
-    if test_xdimvar
-        for icoord=1:numel(SingleCellU)% look for coincidence of dimension with one of the dimensions of the scalar
-            if strcmp(dimname_x,SingleCellU{icoord})% a singleton dimension
-                errormsg=['the singleton dimension ' dimname_vec_x ' has been selected for abscissa'];
-                return
-            end
-        end
-        for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 
-             if strcmp(dimname_vec_x,DimCellU{icoord})% a dimension variable
-                 dimU=[dimU icoord];
-                 break
-             end
-        end
-    end
-    dimextra=(1:numel(DimCellU));
-    dimextra(dimU)=[]; %list of unselected dimension indices
-    DimCellU=DimCellU([dimU dimextra]);
-    eval(['SubField.' VarNameU '=permute(squeeze(SubField.' VarNameU '),[dimU dimextra]);'])
-    eval(['SubField.' VarNameV '=permute(squeeze(SubField.' VarNameV '),[dimU dimextra]);'])
-    SubField.VarDimName{VarSubIndexU}=DimCellU;
-    SubField.VarDimName{VarSubIndexV}=DimCellU;
-    
-    %add default coord_x and/or coord_y if empty
-    if empty_coord_vec_x || empty_coord_vec_y
-        VarName=Field.ListVarName{field_var_index};
-        DimCell=Field.VarDimName{field_var_index};    
-        eval(['npxy=size(SubField.' VarName ')'])
-        if numel(npxy) < numel(DimCell)
-            DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 
-        end
-        ind_select=find(npxy~=1) ;%look for non singleton dimensions
-        DimCell=DimCell(ind_select);
-        npxy=npxy(ind_select);
-        testold=0;
-    %old convention; use of coord_1 and Coord_2
-        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
-            if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1')
-                Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
-                Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
-                testold=1;
-            end
-        end
-        if empty_coord_vec_x        
-                coord_x_name=DimCell{2};
-                SubField.ListVarName=[{coord_x_name} SubField.ListVarName];
-                SubField.VarDimName=[{coord_x_name} SubField.VarDimName];  
-                if testold
-                    eval(['SubField.' coord_x_name '=linspace(Coord_2(1),Coord_2(end),npxy(2));'])
-                else
-                    eval(['SubField.' coord_x_name '=[0.5 npxy(2)-0.5];'])
-                end
-            
-            if ~testold
-                coord_x_attr.units='index';
-            else
-                coord_x_attr.units='cm';
-            end
-            SubField.VarAttribute=[{coord_x_attr} SubField.VarAttribute];  
-        end
-        if empty_coord_vec_y 
-            coord_y_name=DimCell{1};
-            SubField.ListVarName=[{coord_y_name} SubField.ListVarName];
-            SubField.VarDimName=[{coord_y_name} SubField.VarDimName];
-            if testold
-                eval(['SubField.' coord_y_name '=linspace(Coord_1(1),Coord_1(end),npxy(1));']) 
-            else
-                eval(['SubField.' coord_y_name '=[npxy(1)-0.5 0.5];'])
-            end
-            if ~testold
-                coord_y_attr.units='index';
-            else
-                coord_y_attr.units='cm';
-            end
-            SubField.VarAttribute=[{coord_y_attr} SubField.VarAttribute];       
-        end
-    end
-end
-if test_1Dplot 
-    for ilist=1:numel(VarIndex_y)
-        VarName=Field.ListVarName{VarIndex_y(ilist)};
-        eval(['npxy=size(SubField.' VarName ');'])
-        ind_select=find(npxy~=1);
-        SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}(ind_select);
-        eval(['SubField.' VarName '=squeeze(SubField.' VarName ');'])%remove singleton dimensions
-        if testpermute(ilist)
-            eval(['SubField.' VarName '=permute(SubField.' VarName ',[2 1]);'])
-            subvarindex(ilist)
-            SubField.VarDimName{subvarindex(ilist)}
-            SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}([2 1]);
-        end
-    end
-    if empty_coord_x
-        SubField.ListVarName=[{[coord_x_name '_index']} SubField.ListVarName];
-        SubField.VarDimName=[{coord_x_name } SubField.VarDimName];
-        VarName=Field.ListVarName{VarIndex_y(1)};
-        DimCell=Field.VarDimName{VarIndex_y(1)};    
-        eval(['npxy=size(SubField.' VarName ')'])
-        if numel(npxy) < numel(DimCell)
-            DimCell=DimCell(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 
-        end
-        ind_select=find(npxy~=1) ;%look for non singleton dimensions
-        DimCell=DimCell(ind_select);
-        npxy=npxy(ind_select);
-        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=VarIndex_y(1) ...
-                             && isfield(Field.VarAttribute{VarIndex_y(1)},'Coord_1')
-             Coord_1=Field.VarAttribute{VarIndex_y(1)}.Coord_1;%old convention; use of coord_1 
-             eval(['SubField.' coord_x_name '_index=linspace(Coord_1(1),Coord_1(end),npxy(1));']) 
-        else
-            eval(['SubField.' coord_x_name '_index=linspace(0.5,npxy(1)-0.5,npxy(1));']) 
-        end
-        struct.Role='coord_x';
-        SubField.VarAttribute=[{struct} SubField.VarAttribute];
-    end
-end
-
-%-------------------------------------------------
-% give index numbers of the strings str in the list ListvarName
-function VarIndex_y=name2index(cell_str,ListVarName)
-VarIndex_y=[];
-if ischar(cell_str)
-    for ivar=1:length(ListVarName)
-        varlist=ListVarName{ivar};
-        if isequal(varlist,cell_str)
-            VarIndex_y= ivar;
-            break
-        end
-    end
-elseif iscell(cell_str)
-    for isel=1:length(cell_str)
-        varsel=cell_str{isel};
-        for ivar=1:length(ListVarName)
-            varlist=ListVarName{ivar};
-            if isequal(varlist,varsel)
-                VarIndex_y=[VarIndex_y ivar];
-            end
-        end
-    end
-end
Index: unk/src/read_imadoc.m
===================================================================
--- /trunk/src/read_imadoc.m	(revision 7)
+++ 	(revision )
@@ -1,243 +1,0 @@
-%'read_imadoc': reads the xml file for image documentation, OBSOLETE: replaced by imadoc2struct
-%
-%function [error,Heading,nom_type_ima,ext_ima,abs_time,TimeUnit,mode,NbSlice,npx,npy,GeometryCalib]=read_imadoc(filecivxml,testime) 
-%--------------------------------------------------------
-% OUTPUT:
-%error= 0: all right
-%        2: input file not found
-%        1: input file is not an image documentation file 'ImaDoc'
-%           1.1: 'ImaDoc/Heading' element absent
-%           1.2: 'ImaDoc/Camera' element absent
-%                 1.21: 'ImaDoc/Camera/BurstTiming' absent
-%                     1.211: 'ImaDoc/Camera/BurstTiming/FrameFrequency' absent
-%                     1.212: 'ImaDoc/Camera/BurstTiming/Time' absent
-%
-% INPUT:
-% filecivxml: full name of the xml input file
-% testime=1 read the list of times), =0 (default) do not read it to save computing  time
-%
-%  -- TODO: should be replaced by xml2struct --
-
-function [error,Heading,nom_type_ima,ext_ima,abs_time,TimeUnit,mode,NbSlice,npx,npy,GeometryCalib]=read_imadoc(filecivxml,testime) 
-% global t
-error=0;%default
-Heading=[];%default
-nom_type_ima=[];%default
-ext_ima=[];%default
-abs_time=[];%initiation
-TimeUnit='s'; %default
-% GeometryCalib.CoordUnit='cm';%default
-mode=[]; %default
-NbSlice=1;%default
-npx=[];%default
-npy=[];%default
-% GeometryCalib.Pxcmx=1;
-% GeometryCalib.Pxcmy=1;
-GeometryCalib=[];
-NbDtj=1;
-tsai=[];%default
-if ~exist('testime','var')
-    testime=1;%default
-end
-if exist(filecivxml,'file')~=2, error=2, return;end;%input file does not exist
-filecivxml;
-t=xmltree(filecivxml);
-uid_root=find(t,'/ImaDoc');
-if isempty(uid_root), error=1; return; end;%not an ImaDoc .xml file
-%Heading
-uid_Heading=find(t,'/ImaDoc/Heading');
-if isempty(uid_Heading), 
-    error=1.1;
-else
-    uid_Campaign=find(t,'/ImaDoc/Heading/Campaign');
-    uid_Exp=find(t,'/ImaDoc/Heading/Experiment');
-    uid_Device=find(t,'/ImaDoc/Heading/Device');
-    uid_Record=find(t,'/ImaDoc/Heading/Record');
-    uid_FirstImage=find(t,'/ImaDoc/Heading/ImageName');
-    Heading.Campaign=get(t,children(t,uid_Campaign),'value');
-    Heading.Experiment=get(t,children(t,uid_Exp),'value');
-    Heading.Device=get(t,children(t,uid_Device),'value');
-    if ~isempty(uid_Record)
-        Heading.Record=get(t,children(t,uid_Record),'value');
-    end
-    Heading.ImageName=get(t,children(t,uid_FirstImage),'value');
-    FirstImage=Heading.ImageName;
-    if ~isempty(FirstImage)
-        [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type_ima]=name2display(FirstImage);
-    end
-end
-%Camera   
-uid_Camera=find(t,'/ImaDoc/Camera');
-if isempty(uid_Camera)
-    error=1.2;
-else
-    uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');
-    if ~isempty(uid_ImageSize);
-        ImageSize=get(t,children(t,uid_ImageSize),'value');
-        xindex=findstr(ImageSize,'x');
-        if length(xindex)>=2
-            npx=str2num(ImageSize(1:xindex(1)-1));
-            npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1));
-        end
-    end
-    uid_NbSlice=find(t,'/ImaDoc/Camera/NbSlice');
-    if ~isempty(uid_NbSlice)
-        NbSlice=str2num(get(t,children(t,uid_NbSlice),'value'));
-        if isempty(NbSlice),NbSlice=1;end; %default
-    end
-    uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');
-    if ~isempty(uid_TimeUnit)
-        TimeUnit=get(t,children(t,uid_TimeUnit),'value');
-        if isempty(TimeUnit),TimeUnit='s';end; %default
-    end
-    uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');
-    if isempty(uid_BurstTiming), error=1.12,return,end;
-    if testime
-        for k=1:length(uid_BurstTiming)
-            Dtj=[];%default
-            NbDtj=1;%default
-            subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming
-            uid_FrameFrequency=find(subt,'/BurstTiming/FrameFrequency');
-           % if isempty(uid_FrameFrequency), error=1.211,return;
-            if isempty(uid_FrameFrequency),
-                Frequency=1;
-            else
-                Frequency=str2num(get(subt,children(subt,uid_FrameFrequency),'value'));
-            end
-            uid_Dtj=find(subt,'/BurstTiming/Dtj');
-            uid_NbDtj=find(subt,'/BurstTiming/NbDtj');
-            uid_Dti=find(subt,'/BurstTiming/Dti');%new
-            uid_NbDti=find(subt,'/BurstTiming/NbDti');%new
-            if ~isempty(uid_Dtj)
-               Dtj=str2num(get(subt,children(subt,uid_Dtj),'value'));%time intervals in frames
-            end
-            uid_child=children(subt,uid_NbDtj);
-            for ivalue=1:length(uid_child)
-                if isequal(get(subt,uid_child(ivalue),'type'),'chardata')
-                     NbDtj=str2num(get(subt,uid_child(ivalue),'value'));%nbre of intervals Dtj
-               end
-            end
-            if isempty(uid_Dti)|isempty(uid_NbDti)
-               Dti=[]; %default
-            else
-               Dti=str2num(get(subt,children(subt,uid_Dti),'value'));%time intervals in frames
-               uid_child=children(subt,uid_NbDti);
-               for ivalue=1:length(uid_child)
-                  if isequal(get(subt,uid_child(ivalue),'type'),'chardata')
-                     NbDti=str2num(get(subt,uid_child(ivalue),'value'));%nbre of intervals Dti
-                  end
-               end
-            end
-            if ~isempty(Dtj)
-                Dtj=reshape(Dtj'*ones(1,NbDtj),1,length(Dtj)*NbDtj);
-            end
-            Dtj=[0 Dtj];
-            dtunit=Dtj/Frequency;
-            uid_Time=find(subt,'/BurstTiming/Time');
-            if isempty(uid_Time)
-                error=1.212;
-            else
-                nbfield=length(uid_Time);
-               Time=get(subt,children(subt,uid_Time),'value');
-               abstime_read=str2num(char(Time))*ones(1,length(Dtj))+ones(nbfield,1)*cumsum(dtunit);
-               abs_time=[abs_time;abstime_read];
-               if ~isempty(Dti)&size(abs_time,1)==1
-                  abs_time=ones(NbDti+1,1)*abs_time+(Dti/Frequency)*[0:NbDti]'*ones(size(abs_time));
-               end
-            end
-        end
-    end
-end
-% if isempty(abs_time)
-%     abs_time=0;%default
-% end
-%read calibration
-uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');
-if ~isempty(uid_GeometryCalib)
-    if length(uid_GeometryCalib)>1
-        errordlg(['More than one GeometryCalib in ' filecivxml])
-        return
-    end
-    subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib
-    cont=get(subt,1,'contents');
-    if ~isempty(cont)
-        uid_pixcmx=find(subt,'/GeometryCalib/Pxcmx');
-        uid_pixcmy=find(subt,'/GeometryCalib/Pxcmy');
-        if ~isempty(uid_pixcmx) & ~isempty(uid_pixcmy)%NON UTILISE 
-           pixcmx=str2num(get(subt,children(subt,uid_pixcmx),'value'));
-            if isempty(pixcmx),pixcmx=1;end; %default
-            pixcmy=str2num(get(subt,children(subt,uid_pixcmy),'value'));
-            if isempty(pixcmy),pixcmy=1;end; %default
-            tsai.Pxcmx=pixcmx;
-            tsai.Pxcmy=pixcmy;
-        end
-        %default values:
-        tsai.f=1;
-        tsai.dpx=1;
-        tsai.dpy=1;
-        tsai.sx=1;
-        tsai.Cx=0;
-        tsai.Cy=0;
-        tsai.Tz=1;
-        tsai.Tx=0;
-        tsai.Ty=0;
-        tsai.R=[1 0 0; 0 1 0; 0 0 0];
-        tsai.kappa1=0;
-        uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');
-        if ~isempty(uid_CoordUnit) 
-            tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');
-        end
-        uid_focal=find(subt,'/GeometryCalib/focal');
-        uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');
-        uid_sx=find(subt,'/GeometryCalib/sx');
-        uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');
-        uid_kappa1=find(subt,'/GeometryCalib/kappa1');
-        uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');
-        uid_R=find(subt,'/GeometryCalib/R');
-        if ~isempty(uid_focal) & ~isempty(uid_dpx_dpy) & ~isempty(uid_Cx_Cy)
-            tsai.f=str2num(get(subt,children(subt,uid_focal),'value'));
-            dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));
-            tsai.dpx=dpx_dpy(1);
-            tsai.dpy=dpx_dpy(2);
-            if ~isempty(uid_sx)
-               tsai.sx=str2num(get(subt,children(subt,uid_sx),'value')); 
-            end
-            Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));
-            tsai.Cx=Cx_Cy(1);
-            tsai.Cy=Cx_Cy(2);
-        end
-        if ~isempty(uid_Tx_Ty_Tz) 
-            Tx_Ty_T_char=get(subt,children(subt,uid_Tx_Ty_Tz),'value');
-%             if ~ischar(Tx_Ty_T_char)
-%                 error='multiple values for Tx_Ty_Tz';
-%             else
-                Tx_Ty_Tz=str2num(Tx_Ty_T_char);
-%             end
-            tsai.Tx=Tx_Ty_Tz(1);
-            tsai.Ty=Tx_Ty_Tz(2);
-            tsai.Tz=Tx_Ty_Tz(3);
-        end
-        if ~isempty(uid_R)
-            RR=get(subt,children(subt,uid_R),'value');
-            if length(RR)==3
-                tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];
-            end
-        end
-        if ~isempty(uid_kappa1)     
-            tsai.kappa1=str2num(get(subt,children(subt,uid_kappa1),'value'));
-        end
-        %look for laser plane definitions   
-        uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');
-        uid_Pos=find(subt,'/GeometryCalib/PlanePos');
-        if ~isempty(uid_Angle) 
-            tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));
-        end
-        if ~isempty(uid_Pos)
-            for j=1:length(uid_Pos)
-                tsai.PlanePos(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));
-            end
-        end
-        GeometryCalib=tsai;
-    end
-end   
-
Index: unk/src/read_image.m
===================================================================
--- /trunk/src/read_image.m	(revision 7)
+++ 	(revision )
@@ -1,36 +1,0 @@
-%'read_image': reads an image from a single file or a movie file
-function [A,error]=read_image(filename,NomType,num);
- %read  images in different formats. 
-A=[]; %default
-error=0; %default
-if ~exist(filename,'file')
-    error='input file not found in read_image'
-    return
-end
-testframe=0;
-if ~exist('NomType','var')
-    NomType=[];
-end
-if ~exist('num','var')
-    num=1;
-end
-[pth,fl,ext]=fileparts(filename);
-if isequal(lower(ext),'.avi')
-    mov=aviread(filename,num);
-    A=frame2im(mov(1));
-elseif isequal(lower(ext),'.vol')
-     A=imread(filename);
-else
-     form=imformats(ext([2:end]));
-     if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
-         if isequal(NomType,'*');
-            A=imread(filename,num);
-         else 
-           A=imread(filename);  
-         end
-     else
-         error=['ERROR in read_image: file extension not recognized by matlab as image'];
-         return
-     end
-end
- 
Index: unk/src/read_imatext.m
===================================================================
--- /trunk/src/read_imatext.m	(revision 7)
+++ 	(revision )
@@ -1,30 +1,0 @@
-%'read_imatext': reads the .civ file for image documentation (obsolete)
-% fileinput: name of the documentation file 
-% time: matrix of times for the set of images
-%pxcmx: scale along x in pixels/cm
-%pxcmy: scale along y in pixels/cm
-function [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext(fileinput);
-error=0;%default
-time=[]; %default
-TimeUnit='s';
-mode='pairs';
-npx=[]; %default
-npy=[]; %default
-pxcmx=1;%default
-pxcmy=1;%default
-if exist(fileinput,'file')~=2, error=2, return;end;%input file does not exist
-dotciv=textread(fileinput);
-sizdot=size(dotciv);
-if ~isequal(sizdot(1)-8,dotciv(1,1));
-    error=1; %inconsistent number of bursts
-end
-nbfield=sizdot(1)-8;
-npx=(dotciv(2,1));
-npy=(dotciv(2,2));
-pxcmx=(dotciv(6,1));% pixels/cm in the .civ file 
-pxcmy=(dotciv(6,2));
-% nburst=dotciv(3,1); % nbre of bursts
-abs_time1=dotciv([9:nbfield+8],2);
-dtime=dotciv(5,1)*(dotciv([9:nbfield+8],[3:end-1])+1);
-timeshift=[abs_time1 dtime];
-time=cumsum(timeshift,2);
Index: unk/src/read_plot_param.m
===================================================================
--- /trunk/src/read_plot_param.m	(revision 7)
+++ 	(revision )
@@ -1,52 +1,0 @@
-%'read_plot_param':  read plotting parameters from the interface uvmat
-%------------------------------------------
-% function PlotParam=read_plot_param(handles)
-%
-% OUTPUT:
-% PlotParam: structure containing the values of all the relevant plotting parameters 
-%
-% INPUT: 
-% handles: structure containing the handles of the relevant uicontrols in the uvmat interface 
-%
-%      -- TODO:   get the handles using get_plot_handles and findobj as  default input --
-
-function PlotParam=read_plot_param(handles)
-
-PlotParam.Auto_xy=get(handles.auto_xy,'Value');
-
-% scalars
-Scalar.MaxA=str2double(get(handles.MaxA,'String'));
-Scalar.MinA=str2double(get(handles.MinA,'String'));
-Scalar.AutoScal=get(handles.AutoScal,'Value');
-Scalar.BW=get(handles.BW,'Value');
-Scalar.Contours=get(handles.Contours,'Value')==2;
-Scalar.IncrA=str2double(get(handles.IncrA,'String'));
-PlotParam.Scalar=Scalar;
-
-%vectors
-Vectors.VecScale=str2double(get(handles.VecScale,'String'));
-Vectors.AutoVec=get(handles.AutoVec,'Value');%automatic vector length
-Vectors.HideFalse=get(handles.HideFalse,'Value');
-Vectors.HideWarning=get(handles.HideWarning,'Value');
-Vectors.decimate4=get(handles.decimate4,'Value');% =1; for reducing the nbre of vectors
-
-%vector color
-code_list=get(handles.color_code,'String');
-val=get(handles.color_code,'Value');
-% menu_col=get(handles.col_vec,'String');
-% menu_val=get(handles.col_vec,'Value');
-colcode1=str2double(get(handles.colcode1,'String'));% first threshold for rgb, first value for'continuous' 
-colcode2=str2double(get(handles.colcode2,'String'));% second threshold for rgb, last value (saturation) for 'continuous' 
-
-Vectors.ColorCode=code_list{val}; % option of color code for vectors
-Vectors.FixedCbounds=get(handles.AutoVecColor,'Value');% =1; fixed scale for color vector, =0 otherwise (default)
-Vectors.MinC=str2num(get(handles.min_vec,'String')); % imposed min of C, (needed if .FixedCbounds=1)
-Vectors.MaxC=str2num(get(handles.max_vec,'String')); % imposed max of C, needed if .FixedCbounds=1
-if Vectors.MaxC <= Vectors.MinC
-    Vectors.ColorCode='black';
-else
-    Vectors.colcode1=Vectors.MinC+(colcode1-Vectors.MinC)/(Vectors.MaxC-Vectors.MinC);% relative thresholds
-    Vectors.colcode2=Vectors.MinC+(colcode2-Vectors.MinC)/(Vectors.MaxC-Vectors.MinC);
-end
-PlotParam.Vectors=Vectors;
-
Index: unk/src/read_set_object.m
===================================================================
--- /trunk/src/read_set_object.m	(revision 7)
+++ 	(revision )
@@ -1,210 +1,0 @@
-%'read_set_object': read the data on the 'set_object' interface
-%--------------------------------------------------------
-% data=read_set_object(handles)
-%--------------------------------------------------------
-%OUTPUT
-%data: structure of data read on the set_object interface
-%    .Style : style of projection object
-%    .Coord(nbpos,3): set of coordinates defining the object position;
-%    .ProjMode=type of projection ;
-%    .Phi=angle of projection;
-%    .DX,.DY,.DZ=increments;
-%    .YMax,YMin: min and max Y
-%INPUT:
-% handles: structure describing the tags of the edit boxes and menus
-function data=read_set_object(handles)
-%menus 
-if isfield(handles,'ObjectStyle')%case of the set_object interface
-	menu=get(handles.ObjectStyle,'String');
-	value=get(handles.ObjectStyle,'Value');
-	data.Style=menu{value};
-	menu=get(handles.ProjMode,'String');
-	value=get(handles.ProjMode,'Value');
-	data.ProjMode=menu{value};
-	menu=get(handles.MenuCoord,'String');
-	value=get(handles.MenuCoord,'Value');
-	data.CoordType=menu{value};
-    testcalib=0;
-else %default
-    data.Style='points';
-    testcalib=1;
-end
-
-%Euler angles and projection ranges
-if ~testcalib
-	if isequal(get(handles.Phi,'Visible'),'on')
-        data.Phi=str2num(get(handles.Phi,'String'));
-	end
-	if isequal(get(handles.Theta,'Visible'),'on')
-        data.Theta=str2num(get(handles.Theta,'String'));
-	end
-	if isequal(get(handles.Psi,'Visible'),'on')
-        data.Psi=str2num(get(handles.Psi,'String'));
-    end	
-	if isequal(get(handles.DX,'Visible'),'on')
-        data.DX=str2num(get(handles.DX,'String'));
-	end
-	if isequal(get(handles.DY,'Visible'),'on')
-        data.DY=str2num(get(handles.DY,'String'));
-	end
-	if isequal(get(handles.DZ,'Visible'),'on')
-        data.DZ=str2num(get(handles.DZ,'String'));
-    end
-    dimrange=[1 1];%default
-    if isequal(get(handles.ZMin,'Visible'),'on')
-        ZMin=str2num(get(handles.ZMin,'String'));
-        if ~isempty(ZMin)
-           data.RangeZ(1)=ZMin;
-           dimrange=[2 3];
-        end
-    end
-	if isequal(get(handles.ZMax,'Visible'),'on')
-        ZMax=str2num(get(handles.ZMax,'String'));
-        if isempty(ZMax)
-            if dimrange(1)>1
-%                 set(handles.ZMax,'String',get(handles.ZMin,'String'))
-                data.RangeZ(1)=ZMax;
-            end
-        else 
-           data.RangeZ=ZMax;
-           dimrange=[dimrange(1) 3];
-        end
-    end
-    if isequal(get(handles.YMin,'Visible'),'on')
-        YMin=str2num(get(handles.YMin,'String'));
-        if isempty(YMin) 
-%             if dimrange(2)>2
-% %                 set(handles.YMin,'String','0')
-%                 data.RangeY(2)=0;
-%             end
-        else
-            data.RangeY(2)=YMin;
-            dimrange=[2 max(dimrange(2),2)];
-        end
-    end
-    if isequal(get(handles.YMax,'Visible'),'on')
-%         data.YMax=str2num(get(handles.YMax,'String'));
-        YMax=str2num(get(handles.YMax,'String'));
-        if isempty(YMax) 
-%             if dimrange(1)>1
-% %                 set(handles.YMax,'String',get(handles.YMin,'String'))
-%                 if ~isempty(YMin)
-%                 data.RangeY(1)=YMin;
-%                 end
-%             elseif dimrange(2)>2
-% %                 set(handles.YMax,'String',get(handles.ZMin,'String'))
-%                 data.RangeY(2)=ZMin;
-%             end
-        else
-            data.RangeY(1)=YMax;
-            dimrange=[dimrange(1) max(dimrange(2),2)];
-        end
-    end
-    if isequal(get(handles.XMin,'Visible'),'on')
-        XMin=str2num(get(handles.XMin,'String'));
-        if isempty(XMin) 
-%             if ~isempty(YMin)
-%                 if dimrange(2)>1
-% %                     set(handles.XMin,'String',get(handles.YMin,'String'))
-%                     data.RangeX(2)=YMin;
-%                     XMin=YMin;
-%                 end
-%             end
-        else
-            data.RangeX(2)=XMin;
-            %dimrange=[2 max(dimrange(2),1)];
-        end
-	end
-	if isequal(get(handles.XMax,'Visible'),'on')
-         XMax=str2num(get(handles.XMax,'String'));
-         if isempty(XMax) 
-%             if dimrange(1)>1
-% %                 set(handles.XMax,'String',get(handles.XMin,'String'))
-%                 if ~isempty(XMin)
-%                 data.RangeX(2)=XMin;
-%                 end
-%             elseif dimrange(2)>1
-% %                 set(handles.XMax,'String',get(handles.YMax,'String'))
-%                 data.RangeX(1)=YMax;
-%             end
-        else
-            data.RangeX(1)=XMax;
-         end
-    end
-end
-
-
-%positions x,y,z
-Xcolumn=get(handles.XObject,'String');
-Ycolumn=get(handles.YObject,'String');
-if ischar(Xcolumn)
-    sizchar=size(Xcolumn);
-    for icol=1:sizchar(1)
-        Xcolumn_cell{icol}=Xcolumn(icol,:);
-    end
-    Xcolumn=Xcolumn_cell;
-end
-if ischar(Ycolumn)
-    sizchar=size(Ycolumn);
-    for icol=1:sizchar(1)
-        Ycolumn_cell{icol}=Ycolumn(icol,:);
-    end
-    Ycolumn=Ycolumn_cell;
-end
-Zcolumn={};%default
-if isequal(get(handles.ZObject,'Visible'),'on')
-    data.NbDim=3; %test 3D object
-    Zcolumn=get(handles.ZObject,'String');
-    if ischar(Zcolumn)
-        Zcolumn={Zcolumn};
-    end
-end
-nb_points=min(length(Xcolumn),length(Ycolumn));%number of point positions needed to define the object position
-if isequal (data.Style,'line');
-    nb_defining_points=2;
-elseif isequal(data.Style,'plane')|isequal(data.Style,'rectangle')|isequal(data.Style,'ellipse')
-    nb_defining_points=1;
-else
-    nb_defining_points=nb_points;
-end
-data_XObject=[];
-data_YObject=[];
-data_ZObject=[];
-for i=1:nb_points
-    Xnumber=str2num(Xcolumn{i});
-    Ynumber=str2num(Ycolumn{i});
-    if isempty(Xnumber)|isempty(Ynumber)
-        break
-    else
-        data_XObject=[data_XObject; Xnumber(1)];
-        data_YObject=[data_YObject; Ynumber(1)];
-    end
-    if length(Zcolumn)<i | isempty(str2num(Zcolumn{i}))
-        data_ZObject=[data_ZObject; 0];
-    else
-        data_ZObject=[data_ZObject; str2num(Zcolumn{i})];
-    end
-end
-if nb_defining_points > nb_points
-    for i=nb_points+1:nb_defining_points
-        data_XObject=[0;data_XObject];
-        data_YObject=[0;data_YObject];
-        data_ZObject=[0;data_ZObject];
-    end
-end
-if isempty(data_XObject)
-    data_XObject=0;
-end
-if isempty(data_YObject)
-    data_YObject=0;
-end
-if isempty(data_ZObject)
-    data_ZObject=0;
-end
-data.Coord=[data_XObject data_YObject data_ZObject];
-
-set(handles.XObject,'String',mat2cell(data_XObject,length(data_XObject)))%correct the interface display
-set(handles.YObject,'String',mat2cell(data_YObject,length(data_XObject)))
-set(handles.ZObject,'String',mat2cell(data_ZObject,length(data_XObject)))
-
-
Index: unk/src/read_xls.m
===================================================================
--- /trunk/src/read_xls.m	(revision 7)
+++ 	(revision )
@@ -1,328 +1,0 @@
-%'read_xls': function for reading and displaying Excel files  
-%------------------------------------------------------------------------
-% function [hfig_xls]=read_xls(fileinput,hfig)
-% 
-% OUTPUT:
-%  hfig_xls: figure handle for display
-%
-% INPUT:
-% fileinput: name of the input file (char string)
-% hfig: handle of the display figure (a new display figure hfig_xls is created if hfig undefined)
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function [hfig_xls]=read_xls(fileinput,hfig)
-[Tabnum,Tabtext]=xlsread(fileinput);
-    [textnx,textny]=size(Tabtext);
-    [numnx,numny]=size(Tabnum);
-    ilastxt=textnx-numnx;%index of last text row
-    jlastxt=textny-numny;%index of last text column
-    for jtab=1:textny%read line
-        for itab=1:textnx% read column
-            textlu=cell2mat(Tabtext(itab,jtab));
-            if isequal(textlu,[])& itab > ilastxt & jtab > jlastxt %replace txt by number
-                textlu=num2str(Tabnum(itab-ilastxt,jtab-jlastxt));
-            end
-            Tabdisplay(itab,jtab)={textlu};
-            lengthtext(itab)=length(textlu);
-        end
-        widthcolumn(jtab)=max(lengthtext);
-    end
-    Tabchar={};%default
-    for itab=1:textnx    %justify table
-        charchain=[];         
-        for jtab=1:textny% read line
-            textlu=Tabdisplay{itab,jtab};
-            if widthcolumn(jtab)>length(textlu)
-                blankstr=char(46*ones(1,widthcolumn(jtab)-length(textlu)));
-                textlu=[textlu blankstr ];
-            end
-            charchain=[charchain textlu char(9) ' | '];
-        end
-        Tabchar(itab)={charchain};
-    end 
-    if exist('hfig','var') & ishandle(hfig)
-        figure(hfig);
-        hfig_xls=hfig;
-    else
-        hfig_xls=figure;
-    end
-    set(hfig_xls,'Name',fileinput)
-    set(hfig_xls,'MenuBar','none')
-    hpos=get(hfig_xls,'Pos');
-    ExpName.cell=Tabtext([2:textnx],1);%first column (dir name)
-    ExpName.Num=Tabnum;
-%     ExpName.Units=Tabtext(2,[2:textny]);%look for the units line (needs to be the second line)
-    iparam=0;
-    for icol=2:textny
-%         Tabtext(2,icol)
-        if ~isempty(Tabtext{2,icol})&~isequal(Tabtext{2,icol},'')
-            iparam=iparam+1;
-            ExpName.Param{iparam}=Tabtext{1,icol};
-            ExpName.Units{iparam}=Tabtext{2,icol};
-            ExpName.Column(iparam)=icol;
-        end
-    end
- 
-    ExpName.path=fileparts(fileinput);
-    h=uicontrol('Style','listbox', 'Position', [5 5 0.9*hpos(3) 0.9*hpos(4)], 'String', Tabchar, ...
-        'FontName','Monospaced','Callback',@link2file,'UserData',ExpName,'Tag','listbox');  
-%     hh=uicontrol('Style','Pushbutton', 'Position', [0.93*hpos(1) 0.93*hpos(2) 0.05*hpos(3) 0.05*hpos(4)], 'String', 'Update','Callback',@project_update);
-%      set(h,'HorizontalAlignment','left')
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%called by xlsdisplay to navigate from  a .xls file or create the
-% the experiment directories
-function link2file(obj,event,fileinput)
-global t
-bla=get(gcbo,'String');
-ind=get(gcbo,'Value')
-if (ind==1|ind==2),return,end; %no action on the first line
-ExpNameStruct=get(gcbo,'UserData')
-ExpName=ExpNameStruct.cell{ind-1}
-ProjectFullName=ExpNameStruct.path;%full name of the project (including path)
-[Pth,ProjectName]=fileparts(ProjectFullName);
-ExpPath=fullfile(ProjectFullName,ExpName);% full name of the experiment directory
-ExpDocName=fullfile(ExpPath,[ExpName '.xml']);% full name of the .xml file ExpDoc
-if exist(ExpDocName,'file')
-    hh=editxml({ExpDocName})   
-%     [FileName, PathName, filterindex] = uigetfile( ...
-%        {'*.xml','(*.xml)';
-%        '*.xml',  '.xml files '; 
-%         '*.*',  'All Files (*.*)'}, ...
-%         'Pick a file',ExpDocName);
-%      fileinput=[PathName FileName];%complete file name
-%      sizf=size(fileinput);
-%     if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
-%         [path,name,ext]=fileparts(fileinput);
-%     if isequal(ext,'.civ') | isequal(ext,'.log') | isequal(ext,'.cmx') isequal(ext,'.txt')
-%         edit(fileinput)
-%     elseif isequal(ext,'.xml')
-%         varargin{1}=fileinput;
-%         editxml(varargin)
-%     elseif isequal(ext,'.fig')
-%         open(fileinput)
-%     elseif isequal(ext,'.xls')
-%         xlsdisplay(fileinput)
-%     else
-%         uvmat({fileinput})
-%     end
-else
-    answer=questdlg({['ExpDoc file ' ExpDocName ' does not exist, create the experiment?'];''})
-    if isequal(answer,'Yes')
-        if exist(ExpPath,'dir')~=7 %create a directory if it does not exist
-            dircur=pwd; %current working directory
-            cd(ProjectFullName);
-            [m1,m2,m3]=mkdir(ExpName);
-            cd(pwd);%come back to the initial working dir
-        end
-%         %copy exp parameters
-        ParamNames=ExpNameStruct.Param;
-        ParamValues=ExpNameStruct.Num(ind-1,ExpNameStruct.Column-1);
-        ParamUnits=ExpNameStruct.Units;
-        t=xmltree;%new xmltree
-        t=set(t,1,'name','ExpDoc');
-        t=attributes(t,'add',1,'xmlns:xsi','none');
-        [t,ExpElement]=add(t,1,'element','Exp');
-        [t]=add(t,ExpElement,'chardata',ExpName);
-        for iparam=1:length(ParamNames)
-            [t,ParamElement]=add(t,1,'element',ParamNames{iparam});
-            t=add(t,ParamElement,'chardata',num2str(ParamValues(iparam)));
-            t=attributes(t,'add',ParamElement,'unit',ParamUnits{iparam}); %ADD UNIT ATTRIBUTE
-        end
-        list_dir=dir(ExpPath);%list of the Exp directory,  detect sub-directories,.xml and image files
-        nbdir_exp=0;
-        %scan the Exp directory
-        for idir_exp=3:length(list_dir)
-            %detect subdirectories  
-            if list_dir(idir_exp).isdir% 'device' subdirectories
-                nbdir_exp=nbdir_exp+1;
-                ExpData.Device{nbdir_exp}=list_dir(idir_exp).name;
-                [t,DeviceElement]=add(t,1,'element',list_dir(idir_exp).name);
-                t=attributes(t,'add',DeviceElement,'type','DEVICE_DIR');
-                t=attributes(t,'add',DeviceElement,'source','dir');
-                list_subdir=dir(fullfile(ExpPath,list_dir(idir_exp).name));
-                nbsubdir=0;
-                testrecord=1;
-                RootIma='';
-                RootNc='';
-                nbfile=0;
-%                 nbfile={};
-                %scan the Device subdirectory
-                for isubdir=3:length(list_subdir)
-                    if list_subdir(isubdir).isdir
-                        nbsubdir=nbsubdir+1;
-                        Device.Record{nbsubdir}=list_subdir(isubdir).name;
-                    else
-                        nbfile=nbfile+1;
-                        fname{nbfile}=list_subdir(isubdir).name;
-                    end
-                end
-                if isunix%sort by root names and indices , change the separator '_' so that 1_1 come as the first name
-                    fname_mod=regexprep(fname,'_','/');
-                    fname_mod=sort(fname_mod);     %sort by name
-                    fname=regexprep(fname_mod,'/','_');
-                end
-                for ifile=1:nbfile;
-                    [Path,Name,Ext]=fileparts(fname{ifile});
-                    if isequal(Ext,'.xml')
-                       [t,ImaDocElement]=add(t,DeviceElement,'element','ImaDoc');
-                       t=add(t,ImaDocElement,'chardata',fname{ifile});
-                       t=attributes(t,'add',ImaDocElement,'source','file');
-                       testrecord=0;%we have an image series without 'record' subdir
-                    elseif isequal(Ext,'.png')
-                       [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
-                       if ~isequal(Root,RootIma)%only one image recorded for each root name
-                           [t,ImaDocElement]=add(t,DeviceElement,'element','Image');
-                           t=add(t,ImaDocElement,'chardata',fname{ifile});
-                           t=attributes(t,'add',ImaDocElement,'source','file');
-                           RootIma=Root;
-                       end
-                       testrecord=0;%we have an image series without 'record' subdir
-                    elseif isequal(Ext,'.nc')
-                       [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
-                       if ~isequal(Root,RootNc)%only one image recorded for each root name
-                           [t,ImaDocElement]=add(t,DeviceElement,'element','Ncdata');
-                           t=add(t,ImaDocElement,'chardata',fname{ifile});
-                           t=attributes(t,'add',ImaDocElement,'source','file');
-                           RootNc=Root;
-                       end
-                       testrecord=0;%we have an image series without 'record' subdir
-                    end
-                end
-                if testrecord
-                    %the subdevice directory is 'record' (no images detected at this level)
-                    for idir_s=1:nbsubdir
-                        [t,RecordElement]=add(t,DeviceElement,'element',Device.Record{idir_s});
-                        t=attributes(t,'add',RecordElement,'type','RECORD_DIR');
-                        t=attributes(t,'add',RecordElement,'source','dir');
-                        list_subdir=dir(fullfile(ExpPath,list_dir(idir_exp).name,Device.Record{idir_s}));
-                        nbsubdir=0;
-                        RootIma='';
-                        RootNc='';
-                        nbfile=0;
-                        fname={};
-                        for isubdir=3:length(list_subdir)
-                            if list_subdir(isubdir).isdir
-                                nbsubdir=nbsubdir+1;
-                                [t,RecordElement]=add(t,DeviceElement,'element',Device.Record{idir_exp});
-                                t=attributes(t,'add',RecordElement,'type','RECORD_DIR');
-                                t=attributes(t,'add',RecordElement,'source','dir');
-                                %VOIR les .netcdf a l'interieur
-                            else
-                                nbfile=nbfile+1;
-                                fname{nbfile}=list_subdir(isubdir).name;
-                            end
-                        end
-                        if isunix
-                            fname_mod=regexprep(fname,'_','/');
-                            fname_mod=sort(fname_mod);     %sort by name
-                            fname=regexprep(fname_mod,'/','_');
-                        end
-                        for ifile=1:nbfile;           
-                            [Path,Name,Ext]=fileparts(fname{ifile});
-                            if isequal(Ext,'.xml')
-                               [t,ImaDocElement]=add(t,DeviceElement,'element','ImaDoc');
-                               t=add(t,ImaDocElement,'chardata',fname{ifile});
-                               t=attributes(t,'add',ImaDocElement,'source','file');
-                            elseif isequal(Ext,'.png')
-                               [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
-                               if ~isequal(Root,RootIma)
-                                   [t,ImaDocElement]=add(t,DeviceElement,'element','Image');
-                                   t=add(t,ImaDocElement,'chardata',fname{ifile});
-                                   t=attributes(t,'add',ImaDocElement,'source','file');
-                                   RootIma=Root;
-                               end
-                            elseif isequal(Ext,'.nc')
-                               [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
-                               if ~isequal(Root,RootNc)%only one image recorded for each root name
-                                  [t,ImaDocElement]=add(t,DeviceElement,'element','Ncdata');
-                                  t=add(t,ImaDocElement,'chardata',fname{ifile});
-                                  t=attributes(t,'add',ImaDocElement,'source','file');
-                                  RootNc=Root;
-                               end
-                            end
-                        end
-                    end
-                else%the subdevice directory is a civ directory (coexist with images)
-                     for idir_s=1:nbsubdir
-                        [t,RecordElement]=add(t,DeviceElement,'element',Device.Record{idir_s});
-                        t=attributes(t,'add',RecordElement,'type','CIV_DIR');
-                        t=attributes(t,'add',RecordElement,'source','dir');
-                        %list files under the civ directory
-                        list_subdir=dir(fullfile(ExpPath,list_dir(idir_exp).name,Device.Record{idir_s}));
-                                        
-                        nbsubdir=0;
-                        nbfile=0;
-                        RootXml='';
-                        RootNc='';       
-                        fname={};
-                        for isubdir=3:length(list_subdir)
-                            if list_subdir(isubdir).isdir
-                                nbsubdir=nbsubdir+1;
-                                [t,SubElement]=add(t,RecordElement,'element',list_subdir(isubdir).name);
-                                t=attributes(t,'add',SubElement,'type','UNKNOWN_DIR');
-                                t=attributes(t,'add',SubElement,'source','dir');
-                            else
-                                nbfile=nbfile+1;
-                                fname{nbfile}=list_subdir(isubdir).name;
-                            end
-                        end
-                        if isunix
-                            fname_mod=regexprep(fname,'_','/');
-                            fname_mod=sort(fname_mod);     %sort by name
-                            fname=regexprep(fname_mod,'/','_');
-                        end
-                        for ifile=1:nbfile;
-                            [Path,Name,Ext]=fileparts(fname{ifile});
-                            if isequal(Ext,'.xml')
-                               [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
-                               if ~isequal(Root,RootXml)%only one image recorded for each root name
-                                   [t,ImaDocElement]=add(t,RecordElement,'element','CivDoc');
-                                   t=add(t,ImaDocElement,'chardata',fname{ifile});
-                                   t=attributes(t,'add',ImaDocElement,'source','file');
-                                   RootXml=Root;
-                               end
-                            elseif isequal(Ext,'.nc')
-                               [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
-                               if ~isequal(Root,RootNc)%only one image recorded for each root name
-                                  [t,ImaDocElement]=add(t,RecordElement,'element','Ncdata');
-                                  t=add(t,ImaDocElement,'chardata',fname{ifile});
-                                  t=attributes(t,'add',ImaDocElement,'source','file');
-                                  RootNc=Root;
-                               end
-                            end
-                        end
-                    end
-                end
-            end
-        end
-        save(t);%display xml file on the screen
-        save(t,ExpDocName);
-    end
-end
-% [erread,message]=fileattrib('./DATA');
-% if ~isempty(message) & ~isequal(message.UserWrite,1)
-%      errordlg(['Need writting access to ' message.Name])
-%      return
-% end
-
-
-    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-    function project_update(obj,event,fileinput)
-    hchild=get(gcbf,'children');
-    h=findobj(gcbf,'Tag','listbox')
-    
Index: unk/src/set_col_vec.m
===================================================================
--- /trunk/src/set_col_vec.m	(revision 7)
+++ 	(revision )
@@ -1,89 +1,0 @@
-%'set_col_vec': sets the color code for vectors depending on a scalar vec_C and parameters given by the struct colcode
-%function [colorlist,col_vec,minC,colcode1,colcode2,maxC]=colvec(colcode,vec_C)
-%OUTPUT
-%colorlist(nb,3); %list of nb colors
-%col_vec, size=[length(vec_C),3)];%list of color indices corresponding to vec_C
-%minC, maxC: min and max of vec_C
-%colcode1, colcode2: absolute threshold in vec_C corresponding to colcode.colcode1 and colcode.colcode2
-%INPUT
-% colcode: struture setting the colorcode for vectors
-            % colcode.CName: 'ima_cor','black','white',...
-            % colcode.ColorCode ='black', 'white', 'rgb','brg', '64 colors'
-            % colcode.FixedCbounds =0; thresholds scaling relative to min and max, =1 fixed thresholds
-            % colcode.MinC; min 
-            % colcode.MaxC; max
-            % colcode.colcode1: first threshold for rgb, relative to min (0) and max (1)
-            % colcode.colcode2: second threshold for rgb, relative to min (0) and max (1), 
-            % rmq: we need min <= colcode1 <= colcode2 <= max, otherwise
-            % colcode1 and colcode2 are adjusted to the bounds
-% vec_C: matlab vector representing the scalar setting the color
-function [colorlist,col_vec,colcode_out]=set_col_vec(colcode,vec_C)
-
-col_vec=[]; 
-colcode_out=colcode;%default
-if isempty(vec_C) || ~isnumeric(vec_C)
-    colorlist=[0 0 1]; %blue  
-    return
-end
-if (isfield(colcode,'FixedCbounds') && isequal(colcode.FixedCbounds,1))
-    minC=colcode.MinC;
-    maxC=colcode.MaxC;
-else
-    minC=min(vec_C);
-    maxC=max(vec_C);
-end
-
-%default input parameters
-if ~isstruct(colcode),colcode=[];end;
-if ~isfield(colcode,'ColorCode') || isempty(colcode.ColorCode)
-    colorlist=[0 0 1]; %blue  
-    return
-end
-if  isfield(colcode,'colcode1')
-    colcode1=minC+colcode.colcode1*(maxC-minC);
-else
-    colcode1=minC+(maxC-minC)/3;%default
-end
-if isfield(colcode,'colcode2')
-    colcode2=minC+colcode.colcode2*(maxC-minC);
-else
-    colcode2=minC+2*(maxC-minC)/3;%default
-end
-colcode_out.MinC=minC;
-colcode_out.MaxC=maxC;
-
-if strcmp(colcode.ColorCode,'black')
-    colorlist(1,:)=[0 0 0];%black
-    col_vec=ones(size(vec_C));%all vectors at color#1
-elseif strcmp(colcode.ColorCode,'white')
-    colorlist(1,:)=[1 1 1];%white
-    col_vec=ones(size(vec_C));%all vectors at color#1
-elseif strcmp(colcode.ColorCode,'rgb')|| strcmp(colcode.ColorCode,'bgr')% 3 color representation
-    ind1=find(vec_C < colcode1); % =1 for red vectors
-    ind_green=find((vec_C >= colcode1) & (vec_C < colcode2));% =1 for green vectors
-    ind3=find(vec_C >= colcode2);% =1 for blue vectors
-    colorlist(2,:)=[0 1 0];%green
-    col_vec(ind1)=1;
-    col_vec(ind_green)=2;
-    col_vec(ind3)=3;
-    if strcmp(colcode.ColorCode,'rgb')
-        colorlist(1,:)=[1 0 0];%red
-        colorlist(3,:)=[0 0 1];%blue
-    else
-        colorlist(1,:)=[0 0 1];%blue
-        colorlist(3,:)=[1 0 0];%red
-    end
-else
-    colorjet=jet;% ususal colormap from blue to red
-    sizlist=size(colorjet);
-    indsel=ceil((sizlist(1)/64)*(1:64));
-    colorlist(:,1)=colorjet(indsel,1);
-    colorlist(:,2)=colorjet(indsel,2);
-    colorlist(:,3)=colorjet(indsel,3);
-    sizlist=size(colorlist);
-    nblevel=sizlist(1);
-    col2_1=maxC-minC;
-    col_vec=1+floor(nblevel*(vec_C-minC)/col2_1);
-    col_vec=col_vec.*(col_vec<= nblevel)+nblevel*(col_vec >nblevel);% take color #nblevel at saturation
-    col_vec=col_vec.*(col_vec>= 1)+  (col_vec <1);% take color #1 for values below 1
-end
Index: unk/src/set_title.m
===================================================================
--- /trunk/src/set_title.m	(revision 7)
+++ 	(revision )
@@ -1,30 +1,0 @@
-%'set_title': defines the 'TITLE' of a projection object
-%-----------------------------------------------------------
-% function TITLE=set_title(Style,ProjMode)
-% OUTPUT:
-%    TITLE: char string defining the title
-%
-% INPUT:
-%    Style: char string defining the style of the projection opbject
-%    ProjMode:  char string defining the projection mode 
-%------------------------------------------------
-function TITLE=set_title(Style,ProjMode)
-%------------------------------------------------
-TITLE=[]; %default
-if isequal(Style,'points')
-    TITLE='POINTS';
-elseif isequal(Style,'line')|isequal(Style,'polyline')
-    TITLE='LINE';
-elseif isequal(Style,'plane')
-    TITLE='PLANE';
-elseif isequal(Style,'volume')
-    TITLE='VOLUME';
-elseif isequal(Style,'polygon')|isequal(Style,'rectangle')|isequal(Style,'ellipse')
-    if isequal(ProjMode,'inside')|isequal(ProjMode,'outside')
-        TITLE='PATCH';
-    elseif isequal(ProjMode,'mask_inside')|isequal(ProjMode,'mask_outside')
-        TITLE='MASK';
-    else
-        TITLE='LINE';
-    end
-end
Index: unk/src/stra2num.m
===================================================================
--- /trunk/src/stra2num.m	(revision 7)
+++ 	(revision )
@@ -1,21 +1,0 @@
-%'stra2num': transform letters (a, b, c) or numerical strings ('1','2'..) to the corresponding numbers
-%--------------------------------------------
-%  function numres=stra2num(str)
-%
-% OUTPUT: 
-% numres: number (double)
-%
-% INPUT:
-% str: string corresponding to a number or a letter 'a' 'b',.., otherwise the output is empty
-%
-% see also num2stra, name_generator, name2display
-
-function numres=stra2num(str)
-numres=[]; %default
-if double(str) >= 48 & double(str) <= 57 % = test for number strings
-    numres=str2num(str);
-elseif double(str) >= 65 & double(str) <= 90 % test on ascii code for capital letters
-    numres=double(str)-64; %change capital letters to corresponding number in the alphabet
-elseif double(str) >= 97 & double(str) <= 122 % test on ascii code for small letters 
-    numres=double(str)-96; %change small letters to corresponding number in the alphabet
-end
Index: unk/src/struct2nc.m
===================================================================
--- /trunk/src/struct2nc.m	(revision 7)
+++ 	(revision )
@@ -1,144 +1,0 @@
-%'struct2nc': create a netcdf file from a Matlab structure
-%---------------------------------------------------------------------
-% errormsg=struct2nc(flname,Data)
-%
-%OUPUT:
-%errormsg=error message, =[]: default, no error
-%
-%INPUT:
-%flname: name of the netcdf file to create (must end with the extension '.nc')
-%  Data: structure containing all the information of the netcdf file (or netcdf object)
-%           with fields:
-%    .ListGlobalAttribute: cell listing the names of the global attributes (note that a global atribute with the same name as a variable is excluded)
-%        .Att_1,Att_2... : values of the global attributes
-%            .ListDimName: cell listing the names of the array dimensions
-%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
-%            .ListVarName: cell listing the names of the variables
-%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
-%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
-%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function errormsg=struct2nc(flname,Data)
-if ~ischar(flname)
-    errormsg='no name input for the netcf file';
-    return
-end
-if ~exist('Data','var')
-     errormsg='no data  input for the netcdf file';
-    return
-end 
-hhh=which('netcdf.create');% look for built-in matlab library
-
-%USE OF built-in  netcdf library
-if ~isequal(hhh,'')
-    FilePath=fileparts(flname);
-    if ~strcmp(FilePath,'') && ~exist(FilePath,'dir')
-        errormsg=['directory ' FilePath ' needs to be created'];
-        return
-    end
-    [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure
-    ListVarName=Data.ListVarName;
-    nc=netcdf.create(flname,'NC_CLOBBER');%,'clobber'); %create the netcdf file with name flname   
-    %write global constants
-    if isfield(Data,'ListGlobalAttribute')
-        keys=Data.ListGlobalAttribute;
-        for iattr=1:length(keys)
-            if isfield(Data,keys{iattr})
-                 testvar=0;
-                for ivar=1:length(ListVarName)% eliminate possible global attributes with the same name as a variable
-                    if isequal(ListVarName{ivar}, keys{iattr})
-                        testvar=1;
-                        break
-                    end
-                end
-                if ~testvar               
-                    eval(['cte=Data.' keys{iattr} ';'])
-                    if (ischar(cte) ||isnumeric(cte)) &&  ~isempty(cte)&& ~isequal(cte,'')
-                        netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),keys{iattr},cte)
-                    else
-                        errormsg='global attributes must be characters or numbers';
-                        return
-                    end
-                end
-            end
-        end
-    end
-    %create dimensions
-    dimid=[];
-    for idim=1:length(Data.ListDimName)
-         dimid(idim) = netcdf.defDim(nc,Data.ListDimName{idim},Data.DimValue(idim)); 
-    end
-    VarAttribute={}; %default
-    testattr=0;
-    if isfield(Data,'VarAttribute')
-        VarAttribute=Data.VarAttribute;
-        testattr=1;
-    end
-    varid=[];
-    for ivar=1:length(ListVarName)
-        varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'double',dimid(Data.VarDimIndex{ivar}));%define variable  
-    end
-     %write variable attributes
-    if testattr
-        for ivar=1:length(VarAttribute)  
-            if isstruct(VarAttribute{ivar})
-                attr_names=fields(VarAttribute{ivar});
-                for iattr=1:length(attr_names)
-                    eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);
-                    netcdf.putAtt(nc,varid(ivar),attr_names{iattr},attr_val);
-                end
-            end
-        end
-    end
-    netcdf.endDef(nc); %put in data mode
-    for ivar=1:length(ListVarName)
-        if isfield(Data,ListVarName{ivar})
-            eval(['VarVal=Data.' ListVarName{ivar} ';'])%varval=values of the current variable 
-            VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
-            siz=size(VarVal);
-            VarDimName=Data.VarDimName{ivar};%NEW
-            if ischar(VarDimName)%NEW
-                VarDimName={VarDimName};%NEW
-            end%NEW
-            testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2); %NEW
-            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);
-            if ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex))
-                errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
-                break
-            end 
-            if testline || testrange%NEW
-                if testrange
-                    VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));%NEW
-                end
-               %nc{ListVarName{ivar}}=ncfloat(Data.ListDimName(VarDimIndex));%vector of x coordinates
-               netcdf.putVar(nc,varid(ivar), VarVal');
-            else
-                netcdf.putVar(nc,varid(ivar), VarVal);
-                %nc{ListVarName{ivar}}(:) = VarVal;
-            end
-            
-        end
-    end
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%OLD netcdf toolbox
-else
-    errormsg=struct2nc_toolbox(flname,Data);
-end
-
Index: unk/src/struct2nc_toolbox.m
===================================================================
--- /trunk/src/struct2nc_toolbox.m	(revision 7)
+++ 	(revision )
@@ -1,132 +1,0 @@
-%'struct2nc_toolbox': create a netcdf file from a Matlab structure: use of netcdf toolbox
-%---------------------------------------------------------------------
-% errormsg=struct2nc_toolbox(flname,Data)
-%
-%OUPUT:
-%errormsg=error message, =[]: default, no error
-%
-%INPUT:
-%flname: name of the netcdf file to create (must end with the extension '.nc')
-%  Data: structure containing all the information of the netcdf file (or netcdf object)
-%           with fields:
-%    .ListGlobalAttribute: cell listing the names of the global attributes (note that a global atribute with the same name as a variable is excluded)
-%        .Att_1,Att_2... : values of the global attributes
-%            .ListDimName: cell listing the names of the array dimensions
-%               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
-%            .ListVarName: cell listing the names of the variables
-%            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
-%           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
-%        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
-%
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-%     This file is part of the toolbox UVMAT.
-% 
-%     UVMAT is free software; you can redistribute it and/or modify
-%     it under the terms of the GNU General Public License as published by
-%     the Free Software Foundation; either version 2 of the License, or
-%     (at your option) any later version.
-% 
-%     UVMAT is distributed in the hope that it will be useful,
-%     but WITHOUT ANY WARRANTY; without even the implied warranty of
-%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
-function errormsg=struct2nc_toolbox(flname,Data)
-
-FilePath=fileparts(flname);
-if ~strcmp(FilePath,'') &&~exist(FilePath,'dir')
-    errormsg=['directory ' FilePath ' needs to be created'];
-    return
-end
-[Data,errormsg]=check_field_structure(Data);
-if ~isempty(errormsg)
-    return
-end
-ListVarName=Data.ListVarName;
-nc=netcdf(flname,'clobber'); %create the netcdf file with name flname
-%write global constants
-if isfield(Data,'ListGlobalAttribute')
-    keys=Data.ListGlobalAttribute;
-    for iattr=1:length(keys)
-        if isfield(Data,keys{iattr})
-             testvar=0;
-            for ivar=1:length(ListVarName)% eliminate possible global attributes with the same name as a variable
-                if isequal(ListVarName{ivar}, keys{iattr})
-                    testvar=1;
-                    break
-                end
-            end
-            if ~testvar               
-                eval(['cte=Data.' keys{iattr} ';'])
-                if ischar(cte) && ~isequal(cte,'')
-                    eval(['nc.' keys{iattr} '=''' cte ''';']);
-                elseif isnumeric(cte)&& ~isempty(cte)
-                    eval(['nc.' keys{iattr} '= cte; ']);
-                else
-                    errormsg='global attributes must be characters or numbers';
-                    return
-                end
-            end
-        end
-    end
-end
-for idim=1:length(Data.ListDimName)
-    nc(Data.ListDimName{idim})=Data.DimValue(idim);%create dimensions
-end
-
-VarAttribute={}; %default
-testattr=0;
-if isfield(Data,'VarAttribute')
-    VarAttribute=Data.VarAttribute;
-    testattr=1;
-end
-for ivar=1:length(ListVarName)
-    if isfield(Data,ListVarName{ivar})
-        eval(['VarVal=Data.' ListVarName{ivar} ';'])%varval=values of the current variable 
-        siz=size(VarVal);
-        VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
-        VarDimName=Data.VarDimName{ivar};%NEW
-        if ischar(VarDimName)%NEW
-            VarDimName={VarDimName};%NEW
-        end%NEW
-        testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2); %NEW
-        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);
-        if ~testrange && ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex))
-            errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
-            break
-        end 
-        if testline || testrange%NEW
-           dimname=Data.ListDimName{VarDimIndex};
-           if testrange%NEW
-               VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));%NEW
-           end%NEW
-           nc{ListVarName{ivar}}=ncfloat(dimname);%vector of x coordinates
-           nc{ListVarName{ivar}}(:) = VarVal';  
-        else
-            nc{ListVarName{ivar}}=ncfloat(Data.ListDimName(VarDimIndex));%vector of x coordinates
-            nc{ListVarName{ivar}}(:) = VarVal;
-        end
-        %write variable attributes
-        if testattr
-            for ivar=1:length(VarAttribute)  
-                if isstruct(VarAttribute{ivar})
-                    attr_names=fields(VarAttribute{ivar});
-                    for iattr=1:length(attr_names)
-                        eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);
-                        if ischar(attr_val) && ~isequal(attr_val,'')
-                            eval(['nc{''' ListVarName{ivar} '''}.' attr_names{iattr} '=''' attr_val ''';'])
-                        elseif isnumeric(attr_val)&& ~isempty(attr_val)
-                             eval(['nc{''' ListVarName{ivar} '''}.' attr_names{iattr} '=attr_val ;'])
-                        end
-                    end
-                end
-            end
-         end
-    end
-end
-
-close(nc);
Index: unk/src/struct2xml.m
===================================================================
--- /trunk/src/struct2xml.m	(revision 7)
+++ 	(revision )
@@ -1,62 +1,0 @@
-%'struct2xml': transform a matlab structure to a xml tree.
-%--------------------------------------------------------------
-% each field with char string or num vector is transformed into a corresponding  xml element
-% each field with a matrix containing n lines is transformed into a xml element repeated n times 
-% WARNING: PROBLEM WITH HIERARCHICAL structures
-%%%%%%%%%%%%%%%%%%%%%%%
-% OUTPUT:
-% t: xmltree reproducing the structure of Object
-% type 'save(t)' to visualize the xml text and save(filename,t) to save it in a file
-%
-% INPUT:
-%  Object: matlab structure, possibly hierarchical
-%  t: optional input xml tree in which a new branch needs to be appended
-%  root_uid: optional uid of the xml element under which the new subtree must be appended
-
-function t=struct2xml(Object,t,root_uid)
-get(t,root_uid)
-if ~exist('t','var')
-    t=xmltree;
-end
-if ~exist('root_uid','var')
-    root_uid=1;
-end
-fieldnames=fields(Object);
-for ilist=1:length(fieldnames)
-   eval(['val=Object.' fieldnames{ilist} ';'])
-   if isstruct(val)
-      [t,uid]=add(t,root_uid,'element',fieldnames{ilist});
-      fieldnames_sub=fields(val);
-      for ilist_sub=1:length(fieldnames_sub)
-          if isstruct(fieldnames_sub{ilist_sub})
-                t=struct2xml(fieldnames_sub{ilist_sub},t,uid);
-                save(t)
-          else
-              eval(['val_sub=val.' fieldnames_sub{ilist_sub} ';'])
-              t=add_element(t,uid,fieldnames_sub{ilist_sub},val_sub);
-          end
-      end
-   else
-       t=add_element(t,root_uid,fieldnames{ilist},val);
-   end
-end
-
-    
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function t=add_element(t,uid,key,val)
- if ischar(val)
-     [t,new_uid]=add(t,uid,'element',key);
-     [t]=add(t,new_uid,'chardata',val);
- elseif isnumeric(val)
-       siz=size(val);
-       if length(siz)<=2 %do not translate matrices with more than 2 indices
-           for iline=1:siz(1)
-                val_str=num2str(val(iline,:),'%g\t');
-                [t,new_uid]=add(t,uid,'element',key);
-                if siz(1)>1
-                    t = attributes(t,'add',new_uid,'i',num2str(iline));
-                end
-                [t]=add(t,new_uid,'chardata',val_str);
-           end
-       end
- end   
Index: unk/src/sub_field.m
===================================================================
--- /trunk/src/sub_field.m	(revision 7)
+++ 	(revision )
@@ -1,354 +1,0 @@
-%'sub_field': combines two input fields 
-%-----------------------------------------------------------------------
-% function SubData=sub_field(Field,Field_1)
-%
-% OUPUT: 
-% SubData: structure representing the resulting field
-%
-% INPUT: 
-% UvData: main structure UvData associated to the uvmat GUI as 'UserData'
-% Field: cell of Matlab structures representing the input fields
-% 
-%    -- TODO: need to be rationalized --
-
-function [SubData,errormsg]=sub_field(Field,Field_1)
-test_attr=0;
-if isfield(Field,'ListGlobalAttribute')
-    SubData.ListGlobalAttribute=Field.ListGlobalAttribute;
-    for ilist=1:numel(Field.ListGlobalAttribute)
-        AttrName=Field.ListGlobalAttribute{ilist};
-        eval(['SubData.' AttrName '=Field.' AttrName ';'])
-    end
-    test_attr=1;
-end
-if isfield(Field_1,'ListGlobalAttribute')
-    for ilist=1:numel(Field_1.ListGlobalAttribute)
-        test_1=1;
-        AttrName=Field_1.ListGlobalAttribute{ilist};
-        if test_attr
-            for i_prev=1:numel(Field.ListGlobalAttribute)
-                if isequal(Field.ListGlobalAttribute{i_prev},AttrName)
-                    test_1=0; %attribute already written
-                    eval(['Val=Field.' AttrName ';'])                  
-                    eval(['Val_1=Field_1.' AttrName ';'])
-                    if isequal(Val,Val_1)           
-                        break% data already written
-                    else
-                        eval(['SubData.' AttrName '_1=Field_1.' AttrName ';']) 
-                    end
-                end 
-            end
-        end
-        if test_1
-            eval(['SubData.' AttrName '=Field_1.' AttrName ';']) 
-        end
-    end
-end
-SubData.ListVarName=Field.ListVarName;
-SubData.VarDimName=Field.VarDimName;
-if isfield(Field,'VarAttribute')
-    SubData.VarAttribute=Field.VarAttribute;
-end
-%reproduce Field by default
-for ivar=1:numel(Field.ListVarName)
-   VarName=Field.ListVarName{ivar};
-   eval(['SubData.' VarName '=Field.' VarName ';']) 
-end
-
-%fields     
-[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(Field);
-if ~isempty(errormsg)
-    errormsg=['invalid  first input to sub_field:' errormsg];
-    return
-end
-[CellVarIndex_1,NbDim_1,VarTypeCell_1,errormsg]=find_field_indices(Field_1);
-if ~isempty(errormsg)
-    errormsg=['invalid second input to sub_field:' errormsg];
-    return
-end
-iselect=find(NbDim==2);
-if ~isequal(numel(iselect),1)
-    errormsg='invalid  first input to sub_field: it must  contain a single 2D field cell';
-    return
-end
-iselect_1=find(NbDim_1==2);
-if ~isequal(numel(iselect_1),1)
-    errormsg='invalid  second input to sub_field: it must  contain a single 2D field cell';
-    return
-end
-% VarIndex=CellVarIndex{iselect};
-% VarIndex_1=CellVarIndex_1{iselect_1};
-VarType=VarTypeCell{iselect};
-VarType_1=VarTypeCell_1{iselect_1};
-testX=~isempty(VarType.coord_x)&& ~isempty(VarType.coord_y);%unstructured coordiantes
-testX_1=~isempty(VarType_1.coord_x)&& ~isempty(VarType_1.coord_y);%unstructured coordiantes
-testU=~isempty(VarType.vector_x)&& ~isempty(VarType.vector_y);%vector field
-testU_1=~isempty(VarType_1.vector_x)&& ~isempty(VarType_1.vector_y);%vector field
-% testfalse=~isempty(VarType.errorflag);
-testfalse_1=~isempty(VarType_1.errorflag);
-ivar_C=[VarType.scalar VarType.image VarType.color VarType.ancillary]; %defines index (indices) for the scalar or ancillary fields
-if numel(ivar_C)>1
-    errormsg='too many scalar fields in the first input of sub_field.m';
-    return
-end
-ivar_C_1=[VarType_1.scalar VarType_1.image VarType_1.color VarType_1.ancillary]; %defines index (indices) for the scalar or ancillary fields
-if numel(ivar_C_1)>1
-    errormsg='too many scalar fields in the second input of sub_field.m';
-    return
-end
-
-%substract two vector fields or two scalars
-if (testU && testU_1) || (~testU && ~testU_1)
-   %check coincidence in positions
-   %unstructured coordinates
-   if testX
-       XName=Field.ListVarName{VarType.coord_x};
-       YName=Field.ListVarName{VarType.coord_y};
-       eval(['vec_X=Field.' XName ';']) 
-       eval(['vec_Y=Field.' YName ';'])
-       nbpoints=numel(vec_X);
-       vec_X=reshape(vec_X,1,nbpoints);
-       vec_Y=reshape(vec_Y,1,nbpoints);
-       if testX_1 %unstructured coordinates for the second field
-            X_1_Name=Field_1.ListVarName{VarType_1.coord_x};
-            Y_1_Name=Field_1.ListVarName{VarType_1.coord_y};
-            eval(['vec_X_1=Field_1.' X_1_Name ';']) 
-            eval(['vec_Y_1=Field_1.' Y_1_Name ';'])
-            nbpoints_1=numel(vec_X_1);
-       else   %structured coordinates for the second field
-           y_1_Name=Field_1.ListVarName{VarType_1.coord(1)};
-           x_1_Name=Field_1.ListVarName{VarType_1.coord(2)};
-           eval(['y_1=Field_1.' y_1_Name ';']) 
-           eval(['x_1=Field_1.' x_1_Name ';'])  
-           npxy(1)=numel(y_1);
-           npxy(2)=numel(x_1);
-           nbpoints_1=npxy(1)*npxy(2);
-           [vec_X_1,vec_Y_1]=meshgrid(x_1,y_1);
-       end
-       vec_X_1=reshape(vec_X_1,1,nbpoints_1);
-       vec_Y_1=reshape(vec_Y_1,1,nbpoints_1);
-       if testfalse_1
-           FFName_1=Field_1.ListVarName{VarType_1.errorflag};          
-           eval(['vec_FF_1=Field_1.' FFName_1 ';']) 
-           vec_FF_1=reshape(vec_FF_1,1,nbpoints_1);
-           indsel=find(~vec_FF_1);
-           vec_X_1=vec_X_1(indsel);
-           vec_Y_1=vec_Y_1(indsel);
-       end
-       if testU % vector fields
-            U_1_Name=Field_1.ListVarName{VarType_1.vector_x};
-            V_1_Name=Field_1.ListVarName{VarType_1.vector_y};
-            eval(['vec_U_1=Field_1.' U_1_Name ';']) 
-            eval(['vec_V_1=Field_1.' V_1_Name ';'])
-            vec_U_1=reshape(vec_U_1,1,nbpoints_1);
-            vec_V_1=reshape(vec_V_1,1,nbpoints_1);
-            if testfalse_1
-                vec_U_1=vec_U_1(indsel);
-                vec_V_1=vec_V_1(indsel);
-            end            
-       else
-           A_1_Name=Field_1.ListVarName{ivar_C_1};
-           eval(['vec_A_1=Field_1.' A_1_Name ';'])
-           vec_A_1=reshape(vec_A_1,1,nbpoints_1);
-           if testfalse_1
-                vec_A_1=vec_A_1(indsel);
-           end
-       end
-       if ~isequal(vec_X_1,vec_X) && ~isequal(vec_Y_1,vec_Y) % if the unstructured positions are not the same
-           if testU
-               vec_U_1=griddata_uvmat(vec_X_1,vec_Y_1,vec_U_1,vec_X,vec_Y);  %interpolate vectors in the second field
-               vec_V_1=griddata_uvmat(vec_X_1,vec_Y_1,vec_V_1,vec_X,vec_Y);  %interpolate vectors in the second field   
-           else
-               vec_A_1=griddata_uvmat(vec_X_1,vec_Y_1,vec_A_1,vec_X,vec_Y);  %interpolate vectors in the second field
-           end
-       end 
-       if testU
-           UName=Field.ListVarName{VarType.vector_x};
-           VName=Field.ListVarName{VarType.vector_y};  
-           eval(['vec_U=Field.' UName ';']) 
-           eval(['vec_V=Field.' VName ';'])       
-           vec_U=reshape(vec_U,1,numel(vec_U));
-           vec_V=reshape(vec_V,1,numel(vec_V));
-           eval(['SubData.' UName '=vec_U-vec_U_1;'])
-           eval(['SubData.' VName '=vec_V-vec_V_1;'])
-       else
-           AName=Field.ListVarName{ivar_C};
-           eval(['SubData.' AName '=Field.' AName '-vec_A_1;'])
-       end
-   else  %structured coordiantes
-       XName=Field.ListVarName{VarType.coord(2)};
-       YName=Field.ListVarName{VarType.coord(1)};
-       eval(['x=Field.' XName ';']) 
-       eval(['y=Field.' YName ';'])
-       if testX_1 %unstructured coordinates for the second field
-           errormsg='the second input scalar is not on a regular grid: comparison option not implemented';
-           return
-       else
-           XName_1=Field.ListVarName{VarType_1.coord(2)};
-           YName_1=Field.ListVarName{VarType_1.coord(1)};
-           eval(['x_1=Field_1.' XName_1 ';']) 
-           eval(['y_1=Field_1.' YName_1 ';'])
-       end
-       if testU % vector fields
-           UName=Field.ListVarName{VarType.vector_x};
-           VName=Field.ListVarName{VarType.vector_y};
-           U_1_Name=Field_1.ListVarName{VarType_1.vector_x};
-           V_1_Name=Field_1.ListVarName{VarType_1.vector_y};
-           eval(['U_1=Field_1.' U_1_Name ';']) 
-           eval(['V_1=Field_1.' V_1_Name ';'])
-           if ~isequal(x_1,x)||~isequal(y_1,y)
-                [X_1,Y_1]=meshgrid(x_1,y_1);
-                U_1 =interp2(X_1,Y_1,U_1,x,y');
-                V_1 =interp2(X_1,Y_1,V_1,x,y');
-           end
-           val(['SubData.' UName '=Field.' UName '-U_1;'])
-           val(['SubData.' VName '=Field.' VName '-V_1;'])
-       else
-           AName=Field.ListVarName{ivar_C};
-           A_1_Name=Field_1.ListVarName{ivar_C_1};
-           eval(['A_1=double(Field_1.' A_1_Name ');'])
-           if ~isequal(x_1,x)||~isequal(y_1,y)
-                [X_1,Y_1]=meshgrid(x_1,y_1);
-                A_1 =interp2(X_1,Y_1,A_1,x,y');
-           end
-           eval(['SubData.' AName '=double(Field.' AName ')-A_1;'])
-       end
-   end
-end
-
-% merge a vector field and a scalar as second input
-if testU && ~testU_1
-    AName_1=Field_1.ListVarName{ivar_C_1};
-    if isfield(Field_1,'VarAttribute') && numel(Field_1.VarAttribute)>=ivar_C_1
-        AAttr=Field_1.VarAttribute{ivar_C_1} ;
-    else
-        AAttr=[];
-    end
-    if testX_1 %unstructured coordinate
-       XName_1=Field_1.ListVarName{VarType_1.coord_x};
-       YName_1=Field_1.ListVarName{VarType_1.coord_y};
-       SubData.ListVarName=[SubData.ListVarName {XName_1} {YName_1}];
-       DimCell=Field_1.VarDimName([VarType_1.coord_x VarType_1.coord_y ]);
-       if isfield(Field_1,'VarAttribute') 
-           if numel(Field_1.VarAttribute)>=VarType_1.coord_x
-                XAttr=Field_1.VarAttribute{VarType_1.coord_x} ;
-           else
-                XAttr=[];
-           end
-           if numel(Field_1.VarAttribute)>=VarType_1.coord_y
-               YAttr=Field_1.VarAttribute{VarType_1.coord_y} ;
-           else
-               YAttr=[];
-           end
-           SubData.VarAttribute=[SubData.VarAttribute {XAttr} {YAttr}];
-       end
-    else
-       XName_1=Field_1.ListVarName{VarType_1.coord(2)};
-       YName_1=Field_1.ListVarName{VarType_1.coord(1)};
-%        DimCell=[{YName_1} {XName_1}];
-       if isfield(Field_1,'VarAttribute') 
-           if numel(Field_1.VarAttribute)>=VarType_1.coord(2)
-                XAttr=Field_1.VarAttribute{VarType_1.coord(2)} ;
-           else
-                XAttr=[];
-           end
-           if numel(Field_1.VarAttribute)>=VarType_1.coord(1)
-               YAttr=Field_1.VarAttribute{VarType_1.coord(1)} ;
-           else
-               YAttr=[];
-           end
-           SubData.VarAttribute=[SubData.VarAttribute {YAttr} {XAttr}];
-       end
-    end  
-    %look for previously used variable names
-    XName_1_1=XName_1;%default
-    YName_1_1=YName_1;%default
-    AName_1_1=AName_1;%default
-    for iprev=1:numel(SubData.ListVarName)
-        switch SubData.ListVarName{iprev}
-            case XName_1
-                XName_1_1=[XName_1 '_1'];
-            case YName_1
-                YName_1_1=[YName_1 '_1'];
-            case AName_1
-                AName_1_1=[AName_1 '_1']; 
-        end
-    end     
-    if ~testX_1
-          DimCell=[{XName_1_1} {YName_1_1}];
-    end
-    SubData.ListVarName=[SubData.ListVarName {XName_1_1} {YName_1_1} {AName_1_1}];
-    DimCell=[DimCell Field_1.VarDimName(ivar_C_1)]; %(TODO: check for dimension names)
-    SubData.VarDimName=[SubData.VarDimName DimCell];
-    if isfield(Field_1,'VarAttribute')
-        SubData.VarAttribute=[SubData.VarAttribute {AAttr}];
-    end
-    eval(['SubData.' XName_1_1 '=Field_1.' XName_1 ';'])
-    eval(['SubData.' YName_1_1 '=Field_1.' YName_1 ';'])
-    eval(['SubData.' AName_1_1 '=Field_1.' AName_1 ';'])
-end
-
-%merge a scalar as the first input and a vector field as second input
-if ~testU && testU_1
-    UName_1=Field_1.ListVarName{VarType_1.vector_x};
-    VName_1=Field_1.ListVarName{VarType_1.vector_y};
-    UAttr=Field_1.VarAttribute{VarType_1.vector_x};
-    VAttr=Field_1.VarAttribute{VarType_1.vector_y};
-    if testX_1 %unstructured coordinate for the second field
-       XName_1=Field_1.ListVarName{VarType_1.coord_x};
-       YName_1=Field_1.ListVarName{VarType_1.coord_y};
-       
-       XAttr=Field_1.VarAttribute{VarType_1.coord_x};
-       YAttr=Field_1.VarAttribute{VarType_1.coord_y};
-%        SubData.ListVarName=[SubData.ListVarName {XName_1} {YName_1}];
-       DimCell=Field_1.VarDimName([VarType_1.coord_x VarType_1.coord_y ]);
-    else
-       XName_1=Field_1.ListVarName{VarType_1.coord(2)};
-       YName_1=Field_1.ListVarName{VarType_1.coord(1)};
-       if numel(Field_1.VarAttribute)>=VarType_1.coord(2)
-           XAttr=Field_1.VarAttribute{VarType_1.coord(2)};
-       else
-           XAttr=[];
-       end
-       if numel(Field_1.VarAttribute)>=VarType_1.coord(1)
-           YAttr=Field_1.VarAttribute{VarType_1.coord(1)};
-       else
-           YAttr=[];
-       end     
-    end  
-    %check for the existence of the same  variable name
-    XName_1_1=XName_1; %default
-    YName_1_1=YName_1; %default
-    UName_1_1=UName_1; %default
-    VName_1_1=VName_1; %default
-    for iprev=1:numel(SubData.ListVarName)
-        switch SubData.ListVarName{iprev}
-            case XName_1
-                XName_1_1=[XName_1 '_1'];
-            case YName_1
-                YName_1_1=[YName_1 '_1'];
-            case UName_1
-                UName_1_1=[UName_1 '_1'];
-            case VName_1
-                VName_1_1=[VName_1 '_1']; 
-        end
-    end     
-    if ~testX_1
-          DimCell=[{XName_1_1} {YName_1_1}];
-    end
-    SubData.ListVarName=[SubData.ListVarName {XName_1_1} {YName_1_1} {UName_1_1} {VName_1_1}];
-    DimCell=[DimCell Field_1.VarDimName([VarType_1.vector_x VarType_1.vector_y ])];
-    SubData.VarDimName=[SubData.VarDimName DimCell];
-    if ~(isfield(SubData,'VarAttribute') && numel(SubData.VarAttribute)==numel(SubData.ListVarName))
-        for ivar=numel(SubData.VarAttribute)+1:numel(SubData.ListVarName)-4
-             SubData.VarAttribute{ivar}=[];
-        end
-    end
-    SubData.VarAttribute=[SubData.VarAttribute {XAttr} {YAttr} {UAttr} {VAttr}];
-    eval(['SubData.' XName_1_1 '=Field_1.' XName_1 ';'])
-    eval(['SubData.' YName_1_1 '=Field_1.' YName_1 ';'])
-    eval(['SubData.' UName_1_1 '=Field_1.' UName_1 ';'])
-    eval(['SubData.' VName_1_1 '=Field_1.' VName_1 ';'])  
-end
-
-  
Index: unk/src/update_menu.m
===================================================================
--- /trunk/src/update_menu.m	(revision 7)
+++ 	(revision )
@@ -1,27 +1,0 @@
-%'update_menu': find an input string in a menu, add it to the menu at the penultimate position if it does not exist
-%-----------------------------------------------
-% function menu_str=update_menu(handle,strinput)
-%
-% OUTPUT:
-% menu_str: new menu; cell of strings
-%
-% INPUT:
-% handle: handle of the menu to modify (listbox uicontrol)
-% strinput: char string to detect or add in the menu
-
-function menu_str=update_menu(handle,strinput)
-menu_str=get(handle,'String');
-nbmenu=length(menu_str);
-ichoice=0;%default
-for imenu=1:nbmenu
-    if isequal(menu_str{imenu},strinput)
-       ichoice=imenu;
-    end
-end
-if ichoice==0%the input string does not exist in the menu
-    menu_str{nbmenu+1}=menu_str{nbmenu};%shift  the last item ('more...')
-    menu_str{nbmenu}=strinput;
-    set(handle,'String',menu_str)
-    ichoice=nbmenu;
-end
-set(handle,'Value',ichoice)
Index: unk/src/update_obj.m
===================================================================
--- /trunk/src/update_obj.m	(revision 7)
+++ 	(revision )
@@ -1,75 +1,0 @@
-%'update_obj': update the object graph representation and its projection field, record it in the uvmat interface
-%-------------------------------------------------------------------
-%Object=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
-%
-%OUTPUT:
-%UvData: data to be stored as 'Userdata' on the uvmat interface
-%IndexObj: object index for a new object added to the list in UvData
-%   the function updates UvData.Object{IndexObj}, and possibly adds a new plot (UvData.Plane or Line) in the list atached to the interface
-%
-%INPUT:
-%UvIn: structure stored as 'Userdata' on the uvmat interface
-%IndexObjIn: object index for an existing objects stored in UvData
-%ObjectData: structure containing the input object properties
-%PlotHandles: structure containing the handles of the plotting parameter buttons on the uvmat interface (obtained by get_plot_handles.m)
-%-------------------------------------
-
-function Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles)
-
-%default input and output
-Object_out=ObjectData;%default
-if  isfield(UvData,'Object') 
-    Object_set=UvData.Object;
-else
-    Object_set={};%create the object
-end
-
-% object representation in the different projected field plots
-for iview=1:length(Object_set) %loop on projection planes iview
-      if isfield(Object_set{iview},'plotaxes')
-         haxes=Object_set{iview}.plotaxes;% axes for the field plot
-         if ishandle(haxes) & isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists
-             testupdate=0;
-             HandlesDisplay=[];%default
-             if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay')
-                 HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations
-             end
-             hplot_list=findobj(haxes,'Tag','proj_object');
-             for ih=1:length(HandlesDisplay)
-                 plot_detect=find(hplot_list==HandlesDisplay(ih));
-                 if ~isempty(plot_detect)
-                     Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iview},HandlesDisplay(ih),'m');%update the the object representation
-                     testupdate=1;
-                     break
-                 end
-             end
-             if ~testupdate% draw new object plot
-                hh=plot_object(ObjectData,Object_set{iview},haxes,'m');%draw the object with the new object data
-                Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh];
-                PlotData=get(hh,'UserData');
-                PlotData.IndexObj=IndexObj;
-                set(hh,'UserData',PlotData); %record the object index in the graph
-             end
-         end
-      end
-end
-
-% plot the field projected on the object
-if ~isempty(PlotHandles) %&& ~testmask
-    ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
-    if ~isempty(ProjData)   
-        plotaxes=[];%default
-        if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
-            plotaxes=Object_set{IndexObj}.plotaxes;
-        end
-        [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
-        Object_out.plotaxes=plotaxes;
-        plotfig=get(plotaxes,'parent');
-        name_str=get(plotfig,'Name');
-        if ~isequal(name_str,'uvmat')
-            set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' set_title(ObjectData.Style,ObjectData.ProjMode)]);
-        end
-    end
-end
-
-
Index: unk/src/update_waitbar.m
===================================================================
--- /trunk/src/update_waitbar.m	(revision 7)
+++ 	(revision )
@@ -1,14 +1,0 @@
-%'update_waitbar': update the waitbar display, used for ACTION functions in the GUI 'series'
-%------------------------------------------------------------------
-%INPUT:
-% hwaitbar:  handles of the waitbar to update
-% bar_size: vector with 4 elements, representing the abscissa, ordinate, width, height of the waitbar relative to the GUI  
-% advance_ratio: number between 0 and 1 representing the advancement of the calculation (loop index relative to the total length)
-
-function update_waitbar(hwaitbar,bar_size,advance_ratio)
-waitbarpos(1)=bar_size(1);
-waitbarpos(3)=bar_size(3);
-waitbarpos(4)=advance_ratio*bar_size(4);
-waitbarpos(2)=bar_size(4)+bar_size(2)-waitbarpos(4);
-set(hwaitbar,'Position',waitbarpos)
-drawnow
Index: unk/src/write_plot_param.m
===================================================================
--- /trunk/src/write_plot_param.m	(revision 7)
+++ 	(revision )
@@ -1,109 +1,0 @@
-%'write_plot_param': update the plotting parameters on the uvmat interface after a plotting operation
-function write_plot_param(handles,PlotParam)
-
-%scalar or image parameters
-if isfield(PlotParam,'Scalar')
-    set_scal_display(handles,'on')
-    if isfield(PlotParam.Scalar,'MaxA')
-        set(handles.MaxA,'String',num2str(PlotParam.Scalar.MaxA,3));
-    end
-    if isfield(PlotParam.Scalar,'MinA')
-        set(handles.MinA,'String',num2str(PlotParam.Scalar.MinA,3));
-    end
-
-    if isfield(PlotParam.Scalar,'IncrA')
-        set(handles.IncrA,'String',num2str(PlotParam.Scalar.IncrA,3))
-    end
-else
-    set_scal_display(handles,'off')
-end
-
-% parameter for vector field
-if isfield(PlotParam,'Vectors')
-    set_vect_display(handles,'on')
-    if isfield(PlotParam.Vectors,'VecScale')
-        set(handles.VecScale,'String',num2str(PlotParam.Vectors.VecScale,3))
-    end
-    if isfield(PlotParam.Vectors,'MinC')&& isfield(PlotParam.Vectors,'MaxC')
-        MinC=PlotParam.Vectors.MinC;
-        MaxC=PlotParam.Vectors.MaxC;
-        set(handles.min_vec,'String', num2str(MinC,3));
-        set(handles.max_vec,'String',num2str(MaxC,3));
-        list=get(handles.color_code,'String');
-        ichoice=get(handles.color_code,'Value');
-    	color_option=list{ichoice};
-        test3color=strcmp(color_option,'rgb')||strcmp(color_option,'bgr');
-        if test3color% need to update color thresholds
-            set(handles.colcode1,'Visible','on')
-            set(handles.colcode2,'Visible','on')
-            set(handles.slider1,'Visible','on')
-            set(handles.slider2,'Visible','on')
-%             slider1=get(handles.slider1,'Value');
-%             slider2=get(handles.slider2,'Value');
-             colcode1=MinC+(MaxC-MinC)*PlotParam.Vectors.colcode1;
-             colcode2=MinC+(MaxC-MinC)*PlotParam.Vectors.colcode2;
-            set(handles.colcode1,'String',num2str(colcode1,3))
-            set(handles.colcode2,'String',num2str(colcode2,3))
-            set(handles.slider1,'Value',PlotParam.Vectors.colcode1)
-            set(handles.slider2,'Value',PlotParam.Vectors.colcode2)
-        else
-            set(handles.colcode1,'Visible','off')
-            set(handles.colcode2,'Visible','off')
-            set(handles.slider1,'Visible','off')
-            set(handles.slider2,'Visible','off')
-        end
-    end
-else
-    set_vect_display(handles,'off')
-    set(handles.edit_vect,'Visible','off')
-end
-
-%------------------------------------------------------------------
-%prepare interface for scalar display: state ='on' or 'off'
-function set_scal_display(handles,state)
-%------------------------------------------------------------------
-set(handles.SCALAR_title,'Visible',state)
-set(handles.MaxA,'Visible',state)
-set(handles.MinA,'Visible',state)
-%set(handles.IncrA,'Visible',state)
-set(handles.AutoScal,'Visible',state)
-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)
-set(handles.frame_scal,'Visible',state)
-set(handles.npx,'Visible',state)
-set(handles.npy,'Visible',state)
-set(handles.npx_title,'Visible',state)
-set(handles.npy_title,'Visible',state)
-%set(handles.makemask,'Visible',state)
-
-%---------------------------------------------
-%prepare interface for vector display: state ='on' or 'off'
-function set_vect_display(handles,state)
-%------------------------------------------------------------------
-set(handles.frame_vect,'Visible',state)
-set(handles.VECT_title,'Visible',state)
-set(handles.VecScale,'Visible',state)
-set(handles.AutoVec,'Visible',state)
-set(handles.HideFalse,'Visible',state)
-set(handles.HideWarning,'Visible',state)
-set(handles.record,'Visible',state)
-set(handles.colcode1,'Visible',state)
-set(handles.colcode2,'Visible',state)
-set(handles.min_vec,'Visible',state)
-set(handles.max_vec,'Visible',state)
-set(handles.scale_title,'Visible',state)
-set(handles.slider1,'Visible',state)
-set(handles.slider2,'Visible',state)
-set(handles.col_vec,'Visible',state)
-set(handles.Color_title,'Visible',state)
-set(handles.color_code,'Visible',state)
-set(handles.vec_col_bar,'Visible',state)
-set(handles.record,'Visible',state)
-set(handles.AutoVecColor,'Visible',state)
-set(handles.decimate4,'Visible',state)
-set(handles.min_C_title,'Visible',state)
-set(handles.max_C_title,'Visible',state)
-set(handles.MenuEditVectors,'Enable',state)
