Changeset 581 for trunk/src/find_field_cells.m
- Timestamp:
- Mar 12, 2013, 12:52:13 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_field_cells.m
r580 r581 1 %'find_field_cells': test field structure for input in proj_field and plot_field 2 % group the variables into 'fields' with common dimensions 1 %'find_field_cells': analyse the field structure for input in uvmat functions, grouping the variables into 'fields' with common coordinates 3 2 %------------------------------------------------------------------------ 4 3 % function [CellInfo,NbDim,errormsg]=find_field_cells(Data) … … 9 8 % .CoordIndex: array of the indices of the variables representing the coordinates (in the order z,y,x) 10 9 % .CoordSize: array of the nbre of values for each coordinate in a grid, nbre of points in the unstructured case 11 % .Nb Site_tps:10 % .NbCentres_tps: 12 11 % .SubRange_tps 13 12 % .VarIndex: arrays of the variable indices in the field cell … … 19 18 % _vector_x,_y,_z: indices of variables giving the vector components x, y, z 20 19 % _warnflag: index of warnflag 21 % . FieldRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation or derivatives (tps) is needed to calculate the requested field20 % .ProjModeRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation or derivatives (tps) is needed to calculate the requested field 22 21 % .FieldName = operation to be performed to finalise the field cell after projection 23 22 % .SubCheck=0 /1 indicate that the field must be substracted (second entry in uvmat) … … 61 60 62 61 function [CellInfo,NbDim,errormsg]=find_field_cells(Data) 63 62 CellInfo={}; 64 63 NbDim=0; 65 64 errormsg=''; 66 65 if ~isfield(Data,'ListVarName'), errormsg='the list of variables .ListVarName is missing';return;end 67 66 if ~isfield(Data,'VarDimName'), errormsg='the list of dimensions .VarDimName is missing';return;end 68 nbvar=numel(Data.ListVarName);%number of field variables67 nbvar=numel(Data.ListVarName);%number of variables in the field structure 69 68 if ~isequal(numel(Data.VarDimName),nbvar), errormsg='.ListVarName and .VarDimName have unequal length';return;end 70 69 % check the existence of variable data … … 86 85 % 'ancillary','image','color','discrete','scalar','coord_tps'};% rmq vector_x_tps and vector_y_tps to be replaced by vector_x and vector_y 87 86 Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks 88 FieldRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default87 ProjModeRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default 89 88 FieldName=cell(size(Role)); % fieldRequest set to {} by default 90 89 CheckSub=zeros(size(Role));% =1 for fields to substract … … 95 94 Role{ivar}=Data.VarAttribute{ivar}.Role; 96 95 end 97 if isfield(Data.VarAttribute{ivar},' FieldRequest')98 FieldRequest{ivar}=Data.VarAttribute{ivar}.FieldRequest;96 if isfield(Data.VarAttribute{ivar},'ProjModeRequest') 97 ProjModeRequest{ivar}=Data.VarAttribute{ivar}.ProjModeRequest; 99 98 end 100 99 if isfield(Data.VarAttribute{ivar},'FieldName') … … 162 161 check_coord_tps= strcmp('coord_tps',Role(~check_select)); 163 162 ivar_tps=ivar_remain(check_coord_tps);% variable indices corresponding to tps coordinates 163 164 % loop on the tps coordinate sets 164 165 for icell_tps=1:numel(ivar_tps) 166 check_cell=zeros(1,nbvar);% =1 for the variables selected in the current cell 167 check_cell(ivar_tps(icell_tps))=1;% mark the coordiante variable as selected 165 168 DimCell=Data.VarDimName{ivar_tps(icell_tps)};% dimension names for the current tps coordinate variable 166 169 icell=numel(CellInfo)+icell_tps; % new field cell index 167 170 CellInfo{icell}.CoordIndex=ivar_tps(icell_tps);% index of the tps coordinate variable 168 %CellInfo{icell}.VarIndex_subrange_tps=[];169 %CellInfo{icell}.VarIndex_nbsites_tps=[];170 171 if numel(DimCell)==3 171 172 VarDimName=Data.VarDimName(~check_select); 172 173 for ivardim=1:numel(VarDimName) 173 174 if strcmp(VarDimName{ivardim},DimCell{3}) 174 CellInfo{icell}.Nb Site_tps= ivar_remain(ivardim);175 check_cell(ivar_remain(ivardim))=1;% nbre of sites for each tps subdomain175 CellInfo{icell}.NbCentres_tps= ivar_remain(ivardim);% nbre of sites for each tps subdomain 176 check_cell(ivar_remain(ivardim))=1;% mark the variable as selected 176 177 elseif strcmp(VarDimName{ivardim}{1},DimCell{2}) && strcmp(VarDimName{ivardim}{3},DimCell{3}) 177 CellInfo{icell}.SubRange_tps=ivar_remain(ivardim); 178 check_cell(ivar_remain(ivardim))=1;% subrange definiton for tps179 elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3}) 180 check_cell(ivar_remain(ivardim))=1;% variable178 CellInfo{icell}.SubRange_tps=ivar_remain(ivardim);% subrange definiton for tps 179 check_cell(ivar_remain(ivardim))=1;% mark the variable as selected 180 elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3})% variable 181 check_cell(ivar_remain(ivardim))=1;% mark the variable as selected 181 182 end 182 183 end … … 222 223 end 223 224 end 224 ListCoordIndex=ListCoordIndex(check_ coord_select);% list of coordinate variable indices225 ListCoordIndex=ListCoordIndex(check_keep);% list of coordinate variable indices 225 226 ListCoordName=ListCoordName(check_keep);% list of coordinate variable names 226 227 ListDimName=ListDimName(check_keep);% list of coordinate dimension names … … 315 316 CellInfo{icell}.(['VarIndex_' Role{ivar}])= ivar; 316 317 end 317 if ~isempty( FieldRequest{ivar})318 CellInfo{icell}. FieldRequest=FieldRequest{ivar};318 if ~isempty(ProjModeRequest{ivar}) 319 CellInfo{icell}.ProjModeRequest=ProjModeRequest{ivar}; 319 320 end 320 321 if ~isempty(FieldName{ivar})
Note: See TracChangeset
for help on using the changeset viewer.