Index: /trunk/src/calc_field_interp.m
===================================================================
--- /trunk/src/calc_field_interp.m	(revision 653)
+++ /trunk/src/calc_field_interp.m	(revision 654)
@@ -1,4 +1,3 @@
-%'calc_field_interp': defines fields (velocity, vort, div...) from civ data and calculate them
-% for projection with linear interpolation
+%'calc_field_interp': calculate fields (velocity, vort, div...) using linear interpolation if requested
 %---------------------------------------------------------------------
 % [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI)
@@ -10,9 +9,10 @@
 %
 % INPUT:
-% Coord(nbpoints,2): matrix of x,y coordinates of theinput data points
+% Coord(nbpoints,2): matrix of x,y coordinates of the input data points
 % Data: inputfield structure
 % FieldName: string representing the field to calculate, or cell array of fields (as displayed in uvmat/FieldName)
-% XI, YI: set of x and y coordiantes where the fields need to be linearly interpolated
-
+% XI, YI: set of x and y coordinates where the fields need to be linearly interpolated, 
+%        if XI, YI are missing, there is no interpolation (case of colors in vector plots)
+%
 function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI)
 
@@ -25,4 +25,5 @@
 if ischar(FieldName),FieldName={FieldName};end
 check_skipped=zeros(size(FieldName));% default, =1 to mark the variables which can be calculated
+check_interp=ones(size(FieldName));% default, =1 to mark the variables which can be interpolated (not ancillary)
 Operator=cell(size(FieldName));
 
@@ -35,11 +36,10 @@
         if isempty(ivar)
             check_skipped(ilist)=1; %variable not found
-        else
+        elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1));
             if isfield(Data.VarAttribute{ivar},'Role') &&...
                 (strcmp(Data.VarAttribute{ivar}.Role,'ancillary')||strcmp(Data.VarAttribute{ivar}.Role,'warnflag')||strcmp(Data.VarAttribute{ivar}.Role,'errorflag'))
-                check_skipped(ilist)=1; % ancillary variable, not interpolated      
-            elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1));
-                InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list
+                check_interp(ilist)=0; % ancillary variable, not interpolated     
             end
+            InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list
         end
     else
@@ -88,6 +88,8 @@
             case 'vec'
                 if exist('XI','var')
+                    if check_interp
                     VarVal{nbvar+1}=F.(UName{ilist})(XI,YI);
                     VarVal{nbvar+2}=F.(VName{ilist})(XI,YI);
+                    end
                 else
                     VarVal{nbvar+1}=Data.(UName{ilist});
@@ -100,6 +102,8 @@
             case 'norm'
                 if exist('XI','var')
+                    if check_interp
                     U2=F.(UName{ilist})(XI,YI).*F.(UName{ilist})(XI,YI);
                     V2=F.(VName{ilist})(XI,YI).*F.(VName{ilist})(XI,YI);
+                    end
                 else
                     U2=Data.(UName{ilist}).*Data.(UName{ilist});
@@ -111,5 +115,7 @@
             case {'curl','div','strain'}
                 if exist('XI','var')
+                    if check_interp
                     VarVal{nbvar+1}=F.(UName{ilist})(XI,YI);
+                    end
                 else
                     VarVal{nbvar+1}=Data.(UName{ilist});
@@ -120,5 +126,7 @@
                 if ~isempty(FieldName{ilist})
                     if exist('XI','var')
+                        if check_interp
                         VarVal{nbvar+1}=F.(FieldName{ilist})(XI,YI);
+                        end
                     else
                         VarVal{nbvar+1}= Data.(FieldName{ilist});
Index: /trunk/src/check_files.m
===================================================================
--- /trunk/src/check_files.m	(revision 653)
+++ /trunk/src/check_files.m	(revision 654)
@@ -54,4 +54,5 @@
     'fill_GUI';...%  fill a GUI with a set of parameters from a Matlab structure 
     'filter_tps';...% find the thin plate spline coefficients for interpolation-smoothing
+    'find_field_bounds': % find the boounds and typical meshs of coordinates
     'find_field_cells';...% group the variables of a 'field object' into 'field cells' and specify their structure
     'find_file_series';...% check the content of an input file and find the corresponding file series
Index: /trunk/src/find_field_bounds.m
===================================================================
--- /trunk/src/find_field_bounds.m	(revision 654)
+++ /trunk/src/find_field_bounds.m	(revision 654)
@@ -0,0 +1,81 @@
+%'find_field_bounds': % find the boounds and typical meshs of coordinates
+%-----------------------------------------------------------------------
+%function  FieldOut=find_field_bounds(Field)
+%-----------------------------------------------------------------------
+%OUTPUT
+%FieldOut copy of the input Field with the additional items:
+%  .XMin,.XMax,.YMin,.YMax,bounds for x and y
+%  .CoordMesh: typical mesh needed for automatic grids
+
+%INPUT
+% Field
+
+function FieldOut=find_field_bounds(Field)
+FieldOut=Field;%default
+%% analyse input field
+[CellInfo,NbDimArray,errormsg]=find_field_cells(Field);% analyse  the input field structure
+if ~isempty(errormsg)
+    errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error
+    return
+end
+
+NbDim=max(NbDimArray);% spatial dimension of the input field
+imax=find(NbDimArray==NbDim);% indices of field cells to consider
+if isfield(Field,'NbDim')
+    NbDim=double(Field.NbDim);% deal with plane fields containing z coordinates
+end
+
+%% get bounds and mesh (needed  to propose default options for projection objects)
+% if NbDim>1
+CoordMax=zeros(numel(imax),NbDim);
+CoordMin=zeros(numel(imax),NbDim);
+Mesh=zeros(1,numel(imax));
+for ind=1:numel(imax)
+    if strcmp(CellInfo{imax(ind)}.CoordType,'tps')
+        CoordName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable
+        CoordMax(ind,NbDim)=max(max(Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case)
+        CoordMax(ind,NbDim-1)=max(max(Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case)
+        CoordMin(ind,NbDim)=min(min(Field.(CoordName)(1:end-3,1,:),[],1),[],3);
+        CoordMin(ind,NbDim-1)=min(min(Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case)
+    else
+        XName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
+        YName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)};
+        CoordMax(ind,NbDim)=max(max(Field.(XName)));
+        CoordMin(ind,NbDim)=min(min(Field.(XName)));
+        CoordMax(ind,NbDim-1)=max(max(Field.(YName)));
+        CoordMin(ind,NbDim-1)=min(min(Field.(YName)));
+        %         test_x=1;%test for unstructured coordinates
+        if NbDim==3
+            ZName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)};
+            CoordMax(imax(ind),1)=max(max(Field.(ZName)));
+            CoordMin(ind,1)=min(min(Field.(ZName)));
+        end
+    end
+    switch CellInfo{imax(ind)}.CoordType
+        
+        case {'scattered','tps'} %unstructured coordinates
+            NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points
+            Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim)
+        case 'grid'%structured coordinate
+            NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction
+            Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1));
+    end
+end
+Mesh=min(Mesh);
+FieldOut.XMax=max(CoordMax(:,end));
+FieldOut.XMin=min(CoordMin(:,end));
+FieldOut.YMax=max(CoordMax(:,end-1));
+FieldOut.YMin=min(CoordMin(:,end-1));
+if NbDim==3
+    FieldOut.ZMax=max(CoordMax(ind,1));
+    FieldOut.ZMin=max(CoordMin(ind,1));
+end
+% adjust the mesh to a value 1, 2 , 5 *10^n
+ord=10^(floor(log10(Mesh)));%order of magnitude
+if Mesh/ord>=5
+    FieldOut.CoordMesh=5*ord;
+elseif Mesh/ord>=2
+    FieldOut.CoordMesh=2*ord;
+else
+    FieldOut.CoordMesh=ord;
+end
Index: /trunk/src/geometry_calib.m
===================================================================
--- /trunk/src/geometry_calib.m	(revision 653)
+++ /trunk/src/geometry_calib.m	(revision 654)
@@ -50,5 +50,5 @@
 % Edit the above text to modify the response to help geometry_calib
 
-% Last Modified by GUIDE v2.5 29-Jul-2012 08:46:09
+% Last Modified by GUIDE v2.5 29-Jun-2013 23:52:36
 
 % Begin initialization code - DO NOT edit
@@ -208,5 +208,5 @@
 set(handles.geometry_calib,'UserData',UserData)
 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
-MenuPlot_Callback(hObject, eventdata, handles)
+PLOT_Callback(hObject, eventdata, handles)
 set(handles.ListCoord,'Value',index)% indicate in the list the point with max deviation (possible mistake)
 ListCoord_Callback(hObject, eventdata, handles)
@@ -748,5 +748,6 @@
 set(handles.ListCoord,'Value',1)% refresh the display of coordinates
 set(handles.ListCoord,'String',{'......'})
-MenuPlot_Callback(hObject, eventdata, handles)
+PLOT_Callback(hObject, eventdata, handles)
+
 
 %------------------------------------------------------------------------
@@ -800,5 +801,5 @@
 %update the plot 
 ListCoord_Callback(hObject, eventdata, handles)
-MenuPlot_Callback(hObject, eventdata, handles)
+PLOT_Callback(hObject, eventdata, handles)
 
 %------------------------------------------------------------------------
@@ -917,45 +918,4 @@
 plot_field(Data)
 
-%------------------------------------------------------------------------
-function MenuPlot_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
-%UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
-hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
-%hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
-h_menu_coord=findobj(huvmat,'Tag','TransformName');
-menu=get(h_menu_coord,'String');
-choice=get(h_menu_coord,'Value');
-if iscell(menu)
-    option=menu{choice};
-else
-    option='px'; %default
-end
-Coord_cell=get(handles.ListCoord,'String');
-ObjectData=read_geometry_calib(Coord_cell);
-%ObjectData=read_geometry_calib(handles);%read the interface input parameters defining the object
-if ~isempty(ObjectData.Coord)
-    if isequal(option,'phys')
-        ObjectData.Coord=ObjectData.Coord(:,1:3);
-    elseif isequal(option,'px')||isequal(option,'')
-        ObjectData.Coord=ObjectData.Coord(:,4:5);
-    else
-        msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be '''', px or phys ')
-    end
-end
-
-set(0,'CurrentFigure',huvmat)
-set(huvmat,'CurrentAxes',hhuvmat.PlotAxes)
-hh=findobj('Tag','calib_points');
-if  ~isempty(ObjectData.Coord) && isempty(hh)
-    hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
-elseif isempty(ObjectData.Coord)%empty list of points, suppress the plot
-    delete(hh)
-else
-    set(hh,'XData',ObjectData.Coord(:,1))
-    set(hh,'YData',ObjectData.Coord(:,2))
-end
-pause(.1)
-figure(handles.geometry_calib)
 
 % --------------------------------------------------------------------
@@ -969,4 +929,31 @@
    web([helpfile '#geometry_calib'])
 end
+
+% --------------------------------------------------------------------
+function MenuSetScale_Callback(hObject, eventdata, handles)
+% hObject    handle to MenuSetScale (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+ answer=msgbox_uvmat('INPUT_TXT','scale pixel/cm?','')
+ %create test points
+ huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
+UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
+Xima=0.8*[UvData.Field.XMin UvData.Field.XMax UvData.Field.XMax UvData.Field.XMin]';
+Yima=0.8*[UvData.Field.YMin UvData.Field.YMax UvData.Field.YMax UvData.Field.YMin]';
+x=Xima/str2num(answer);
+y=Yima/str2num(answer);
+for j=1:4
+    for i=1:5
+          Coord{j,1}=num2str(x);%
+          Coord{j,2}=num2str(y);%
+          Coord{j,3}='0';%
+          Coord{j,4}=num2str(Xima);%
+          Coord{j,5}=num2str(Yima);%
+    end
+end
+
+Tabchar=cell2tab(Coord,' | ');
+Tabchar=[Tabchar ;{'......'}];
+set(handles.ListCoord,'String',Tabchar)
 
 %------------------------------------------------------------------------
@@ -1140,5 +1127,5 @@
 set(handles.ListCoord,'Value',1)
 set(handles.ListCoord,'String',Tabchar)
-MenuPlot_Callback(hObject, eventdata, handles)
+PLOT_Callback(hObject, eventdata, handles)
 
 %-----------------------------------------------------------------------
@@ -1233,5 +1220,5 @@
 set(handles.ListCoord,'Value',1)
 set(handles.ListCoord,'String',Tabchar)
-MenuPlot_Callback(handles.geometry_calib, [], handles)
+PLOT_Callback(handles.geometry_calib, [], handles)
 
 % -----------------------------------------------------------------------
@@ -1280,5 +1267,5 @@
         set(handles.ListCoord,'String',Coord_cell)         
         ListCoord_Callback(hObject, eventdata, handles) 
-        MenuPlot_Callback(hObject,eventdata,handles)
+        PLOT_Callback(hObject,eventdata,handles)
      end
 end
@@ -1357,5 +1344,5 @@
     CoordCell=reshape(CoordCell,[],5);
     Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
-    MenuPlot_Callback(handles.geometry_calib, [], handles)
+    PLOT_Callback(handles.geometry_calib, [], handles)
 end
 set(handles.calib_type,'Value',val_cal)
@@ -1405,2 +1392,49 @@
 % Hint: delete(hObject) closes the figure
 delete(hObject);
+
+%------------------------------------------------------------------------
+% --- Executes on button press in PLOT.
+%------------------------------------------------------------------------
+function PLOT_Callback(hObject, eventdata, handles)
+
+huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
+%UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
+hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
+%hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
+h_menu_coord=findobj(huvmat,'Tag','TransformName');
+menu=get(h_menu_coord,'String');
+choice=get(h_menu_coord,'Value');
+if iscell(menu)
+    option=menu{choice};
+else
+    option='px'; %default
+end
+Coord_cell=get(handles.ListCoord,'String');
+ObjectData=read_geometry_calib(Coord_cell);
+%ObjectData=read_geometry_calib(handles);%read the interface input parameters defining the object
+if ~isempty(ObjectData.Coord)
+    if isequal(option,'phys')
+        ObjectData.Coord=ObjectData.Coord(:,1:3);
+    elseif isequal(option,'px')||isequal(option,'')
+        ObjectData.Coord=ObjectData.Coord(:,4:5);
+    else
+        msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be '''', px or phys ')
+    end
+end
+
+set(0,'CurrentFigure',huvmat)
+set(huvmat,'CurrentAxes',hhuvmat.PlotAxes)
+hh=findobj('Tag','calib_points');
+if  ~isempty(ObjectData.Coord) && isempty(hh)
+    hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
+elseif isempty(ObjectData.Coord)%empty list of points, suppress the plot
+    delete(hh)
+else
+    set(hh,'XData',ObjectData.Coord(:,1))
+    set(hh,'YData',ObjectData.Coord(:,2))
+end
+pause(.1)
+figure(handles.geometry_calib)
+
+
+ 
Index: /trunk/src/get_field.m
===================================================================
--- /trunk/src/get_field.m	(revision 653)
+++ /trunk/src/get_field.m	(revision 654)
@@ -140,4 +140,9 @@
 set(handles.ordinate,'Value',1)% fill the menu of y vector components
 set(handles.ordinate,'String',Field.ListVarName)% fill the menu of y vector components
+if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata')
+        set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})
+else
+     set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'})
+end
 if Field.MaxDim>=2 % case of 2D (or 3D) fields
     if isfield(CellInfo{imax},'VarIndex_vector_x') &&  isfield(CellInfo{imax},'VarIndex_vector_y')
@@ -149,4 +154,5 @@
         set(handles.FieldOption,'Value',2)
     end
+
 else % case of 1D fields
     set(handles.FieldOption,'Value',1)
@@ -338,4 +344,5 @@
 switch FieldOption
     case '1D plot'
+        set(handles.Coordinates,'Visible','on')
         set(handles.PanelOrdinate,'Visible','on')
         pos=get(handles.PanelOrdinate,'Position');
@@ -352,4 +359,5 @@
         ordinate_Callback(hObject, eventdata, handles)
     case 'scalar'
+        set(handles.Coordinates,'Visible','on')
         set(handles.PanelOrdinate,'Visible','off')
         set(handles.PanelScalar,'Visible','on')
@@ -364,4 +372,5 @@
         scalar_Callback(hObject, eventdata, handles)
     case 'vectors'
+        set(handles.Coordinates,'Visible','on')
         set(handles.PanelOrdinate,'Visible','off')
         set(handles.PanelScalar,'Visible','off')
@@ -375,4 +384,9 @@
         set(handles.Y_title,'Visible','on')      
         vector_Callback(handles)
+    case 'civdata...'
+        set(handles.PanelOrdinate,'Visible','off')
+        set(handles.PanelScalar,'Visible','off')
+        set(handles.PanelVectors,'Visible','off')
+        set(handles.Coordinates,'Visible','off')
 end
 
Index: /trunk/src/msgbox_uvmat.m
===================================================================
--- /trunk/src/msgbox_uvmat.m	(revision 653)
+++ /trunk/src/msgbox_uvmat.m	(revision 654)
@@ -1,4 +1,5 @@
 %'msgbox_uvmat': associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls
-% msgbox_uvmat(title,display)
+%
+% answer=msgbox_uvmat(title,display,default_answer,Position)
 %
 % OUTPUT:
Index: /trunk/src/proj_field.m
===================================================================
--- /trunk/src/proj_field.m	(revision 653)
+++ /trunk/src/proj_field.m	(revision 654)
@@ -893,5 +893,5 @@
     norm_plane(3)=OmAxis(3)*coeff+cos_om;
 end
-testangle=~isequal(PlaneAngle,[0 0 0]);% && ~test90y && ~test90x;%=1 for slanted plane
+testangle=~isequal(PlaneAngle,[0 0 0])||~isequal(ObjectData.Coord(1:2),[0 0 ]) ;% && ~test90y && ~test90x;%=1 for slanted plane
 
 %% mesh sizes DX and DY
@@ -984,34 +984,18 @@
 %% group the variables (fields of 'FieldData') in cells of variables with the same dimensions
 [CellInfo,NbDimArray,errormsg]=find_field_cells(FieldData);
+
 if ~isempty(errormsg)
     errormsg=['error in proj_field/proj_plane:' errormsg];
     return
 end
-
-%% projection modes
-check_grid=0;
+check_grid=zeros(size(CellInfo));% =1 if a grid is needed , =0 otherwise, for each field cell
+
 ProjMode=cell(size(CellInfo));
-for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
-    ProjMode{icell}=ObjectData.ProjMode;
-    if isfield(CellInfo{icell},'ProjModeRequest')
-        switch CellInfo{icell}.ProjModeRequest
-            case 'interp_lin'
-                ProjMode{icell}='interp_lin';
-            case 'interp_tps'
-                ProjMode{icell}='interp_tps';
-        end
-    end
-    if strcmp(ProjMode{icell},'interp_lin')||strcmp(ProjMode{icell},'interp_tps')
-        check_grid=1;
-    end
-end
-
-%% define the new coordinates in case of interpolation on a grid
-if check_grid
-    AYName='coord_y';
-    AXName='coord_x';
-    ProjData.ListVarName={'coord_y','coord_x'};
-    ProjData.VarDimName={'coord_y','coord_x'};
-    ProjData.VarAttribute={[],[]};
+for icell=1:numel(CellInfo)
+    ProjMode{icell}=ObjectData.ProjMode;% projection mode of the plane object
+end
+    icell_grid=[];% field cell index which defines the grid
+if ~strcmp(ObjectData.ProjMode,'projection')
+    %% define the new coordinates in case of interpolation on a imposed grid
     if ~testYMin
         errormsg='min Y value not defined for the projection grid';return
@@ -1026,15 +1010,170 @@
         errormsg='max X value not defined for the projection grid';return
     end
-    ProjData.coord_y=[YMin YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined
-    ProjData.coord_x=[XMin XMax];
-    coord_x_proj=XMin:DX:XMax;
-    coord_y_proj=YMin:DY:YMax;
-    [X,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
-    XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system
-    YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3));
-end
-
+else
+    %% case of a grid requested by the input field
+
+    for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
+        if isfield(CellInfo{icell},'ProjModeRequest')
+            switch CellInfo{icell}.ProjModeRequest
+                case 'interp_lin'
+                    ProjMode{icell}='interp_lin';
+                case 'interp_tps'
+                    ProjMode{icell}='interp_tps';
+            end
+        end
+        if strcmp(ProjMode{icell},'interp_lin')||strcmp(ProjMode{icell},'interp_tps')
+            check_grid(icell)=1;
+        end
+        if strcmp(CellInfo{icell}.CoordType,'grid')&&NbDimArray(icell)>=2
+            if ~testangle && isempty(icell_grid)% if the input gridded data is not modified, choose the first one in case of multiple gridded field cells
+                icell_grid=icell;
+                ProjMode{icell}='projection';
+            end
+            check_grid(icell)=1;
+        end
+    end
+    if ~isempty(find(check_grid))% if a grid is requested by the input field
+        if isempty(icell_grid)%  if the grid is not given by cell #icell_grid
+            if ~isfield(FieldData,'XMax')
+                FieldData=find_field_bounds(FieldData);
+%             CellIndex=find(check_grid);
+%             for igrid=1:numel(CellIndex)
+%                 icell=CellIndex(igrid);% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
+%                 NbDim=NbDimArray(icell);
+%                 for idim=1:NbDim %loop on space dimensions
+%                     ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension
+%                     Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field
+%                     if ~isequal(ivar,0)%  a variable corresponds to the dimension #idim
+%                         
+%                         
+%                         
+%                     else
+%                                                     Coord_i_str=['Coord_' num2str(idim)];
+%                             DCoord_min(idim)=1;%default
+%                             Coord{idim}=[0.5 DimValue(idim)-0.5];
+%                             test_direct(idim)=1;
+%                     end
+%                 % default bounds, case of gridded data
+%                 if strcmp(CellInfo{icell}.CoordType,'grid')
+%                     % find default mesh
+%                     for idim=1:NbDim %loop on space dimensions
+%                         test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
+%                         ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension
+%                         DimValue=size(FieldData.(FieldData.ListVarName{ivar}));
+%                         if ~isequal(ivar,0)%  a variable corresponds to the dimension #idim
+%                             Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field
+%                             if numel(Coord{idim})==2 %input array defined on a regular grid
+%                                 DCoord_min(idim)=(Coord{idim}(2)-Coord{idim}(1))/DimValue(idim);
+%                                 Coord{idim}=linspace(Coord{idim}(1),Coord{idim}(2),DimValue(idim));
+%                             else
+%                                 DCoord=diff(Coord{idim});%array of coordinate derivatives for the input field
+%                                 DCoord_min(idim)=min(DCoord);
+%                                 DCoord_max=max(DCoord);
+%                                 if abs(DCoord_max-DCoord_min(idim))>abs(DCoord_max/1000)
+%                                     msgbox_uvmat('ERROR',['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
+%                             end
+%                             test_direct(idim)=(DCoord_min(idim)>0);
+%                         else  % no variable associated with the  dimension #idim, the coordinate value is set equal to the matrix index by default
+% %                             Coord_i_str=['Coord_' num2str(idim)];
+% %                             DCoord_min(idim)=1;%default
+% %                             Coord{idim}=[0.5 DimValue(idim)-0.5];
+% %                             test_direct(idim)=1;
+%                         end
+%                     end
+%                     if isempty(DY)
+%                         DY=abs(DCoord_min(NbDim-1));
+%                     end
+%                     npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol
+%                     if isempty(DX)
+%                         DX=abs(DCoord_min(NbDim));
+%                     end
+%                     npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol
+%                     for idim=1:NbDim
+%                         if test_interp(idim)
+%                             DimValue(idim)=1+round(abs(Coord{idim}(end)-Coord{idim}(1))/abs(DCoord_min(idim)));%nbre of points after possible interpolation on a regular gri
+%                         end
+%                     end
+%                     Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY);
+%                     test_direct_y=test_direct(NbDim-1);
+%                     Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX);
+%                     test_direct_x=test_direct(NbDim);
+%                     DAX=DCoord_min(NbDim);
+%                     DAY=DCoord_min(NbDim-1);
+%                     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);% image corners in the new coordiantes
+%                     ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);
+%                     xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame
+%                     ycor_new=-xcorner*sin_om+ycorner*cos_om;
+%                     if ~testXMax
+%                         XMax(igrid)=max(xcor_new);
+%                     end
+%                     if ~testXMin
+%                         XMin(igrid)=min(xcor_new);
+%                     end
+%                     if ~testYMax
+%                         YMax(igrid)=max(ycor_new);
+%                     end
+%                     if ~testYMin
+%                         YMin(igrid)=min(ycor_new);
+%                     end
+%                     DX(igrid)=(maxAX-minAX)/(DimValue(NbDim)-1);
+%                     DY(igrid)=(maxAY-minAY)/(DimValue(NbDim-1)-1);
+%                     if NbDim==3
+%                         DZ(igrid)=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);
+%                         if ~test_direct(1)
+%                             DZ=-DZ;
+%                         end
+%                         Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));
+%                         test_direct_z=test_direct(1);
+%                     end
+%                 else
+%                     
+%                 end
+%                 YMax=max(YMax);
+%                 YMin=min(YMin);
+%                 XMax=max(XMax);
+%                 XMin=min(XMin);
+            end
+        end
+    end
+end
+if ~isempty(find(check_grid))||~strcmp(ObjectData.ProjMode,'projection')%no existing gridded data used
+    if isempty(icell_grid)||~strcmp(ObjectData.ProjMode,'projection')%no existing gridded data used
+        AYName='coord_y';
+        AXName='coord_x';
+        if ~strcmp(ObjectData.ProjMode,'projection')
+            ProjData.coord_y=[ObjectData.RangeY(1) ObjectData.RangeY(2)];%note that if projection is done on a grid, the Min and Max along each direction must have been defined
+        ProjData.coord_x=[ObjectData.RangeX(1) ObjectData.RangeX(2)];
+        coord_x_proj=ObjectData.RangeX(1):ObjectData.DX:ObjectData.RangeX(2);
+        coord_y_proj=ObjectData.RangeY(1):ObjectData.DY:ObjectData.RangeY(2);
+        else
+        ProjData.coord_y=[FieldData.YMin FieldData.YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined
+        ProjData.coord_x=[FieldData.XMin FieldData.XMax];
+        coord_x_proj=FieldData.XMin:FieldData.CoordMesh:FieldData.XMax;
+        coord_y_proj=FieldData.YMin:FieldData.CoordMesh:FieldData.YMax;
+        end
+        [X,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
+        XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system
+        YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3));
+    else% we use the existing grid from field cell #icell_grid
+        NbDim=NbDimArray(icell_grid);
+        AYName=FieldData.ListVarName{CellInfo{icell_grid}.CoordIndex(NbDim-1)};%name of input x coordinate (name preserved on projection)
+        AXName=FieldData.ListVarName{CellInfo{icell_grid}.CoordIndex(NbDim)};%name of input y coordinate (name preserved on projection)
+        ProjData.(AYName)=FieldData.(AYName); % new (projected ) y coordinates
+        ProjData.(AXName)=FieldData.(AXName); % new (projected ) y coordinates
+    end
+            ProjData.ListVarName={AYName,AXName};
+        ProjData.VarDimName={AYName,AXName};
+        ProjData.VarAttribute={[],[]};
+end
+    
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
+% LOOP ON FIELD CELLS, PROJECT VARIABLES
 % CellVarIndex=cells of variable index arrays
 %ivar_new=0; % index of the current variable in the projected field
@@ -1050,15 +1189,15 @@
     end
     VarIndex=CellInfo{icell}.VarIndex;%  indices of the selected variables in the list FieldData.ListVarName
-%     ivar_U=[];ivar_V=[];ivar_W=[];
-%     if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')
-%         ivar_U=CellInfo{icell}.VarIndex_vector_x_tps;
-%         ivar_V=CellInfo{icell}.VarIndex_vector_y_tps;
-%     elseif isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y')
-%         ivar_U=CellInfo{icell}.VarIndex_vector_x;
-%         ivar_V=CellInfo{icell}.VarIndex_vector_y;
-%     end
-%     if isfield(CellInfo{icell},'VarIndex_vector_z')
-%         ivar_W=CellInfo{icell}.VarIndex_vector_z;
-%     end
+    %     ivar_U=[];ivar_V=[];ivar_W=[];
+    %     if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')
+    %         ivar_U=CellInfo{icell}.VarIndex_vector_x_tps;
+    %         ivar_V=CellInfo{icell}.VarIndex_vector_y_tps;
+    %     elseif isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y')
+    %         ivar_U=CellInfo{icell}.VarIndex_vector_x;
+    %         ivar_V=CellInfo{icell}.VarIndex_vector_y;
+    %     end
+    %     if isfield(CellInfo{icell},'VarIndex_vector_z')
+    %         ivar_W=CellInfo{icell}.VarIndex_vector_z;
+    %     end
     %dimensions
     DimCell=FieldData.VarDimName{VarIndex(1)};
@@ -1252,97 +1391,47 @@
             Coord_x=[];
             
-            % find default mesh
-            for idim=1:NbDim %loop on space dimensions
-                test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
-                ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension
-                if ~isequal(ivar,0)%  a variable corresponds to the dimension #idim
-                    Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field
-                    if numel(Coord{idim})==2 %input array defined on a regular grid
-                        DCoord_min(idim)=(Coord{idim}(2)-Coord{idim}(1))/DimValue(idim);
-                        Coord{idim}=linspace(Coord{idim}(1),Coord{idim}(2),DimValue(idim));
-                    else
-                        DCoord=diff(Coord{idim});%array of coordinate derivatives for the input field
-                        DCoord_min(idim)=min(DCoord);
-                        DCoord_max=max(DCoord);
-                        if abs(DCoord_max-DCoord_min(idim))>abs(DCoord_max/1000)
-                            msgbox_uvmat('ERROR',['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
-                    end
-                    test_direct(idim)=(DCoord_min(idim)>0);
-                else  % no variable associated with the  dimension #idim, the coordinate value is set equal to the matrix index by default
-                    Coord_i_str=['Coord_' num2str(idim)];
-                    DCoord_min(idim)=1;%default
-                    Coord{idim}=[0.5 DimValue(idim)-0.5];
-                    test_direct(idim)=1;
-                end
-            end
-            if isempty(DY)
-                DY=abs(DCoord_min(NbDim-1));
-            end
-            npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol
-            if isempty(DX)
-                DX=abs(DCoord_min(NbDim));
-            end
-            npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol
-            for idim=1:NbDim
-                if test_interp(idim)
-                    DimValue(idim)=1+round(abs(Coord{idim}(end)-Coord{idim}(1))/abs(DCoord_min(idim)));%nbre of points after possible interpolation on a regular gri
-                end
-            end
-            Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY);
-            test_direct_y=test_direct(NbDim-1);
-            Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX);
-            test_direct_x=test_direct(NbDim);
-            DAX=DCoord_min(NbDim);
-            DAY=DCoord_min(NbDim-1);
             
-            % default bounds
-            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);% image corners in the new coordiantes
-            ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);
-            xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame
-            ycor_new=-xcorner*sin_om+ycorner*cos_om;
-            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)/(DimValue(NbDim)-1);
-            DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1);
-            if DX==0
-                DX=DXinit;
-            end
-            if DY==0
-                DY=DYinit;
-            end
-            if NbDim==3
-                DZ=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);
-                if ~test_direct(1)
-                    DZ=-DZ;
-                end
-                Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));
-                test_direct_z=test_direct(1);
-            end
+            
+            %             % default bounds
+            %             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);% image corners in the new coordiantes
+            %             ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);
+            %             xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame
+            %             ycor_new=-xcorner*sin_om+ycorner*cos_om;
+            %             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)/(DimValue(NbDim)-1);
+            %             DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1);
+            %             if DX==0
+            %                 DX=DXinit;
+            %             end
+            %             if DY==0
+            %                 DY=DYinit;
+            %             end
+            %             if NbDim==3
+            %                 DZ=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);
+            %                 if ~test_direct(1)
+            %                     DZ=-DZ;
+            %                 end
+            %                 Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));
+            %                 test_direct_z=test_direct(1);
+            %             end
             %define new coordiantes if not already done by the definition of a projection grid
             if ~check_grid
-                AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(NbDim-1)};%name of input x coordinate (name preserved on projection)
-                AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(NbDim)};%name of input y coordinate (name preserved on projection)
-                ListVarName=[ListVarName {AYName} {AXName}];% update the list of projected variables
-                VarDimName=[VarDimName {AYName} {AXName}];% update the corresponding list of dimensions
-                VarAttribute=[VarAttribute {[]} {[]}];% update the list of attributes
-                ProjData.(AYName)=[YMin YMax]; % new (projected ) y coordinates
-                ProjData.(AXName)=[XMin XMax]; % new (projected ) y coordinates
+                
+                
             end
             
@@ -1370,4 +1459,5 @@
                         VarAttribute=[VarAttribute FieldData.VarAttribute(VarIndex)];
                     end
+                    
                     ProjData.(AYName)=FieldData.(AYName);
                     ProjData.(AXName)=FieldData.(AXName);
@@ -1540,8 +1630,8 @@
                     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
+                %                 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
@@ -1552,5 +1642,5 @@
 % SubData.VarDimName={};
 % SubData.VarAttribute={};
-% check_remove=zeros(size(ProjData.ListVarName)); 
+% check_remove=zeros(size(ProjData.ListVarName));
 % for iproj=1:numel(ProjData.VarAttribute)
 %     if isfield(ProjData.VarAttribute{iproj},'CheckSub')&&isequal(ProjData.VarAttribute{iproj}.CheckSub,1)
@@ -1560,5 +1650,5 @@
 %         SubData.VarAttribute=[SubData.VarAttribute ProjData.VarAttribute{iproj}];
 %         SubData.(VarName)=ProjData.(VarName);
-%         check_remove(iproj)=1;        
+%         check_remove(iproj)=1;
 %     end
 % end
@@ -1569,9 +1659,10 @@
 %     ProjData.VarAttribute(ind_remove)=[];
 %     ProjData=sub_field(ProjData,[],SubData);
-% end   
+% end
 
 %-----------------------------------------------------------------
-%projection in a volume 
- function  [ProjData,errormsg] = proj_volume(FieldData, ObjectData)
+%projection in a volume
+function  [ProjData,errormsg] = proj_volume(FieldData, ObjectData)
+
 %-----------------------------------------------------------------
 ProjData=FieldData;%default output
@@ -1584,6 +1675,6 @@
 end
 
-%% rotation angles 
-VolumeAngle=[0 0 0]; 
+%% rotation angles
+VolumeAngle=[0 0 0];
 norm_plane=[0 0 1];
 if isfield(ObjectData,'Angle')&& isequal(size(ObjectData.Angle),[1 3])&& ~isequal(ObjectData.Angle,[0 0 0])
Index: /trunk/src/read_civdata.m
===================================================================
--- /trunk/src/read_civdata.m	(revision 653)
+++ /trunk/src/read_civdata.m	(revision 654)
@@ -73,5 +73,7 @@
         switch FieldNames{ilist}
             case{'U','V','norm(U,V)'}
+                if ~strcmp(FieldNames{1},'vec(U,V)')% if the scalar is not used as color of vectors
                 ProjModeRequest='interp_lin';
+                end
             case {'curl(U,V)','div(U,V)','strain(U,V)'}
                 ProjModeRequest='interp_tps';
Index: /trunk/src/read_field.m
===================================================================
--- /trunk/src/read_field.m	(revision 653)
+++ /trunk/src/read_field.m	(revision 654)
@@ -49,7 +49,8 @@
         end
     end
+    check_colorvar=zeros(size(InputField));
     if isfield(ParamIn,'ColorVar')
         InputField=[ParamIn.FieldName {ParamIn.ColorVar}];
-        check_colorvar=1;
+        check_colorvar(numel(InputField))=1;
     end
 end
@@ -70,24 +71,25 @@
         for ilist=1:numel(InputField)
             r=regexp(InputField{ilist},'(?<Operator>(^vec|^norm))\((?<UName>.+),(?<VName>.+)\)$','names');
-            if isempty(r)
+            if isempty(r)%  no operator used
                 ListVar=[ListVar InputField(ilist)];
+                if check_colorvar(ilist)
+                                    Role{numel(ListVar)}='ancillary';% not projected with interpolation
+                ProjModeRequest{numel(ListVar)}='';
+                else
                 Role{numel(ListVar)}='scalar';
                 ProjModeRequest{numel(ListVar)}='interp_lin';%scalar field (requires interpolation for plot)
-            else
+                end
+            else  % an operator 'vec' or 'norm' is used
                 ListVar=[ListVar {r.UName,r.VName}];
                 Role{numel(ListVar)}='vector_y';
                 Role{numel(ListVar)-1}='vector_x';
-                            switch r.Operator
-                                case 'norm'
+                      if ~check_colorvar(ilist) && strcmp(r.Operator,'norm')
                                     ProjModeRequest{numel(ListVar)-1}='interp_lin';%scalar field (requires interpolation for plot)
                                     ProjModeRequest{numel(ListVar)}='interp_lin';
-                                otherwise
+                      else
                                    ProjModeRequest{numel(ListVar)-1}='';
                                    ProjModeRequest{numel(ListVar)}='';
                             end
             end
-        end
-        if check_colorvar
-            Role{numel(ListVar)}='ancillary';% scalar used for color vector (not projected)
         end
         if isfield(ParamIn,'TimeDimName')% case of reading of a single time index in a multidimensional array
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 653)
+++ /trunk/src/series.m	(revision 654)
@@ -120,5 +120,5 @@
 
 %% list of builtin functions in the mebu ActionName
-ActionList={'check_data_files';'aver_stat';'time_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback
+ActionList={'check_data_files';'aver_stat';'time_series';'civ_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback
 NbBuiltinAction=numel(ActionList);
 [path_series,name,ext]=fileparts(which('series'));% path to the GUI series
Index: /trunk/src/set_col_vec.m
===================================================================
--- /trunk/src/set_col_vec.m	(revision 653)
+++ /trunk/src/set_col_vec.m	(revision 654)
@@ -53,6 +53,6 @@
         maxC=max(vec_C);
     end
-    colcode_out.MinC=minC;
-    colcode_out.MaxC=maxC;
+    colcode_out.MinVec=minC;
+    colcode_out.MaxVec=maxC;
     if strcmp(colcode.ColorCode,'rgb')|| strcmp(colcode.ColorCode,'bgr')% 3 color representation
         if  isfield(colcode,'ColCode1')
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 653)
+++ /trunk/src/uvmat.m	(revision 654)
@@ -2418,4 +2418,5 @@
 %       abstime_1=[];
 % end  
+set(handles.TimeValue,'String',num2str(abstime))
 abstime_1=[];
 TimeName_1=get(handles.TimeName_1,'String');
@@ -2480,70 +2481,72 @@
 
 %% analyse input field
-[CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse  the input field structure
-if ~isempty(errormsg)
-    errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error
-    return
-end
-
-NbDim=max(NbDimArray);% spatial dimension of the input field
-imax=find(NbDimArray==NbDim);% indices of field cells to consider
-if isfield(UvData.Field,'NbDim')
-    NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates
-end
-
-%% get bounds and mesh (needed  to propose default options for projection objects)
-if NbDim>1
-    CoordMax=zeros(numel(imax),NbDim);
-    CoordMin=zeros(numel(imax),NbDim);
-    Mesh=zeros(1,numel(imax));
-    for ind=1:numel(imax)
-        if strcmp(CellInfo{imax(ind)}.CoordType,'tps')
-            CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable
-            CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case)
-            CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case)
-            CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);
-            CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case)
-        else
-            XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
-            YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)};
-            CoordMax(ind,NbDim)=max(max(UvData.Field.(XName)));
-            CoordMin(ind,NbDim)=min(min(UvData.Field.(XName)));
-            CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName)));
-            CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName)));
-            %         test_x=1;%test for unstructured coordinates
-            if NbDim==3
-                ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)};
-                CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName)));
-                CoordMin(ind,1)=min(min(UvData.Field.(ZName)));
-            end
-        end
-        switch CellInfo{imax(ind)}.CoordType
-            
-            case {'scattered','tps'} %unstructured coordinates
-                NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points
-                Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim)
-            case 'grid'%structured coordinate
-                NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction
-                Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1));                
-        end
-    end
-    UvData.Field.CoordMesh=min(Mesh);
-    UvData.Field.XMax=max(CoordMax(:,end));
-    UvData.Field.XMin=min(CoordMin(:,end));
-    UvData.Field.YMax=max(CoordMax(:,end-1));
-    UvData.Field.YMin=min(CoordMin(:,end-1));
-    if NbDim==3
-        UvData.Field.ZMax=max(CoordMax(ind,1));
-        UvData.Field.ZMin=max(CoordMin(ind,1));
-    end
-    % adjust the mesh to a value 1, 2 , 5 *10^n
-    ord=10^(floor(log10(UvData.Field.CoordMesh)));%order of magnitude
-    if UvData.Field.CoordMesh/ord>=5
-        UvData.Field.CoordMesh=5*ord;
-    elseif UvData.Field.CoordMesh/ord>=2
-        UvData.Field.CoordMesh=2*ord;
-    else
-        UvData.Field.CoordMesh=ord;
-    end
+% [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse  the input field structure
+% if ~isempty(errormsg)
+%     errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error
+%     return
+% end
+% 
+% NbDim=max(NbDimArray);% spatial dimension of the input field
+% imax=find(NbDimArray==NbDim);% indices of field cells to consider
+% if isfield(UvData.Field,'NbDim')
+%     NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates
+% end
+% 
+% %% get bounds and mesh (needed  to propose default options for projection objects)
+% if NbDim>1
+%     CoordMax=zeros(numel(imax),NbDim);
+%     CoordMin=zeros(numel(imax),NbDim);
+%     Mesh=zeros(1,numel(imax));
+%     for ind=1:numel(imax)
+%         if strcmp(CellInfo{imax(ind)}.CoordType,'tps')
+%             CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable
+%             CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case)
+%             CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case)
+%             CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);
+%             CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case)
+%         else
+%             XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
+%             YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)};
+%             CoordMax(ind,NbDim)=max(max(UvData.Field.(XName)));
+%             CoordMin(ind,NbDim)=min(min(UvData.Field.(XName)));
+%             CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName)));
+%             CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName)));
+%             %         test_x=1;%test for unstructured coordinates
+%             if NbDim==3
+%                 ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)};
+%                 CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName)));
+%                 CoordMin(ind,1)=min(min(UvData.Field.(ZName)));
+%             end
+%         end
+%         switch CellInfo{imax(ind)}.CoordType
+%             
+%             case {'scattered','tps'} %unstructured coordinates
+%                 NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points
+%                 Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim)
+%             case 'grid'%structured coordinate
+%                 NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction
+%                 Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1));                
+%         end
+%     end
+%     UvData.Field.CoordMesh=min(Mesh);
+%     UvData.Field.XMax=max(CoordMax(:,end));
+%     UvData.Field.XMin=min(CoordMin(:,end));
+%     UvData.Field.YMax=max(CoordMax(:,end-1));
+%     UvData.Field.YMin=min(CoordMin(:,end-1));
+%     if NbDim==3
+%         UvData.Field.ZMax=max(CoordMax(ind,1));
+%         UvData.Field.ZMin=max(CoordMin(ind,1));
+%     end
+%     % adjust the mesh to a value 1, 2 , 5 *10^n
+%     ord=10^(floor(log10(UvData.Field.CoordMesh)));%order of magnitude
+%     if UvData.Field.CoordMesh/ord>=5
+%         UvData.Field.CoordMesh=5*ord;
+%     elseif UvData.Field.CoordMesh/ord>=2
+%         UvData.Field.CoordMesh=2*ord;
+%     else
+%         UvData.Field.CoordMesh=ord;
+%     end
+if UvData.Field.NbDim>1
+    UvData.Field=find_field_bounds(UvData.Field);
     % default projection plane
     if isempty(UvData.ProjObject{1})
@@ -2555,5 +2558,5 @@
     end
     %% 3D case (menuvolume)
-    if NbDim==3% && UvData.NewSeries
+    if UvData.Field.NbDim==3% && UvData.NewSeries
         test_set_object=1;
         hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
@@ -2607,5 +2610,5 @@
 
 %% usual 1D (x,y) plots
-if NbDim<=1
+if UvData.Field.NbDim<=1
     set(handles.Objects,'Visible','off')
     set(handles.ListObject_1_title,'Visible','off')
@@ -2727,4 +2730,5 @@
                 view_field(ObjectData)
             else
+              %  ObjectData.VarAttribute{5}.Role='scalar';TODO    CORRECT
                 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
                 if imap==1
@@ -3155,5 +3159,5 @@
         set(handles.FixVelType,'visible','off')
         set(handles.VelType,'Visible','off')
-        set(handles.VelType_1,'Visible','off')
+        %set(handles.VelType_1,'Visible','off')
         
         %read selection from get_field
@@ -3163,10 +3167,8 @@
         FieldList={};
         VecColorList={};
-        XName=GetFieldData.Coordinates.Coord_x;
         switch GetFieldData.FieldOption
             case 'vectors'
                 UName=GetFieldData.PanelVectors.vector_x;
                 VName=GetFieldData.PanelVectors.vector_y;
-                XName=GetFieldData.Coordinates.Coord_x;
                 YName={GetFieldData.Coordinates.Coord_y};
                 CName=GetFieldData.PanelVectors.vec_color;
@@ -3174,11 +3176,16 @@
             case 'scalar'
                 AName=GetFieldData.PanelScalar.scalar;
-                XName=GetFieldData.Coordinates.Coord_x;
                 YName={GetFieldData.Coordinates.Coord_y};
                 FieldList={AName};
             case '1D plot'
                 YName=GetFieldData.PanelOrdinate.ordinate;
-                XName=GetFieldData.Coordinates.Coord_x;
-        end
+            case 'civdata...'%return to civdata from get_field
+               % [FieldList,VecColorList]=set_field_list('U','V','C');
+                set(handles.FieldName,'Value',2)
+                set(handles.FixVelType,'visible','on')
+                set(handles.VelType,'Visible','on')
+        end
+        if ~strcmp(GetFieldData.FieldOption,'civdata...')
+            XName=GetFieldData.Coordinates.Coord_x;
         TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
         if strcmp(TimeNameStr,'file index')
@@ -3203,4 +3210,5 @@
         UvData.FileType{1}='netcdf';
         set(handles.uvmat,'UserData',UvData)
+        end
         run0_Callback(hObject, eventdata, handles)
         
@@ -4076,5 +4084,5 @@
 function num_MinVec_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
-max_vec_Callback(hObject, eventdata, handles)
+num_MaxVec_Callback(hObject, eventdata, handles)
 
 %------------------------------------------------------------------------
@@ -5202,6 +5210,12 @@
 function MenuPIV_Callback(hObject, eventdata, handles)
     Param=read_param(handles);
-    Param.ActionName='civ_series';
-series(Param)
+%     Param.ActionName='civ_series';
+hseries=series(Param);
+hhseries=guidata(hseries);
+ActionMenu=get(hhseries.ActionName,'String');
+index_action=find(strcmp('civ_series',ActionMenu));
+set(hhseries.ActionName,'Value',index_action);
+series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading  in uvmat, show the image in phys coordinates
+
 
 %------------------------------------------------------------------------
