source: trunk/src/find_field_cells.m @ 1085

Last change on this file since 1085 was 1085, checked in by sommeria, 4 years ago

aver_spectral added andsmall bug repairs

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