Changeset 654 for trunk/src/calc_field_interp.m
- Timestamp:
- Jun 30, 2013, 11:16:45 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field_interp.m
r650 r654 1 %'calc_field_interp': defines fields (velocity, vort, div...) from civ data and calculate them 2 % for projection with linear interpolation 1 %'calc_field_interp': calculate fields (velocity, vort, div...) using linear interpolation if requested 3 2 %--------------------------------------------------------------------- 4 3 % [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI) … … 10 9 % 11 10 % INPUT: 12 % Coord(nbpoints,2): matrix of x,y coordinates of the input data points11 % Coord(nbpoints,2): matrix of x,y coordinates of the input data points 13 12 % Data: inputfield structure 14 13 % 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 14 % XI, YI: set of x and y coordinates where the fields need to be linearly interpolated, 15 % if XI, YI are missing, there is no interpolation (case of colors in vector plots) 16 % 17 17 function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI) 18 18 … … 25 25 if ischar(FieldName),FieldName={FieldName};end 26 26 check_skipped=zeros(size(FieldName));% default, =1 to mark the variables which can be calculated 27 check_interp=ones(size(FieldName));% default, =1 to mark the variables which can be interpolated (not ancillary) 27 28 Operator=cell(size(FieldName)); 28 29 … … 35 36 if isempty(ivar) 36 37 check_skipped(ilist)=1; %variable not found 37 else 38 elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1)); 38 39 if isfield(Data.VarAttribute{ivar},'Role') &&... 39 40 (strcmp(Data.VarAttribute{ivar}.Role,'ancillary')||strcmp(Data.VarAttribute{ivar}.Role,'warnflag')||strcmp(Data.VarAttribute{ivar}.Role,'errorflag')) 40 check_skipped(ilist)=1; % ancillary variable, not interpolated 41 elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1)); 42 InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list 41 check_interp(ilist)=0; % ancillary variable, not interpolated 43 42 end 43 InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list 44 44 end 45 45 else … … 88 88 case 'vec' 89 89 if exist('XI','var') 90 if check_interp 90 91 VarVal{nbvar+1}=F.(UName{ilist})(XI,YI); 91 92 VarVal{nbvar+2}=F.(VName{ilist})(XI,YI); 93 end 92 94 else 93 95 VarVal{nbvar+1}=Data.(UName{ilist}); … … 100 102 case 'norm' 101 103 if exist('XI','var') 104 if check_interp 102 105 U2=F.(UName{ilist})(XI,YI).*F.(UName{ilist})(XI,YI); 103 106 V2=F.(VName{ilist})(XI,YI).*F.(VName{ilist})(XI,YI); 107 end 104 108 else 105 109 U2=Data.(UName{ilist}).*Data.(UName{ilist}); … … 111 115 case {'curl','div','strain'} 112 116 if exist('XI','var') 117 if check_interp 113 118 VarVal{nbvar+1}=F.(UName{ilist})(XI,YI); 119 end 114 120 else 115 121 VarVal{nbvar+1}=Data.(UName{ilist}); … … 120 126 if ~isempty(FieldName{ilist}) 121 127 if exist('XI','var') 128 if check_interp 122 129 VarVal{nbvar+1}=F.(FieldName{ilist})(XI,YI); 130 end 123 131 else 124 132 VarVal{nbvar+1}= Data.(FieldName{ilist});
Note: See TracChangeset
for help on using the changeset viewer.