Changeset 579
- Timestamp:
- Mar 6, 2013, 9:20:51 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field_interp.m
r575 r579 2 2 % for projection with linear interpolation 3 3 %--------------------------------------------------------------------- 4 % [ DataOut,VarAttribute,errormsg]=calc_field_interp(Coord_tps,NbSites,SubRange,FieldVar,Operation,Coord_interp)4 % [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI) 5 5 % 6 6 % OUTPUT: 7 7 % VarVal: array giving the values of the calculated field 8 % ListVarName: corresponding list of variable names 9 % VarAttribute: corresponding list of variable attributes, each term #ilist is of the form VarAttribute{ilist}.tag=value 8 10 % 9 11 % INPUT: 10 % Coord_tps: 11 % NbSites 12 % SubRange 13 % FieldVar 14 % Operation: cell array representing the list of operations (eg div, rot..) 15 % Coord_interp: coordiantes of sites on which the fields need to be calculated 12 % Coord(nbpoints,2): matrix of x,y coordinates of theinput data points 13 % Data: inputfield structure 14 % FieldName: string representing the field to calculate, or cell array of fields (as displayed in uvmat/FieldName) 15 % XI, YI: set of x and y coordiantes where the fields need to be linearly interpolated 16 16 17 function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data, Operation,XI,YI)17 function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI) 18 18 19 VarVal= [];19 VarVal={}; 20 20 ListVarName={}; 21 21 VarAttribute={}; 22 22 errormsg=''; 23 23 InputVarList={}; 24 if ischar(Operation),Operation={Operation};end 25 check_skipped=zeros(size(Operation)); 26 Operator=cell(size(Operation)); 27 for ilist=1:numel(Operation) 28 r=regexp(Operation{ilist},'(?<Operator>(^vec|^norm))\((?<UName>.+),(?<VName>.+)\)$','names'); 29 if isempty(r) % the operation is the variable 30 if ~isfield(Data,Operation{ilist}) 31 check_skipped(ilist)=1; 24 if ischar(FieldName),FieldName={FieldName};end 25 check_skipped=zeros(size(FieldName));% default, =1 to mark the variables which can be calculated 26 Operator=cell(size(FieldName)); 27 for ilist=1:numel(FieldName) 28 Operator{ilist}='';%default empty operator (vec, norm,...) 29 r=regexp(FieldName{ilist},'(?<Operator>(^vec|^norm|^curl|^div|^strain))\((?<UName>.+),(?<VName>.+)\)$','names');% analyse the field name 30 if isempty(r) % the field name is a variable itself 31 if ~isfield(Data,FieldName{ilist}) 32 check_skipped(ilist)=1; %variable not found 32 33 else 33 if isempty(find(strcmp( Operation{ilist},InputVarList)));34 InputVarList=[InputVarList Operation{ilist}];% the variable is added to the listif it is not already in the list34 if isempty(find(strcmp(FieldName{ilist},InputVarList), 1)); 35 InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list 35 36 end 36 Operator{ilist}='';37 37 end 38 38 else 39 if ~isfield(Data,r.UName)||~isfield(Data,r.VName) 39 if ~isfield(Data,r.UName)||~isfield(Data,r.VName)%needed input variable not found 40 40 check_skipped(ilist)=1; 41 elseif strcmp(r.Operator,'curl')||strcmp(r.Operator,'div')||strcmp(r.Operator,'strain') 42 Operator{ilist}=r.Operator; 43 switch r.Operator 44 case 'curl'% case of CivX data format 45 UName{ilist}='vort'; 46 Data.vort=Data.DjUi(:,1,2)-Data.DjUi(:,2,1); 47 case 'div' 48 UName{ilist}='div'; 49 Data.div=Data.DjUi(:,1,1)+Data.DjUi(:,2,2); 50 case 'strain' 51 UName{ilist}='strain'; 52 Data.strain=Data.DjUi(:,1,2)+Data.DjUi(:,2,1); 53 end 54 InputVarList=[InputVarList UName{ilist}]; %the variable is added to the list if it is not already in the list 41 55 else 42 56 UName{ilist}=r.UName; … … 45 59 InputVarList=[InputVarList UName{ilist}]; %the variable is added to the list if it is not already in the list 46 60 end 47 if isempty(find(strcmp(r.VName,InputVarList) ));61 if isempty(find(strcmp(r.VName,InputVarList), 1)); 48 62 InputVarList=[InputVarList VName{ilist}]; %the variable is added to the list if it is not already in the list 49 63 end … … 58 72 end 59 73 end 60 for ilist=1:numel( Operation)74 for ilist=1:numel(FieldName) 61 75 if ~check_skipped(ilist) 62 76 nbvar=numel(ListVarName); … … 85 99 ListVarName{nbvar+1}='norm'; 86 100 VarAttribute{nbvar+1}.Role='scalar'; 101 case {'curl','div','strain'} 102 if exist('XI','var') 103 VarVal{nbvar+1}=F.(UName{ilist})(XI,YI); 104 else 105 VarVal{nbvar+1}=Data.(UName{ilist}); 106 end 107 ListVarName{nbvar+1}=UName{ilist}; 108 VarAttribute{nbvar+1}.Role='scalar'; 87 109 otherwise 88 if ~isempty( Operation{ilist})110 if ~isempty(FieldName{ilist}) 89 111 if exist('XI','var') 90 VarVal{nbvar+1}=F.( Operation{ilist})(XI,YI);112 VarVal{nbvar+1}=F.(FieldName{ilist})(XI,YI); 91 113 else 92 VarVal{nbvar+1}= Data.( Operation{ilist});114 VarVal{nbvar+1}= Data.(FieldName{ilist}); 93 115 end 94 ListVarName{nbvar+1}= Operation{ilist};116 ListVarName{nbvar+1}=FieldName{ilist}; 95 117 VarAttribute{nbvar+1}.Role='scalar'; 96 118 end … … 99 121 end 100 122 % put an error flag to indicate NaN data 101 if exist('XI','var') 123 if exist('XI','var')&&~isempty(VarVal) 102 124 nbvar=numel(ListVarName); 103 125 ListVarName{nbvar+1}='FF'; -
trunk/src/read_civxdata.m
r533 r579 93 93 Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel 94 94 if strcmp(role{var_ind(ivar)},'vector_x') 95 Field.VarAttribute{ivar}. Operation=FieldNames;95 Field.VarAttribute{ivar}.FieldName=FieldNames; 96 96 if testinterp 97 97 Field.VarAttribute{ivar}.FieldRequest='interp_lin'; … … 213 213 testder=0; 214 214 for ilist=1:length(FieldNames) 215 testder=~isempty(regexp(FieldNames{ilist},'(^curl|^div| strain)', 'once'));%test need for derivatives215 testder=~isempty(regexp(FieldNames{ilist},'(^curl|^div|^strain)', 'once'));%test need for derivatives 216 216 if testder, break;end 217 217 end -
trunk/src/uvmat.m
r576 r579 2464 2464 if strcmp(CellInfo{imax(ind)}.CoordType,'tps') 2465 2465 CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable 2466 CoordMax(ind,NbDim)=max( UvData.Field.(CoordName)(1:end-3,1,:));2467 CoordMax(ind,NbDim-1)=max( UvData.Field.(CoordName)(1:end-3,2,:));2468 CoordMin(ind,NbDim)=min( UvData.Field.(CoordName)(1:end-3,1,:));2469 CoordMin(ind,NbDim-1)=min( UvData.Field.(CoordName)(1:end-3,2,:));2466 CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case) 2467 CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case) 2468 CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3); 2469 CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case) 2470 2470 else 2471 2471 XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
Note: See TracChangeset
for help on using the changeset viewer.