source: trunk/src/find_field_cells.m @ 1114

Last change on this file since 1114 was 1107, checked in by g7moreau, 3 years ago

Update Copyright to 2022

File size: 23.0 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-2022, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
49%   http://www.legi.grenoble-inp.fr
50%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.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}.VarType='scalar';
165        DimCell{icell}=Data.VarDimName{ind_scalar(iscalar)};
166        DimCell_var=Data.VarDimName{ind_scalar(iscalar)};% cell of dimension names for ivar_coord_x(icell)
167        CellInfo{icell}.VarIndex_scalar=ind_scalar(iscalar);
168        CellInfo{icell}.VarIndex=ind_scalar(iscalar);
169    else
170        CellInfo{iprev}.VarIndex_scalar=[CellInfo{iprev}.VarIndex_scalar ind_scalar(iscalar)];
171        CellInfo{iprev}.VarIndex=[CellInfo{iprev}.VarIndex ind_scalar(iscalar)];
172    end
173end
174
175%% initate or complement cells around each vector field with different coordinates
176for index_list=1:numel(ind_vector_x)
177    icell=[];
178    for iprev=1:numel(DimCell)% look for previous cells of vectors with the same dimensions
179        if isequal(DimCell{iprev},Data.VarDimName{ind_vector_x(index_list)})&& ~strcmp(CellInfo{iprev}.VarType, 'scalar')
180            icell=iprev;
181            break
182        end
183    end
184    if isempty(icell)% new cell
185        cell_counter=cell_counter+1;   
186        icell=cell_counter;
187        CellInfo{icell}.VarType='vector';
188        DimCell{icell}=Data.VarDimName{ind_vector_x(index_list)};   
189        CellInfo{icell}.VarIndex=ind_vector_x(index_list);
190        CellInfo{icell}.VarIndex_vector_x=ind_vector_x(index_list);
191    else
192        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_vector_x(index_list)];
193        if isfield(CellInfo{icell},'VarIndex_vector_x')
194            CellInfo{icell}.VarIndex_vector_x=[CellInfo{icell}.VarIndex_vector_x ind_vector_x(index_list)];
195        else
196            CellInfo{icell}.VarIndex_vector_x=ind_vector_x(index_list);
197        end
198    end
199end
200
201%% complement with vector_y
202if ~isempty(ind_vector_x)
203    for index_list=1:numel(ind_vector_y)
204        for iprev=1:numel(DimCell)
205            if isequal(DimCell{iprev},Data.VarDimName{ind_vector_y(index_list)})&& ~strcmp(CellInfo{iprev}.VarType, 'scalar')
206                icell=iprev;
207                break
208            end
209        end
210        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_vector_y(index_list)];
211        if isfield(CellInfo{icell},'VarIndex_vector_y')
212             CellInfo{icell}.VarIndex_vector_y=[CellInfo{icell}.VarIndex_vector_y ind_vector_y(index_list)];
213        else
214            CellInfo{icell}.VarIndex_vector_y=ind_vector_y(index_list);
215        end
216    end
217   
218    %% look for the associated z vector component
219    for index_list=1:numel(ind_vector_z)
220        for iprev=1:numel(DimCell)
221            if isequal(DimCell{iprev},Data.VarDimName{ind_vector_z(index_list)})&& ~strcmp(CellInfo{iprev}.VarType, 'scalar')
222                icell=iprev;
223                break
224            end
225        end
226        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_vector_z(index_list)];
227        if isfield(CellInfo{icell},'VarIndex_vector_z')
228            CellInfo{icell}.VarIndex_vector_z=[CellInfo{icell}.VarIndex_vector_z ind_vector_z(index_list)];
229        else
230            CellInfo{icell}.VarIndex_vector_z=ind_vector_z(index_list);
231        end
232        nbvar=3;
233    end
234   
235    %% look for the associated vector color scalar (ancillary)
236    for index_list=1:numel(ind_ancillary)
237        for iprev=1:numel(DimCell)
238            if isequal(DimCell{iprev},Data.VarDimName{ind_ancillary(index_list)})&& ~strcmp(CellInfo{iprev}.VarType, 'scalar')
239                icell=iprev;
240                break
241            end
242        end
243        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_ancillary(index_list)];
244        if isfield(CellInfo{icell},'VarIndex_ancillary')
245            CellInfo{icell}.VarIndex_ancillary=[CellInfo{icell}.VarIndex_ancillary ind_ancillary(index_list)];
246        else
247             CellInfo{icell}.VarIndex_ancillary=ind_ancillary(index_list);
248        end
249    end
250   
251    %% look for the associated warnflag
252    for index_list=1:numel(ind_warnflag)
253        for iprev=1:numel(DimCell)
254            if isequal(DimCell{iprev},Data.VarDimName{ind_warnflag(index_list)})
255                icell=iprev;
256                break
257            end
258        end
259        CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_warnflag(index_list)];
260        if isfield(CellInfo{icell},'VarIndex_warnflag')
261            CellInfo{icell}.VarIndex_warnflag=[CellInfo{icell}.VarIndex_warnflag ind_ancillary(index_list)];
262        else
263            CellInfo{icell}.VarIndex_warnflag=ind_warnflag(index_list);
264        end
265    end
266end
267
268%% look for the associated errorflag
269for index_list=1:numel(ind_errorflag)
270    for iprev=1:numel(DimCell)
271        if isequal(DimCell{iprev},Data.VarDimName{ind_errorflag(index_list)})
272            icell=iprev;
273            break
274        end
275    end
276    CellInfo{icell}.VarIndex=[CellInfo{icell}.VarIndex ind_errorflag(index_list)];
277    if isfield(CellInfo{icell},'VarIndex_errorflag')
278        CellInfo{icell}.VarIndex_errorflag=[CellInfo{icell}.VarIndex_errorflag ind_errorflag(index_list)];
279    else
280        CellInfo{icell}.VarIndex_errorflag=ind_errorflag(index_list);
281    end
282end
283
284
285%% find coordinates for each cell around field variables, scalars or vectors
286for icell=1:numel(CellInfo)
287    CellInfo{icell}.CoordType='';
288    ind_var=CellInfo{icell}.VarIndex(1);
289    DimCell_var=Data.VarDimName{ind_var};% cell of dimension names for ivar_coord_x(icell)
290    if ~check_var
291        for idim=1:numel(DimCell_var)
292            CellInfo{icell}.DimIndex(idim)=find(strcmp(DimCell_var{idim},Data.ListDimName));
293        end
294    end
295    %look for z scattered coordinates
296    if isempty(ind_coord_z)
297        NbDim(icell)=2;
298        CellInfo{icell}.CoordIndex=[0 0];
299    else
300        NbDim(icell)=3;
301        CellInfo{icell}.CoordIndex=[0 0 0];
302        for ivar=ind_coord_z
303            DimCell=Data.VarDimName{ivar};
304            if isequal(DimCell,DimCell_var)
305                CellInfo{icell}.CoordType='scattered';
306                CellInfo{icell}.CoordIndex(1)=ivar;
307                CellInfo{icell}.ZName=Data.ListVarName{ivar};
308                CellInfo{icell}.ZIndex=ivar;
309                break
310            end
311        end
312    end
313    % look for y coordinate
314    for ivar=ind_coord_y
315        % detect scattered y coordinates, variable with the same dimension(s) as the field variable considered
316        DimCell=Data.VarDimName{ivar};
317        if isequal(DimCell,DimCell_var)
318            CellInfo{icell}.CoordType='scattered';
319            CellInfo{icell}.CoordIndex(NbDim(icell)-1)=ivar;
320            CellInfo{icell}.YName=Data.ListVarName{ivar};
321            CellInfo{icell}.YIndex=ivar;
322            break
323        end
324    end
325   
326    %look for x coordinates
327    if strcmp(CellInfo{icell}.CoordType,'scattered')
328        for ivar=ind_coord_x
329            DimCell=Data.VarDimName{ivar};
330            if isequal(DimCell,DimCell_var)
331                CellInfo{icell}.CoordIndex(NbDim(icell))=ivar;
332                CellInfo{icell}.XName=Data.ListVarName{ivar};
333                CellInfo{icell}.XIndex=ivar;
334                break
335            end
336        end
337    end
338    if isfield(CellInfo{icell},'ZName')
339        if isfield(CellInfo{icell},'YName')&& isfield(CellInfo{icell},'XName')
340            continue %scattered coordinates OK
341        end
342    else
343        if isfield(CellInfo{icell},'YName')
344            if isfield(CellInfo{icell},'XName')
345                NbDim(icell)=2;
346                continue %scattered coordinates OK
347            end
348        else
349            if isfield(CellInfo{icell},'XName') % only one coordinate x, switch vector field to 1D plot
350                for ind=1:numel(CellInfo{icell}.VarIndex)
351                    Role{CellInfo{icell}.VarIndex(ind)}='coord_y';
352                end
353                continue
354            end
355        end
356    end
357   
358    %look for grid  coordinates
359    if isempty(CellInfo{icell}.CoordType)
360        NbDim(icell)=numel(DimCell_var);
361        CellInfo{icell}.DimOrder=[];
362        if NbDim(icell)==3
363            if strcmp(DimCell_var{3},'rgb')
364                NbDim(icell)=2;% case of color images
365            else
366                %coord z
367                for ivar=ind_coord_z
368                    if check_coord_names(ivar)
369                        DimRank=find(strcmp(Data.VarDimName{ivar},DimCell_var));
370                        check_coord=~isempty(DimRank);
371                    elseif check_coord_raster(ivar)
372                        DimRank=find(strcmp(Data.ListVarName{ivar},DimCell_var));
373                        check_coord=~isempty(DimRank);
374                    end
375                    if check_coord
376                        CellInfo{icell}.CoordType='grid';
377                        CellInfo{icell}.CoordIndex(1)=ivar;
378                        CellInfo{icell}.ZName=Data.ListVarName{ivar};
379                        CellInfo{icell}.ZIndex=ivar;
380                        CellInfo{icell}.DimOrder=DimRank;
381                        break
382                    end
383                end
384            end
385        end
386        for ivar=ind_coord_y
387            if check_coord_names(ivar)
388                DimRank=find(strcmp(Data.VarDimName{ivar},DimCell_var));
389                check_coord=~isempty(DimRank);
390            elseif check_coord_raster(ivar)
391                DimRank=find(strcmp(Data.ListVarName{ivar},DimCell_var));
392                check_coord=~isempty(DimRank);
393            end
394            if check_coord
395                CellInfo{icell}.CoordType='grid';
396                CellInfo{icell}.CoordIndex(NbDim(icell)-1)=ivar;
397                CellInfo{icell}.YName=Data.ListVarName{ivar};
398                CellInfo{icell}.YIndex=ivar;
399                CellInfo{icell}.DimOrder=[CellInfo{icell}.DimOrder DimRank];
400                break
401            end
402        end
403        for ivar=ind_coord_x
404            if check_coord_names(ivar)
405                DimRank=find(strcmp(Data.VarDimName{ivar},DimCell_var));
406                check_coord=~isempty(DimRank);
407            elseif check_coord_raster(ivar)
408                DimRank=find(strcmp(Data.ListVarName{ivar},DimCell_var));
409                check_coord=~isempty(DimRank);
410            end
411            %             check_coord= (check_coord_names(ivar) && strcmp(Data.VarDimName{ivar},DimCell_var{NbDim(icell)}))||...% coord variable
412            %                 (check_coord_raster(ivar) && strcmp(Data.ListVarName{ivar},DimCell_var{NbDim(icell)})); % raster coord defined by min and max
413            if check_coord
414                CellInfo{icell}.CoordIndex(NbDim(icell))=ivar;
415                CellInfo{icell}.XName=Data.ListVarName{ivar};
416                CellInfo{icell}.XIndex=ivar;
417                CellInfo{icell}.DimOrder=[CellInfo{icell}.DimOrder DimRank];
418                break
419            end
420        end
421    end
422    %look for tps coordinates
423    for ivar=ind_coord_tps
424        DimCell=Data.VarDimName{ivar};
425        if  numel(DimCell)==3 && strcmp(DimCell{1},DimCell_var{1})
426            CellInfo{icell}.CoordType='tps';
427            CellInfo{icell}.CoordIndex=ivar;
428            if check_var
429                NbDim(icell)=size(Data.(Data.ListVarName{ivar}),2);
430            else
431                DimIndex=find(strcmp(Data.VarDimName{ivar}{2},Data.ListDimName));
432                NbDim(icell)= Data.DimValue(DimIndex);
433            end
434            for ivardim=1:numel(Data.VarDimName)
435                if strcmp(Data.VarDimName{ivardim},DimCell{3})
436                    CellInfo{icell}.NbCentres_tps= ivardim;% nbre of sites for each tps subdomain
437                elseif strcmp(Data.VarDimName{ivardim}{1},DimCell{2}) && numel(Data.VarDimName{ivardim})>=3 && strcmp(Data.VarDimName{ivardim}{3},DimCell{3})
438                    CellInfo{icell}.SubRange_tps=ivardim;% subrange definiton for tps
439                end
440            end
441        end
442        break
443    end
444end
445
446%% get number of coordinate points for each cell
447if check_var
448    for icell=1:numel(CellInfo)
449        switch CellInfo{icell}.CoordType
450            case 'scattered'
451                CellInfo{icell}.CoordSize=numel(Data.(CellInfo{icell}.XName));
452            case 'grid'
453                VarName=Data.ListVarName{CellInfo{icell}.VarIndex(1)};
454                if NbDim(icell)==3
455                    CellInfo{icell}.CoordSize=[size(Data.(VarName),3) size(Data.(VarName),2) size(Data.(VarName),1)];
456                else
457                    CellInfo{icell}.CoordSize=[size(Data.(VarName),1) size(Data.(VarName),2)];
458                end
459            case 'tps'
460                NbDim(icell)=size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),2);
461                CellInfo{icell}.CoordSize=size(Data.(Data.ListVarName{CellInfo{icell}.CoordIndex}),1);
462        end
463    end
464else
465    for icell=1:numel(CellInfo)
466        CellInfo{icell}.CoordSize=size(Data.DimValue(CellInfo{icell}.DimIndex));
467    end
468end
469
470%% cell for ordinary plots: look for coord_x not included in scalar or vector cells
471iremove=false(1,numel(ind_coord_y));
472for ilist=1:numel(ind_coord_y)% remove the y coordinates which have been used already in scalar or vector fields
473    for icell=1:numel(CellInfo)
474        if isfield(CellInfo{icell},'YIndex')&& isequal(CellInfo{icell}.YIndex,ind_coord_y(ilist))
475            iremove(ilist)=true;
476            continue
477        end
478    end
479end
480ind_coord_y(iremove)=[];
481if ~isempty(ind_coord_x)
482    y_nbre=zeros(1,numel(ind_coord_x));
483    for icell=1:numel(ind_coord_x)
484        Cell1DPlot{icell}.VarType='1DPlot';
485        Cell1DPlot{icell}.XIndex=ind_coord_x(icell);
486        Cell1DPlot{icell}.XName=Data.ListVarName{ind_coord_x(icell)};
487        Cell1DPlot{icell}.YIndex=[];
488        Cell1DPlot{icell}.YIndex_discrete=[];
489        DimCell_x=Data.VarDimName{ind_coord_x(icell)};
490        for ivar=[ind_coord_y ind_histo]% look for y coordinate corresponding to coord_x
491            DimCell=Data.VarDimName{ivar};%dimensions of coord_y
492            if  numel(DimCell_x)==1 && strcmp(DimCell_x{1},DimCell{1})
493                y_nbre(icell)=y_nbre(icell)+1;
494                Cell1DPlot{icell}.YIndex(y_nbre(icell))=ivar;
495            end
496        end
497        for ivar=ind_discrete
498            DimCell=Data.VarDimName{ivar};
499            %if  numel(DimCell)==1 && strcmp(DimCell_x{1},DimCell{1})
500            if  strcmp(DimCell_x{1},DimCell{1})
501                y_nbre(icell)=y_nbre(icell)+1;
502                Cell1DPlot{icell}.YIndex_discrete(y_nbre(icell))=ivar;
503            end
504        end
505    end
506    Cell1DPlot(y_nbre==0)=[];
507    CellInfo=[CellInfo Cell1DPlot];
508    NbDim=[NbDim ones(1,numel(Cell1DPlot))];
509end
510
511%% document roles of non-coordinate variables
512for icell=1:numel(CellInfo)
513    if isfield(CellInfo{icell},'VarIndex')
514        check_fieldname=0;
515        VarIndex=CellInfo{icell}.VarIndex;
516        for ivar=VarIndex
517            %         if isfield(CellInfo{icell},['VarIndex_' Role{ivar}])
518            %             CellInfo{icell}.(['VarIndex_' Role{ivar}])=[CellInfo{icell}.(['VarIndex_' Role{ivar}]) ivar];
519            %         else
520            %             CellInfo{icell}.(['VarIndex_' Role{ivar}])= ivar;
521            %         end
522            if ~isempty(ProjModeRequest{ivar})
523                CellInfo{icell}.ProjModeRequest=ProjModeRequest{ivar};
524            end
525            if ~isempty(FieldName{ivar})
526                CellInfo{icell}.FieldName=FieldName{ivar};
527                check_fieldname=1;
528            end
529            if CheckSub(ivar)==1
530                CellInfo{icell}.CheckSub=1;
531            end
532        end
533        if ~check_fieldname% default FieldName
534            if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y')
535                UName=Data.ListVarName{CellInfo{icell}.VarIndex_vector_x};
536                VName=Data.ListVarName{CellInfo{icell}.VarIndex_vector_y};       
537                CellInfo{icell}.FieldName=['vec(' UName ',' VName ')'];
538            end
539        end
540    end
541end
542
543
544
Note: See TracBrowser for help on using the repository browser.