Changeset 515 for trunk/src/calc_tps.m
- Timestamp:
- Aug 15, 2012, 11:36:12 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_tps.m
r508 r515 1 function DataOut=calc_tps(DataIn )1 function DataOut=calc_tps(DataIn,checkall) 2 2 DataOut=DataIn;%default 3 3 SubDomain=1000; %default, estimated nbre of vectors in a subdomain used for tps … … 5 5 SubDomain=DataIn.SubDomain;% 6 6 end 7 [DataOut.SubRange,DataOut.NbSites,DataOut.Coord_tps,DataOut.U_tps,DataOut.V_tps] =... 8 filter_tps([DataIn.X(DataIn.FF==0) DataIn.Y(DataIn.FF==0)],DataIn.U(DataIn.FF==0),DataIn.V(DataIn.FF==0),[],SubDomain,0); 9 nbvar=numel(DataIn.ListVarName); 10 DataOut.ListVarName=[DataIn.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}]; 11 DataOut.VarDimName=[DataIn.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},... 12 {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}]; 13 DataOut.VarAttribute{nbvar+3}.Role='coord_tps'; 14 DataOut.VarAttribute{nbvar+4}.Role='vector_x'; 15 DataOut.VarAttribute{nbvar+5}.Role='vector_y'; 16 if isfield(DataOut,'ListDimName')%cleaning 17 DataOut=rmfield(DataOut,'ListDimName'); 7 [CellVarIndex,NbDimVec,VarTypeCell,errormsg]=find_field_cells(DataIn); 8 nbtps=0; 9 for icell=1:numel(CellVarIndex); 10 VarType=VarTypeCell{icell}; 11 if NbDimVec(icell)>=2 && ~isempty(VarType.coord_x) 12 nbtps=nbtps+1; 13 X=DataIn.(DataIn.ListVarName{VarType.coord_x}); 14 Y=DataIn.(DataIn.ListVarName{VarType.coord_y}); 15 if ~isempty(VarType.vector_x)&&~isempty(VarType.vector_y) 16 Attr=DataIn.VarAttribute{VarType.vector_x}; 17 if ~isfield(Attr,'VarIndex_tps')&& (checkall || (isfield(Attr,'FieldRequest')&&strcmp(Attr.FieldRequest,'derivatives'))) 18 U=DataIn.(DataIn.ListVarName{VarType.vector_x}); 19 V=DataIn.(DataIn.ListVarName{VarType.vector_y}); 20 else 21 continue 22 end 23 end 24 if ~isempty(VarType.errorflag) 25 FF=DataIn.(DataIn.ListVarName{VarType.errorflag}); 26 X=X(FF==0); 27 Y=Y(FF==0); 28 U=U(FF==0); 29 V=V(FF==0); 30 end 31 if nbtps==1 32 ListNewVar={'SubRange','NbSites','Coord_tps','U_tps','V_tps'}; 33 ListNewDim={'nb_tps','nb_subdomain'}; 34 DataOut.VarDimName=[DataIn.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},... 35 {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}]; 36 else 37 ListNewVar={['SubRange_' num2str(nbtps-1)],['NbSites_' num2str(nbtps-1)],['Coord_tps_' num2str(nbtps-1)],['U_tps_' num2str(nbtps-1)] ,['V_tps_' num2str(nbtps-1)]}; 38 ListNewDim={['nb_tps_' num2str(nbtps-1)],['nb_subdomain_' num2str(nbtps-1)]}; 39 DataOut.VarDimName=[DataIn.VarDimName {{'nb_coord','nb_bounds',ListNewDim{2}},ListNewDim(2),... 40 {ListNewDim{1},'nb_coord',ListNewDim{2}},ListNewDim,ListNewDim}]; 41 end 42 DataOut.ListVarName=[DataIn.ListVarName ListNewVar]; 43 44 [DataOut.(ListNewVar{1}),DataOut.(ListNewVar{2}),DataOut.(ListNewVar{3}),DataOut.(ListNewVar{4}),DataOut.(ListNewVar{5})] =... 45 filter_tps([X Y],U,V,[],SubDomain,0); 46 nbvar=numel(DataIn.ListVarName); 47 48 DataOut.VarAttribute{nbvar+3}.Role='coord_tps'; 49 DataOut.VarAttribute{nbvar+4}=DataIn.VarAttribute{VarType.vector_x};%reproduce attributes of velocity 50 DataOut.VarAttribute{nbvar+4}.Role='vector_x_tps'; 51 DataIn.VarAttribute{VarType.vector_x}.VarIndex_tps=nbvar+4;% indicte the correspondance with initial data 52 DataOut.VarAttribute{nbvar+5}=DataIn.VarAttribute{VarType.vector_y};%reproduce attributes of velocity 53 DataOut.VarAttribute{nbvar+5}.Role='vector_y_tps'; 54 % if isfield(DataOut.VarAttribute{VarType.vector_x},'FieldRequest') 55 % DataOut.VarAttribute{VarType.vector_x}=rmfield(DataOut.VarAttribute{VarType.vector_x},'FieldRequest'); 56 % end 57 % if isfield(DataOut.VarAttribute{VarType.vector_x},'Operation') 58 % DataOut.VarAttribute{VarType.vector_x}=rmfield(DataOut.VarAttribute{VarType.vector_x},'Operation'); 59 % end 60 if isfield(DataOut,'ListDimName')%cleaning'FieldRequest' 61 DataOut=rmfield(DataOut,'ListDimName'); 62 end 63 if isfield(DataOut,'DimValue')%cleaning 64 DataOut=rmfield(DataOut,'DimValue'); 65 end 66 end 18 67 end 19 if isfield(DataOut,'DimValue')%cleaning20 DataOut=rmfield(DataOut,'DimValue');21 end
Note: See TracChangeset
for help on using the changeset viewer.