source: trunk/src/find_field_cells.m @ 1130

Last change on this file since 1130 was 1127, checked in by g7moreau, 11 months ago

Update Joel email

File size: 23.1 KB
Line 
1%'find_field_cells': analyse the field structure for input in uvmat functions, grouping the variables  into 'fields' with common coordinates
2%------------------------------------------------------------------------
3% function  [CellInfo,NbDim,errormsg]=find_field_cells(Data)
4%
5% OUTPUT:
6% CellInfo: cell of structures describing field cells
7%     .CoordType:  type of coordinates for each field cell = 'scattered','grid','tps';
8%     .CoordIndex: array of the indices of the variables representing the coordinates (in the order z,y,x)
9%     .CoordSize: array of the nbre of values for each  coordinate in a grid, nbre of points in the unstructured case
10%     .NbCentres_tps:
11%     .SubRange_tps
12%     .VarIndex: arrays of the variable indices in the field cell
13%     .VarIndex_ancillary: indices of ancillary variables
14%              _color : color image, the last index, which is not a coordinate variable, represent the 3 color components rgb
15%              _discrete: like scalar, but set of data points without continuity, represented as dots in a usual plot, instead of continuous lines otherwise
16%              _errorflag: index of error flag
17%              _image   : B/W image, (behaves like scalar)
18%              _vector_x,_y,_z: indices of variables giving the vector components x, y, z
19%              _warnflag: index of warnflag
20%              _histo: index of variable used as histogram
21%       .DimIndex
22%      .ProjModeRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation  or derivatives (tps) is needed to calculate the requested field
23%      .FieldName = operation to be performed to finalise the field cell after projection
24%      .SubCheck=0 /1 indicate that the field must be substracted (second  entry in uvmat)
25% NbDim: array with the length of CellVarIndex, giving the space dimension of each field cell
26% errormsg: error message
27%   
28% INPUT:
29% Data: structure representing fields, output of check_field_structure
30%            .ListGlobalAttributes
31%            .ListVarName: cell array listing the names (cahr strings) of the variables
32%            .VarDimName: cell array of cells containing the set of dimension names for each variable of .ListVarName
33%            .VarAttribute: cell array of structures containing the variable attributes:
34%                     .VarAttribute{ilist}.key=value, where ilist is the variable
35%                     index, key is the name of the attribute, value its value (char string or number)
36%            .Attr1, .Attr2....
37%        case of actual data:
38%            .Var1, .Var2...
39%        case of data structure, without the  data themselves
40%            .LisDimName: list of dimension names
41%            .DimValue: list of corresponding dimension values
42% HELP:
43% to get the dimensions of arrays common to the field #icell
44%         VarIndex=CellVarIndex{icell}; % list of variable indices
45%         DimIndex=Data.VarDimIndex{VarIndex(1)} % list of dimensions for each variable in the cell #icell
46
47%=======================================================================
48% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
49%   http://www.legi.grenoble-inp.fr
50%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
51%
52%     This file is part of the toolbox UVMAT.
53%
54%     UVMAT is free software; you can redistribute it and/or modify
55%     it under the terms of the GNU General Public License as published
56%     by the Free Software Foundation; either version 2 of the license,
57%     or (at your option) any later version.
58%
59%     UVMAT is distributed in the hope that it will be useful,
60%     but WITHOUT ANY WARRANTY; without even the implied warranty of
61%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
62%     GNU General Public License (see LICENSE.txt) for more details.
63%=======================================================================
64
65%    group the variables  into 'fields' with common dimensions
66
67function [CellInfo,NbDim,errormsg]=find_field_cells(Data)
68CellInfo={};%default output
69%NbDim=0;
70NbDim=[];
71errormsg='';
72if ~isfield(Data,'ListVarName'), errormsg='the list of variables .ListVarName is missing';return;end
73if ~isfield(Data,'VarDimName'), errormsg='the list of dimensions .VarDimName is missing';return;end
74nbvar=numel(Data.ListVarName);%number of variables in the field structure
75if ~isequal(numel(Data.VarDimName),nbvar), errormsg='.ListVarName and .VarDimName have unequal length';return;end
76% check the existence of variable data
77check_var=1;
78for ilist=1:numel(Data.ListVarName)
79    if ~isfield(Data,Data.ListVarName{ilist})
80        check_var=0;% dimensions of array defined, but the corresponding array is not given
81        break
82    end
83end
84
85%% role of variables and list of requested operations
86%ListRole={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','vector_x_tps','vector_y_tps','warnflag','errorflag',...
87%   'ancillary','image','color','discrete','scalar','coord_tps'};% rmq vector_x_tps and vector_y_tps to be replaced by vector_x and vector_y
88Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks
89ProjModeRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default
90FieldName=cell(size(Role)); % fieldRequest set to {} by default
91CheckSub=zeros(size(Role));% =1 for fields to substract
92%Role=regexprep(Role,' ','scalar'); % Role set to 'scalar' by default
93if isfield(Data,'VarAttribute')
94    for ivar=1:numel(Data.VarAttribute)
95        if isfield(Data.VarAttribute{ivar},'Role')
96            Role{ivar}=Data.VarAttribute{ivar}.Role;
97        end
98        if isfield(Data.VarAttribute{ivar},'ProjModeRequest')
99            ProjModeRequest{ivar}=Data.VarAttribute{ivar}.ProjModeRequest;
100        end
101        if isfield(Data.VarAttribute{ivar},'FieldName')
102            FieldName{ivar}=Data.VarAttribute{ivar}.FieldName;
103        end
104        if isfield(Data.VarAttribute{ivar},'CheckSub')
105            CheckSub(ivar)=Data.VarAttribute{ivar}.CheckSub;
106        end
107    end
108end
109
110%% detect  fields with different roles
111ind_scalar=find(strcmp('scalar',Role));
112ind_errorflag=find(strcmp('errorflag',Role));
113ind_image=find(strcmp('image',Role));
114ind_vector_x=[find(strcmp('vector_x',Role)) find(strcmp('vector_x_tps',Role))];
115if ~isempty(ind_vector_x)
116    ind_vector_y=[find(strcmp('vector_y',Role)) find(strcmp('vector_y_tps',Role))];
117    ind_vector_z=find(strcmp('vector_z',Role));
118    ind_warnflag=find(strcmp('warnflag',Role));
119    ind_ancillary=find(strcmp('ancillary',Role));
120end
121ind_discrete=find(strcmp('discrete',Role));
122ind_coord_x=[find(strcmp('coord_x',Role)) find(strcmp('histo',Role))];
123ind_coord_y=find(strcmp('coord_y',Role));
124ind_coord_z=find(strcmp('coord_z',Role));
125ind_histo=find(strcmp('histo',Role));
126ind_coord_tps=find(strcmp('coord_tps',Role));
127check_string=cellfun(@ischar,Data.VarDimName)==1;
128index_string=find(check_string);
129for ivar=index_string
130    Data.VarDimName{ivar}={Data.VarDimName{ivar}};%transform char strings into cells
131end
132check_coord_names= cellfun(@numel,Data.VarDimName)==1;
133check_coord_raster=false(size(check_coord_names));% check variables describing regular mesh (raster coordinates), from two values, min and max.
134if check_var
135    for ivar=find(check_coord_names)
136        if numel(Data.(Data.ListVarName{ivar}))==2
137            check_coord_raster(ivar)=true;
138        end
139    end
140else
141    for ivar=find(check_coord_names)
142        DimIndex=find(strcmp(Data.VarDimName{ivar},Data.ListDimName));
143        if Data.DimValue(DimIndex)==2
144            check_coord_raster(ivar)=true;
145        end
146    end
147end
148
149
150%% initate cells around each scalar field with different coordinates
151cell_counter=0;
152DimCell={};
153for iscalar=1:numel(ind_scalar)
154    icell=[];
155    for iprev=1:numel(DimCell)
156        if isequal(DimCell{iprev},Data.VarDimName{ind_scalar(iscalar)})
157            icell=iprev;
158            break
159        end
160    end
161    if isempty(icell)
162        cell_counter=cell_counter+1;
163        icell=cell_counter;
164        CellInfo{icell}.FieldName=Data.ListVarName{ind_scalar(iscalar)};
165        CellInfo{icell}.VarType='scalar';
166        DimCell{icell}=Data.VarDimName{ind_scalar(iscalar)};
167        DimCell_var=Data.VarDimName{ind_scalar(iscalar)};% cell of dimension names for ivar_coord_x(icell)
168        CellInfo{icell}.VarIndex_scalar=ind_scalar(iscalar);
169        CellInfo{icell}.VarIndex=ind_scalar(iscalar);
170    else
171        CellInfo{iprev}.VarIndex_scalar=[CellInfo{iprev}.VarIndex_scalar ind_scalar(iscalar)];
172        CellInfo{iprev}.VarIndex=[CellInfo{iprev}.VarIndex ind_scalar(iscalar)];
173    end
174end
175
176%% initate or complement cells around each vector field with different coordinates
177for index_list=1:numel(ind_vector_x)
178    icell=[];
179    for iprev=1:numel(DimCell)% look for previous cells of vectors with the same dimensions
180        if isequal(DimCell{iprev},Data.VarDimName{ind_vector_x(index_list)})&& ~strcmp(CellInfo{iprev}.VarType, 'scalar')
181            icell=iprev;
182            break
183        end
184    end
185    if isempty(icell)% new cell
186        cell_counter=cell_counter+1;   
187        icell=cell_counter;
188        CellInfo{icell}.VarType='vector';
189        DimCell{icell}=Data.VarDimName{ind_vector_x(index_list)};   
190        CellInfo{icell}.VarIndex=ind_vector_x(index_list);
191        CellInfo{icell}.VarIndex_vector_x=ind_vector_x(index_list);
192    else
193        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_vector_x(index_list)];
194        if isfield(CellInfo{icell},'VarIndex_vector_x')
195            CellInfo{icell}.VarIndex_vector_x=[CellInfo{icell}.VarIndex_vector_x ind_vector_x(index_list)];
196        else
197            CellInfo{icell}.VarIndex_vector_x=ind_vector_x(index_list);
198        end
199    end
200end
201
202%% complement with vector_y
203if ~isempty(ind_vector_x)
204    for index_list=1:numel(ind_vector_y)
205        for iprev=1:numel(DimCell)
206            if isequal(DimCell{iprev},Data.VarDimName{ind_vector_y(index_list)})&& ~strcmp(CellInfo{iprev}.VarType, 'scalar')
207                icell=iprev;
208                break
209            end
210        end
211        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_vector_y(index_list)];
212        if isfield(CellInfo{icell},'VarIndex_vector_y')
213             CellInfo{icell}.VarIndex_vector_y=[CellInfo{icell}.VarIndex_vector_y ind_vector_y(index_list)];
214        else
215            CellInfo{icell}.VarIndex_vector_y=ind_vector_y(index_list);
216        end
217    end
218   
219    %% look for the associated z vector component
220    for index_list=1:numel(ind_vector_z)
221        for iprev=1:numel(DimCell)
222            if isequal(DimCell{iprev},Data.VarDimName{ind_vector_z(index_list)})&& ~strcmp(CellInfo{iprev}.VarType, 'scalar')
223                icell=iprev;
224                break
225            end
226        end
227        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_vector_z(index_list)];
228        if isfield(CellInfo{icell},'VarIndex_vector_z')
229            CellInfo{icell}.VarIndex_vector_z=[CellInfo{icell}.VarIndex_vector_z ind_vector_z(index_list)];
230        else
231            CellInfo{icell}.VarIndex_vector_z=ind_vector_z(index_list);
232        end
233        nbvar=3;
234    end
235   
236    %% look for the associated vector color scalar (ancillary)
237    for index_list=1:numel(ind_ancillary)
238        for iprev=1:numel(DimCell)
239            if isequal(DimCell{iprev},Data.VarDimName{ind_ancillary(index_list)})&& ~strcmp(CellInfo{iprev}.VarType, 'scalar')
240                icell=iprev;
241                break
242            end
243        end
244        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_ancillary(index_list)];
245        if isfield(CellInfo{icell},'VarIndex_ancillary')
246            CellInfo{icell}.VarIndex_ancillary=[CellInfo{icell}.VarIndex_ancillary ind_ancillary(index_list)];
247        else
248             CellInfo{icell}.VarIndex_ancillary=ind_ancillary(index_list);
249        end
250    end
251   
252    %% look for the associated warnflag
253    for index_list=1:numel(ind_warnflag)
254        for iprev=1:numel(DimCell)
255            if isequal(DimCell{iprev},Data.VarDimName{ind_warnflag(index_list)})
256                icell=iprev;
257                break
258            end
259        end
260        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_warnflag(index_list)];
261        if isfield(CellInfo{icell},'VarIndex_warnflag')
262            CellInfo{icell}.VarIndex_warnflag=[CellInfo{icell}.VarIndex_warnflag ind_ancillary(index_list)];
263        else
264            CellInfo{icell}.VarIndex_warnflag=ind_warnflag(index_list);
265        end
266    end
267end
268
269%% look for the associated errorflag
270for index_list=1:numel(ind_errorflag)
271    for iprev=1:numel(DimCell)
272        if isequal(DimCell{iprev},Data.VarDimName{ind_errorflag(index_list)})
273            icell=iprev;
274            break
275        end
276    end
277    CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_errorflag(index_list)];
278    if isfield(CellInfo{icell},'VarIndex_errorflag')
279        CellInfo{icell}.VarIndex_errorflag=[CellInfo{icell}.VarIndex_errorflag ind_errorflag(index_list)];
280    else
281        CellInfo{icell}.VarIndex_errorflag=ind_errorflag(index_list);
282    end
283end
284
285
286%% find coordinates for each cell around field variables, scalars or vectors
287for icell=1:numel(CellInfo)
288    CellInfo{icell}.CoordType='';
289    ind_var=CellInfo{icell}.VarIndex(1);
290    DimCell_var=Data.VarDimName{ind_var};% cell of dimension names for ivar_coord_x(icell)
291    if ~check_var
292        for idim=1:numel(DimCell_var)
293            CellInfo{icell}.DimIndex(idim)=find(strcmp(DimCell_var{idim},Data.ListDimName));
294        end
295    end
296    %look for z scattered coordinates
297    if isempty(ind_coord_z)
298        NbDim(icell)=2;
299        CellInfo{icell}.CoordIndex=[0 0];
300    else
301        NbDim(icell)=3;
302        CellInfo{icell}.CoordIndex=[0 0 0];
303        for ivar=ind_coord_z
304            DimCell=Data.VarDimName{ivar};
305            if isequal(DimCell,DimCell_var)
306                CellInfo{icell}.CoordType='scattered';
307                CellInfo{icell}.CoordIndex(1)=ivar;
308                CellInfo{icell}.ZName=Data.ListVarName{ivar};
309                CellInfo{icell}.ZIndex=ivar;
310                break
311            end
312        end
313    end
314    % look for y coordinate
315    for ivar=ind_coord_y
316        % detect scattered y coordinates, variable with the same dimension(s) as the field variable considered
317        DimCell=Data.VarDimName{ivar};
318        if isequal(DimCell,DimCell_var)
319            CellInfo{icell}.CoordType='scattered';
320            CellInfo{icell}.CoordIndex(NbDim(icell)-1)=ivar;
321            CellInfo{icell}.YName=Data.ListVarName{ivar};
322            CellInfo{icell}.YIndex=ivar;
323            break
324        end
325    end
326   
327    %look for x coordinates
328    if strcmp(CellInfo{icell}.CoordType,'scattered')
329        for ivar=ind_coord_x
330            DimCell=Data.VarDimName{ivar};
331            if isequal(DimCell,DimCell_var)
332                CellInfo{icell}.CoordIndex(NbDim(icell))=ivar;
333                CellInfo{icell}.XName=Data.ListVarName{ivar};
334                CellInfo{icell}.XIndex=ivar;
335                break
336            end
337        end
338    end
339    if isfield(CellInfo{icell},'ZName')
340        if isfield(CellInfo{icell},'YName')&& isfield(CellInfo{icell},'XName')
341            continue %scattered coordinates OK
342        end
343    else
344        if isfield(CellInfo{icell},'YName')
345            if isfield(CellInfo{icell},'XName')
346                NbDim(icell)=2;
347                continue %scattered coordinates OK
348            end
349        else
350            if isfield(CellInfo{icell},'XName') % only one coordinate x, switch vector field to 1D plot
351                for ind=1:numel(CellInfo{icell}.VarIndex)
352                    Role{CellInfo{icell}.VarIndex(ind)}='coord_y';
353                end
354                continue
355            end
356        end
357    end
358   
359    %look for grid  coordinates
360    if isempty(CellInfo{icell}.CoordType)
361        NbDim(icell)=numel(DimCell_var);
362        CellInfo{icell}.DimOrder=[];
363        if NbDim(icell)==3
364            if strcmp(DimCell_var{3},'rgb')
365                NbDim(icell)=2;% case of color images
366            else
367                %coord z
368                for ivar=ind_coord_z
369                    if check_coord_names(ivar)
370                        DimRank=find(strcmp(Data.VarDimName{ivar},DimCell_var));
371                        check_coord=~isempty(DimRank);
372                    elseif check_coord_raster(ivar)
373                        DimRank=find(strcmp(Data.ListVarName{ivar},DimCell_var));
374                        check_coord=~isempty(DimRank);
375                    end
376                    if check_coord
377                        CellInfo{icell}.CoordType='grid';
378                        CellInfo{icell}.CoordIndex(1)=ivar;
379                        CellInfo{icell}.ZName=Data.ListVarName{ivar};
380                        CellInfo{icell}.ZIndex=ivar;
381                        CellInfo{icell}.DimOrder=DimRank;
382                        break
383                    end
384                end
385            end
386        end
387        for ivar=ind_coord_y
388            if check_coord_names(ivar)
389                DimRank=find(strcmp(Data.VarDimName{ivar},DimCell_var));
390                check_coord=~isempty(DimRank);
391            elseif check_coord_raster(ivar)
392                DimRank=find(strcmp(Data.ListVarName{ivar},DimCell_var));
393                check_coord=~isempty(DimRank);
394            end
395            if check_coord
396                CellInfo{icell}.CoordType='grid';
397                CellInfo{icell}.CoordIndex(NbDim(icell)-1)=ivar;
398                CellInfo{icell}.YName=Data.ListVarName{ivar};
399                CellInfo{icell}.YIndex=ivar;
400                CellInfo{icell}.DimOrder=[CellInfo{icell}.DimOrder DimRank];
401                break
402            end
403        end
404        for ivar=ind_coord_x
405            if check_coord_names(ivar)
406                DimRank=find(strcmp(Data.VarDimName{ivar},DimCell_var));
407                check_coord=~isempty(DimRank);
408            elseif check_coord_raster(ivar)
409                DimRank=find(strcmp(Data.ListVarName{ivar},DimCell_var));
410                check_coord=~isempty(DimRank);
411            end
412            %             check_coord= (check_coord_names(ivar) && strcmp(Data.VarDimName{ivar},DimCell_var{NbDim(icell)}))||...% coord variable
413            %                 (check_coord_raster(ivar) && strcmp(Data.ListVarName{ivar},DimCell_var{NbDim(icell)})); % raster coord defined by min and max
414            if check_coord
415                CellInfo{icell}.CoordIndex(NbDim(icell))=ivar;
416                CellInfo{icell}.XName=Data.ListVarName{ivar};
417                CellInfo{icell}.XIndex=ivar;
418                CellInfo{icell}.DimOrder=[CellInfo{icell}.DimOrder DimRank];
419                break
420            end
421        end
422    end
423    %look for tps coordinates
424    for ivar=ind_coord_tps
425        DimCell=Data.VarDimName{ivar};
426        if  numel(DimCell)==3 && strcmp(DimCell{1},DimCell_var{1})
427            CellInfo{icell}.CoordType='tps';
428            CellInfo{icell}.CoordIndex=ivar;
429            if check_var
430                NbDim(icell)=size(Data.(Data.ListVarName{ivar}),2);
431            else
432                DimIndex=find(strcmp(Data.VarDimName{ivar}{2},Data.ListDimName));
433                NbDim(icell)= Data.DimValue(DimIndex);
434            end
435            for ivardim=1:numel(Data.VarDimName)
436                if strcmp(Data.VarDimName{ivardim},DimCell{3})
437                    CellInfo{icell}.NbCentres_tps= ivardim;% nbre of sites for each tps subdomain
438                elseif strcmp(Data.VarDimName{ivardim}{1},DimCell{2}) && numel(Data.VarDimName{ivardim})>=3 && strcmp(Data.VarDimName{ivardim}{3},DimCell{3})
439                    CellInfo{icell}.SubRange_tps=ivardim;% subrange definiton for tps
440                end
441            end
442        end
443        break
444    end
445end
446
447%% get number of coordinate points for each cell
448if check_var
449    for icell=1:numel(CellInfo)
450        switch CellInfo{icell}.CoordType
451            case 'scattered'
452                CellInfo{icell}.CoordSize=numel(Data.(CellInfo{icell}.XName));
453            case 'grid'
454                VarName=Data.ListVarName{CellInfo{icell}.VarIndex(1)};
455                if NbDim(icell)==3
456                    CellInfo{icell}.CoordSize=[size(Data.(VarName),3) size(Data.(VarName),2) size(Data.(VarName),1)];
457                else
458                    CellInfo{icell}.CoordSize=[size(Data.(VarName),1) size(Data.(VarName),2)];
459                end
460            case 'tps'
461                NbDim(icell)=size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),2);
462                CellInfo{icell}.CoordSize=size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),1);
463        end
464    end
465else
466    for icell=1:numel(CellInfo)
467        CellInfo{icell}.CoordSize=size(Data.DimValue(CellInfo{icell}.DimIndex));
468    end
469end
470
471%% cell for ordinary plots: look for coord_x not included in scalar or vector cells
472iremove=false(1,numel(ind_coord_y));
473for ilist=1:numel(ind_coord_y)% remove the y coordinates which have been used already in scalar or vector fields
474    for icell=1:numel(CellInfo)
475        if isfield(CellInfo{icell},'YIndex')&& isequal(CellInfo{icell}.YIndex,ind_coord_y(ilist))
476            iremove(ilist)=true;
477            continue
478        end
479    end
480end
481ind_coord_y(iremove)=[];
482if ~isempty(ind_coord_x)
483    y_nbre=zeros(1,numel(ind_coord_x));
484    for icell=1:numel(ind_coord_x)
485        Cell1DPlot{icell}.VarType='1DPlot';
486        Cell1DPlot{icell}.XIndex=ind_coord_x(icell);
487        Cell1DPlot{icell}.XName=Data.ListVarName{ind_coord_x(icell)};
488        Cell1DPlot{icell}.YIndex=[];
489        Cell1DPlot{icell}.YIndex_discrete=[];
490        DimCell_x=Data.VarDimName{ind_coord_x(icell)};
491        for ivar=[ind_coord_y ind_histo]% look for y coordinate corresponding to coord_x
492            DimCell=Data.VarDimName{ivar};%dimensions of coord_y
493            if  numel(DimCell_x)==1 && strcmp(DimCell_x{1},DimCell{1})
494                y_nbre(icell)=y_nbre(icell)+1;
495                Cell1DPlot{icell}.YIndex(y_nbre(icell))=ivar;
496            end
497        end
498        for ivar=ind_discrete
499            DimCell=Data.VarDimName{ivar};
500            %if  numel(DimCell)==1 && strcmp(DimCell_x{1},DimCell{1})
501            if  strcmp(DimCell_x{1},DimCell{1})
502                y_nbre(icell)=y_nbre(icell)+1;
503                Cell1DPlot{icell}.YIndex_discrete(y_nbre(icell))=ivar;
504            end
505        end
506    end
507    Cell1DPlot(y_nbre==0)=[];
508    CellInfo=[CellInfo Cell1DPlot];
509    NbDim=[NbDim ones(1,numel(Cell1DPlot))];
510end
511
512%% document roles of non-coordinate variables
513for icell=1:numel(CellInfo)
514    if isfield(CellInfo{icell},'VarIndex')
515        check_fieldname=0;
516        VarIndex=CellInfo{icell}.VarIndex;
517        for ivar=VarIndex
518            %         if isfield(CellInfo{icell},['VarIndex_' Role{ivar}])
519            %             CellInfo{icell}.(['VarIndex_' Role{ivar}])=[CellInfo{icell}.(['VarIndex_' Role{ivar}]) ivar];
520            %         else
521            %             CellInfo{icell}.(['VarIndex_' Role{ivar}])= ivar;
522            %         end
523            if ~isempty(ProjModeRequest{ivar})
524                CellInfo{icell}.ProjModeRequest=ProjModeRequest{ivar};
525            end
526            if ~isempty(FieldName{ivar})
527                CellInfo{icell}.FieldName=FieldName{ivar};
528                check_fieldname=1;
529            end
530            if CheckSub(ivar)==1
531                CellInfo{icell}.CheckSub=1;
532            end
533        end
534        if ~check_fieldname% default FieldName
535            if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y')
536                UName=Data.ListVarName{CellInfo{icell}.VarIndex_vector_x};
537                VName=Data.ListVarName{CellInfo{icell}.VarIndex_vector_y};       
538                CellInfo{icell}.FieldName=['vec(' UName ',' VName ')'];
539            end
540        end
541    end
542end
543
544
545
Note: See TracBrowser for help on using the repository browser.