source: trunk/src/calc_field_interp.m @ 515

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

improvement of calc-field and combination of two fields

File size: 2.5 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
19%% nbre of subdomains
20% if ndims(Coord_interp)==3
21%     nb_coord=size(Coord_interp,3);
22%     npx=size(Coord_interp,2);
23%     npy=size(Coord_interp,1);
24%     nb_sites=npx*npy;
25%     Coord_interp=reshape(Coord_interp,nb_sites,nb_coord);
26% else
27%     nb_coord=size(Coord_interp,2);
28%     nb_sites=size(Coord_interp,1);
29% end
30VarVal=[];
31ListVarName={};
32VarAttribute={};
33errormsg='';
34check_u=0;
35check_v=0;
36for ilist=1:length(Operation)
37    switch Operation{ilist}
38        case {'U'}
39           check_u=1;
40        case {'V'}
41            check_v=1;
42          case {'vec(U,V)','norm(U,V)'} 
43             check_u=1;
44             check_v=1;
45    end
46end
47if check_u
48    F_u = TriScatteredInterp(Coord,FieldVar(:,1),'linear');
49end
50if check_v
51    F_v = TriScatteredInterp(Coord,FieldVar(:,2),'linear');
52end
53for ilist=1:length(Operation)
54    nbvar=numel(ListVarName);
55    switch Operation{ilist}
56        case 'vec(U,V)'
57            VarVal{nbvar+1}=F_u(XI,YI);
58            VarVal{nbvar+2}=F_v(XI,YI);
59            ListVarName{nbvar+1}='U';
60            ListVarName{nbvar+2}='V';
61            VarAttribute{nbvar+1}.Role='vector_x';
62            VarAttribute{nbvar+2}.Role='vector_y';
63        case 'U'
64            VarVal{nbvar+1}=F_u(XI,YI);
65            ListVarName{nbvar+1}='U';
66            VarAttribute{nbvar+1}.Role='scalar';
67        case 'V'
68            VarVal{nbvar+1}=F_v(XI,YI);
69            ListVarName{nbvar+1}='V';
70            VarAttribute{nbvar+1}.Role='scalar';
71        case 'norm(U,V)'
72            VarVal{nbvar+1}=sqrt(F_u(XI,YI).*F_u(XI,YI)+F_v(XI,YI).*F_v(XI,YI));
73            ListVarName{nbvar+1}='norm(U,V)';
74            VarAttribute{nbvar+1}.Role='scalar';
75    end
76end
77nbvar=numel(ListVarName);
78ListVarName{nbvar+1}='FF';
79VarVal{nbvar+1}=isnan(VarVal{nbvar});
80VarAttribute{nbvar+1}.Role='errorflag';
81
82% Attr_FF.Role='errorflag';
83% VarAttribute=[VarAttribute {Attr_FF}];
84
85
86
87
88
Note: See TracBrowser for help on using the repository browser.