Changeset 515 for trunk/src/find_field_cells.m
- Timestamp:
- Aug 15, 2012, 11:36:12 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_field_cells.m
r514 r515 19 19 % .scalar: scalar field (default) 20 20 % .coord: vector of indices of coordinate variables corresponding to matrix dimensions 21 % 22 % .FieldRequest= 'interp', 'derivatives' indicate whether interpolation or derivatives (tps) is needed to calculate the requested field 23 % .FieldNames = cell of fields to calculate from the fied cell 24 % 21 25 % errormsg: error message 22 26 % … … 49 53 % GNU General Public License (file UVMAT/COPYING.txt) for more details.for input in proj_field and plot_field 50 54 % group the variables into 'fields' with common dimensions 51 %------------------------------------------------------------------------52 % function [CellVarIndex,NbDim,CellVarType,errormsg]=find_field_cells(Data)53 %54 % OUTPUT:55 % CellVaxIndex: cell whose elements are arrays of indices in the list data.ListVarName56 % CellvarIndex{i} represents a set of variables with the same dimensions57 % NbDim: array with the length of CellVarIndex, giving its space dimension58 % CellVarType: cell array of structures with fields59 % .coord_x, y, z: indices (in .ListVarname) of variables representing unstructured coordinates x, y, z60 % .vector_x,_y,_z: indices of variables giving the vector components x, y, z61 % .warnflag: index of warnflag62 % .errorflag: index of error flag63 % .ancillary: indices of ancillary variables64 % .image : B/W image, (behaves like scalar)65 % .color : color image, the last index, which is not a coordinate variable, represent the 3 color components rgb66 % .discrete: like scalar, but set of data points without continuity, represented as dots in a usual plot, instead of continuous lines otherwise67 % .scalar: scalar field (default)68 % .coord: vector of indices of coordinate variables corresponding to matrix dimensions69 % errormsg: error message70 %71 % INPUT:72 % Data: structure representing fields, output of check_field_structure73 % .ListVarName: cell array listing the names (cahr strings) of the variables74 % .VarDimName: cell array of cells containing the set of dimension names for each variable of .ListVarName75 % .VarAttribute: cell array of structures containing the variable attributes:76 % .VarAttribute{ilist}.key=value, where ilist is the variable77 % index, key is the name of the attribute, value its value (char string or number)78 %79 % HELP:80 % to get the dimensions of arrays common to the field #icell81 % VarIndex=CellVarIndex{icell}; % list of variable indices82 % DimIndex=Data.VarDimIndex{VarIndex(1)} % list of dimensions for each variable in the cell #icell83 %84 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA85 % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.86 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA87 % This file is part of the toolbox UVMAT.88 %89 % UVMAT is free software; you can redistribute it and/or modify90 % it under the terms of the GNU General Public License as published by91 % the Free Software Foundation; either version 2 of the License, or92 % (at your option) any later version.93 %94 % UVMAT is distributed in the hope that it will be useful,95 % but WITHOUT ANY WARRANTY; without even the implied warranty of96 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the97 % GNU General Public License (file UVMAT/COPYING.txt) for more details.98 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA99 55 100 56 function [CellVarIndex,NbDim,CellVarType,errormsg]=find_field_cells(Data) 101 57 CellVarIndex={}; 102 58 103 NbDim=[];104 59 CellVarType=[]; 105 60 errormsg=[]; … … 108 63 109 64 NbDim=[]; 110 ivardim=0;111 65 VarDimIndex=[]; 112 66 VarDimName={}; … … 116 70 end 117 71 118 %% role of variables 72 %% role of variables and list of requested operations 119 73 Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks 74 FieldRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default 75 Operation=cell(size(Role)); % fieldRequest set to {} by default 76 CheckSub=zeros(size(Role));% =1 for fields to substract 120 77 Role=regexprep(Role,' ','scalar'); % Role set to 'scalar' by default 121 78 if isfield(Data,'VarAttribute') … … 124 81 Role{ivar}=Data.VarAttribute{ivar}.Role; 125 82 end 83 if isfield(Data.VarAttribute{ivar},'FieldRequest') 84 FieldRequest{ivar}=Data.VarAttribute{ivar}.FieldRequest; 85 end 86 if isfield(Data.VarAttribute{ivar},'Operation') 87 Operation{ivar}=Data.VarAttribute{ivar}.Operation; 88 end 89 if isfield(Data.VarAttribute{ivar},'CheckSub') 90 CheckSub(ivar)=Data.VarAttribute{ivar}.CheckSub; 91 end 126 92 end 127 93 end 128 94 129 95 %% loop on the list of variables, group them by common dimensions 96 CellVarType=cell(1,length(CellVarIndex)); 130 97 for ivar=1:nbvar 131 98 if ischar(Data.VarDimName{ivar}) … … 146 113 icell=icell+1; 147 114 CellVarIndex{icell}=ivar;%put the current variable index in the new cell 148 NbDim(icell)=numel(DimCell);%default 149 end 150 151 %look for dimension variables 152 % if numel(DimCell)==1% if the variable has a single dimension 153 % if strcmp(DimCell{1},Data.ListVarName{ivar}) %|| strcmp(Role{ivar},'dimvar') 154 % ivardim=ivardim+1; 155 % VarDimIndex(ivardim)=ivar;%index of the variable 156 % VarDimName{ivardim}=DimCell{1};%name of the dimension 157 % end 158 % end 115 NbDim(icell)=numel(DimCell);%default 116 CellVarType{icell}=[]; 117 end 118 if ~isempty(FieldRequest{ivar}) 119 CellVarType{icell}.FieldRequest=FieldRequest{ivar}; 120 end 121 if ~isempty(Operation{ivar}) 122 CellVarType{icell}.Operation=Operation{ivar}; 123 end 124 if CheckSub(ivar) 125 CellVarType{icell}.CheckSub=1; 126 end 159 127 end 160 128 … … 163 131 ind_dim_var_cell=find(checksinglecell); 164 132 %CoordType(ind_dim_var_cell)='dim_var';% to be used in output 133 %VarDimIndex=cell(size(ind_dim_var_cell)); 134 VarDimName=cell(size(ind_dim_var_cell)); 165 135 for icoord=1:numel(ind_dim_var_cell) 166 VarDimIndex(icoord)=CellVarIndex{ind_dim_var_cell(icoord)};167 VarDimName{icoord}=Data.VarDimName{VarDimIndex(icoord)}{1};136 VarDimIndex(icoord)=CellVarIndex{ind_dim_var_cell(icoord)}; 137 VarDimName{icoord}=Data.VarDimName{VarDimIndex(icoord)}{1}; 168 138 end 169 139 … … 201 171 202 172 index_remove=[]; 203 CellVarType=cell(1,length(CellVarIndex));204 173 for icell=1:length(CellVarIndex) 205 174 if checksinglecell(icell) … … 262 231 coord(idim)=VarDimIndex(ind_coord); 263 232 end 264 % for ivardim=1:numel(VarDimName)265 % if strcmp(VarDimName{ivardim},DimCell{idim})266 % coord(idim)=VarDimIndex(ivardim);267 % break268 % end269 % end270 233 end 271 234 NbDim(icell)=numel(find(coord));
Note: See TracChangeset
for help on using the changeset viewer.