Changeset 674 for trunk/src/find_field_cells.m
- Timestamp:
- Aug 23, 2013, 2:56:17 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_field_cells.m
r648 r674 107 107 108 108 %% find scattered (unstructured) coordinates 109 ivar_coord_x=find(strcmp('coord_x',Role)); 110 % VarDimCell=cell(numel(ivar_coord_x)); 109 ivar_coord_x=find(strcmp('coord_x',Role));%find variables with Role='coord_x' 111 110 check_select=false(1,nbvar); 112 111 check_coord=false(1,nbvar); 113 112 CellInfo=cell(1,numel(ivar_coord_x)); 114 113 NbDim=zeros(1,numel(ivar_coord_x)); 114 % loop on unstructured coordinate x -> different field cells 115 115 for icell=1:numel(ivar_coord_x) 116 DimCell=Data.VarDimName{ivar_coord_x(icell)}; 117 if ischar(DimCell),DimCell={DimCell};end 116 DimCell=Data.VarDimName{ivar_coord_x(icell)};% cell of dimension names for ivar_coord_x(icell) 117 if ischar(DimCell),DimCell={DimCell};end % transform char to cell for a single dimension 118 % look for variables sharing dimension(s) with ivar_coord_x(icell) 118 119 check_cell=zeros(numel(DimCell),nbvar); 119 120 for idim=1:numel(DimCell) … … 123 124 end 124 125 check_cell=sum(check_cell,1)==numel(DimCell);%logical array=1 for variables belonging to the current cell 125 VarIndex=find(check_cell); 126 VarIndex=find(check_cell);% list of detected variable indices 126 127 if ~(numel(VarIndex)==1 && numel(DimCell)==1)% exclude case of isolated coord_x variable (treated later) 127 128 if ~(numel(VarIndex)==1 && numel(DimCell)>1)% a variable is associated to coordinate … … 132 133 else 133 134 for idim=1:numel(DimCell) 134 check_index= strcmp(DimCell{idim},Data.ListDimName);135 CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index);135 check_index= strcmp(DimCell{idim},Data.ListDimName); 136 CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index); 136 137 end 137 138 CellInfo{icell}.CoordSize=prod(CellInfo{icell}.CoordSize); … … 291 292 NbDim=[NbDim NewNbDim]; 292 293 CellInfo=[CellInfo NewCellInfo]; 293 %294 % %% suppress empty cells295 % check_empty=cellfun(@isempty,CellInfo);296 % CellInfo(check_empty)=[];297 % NbDim(check_empty)=[];298 294 299 295 %% suppress empty cells or cells with a single coordinate variable … … 308 304 309 305 %% document roles of non-coordinate variables 310 % ListRole={'vector_x','vector_y','vector_z','vector_x_tps','vector_y_tps','warnflag','errorflag',...311 % 'ancillary','image','color','discrete','scalar'};% except coord,coord_x,_y,_z,Coord_tps already taken, into account312 306 for icell=1:numel(CellInfo) 313 307 VarIndex=CellInfo{icell}.VarIndex;
Note: See TracChangeset
for help on using the changeset viewer.