source: trunk/src/find_field_cells.m @ 1083

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

bug on velocity comparison solved

File size: 23.1 KB
RevLine 
[581]1%'find_field_cells': analyse the field structure for input in uvmat functions, grouping the variables  into 'fields' with common coordinates
[514]2%------------------------------------------------------------------------
[530]3% function  [CellInfo,NbDim,errormsg]=find_field_cells(Data)
[514]4%
5% OUTPUT:
[530]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
[581]10%     .NbCentres_tps:
[530]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
[1058]19%              _warnflag: index of warnflag
20%              _histo: index of variable used as histogram
[1045]21%       .DimIndex
[581]22%      .ProjModeRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation  or derivatives (tps) is needed to calculate the requested field
[576]23%      .FieldName = operation to be performed to finalise the field cell after projection
[530]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
[514]26% errormsg: error message
27%   
28% INPUT:
29% Data: structure representing fields, output of check_field_structure
[575]30%            .ListGlobalAttributes
[514]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)
[575]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
[514]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
[809]46
47%=======================================================================
[1071]48% Copyright 2008-2020, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
[809]49%   http://www.legi.grenoble-inp.fr
50%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
[514]51%
52%     This file is part of the toolbox UVMAT.
[809]53%
[514]54%     UVMAT is free software; you can redistribute it and/or modify
[809]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%
[514]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
[809]62%     GNU General Public License (see LICENSE.txt) for more details.
63%=======================================================================
64
[514]65%    group the variables  into 'fields' with common dimensions
66
[530]67function [CellInfo,NbDim,errormsg]=find_field_cells(Data)
[1045]68CellInfo={};%default output
[1083]69%NbDim=0;
70NbDim=[];
[535]71errormsg='';
[530]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
[581]74nbvar=numel(Data.ListVarName);%number of variables in the field structure
[530]75if ~isequal(numel(Data.VarDimName),nbvar), errormsg='.ListVarName and .VarDimName have unequal length';return;end
[535]76% check the existence of variable data
77check_var=1;
78for ilist=1:numel(Data.ListVarName)
79    if ~isfield(Data,Data.ListVarName{ilist})
[1009]80        check_var=0;% dimensions of array defined, but the corresponding array is not given
[535]81        break
[530]82    end
83end
[514]84
[515]85%% role of variables and list of requested operations
[530]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
[514]88Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks
[581]89ProjModeRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default
[576]90FieldName=cell(size(Role)); % fieldRequest set to {} by default
[515]91CheckSub=zeros(size(Role));% =1 for fields to substract
[1045]92%Role=regexprep(Role,' ','scalar'); % Role set to 'scalar' by default
[514]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
[581]98        if isfield(Data.VarAttribute{ivar},'ProjModeRequest')
99            ProjModeRequest{ivar}=Data.VarAttribute{ivar}.ProjModeRequest;
[515]100        end
[576]101        if isfield(Data.VarAttribute{ivar},'FieldName')
102            FieldName{ivar}=Data.VarAttribute{ivar}.FieldName;
[515]103        end
104        if isfield(Data.VarAttribute{ivar},'CheckSub')
105            CheckSub(ivar)=Data.VarAttribute{ivar}.CheckSub;
106        end
[514]107    end
108end
109
[1045]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));
[1058]122ind_coord_x=[find(strcmp('coord_x',Role)) find(strcmp('histo',Role))];
[1045]123ind_coord_y=find(strcmp('coord_y',Role));
124ind_coord_z=find(strcmp('coord_z',Role));
[1058]125ind_histo=find(strcmp('histo',Role));
[1045]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;
[530]138        end
[514]139    end
[1045]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;
[514]145        end
146    end
[530]147end
148
[581]149
[1083]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)-1
158        if isequal(DimCell{iprev},Data.VarDimName{ind_scalar(iscalar)})
159            icell=iprev;
[1045]160            break
[530]161        end
[514]162    end
[1083]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
[514]175end
176
[1083]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;
[1045]183            break
[514]184        end
185    end
[1083]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
[1045]200    end
[1083]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
[1045]211        end
[1083]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
[1045]218    end
[1083]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
[1045]227        end
[1083]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;
[1045]235    end
[1083]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
[1045]244        end
[1083]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
[1045]251    end
[1083]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;
[1045]275            break
276        end
277    end
[1083]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
[514]284end
285
[1083]286
[1045]287%% find coordinates for each cell around field variables, scalars or vectors
[1083]288for icell=1:numel(CellInfo)
[1045]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
[514]296    end
[1045]297    %look for z scattered coordinates
298    if isempty(ind_coord_z)
299        NbDim(icell)=2;
300        CellInfo{icell}.CoordIndex=[0 0];
[530]301    else
[1045]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
[530]314    end
[1045]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
[514]326    end
[1045]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
[1078]351            if isfield(CellInfo{icell},'XName') % only one coordinate x, switch vector field to 1D plot
[1045]352                for ind=1:numel(CellInfo{icell}.VarIndex)
353                    Role{CellInfo{icell}.VarIndex(ind)}='coord_y';
[535]354                end
[1045]355                continue
[535]356            end
[514]357        end
[530]358    end
[1045]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
[1057]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
[1045]385                end
386            end
[514]387        end
[1045]388        for ivar=ind_coord_y
[1048]389            if check_coord_names(ivar)
[1057]390                DimRank=find(strcmp(Data.VarDimName{ivar},DimCell_var));
[1045]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)
[1057]407                DimRank=find(strcmp(Data.VarDimName{ivar},DimCell_var));
[1045]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
[1057]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
[1045]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
[530]423    end
[1045]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
[530]445    end
446end
447
[1045]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'
[1048]455                VarName=Data.ListVarName{CellInfo{icell}.VarIndex(1)};
[1045]456                if NbDim(icell)==3
[1048]457                    CellInfo{icell}.CoordSize=[size(Data.(VarName),3) size(Data.(VarName),2) size(Data.(VarName),1)];
[1045]458                else
[1057]459                    CellInfo{icell}.CoordSize=[size(Data.(VarName),1) size(Data.(VarName),2)];
[1045]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
[569]465    end
[1045]466else
467    for icell=1:numel(CellInfo)
468        CellInfo{icell}.CoordSize=size(Data.DimValue(CellInfo{icell}.DimIndex));
469    end
[569]470end
[530]471
[1083]472%% cell for ordinary plots: look for coord_x not included in scalar or vector cells
[1045]473iremove=false(1,numel(ind_coord_y));
[1083]474for ilist=1:numel(ind_coord_y)% remove the y coordinates which have been used already in scalar or vector fields
[1045]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)};
[1048]489        Cell1DPlot{icell}.YIndex=[];
490        Cell1DPlot{icell}.YIndex_discrete=[];
[1045]491        DimCell_x=Data.VarDimName{ind_coord_x(icell)};
[1083]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
[1049]494            if  numel(DimCell_x)==1 && strcmp(DimCell_x{1},DimCell{1})
[1045]495                y_nbre(icell)=y_nbre(icell)+1;
496                Cell1DPlot{icell}.YIndex(y_nbre(icell))=ivar;
497            end
498        end
[1048]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
[1045]506    end
[1048]507    Cell1DPlot(y_nbre==0)=[];
[1045]508    CellInfo=[CellInfo Cell1DPlot];
509    NbDim=[NbDim ones(1,numel(Cell1DPlot))];
510end
511
[530]512%% document roles of non-coordinate variables
513for icell=1:numel(CellInfo)
[1045]514    if isfield(CellInfo{icell},'VarIndex')
[1078]515        check_fieldname=0;
[1045]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};
[1078]528                check_fieldname=1;
[1045]529            end
530            if CheckSub(ivar)==1
531                CellInfo{icell}.CheckSub=1;
532            end
[514]533        end
[1078]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
[514]541    end
542end
[1045]543
544
545
Note: See TracBrowser for help on using the repository browser.