source: trunk/src/calc_field_interp.m @ 516

Last change on this file since 516 was 516, checked in by sommeria, 9 years ago

various bug corrections

File size: 2.2 KB
Line 
1
2%'calc_field': defines fields (velocity, vort, div...) from civx data and calculate them
3%---------------------------------------------------------------------
4% [DataOut,VarAttribute,errormsg]=calc_field_interp(Coord_tps,NbSites,SubRange,FieldVar,Operation,Coord_interp)
5%
6% OUTPUT:
7% DataOut: structure representing the output fields
8%
9% 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
16
17function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,FieldVar,Operation,XI,YI)
18
19VarVal=[];
20ListVarName={};
21VarAttribute={};
22errormsg='';
23check_u=0;
24check_v=0;
25for ilist=1:length(Operation)
26    switch Operation{ilist}
27        case {'U'}
28           check_u=1;
29        case {'V'}
30            check_v=1;
31          case {'vec(U,V)','norm(U,V)'} 
32             check_u=1;
33             check_v=1;
34    end
35end
36if check_u
37    F_u = TriScatteredInterp(Coord,FieldVar(:,1),'linear');
38end
39if check_v
40    F_v = TriScatteredInterp(Coord,FieldVar(:,2),'linear');
41end
42for ilist=1:length(Operation)
43    nbvar=numel(ListVarName);
44    switch Operation{ilist}
45        case 'vec(U,V)'
46            VarVal{nbvar+1}=F_u(XI,YI);
47            VarVal{nbvar+2}=F_v(XI,YI);
48            ListVarName{nbvar+1}='U';
49            ListVarName{nbvar+2}='V';
50            VarAttribute{nbvar+1}.Role='vector_x';
51            VarAttribute{nbvar+2}.Role='vector_y';
52        case 'U'
53            VarVal{nbvar+1}=F_u(XI,YI);
54            ListVarName{nbvar+1}='U';
55            VarAttribute{nbvar+1}.Role='scalar';
56        case 'V'
57            VarVal{nbvar+1}=F_v(XI,YI);
58            ListVarName{nbvar+1}='V';
59            VarAttribute{nbvar+1}.Role='scalar';
60        case 'norm(U,V)'
61            VarVal{nbvar+1}=sqrt(F_u(XI,YI).*F_u(XI,YI)+F_v(XI,YI).*F_v(XI,YI));
62            ListVarName{nbvar+1}='norm(U,V)';
63            VarAttribute{nbvar+1}.Role='scalar';
64    end
65end
66nbvar=numel(ListVarName);
67ListVarName{nbvar+1}='FF';
68VarVal{nbvar+1}=isnan(VarVal{nbvar});
69VarAttribute{nbvar+1}.Role='errorflag';
70
71% Attr_FF.Role='errorflag';
72% VarAttribute=[VarAttribute {Attr_FF}];
73
74
75
76
77
Note: See TracBrowser for help on using the repository browser.