Index: /trunk/src/find_field_cells.m
===================================================================
--- /trunk/src/find_field_cells.m	(revision 534)
+++ /trunk/src/find_field_cells.m	(revision 535)
@@ -55,29 +55,24 @@
 
 function [CellInfo,NbDim,errormsg]=find_field_cells(Data)
-% CellVarIndex={};
-% CellInfo={}
+
 NbDim=0;
-% CellVarType=[];
-errormsg=[];
+errormsg='';
 if ~isfield(Data,'ListVarName'), errormsg='the list of variables .ListVarName is missing';return;end
 if ~isfield(Data,'VarDimName'), errormsg='the list of dimensions .VarDimName is missing';return;end
 nbvar=numel(Data.ListVarName);%number of field variables
 if ~isequal(numel(Data.VarDimName),nbvar), errormsg='.ListVarName and .VarDimName have unequal length';return;end
-if isfield(Data,'ListDimName')&& isfield(Data,'DimValue')&&isequal(numel(Data.ListDimName),numel(Data.DimValue))
-    check_dim=1;% dimensions of data defined, data not needed for this function
-else
-    check_dim=0;
-    for ilist=1:numel(Data.ListVarName)
-        if ~isfield(Data,Data.ListVarName{ilist})
-            errormsg=['missing variable ' Data.ListVarName{ilist}];
-            return
-        end
-    end
-end
-icell=0;
-
-% NbDim=[];
-% VarDimIndex=[];
-% VarDimName={};
+% check the existence of variable data
+check_var=1;
+for ilist=1:numel(Data.ListVarName)
+    if ~isfield(Data,Data.ListVarName{ilist})
+        check_var=0;% dimensions of data defined, data not needed for this function
+        break
+    end
+end
+if ~check_var &&  ~(isfield(Data,'ListDimName')&& isfield(Data,'DimValue')&&isequal(numel(Data.ListDimName),numel(Data.DimValue)))
+    errormsg=['missing variable or values of dimensions' Data.ListVarName{ilist}];
+    return
+end
+
 
 %% role of variables and list of requested operations
@@ -127,5 +122,7 @@
             CellInfo{icell}.CoordIndex=ivar_coord_x(icell);
             % size of coordinate var
-            if check_dim
+            if check_var
+                CellInfo{icell}.CoordSize=numel(Data.(Data.ListVarName{ivar_coord_x(icell)}));
+            else
                 for idim=1:numel(DimCell)
                  check_index= strcmp(DimCell{idim},Data.ListDimName);
@@ -133,6 +130,4 @@
                 end
                 CellInfo{icell}.CoordSize=prod(CellInfo{icell}.CoordSize);
-            else
-                CellInfo{icell}.CoordSize=numel(Data.(Data.ListVarName{ivar_coord_x(icell)}));
             end
             ind_y=find(strcmp('coord_y',Role(VarIndex)));
@@ -157,11 +152,11 @@
 
 %% look for tps coordinates
-ivar_remain=find(~check_select);
+ivar_remain=find(~check_select);% indices of remaining variables (not already selected)
 check_coord_tps= strcmp('coord_tps',Role(~check_select));
-ivar_tps=ivar_remain(check_coord_tps);
+ivar_tps=ivar_remain(check_coord_tps);% variable indices corresponding to tps coordinates
 for icell_tps=1:numel(ivar_tps)
-    DimCell=Data.VarDimName{ivar_tps(icell_tps)};
-    icell=numel(CellInfo)+icell_tps;
-    CellInfo{icell}.CoordIndex=ivar_tps(icell);
+    DimCell=Data.VarDimName{ivar_tps(icell_tps)};% dimension names for the current tps coordinate variable
+    icell=numel(CellInfo)+icell_tps; % new field cell index
+    CellInfo{icell}.CoordIndex=ivar_tps(icell_tps);% index of the  tps coordinate variable
     CellInfo{icell}.VarIndex_subrange_tps=[];
     CellInfo{icell}.VarIndex_nbsites_tps=[];
@@ -182,5 +177,8 @@
     CellInfo{icell}.CoordType='tps';
     CellInfo{icell}.VarIndex=find(check_cell);
-    if check_dim
+    if check_var
+        NbDim(icell)=size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),2);
+        CellInfo{icell}.CoordSize=size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),1)*size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),3);
+    else
         check_index_1= strcmp(DimCell{1},Data.ListDimName);
         check_index_2= strcmp(DimCell{2},Data.ListDimName);
@@ -188,24 +186,26 @@
         NbDim(icell)=Data.DimValue(check_index_2);
         CellInfo{icell}.CoordSize=Data.DimValue(check_index_1)*Data.DimValue(check_index_3);
-    else
-        NbDim(icell)=size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),2);
-        CellInfo{icell}.CoordSize=size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),1)*size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),3);
     end
     check_select=check_select|check_cell;
 end
 
-%% look for dimension variables and corresponding gridded data
-ivar_remain=find(~check_select);
+%% look for coordinate variables and corresponding gridded data:
+% coordinate variables are variables associated with a single dimension, defining the coordinate values
+% two cases: 1)the coordiante variable represents the set of coordiante values
+%            2)the coordinate variable contains only two elements, representing the coordinate bounds for the dimension with the same name as the cordinate
+ivar_remain=find(~check_select);% indices of remaining variables, not already taken into account
+ListVarName=Data.ListVarName(~check_select);%list of remaining variables
 VarDimName=Data.VarDimName(~check_select);%dimensions of remaining variables
-check_coord= cellfun(@numel,VarDimName)==1|cellfun(@ischar,VarDimName)==1;% find variables with a single dimension
-ListCoordIndex=ivar_remain(check_coord);
-ListCoordName=Data.ListVarName(ListCoordIndex);
-ListDimName=Data.VarDimName(ListCoordIndex);
-%remove redondant values
+check_coord= cellfun(@numel,VarDimName)==1|cellfun(@ischar,VarDimName)==1;% find remaining variables with a single dimension
+ListCoordIndex=ivar_remain(check_coord);% indices of remaining variables with a single dimension
+ListCoordName=Data.ListVarName(ListCoordIndex);% corresponding names of remaining variables with a single dimension
+ListDimName=Data.VarDimName(ListCoordIndex);% dimension names of remaining variables with a single dimension
+
+%remove redondant variables -> keep only one variable per dimension
 check_keep=logical(ones(size(ListDimName)));
 for idim=1:numel(ListDimName)
-    prev_ind=strcmp(ListDimName{idim},ListDimName(1:idim-1));
+    prev_ind=strcmp(ListDimName{idim},ListDimName(1:idim-1));% check whether the dimension is already taken into account
     if ~isempty(prev_ind)
-        if strcmp(ListCoordName{idim},ListDimName{idim}) %coordinate variable
+        if strcmp(ListCoordName{idim},ListDimName{idim}) %variable with the same name as the coordinate taken in priority
             check_keep(prev_ind)=0;
         else
@@ -214,44 +214,57 @@
     end
 end
-ListCoordIndex=ListCoordIndex(check_keep);
-ListCoordName=ListCoordName(check_keep);
-ListDimName=ListDimName(check_keep);
-
-CoordSize=[];
+ListCoordIndex=ListCoordIndex(check_keep);% list of coordinate variable indices
+ListCoordName=ListCoordName(check_keep);% list of coordinate variable names
+ListDimName=ListDimName(check_keep);% list of coordinate dimension names
+
+% determine dimension sizes
+CoordSize=zeros(size(ListCoordIndex));
 for ilist=1:numel(ListCoordIndex)
     if iscell(ListDimName{ilist})
         ListDimName(ilist)=ListDimName{ilist};%transform cell to string
     end
-    if check_dim% if the list of dimensions is directly defined
-        check_index= strcmp(ListDimName{ilist},Data.ListDimName);
-        DimValue=Data.DimValue(check_index);
+    if check_var% if the list of dimensions has been directly defined, no variable data available
+        CoordSize(ilist)=numel(Data.(ListCoordName{ilist}));% number of elements in the variable corresponding to the dimension #ilist
     else
-        DimValue=numel(Data.(ListCoordName{ilist}));
-    end
-    if DimValue==2% case of uniform grid coordinate defined by lower and upper bounds only
-        ListDimName{ilist}=ListCoordName{ilist};% look for dimensions with name equal to coordinate for
-        if check_dim
-            check_index= strcmp(ListCoordName{ilist},Data.ListDimName);
-            CoordSize(ilist)=Data.DimValue(check_index);
-        else
-            CoordSize(ilist)=numel(Data.(ListCoordName{ilist}));
-        end
-    else
-        CoordSize(ilist)=DimValue;
-    end
-end
+        check_index= strcmp(ListDimName{ilist},Data.ListDimName);% find the  index in the list of dimensions
+        CoordSize(ilist)=Data.DimValue(check_index);% find the  corresponding dimension value
+    end
+    if CoordSize(ilist)==2% case of uniform grid coordinate defined by lower and upper bounds only
+        ListDimName{ilist}=ListCoordName{ilist};% replace the dimension name by the coordinate variable name 
+%         if check_var
+%             check_index= strcmp(ListCoordName{ilist},Data.ListDimName);
+%             CoordSize(ilist)=Data.DimValue(check_index);
+%         else
+%             CoordSize(ilist)=numel(Data.(ListCoordName{ilist}));
+% %         end
+%     else
+%         CoordSize(ilist)=DimValue;
+    end
+end
+
+% group the remaining variables in cells sharing the same coordinate variables
 NewCellInfo={};
 NewCellDimIndex={};
 NewNbDim=[];
-for ivardim=1:numel(VarDimName) % loop on the list of remaining variables
-    DimCell=VarDimName{ivardim};% dimension names of the current variable
+for ivardim=1:numel(VarDimName) % loop at the list of remaining variables
+    DimCell=VarDimName{ivardim};% dimension names of the current variable 
     if ischar(DimCell), DimCell={DimCell}; end %transform char to cell if needed
     DimIndices=[];
     for idim=1:numel(DimCell)
-        ind_dim=find(strcmp(DimCell{idim},ListDimName));%find the dim index in the list of coord dimensions
+        ind_dim=find(strcmp(DimCell{idim},ListDimName));%find the dim index in the list of coordinate variables
         if ~isempty(ind_dim)
             DimIndices=[DimIndices ind_dim]; %update the list of coord dimensions included in DimCell
-        end
-    end
+            if check_var && CoordSize(ind_dim)==2 % determine the size of the coordinate in case of coordiante variable limited to lower and upper bounds
+                if isvector(Data.(ListVarName{ivardim})) || iscolumn(Data.(ListVarName{ivardim}))
+                    if numel(Data.(ListVarName{ivardim}))>2
+                        CoordSize(ind_dim)=numel(Data.(ListVarName{ivardim}));
+                    end
+                else
+                    CoordSize(ind_dim)=size(Data.(ListVarName{ivardim}),idim);
+                end
+            end
+        end
+    end
+    % look for cells of variables with the same coordinate variables
     check_previous=0;
     for iprev=1:numel(NewCellInfo)
@@ -262,4 +275,5 @@
         end
     end
+    % create a new cell if no previous one contains the coordinate variables
     if ~check_previous
         nbcell=numel(NewCellInfo)+1;
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 534)
+++ /trunk/src/plot_field.m	(revision 535)
@@ -270,26 +270,48 @@
 Data={};
 for icell=1:length(CellInfo)
-    VarIndex=CellInfo{icell}.VarIndex;%  indices of the selected variables in the list data.ListVarName
+    
+    % select types of  variables to be projected
+    ListProj={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'};
+    check_proj=false(size(FieldData.ListVarName));
+    for ilist=1:numel(ListProj)
+        if isfield(CellInfo{icell},ListProj{ilist})
+            check_proj(CellInfo{icell}.(ListProj{ilist}))=1;
+        end
+    end
+    VarIndex=find(check_proj);
+    %
+    %     VarIndex=CellInfo{icell}.VarIndex;%  indices of the selected variables in the list data.ListVarName
+    %     for ivar=1:length(VarIndex)
+    %         checkancillary=0;
+    %         if length(FieldData.VarAttribute)>=VarIndex(ivar)
+    %             VarAttribute=FieldData.VarAttribute{VarIndex(ivar)};
+    %             if isfield(VarAttribute,'Role')&&(strcmp(VarAttribute.Role,'ancillary')||strcmp(VarAttribute.Role,'coord_tps')...
+    %                     ||strcmp(VarAttribute.Role,'vector_x_tps')||strcmp(VarAttribute.Role,'vector_y_tps'))
+    %                 checkancillary=1;
+    %             end
+    %         end
+    %         if ~checkancillary% does not display variables with attribute '.Role=ancillary'
     for ivar=1:length(VarIndex)
-        checkancillary=0;
-        if length(FieldData.VarAttribute)>=VarIndex(ivar)
-            VarAttribute=FieldData.VarAttribute{VarIndex(ivar)};
-            if isfield(VarAttribute,'Role')&&(strcmp(VarAttribute.Role,'ancillary')||strcmp(VarAttribute.Role,'coord_tps')...
-                    ||strcmp(VarAttribute.Role,'vector_x_tps')||strcmp(VarAttribute.Role,'vector_y_tps'))
-                checkancillary=1;
-            end
-        end
-%         if ~checkancillary% does not display variables with attribute '.Role=ancillary'
-            VarName=FieldData.ListVarName{VarIndex(ivar)};
-            VarValue=FieldData.(VarName);
-            Data =[Data [{VarName}; num2cell(VarValue)]];
-            if size(VarValue,1)~=1
-                VarValue=VarValue';% put the different values on a line
-            end
-            if size(VarValue,1)==1
-            txt=[VarName '=' num2str(VarValue)];
-            txt_cell=[txt_cell;{txt}];
-            end
-%         end
+    VarName=FieldData.ListVarName{VarIndex(ivar)};
+    VarValue=FieldData.(VarName);
+    if iscolumn(VarValue)
+        VarValue=VarValue';% put the different values on a line
+    end
+    if numel(VarValue)>1 && numel(VarValue)<10
+        for ind=1:numel(VarValue)
+            VarNameCell{1,ind}=[VarName '_' num2str(ilist)];
+        end
+    else
+        VarNameCell={VarName};
+    end
+    if numel(VarValue)<10
+        Data =[Data [VarNameCell; num2cell(VarValue)]];
+    else
+        Data =[Data [VarNameCell; {['size ' num2str(size(VarValue))]}]];
+    end
+    if size(VarValue,1)==1
+        txt=[VarName '=' num2str(VarValue)];
+        txt_cell=[txt_cell;{txt}];
+    end
     end
 end
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 534)
+++ /trunk/src/uvmat.m	(revision 535)
@@ -293,5 +293,4 @@
     display_file_name(handles,inputfile)
     %%%%%%%
-    testinputfield=1;
 end
 
@@ -2404,18 +2403,19 @@
 %% get bounds and mesh (needed  to propose default options for projection objects)
 if NbDim>1
-    CoordMax=zeros(1,numel(imax));
-    CoordMin=zeros(1,numel(imax));
+    CoordMax=zeros(numel(imax),NbDim);
+    CoordMin=zeros(numel(imax),NbDim);
+    Mesh=zeros(numel(imax),NbDim);
     for ind=1:numel(imax)
         XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
         YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)};
-        CoordMax(ind,1)=max(max(UvData.Field.(XName)));
-        CoordMin(ind,1)=min(min(UvData.Field.(XName)));
-        CoordMax(ind,2)=max(max(UvData.Field.(YName)));
-        CoordMin(ind,2)=min(min(UvData.Field.(YName)));
+        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),3)=max(max(UvData.Field.(ZName)));
-            CoordMin(ind,3)=min(min(UvData.Field.(ZName)));
+            CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName)));
+            CoordMin(ind,1)=min(min(UvData.Field.(ZName)));
         end
         
@@ -2423,10 +2423,9 @@
             
             case 'scattered' %unstructured coordinates
-                NbPoints(ind)=CellInfo{imax(ind)}.CoordSize;% nbre of points
-                Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim)
+                NbPoints=CellInfo{imax(ind)}.CoordSize;% 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
-                Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./NbPoints);
-                
+                NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction
+                Mesh(ind,:)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1));                
         end
     end
@@ -2525,5 +2524,5 @@
     % main projection object (uvmat display)
     list_object=get(handles.ListObject_1,'String');
-    if isequal(list_object,{''})%refresh list of objects if the menu is empty
+    if isequal(list_object,{''})||isequal(list_object,' ')%refresh list of objects if the menu is empty
         set(handles.ListObject,'Value',1)
         set(handles.ListObject,'String',{'plane'})
