source: trunk/src/civ_uvmat.m @ 247

Last change on this file since 247 was 246, checked in by sommeria, 13 years ago

thin plate shell (patch) introduced

File size: 18.9 KB
Line 
1% To develop....
2function [Data,errormsg]= civ_uvmat(Param,ncfile)
3errormsg='';
4Data.ListGlobalAttribute={'Conventions','Program','CivStage'};
5Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes
6Data.Program='civ_uvmat';
7Data.CivStage=0;%default
8ListVarCiv1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};
9ListVarFix1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F','Civ1_FF'};
10
11%% Civ1
12if isfield (Param,'Civ1')
13    par_civ1=Param.Civ1;
14    str2num(par_civ1.rho)
15    image1=imread(par_civ1.filename_ima_a);
16    image2=imread(par_civ1.filename_ima_b);
17    stepx=str2num(par_civ1.dx);
18    stepy=str2num(par_civ1.dy);
19    ibx2=ceil(str2num(par_civ1.ibx)/2);
20    iby2=ceil(str2num(par_civ1.iby)/2);
21    isx2=ceil(str2num(par_civ1.isx)/2);
22    isy2=ceil(str2num(par_civ1.isy)/2);
23    shiftx=str2num(par_civ1.shiftx);
24    shifty=str2num(par_civ1.shifty);
25    miniy=max(1+isy2+shifty,1+iby2);
26    minix=max(1+isx2-shiftx,1+ibx2);
27    maxiy=min(size(image1,1)-isy2+shifty,size(image1,1)-iby2);
28    maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
29    [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
30    PointCoord(:,1)=reshape(GridX,[],1);
31    PointCoord(:,2)=reshape(GridY,[],1);
32   
33    % caluclate velocity data (y and v in indices, reverse to y component)
34    [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho), []);
35    list_param=(fieldnames(par_civ1))';
36    list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'};
37    index=zeros(size(list_param));
38    for ilist=1:length(list_remove)
39        index=strcmp(list_remove{ilist},list_param);
40        if ~isempty(find(index,1))
41            list_param(index)=[];
42        end
43    end
44    for ilist=1:length(list_param)
45        Civ1_param{ilist}=['Civ1_' list_param{ilist}];
46        eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])
47    end
48    if isfield(Data,'Civ1_gridname') && strcmp(Data.Civ1_gridname(1:6),'noFile')
49        Data.Civ1_gridname='';
50    end
51    if isfield(Data,'Civ1_maskname') && strcmp(Data.Civ1_maskname(1:6),'noFile')
52        Data.Civ1_maskname='';
53    end
54    Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param {'Civ1_Time','Civ1_Dt'}];
55    Data.Civ1_Time=str2double(par_civ1.T0);
56    Data.Civ1_Dt=str2double(par_civ1.Dt);
57    Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};%  cell array containing the names of the fields to record
58    Data.VarDimName={'nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};
59    Data.VarAttribute{1}.Role='coord_x';
60    Data.VarAttribute{2}.Role='coord_y';
61    Data.VarAttribute{3}.Role='vector_x';
62    Data.VarAttribute{4}.Role='vector_y';
63    Data.VarAttribute{5}.Role='warnflag';
64    Data.Civ1_X=reshape(xtable,[],1);
65    Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1);
66    Data.Civ1_U=reshape(utable,[],1);
67    Data.Civ1_V=reshape(-vtable,[],1);
68    Data.Civ1_C=reshape(ctable,[],1);
69    Data.Civ1_F=reshape(F,[],1);
70    Data.CivStage=1;
71else
72    if isfield(Param,'Fix1')
73        Data=nc2struct(ncfile,ListVarCiv1);%read civ1 data in the existing netcdf file
74    else
75        Data=nc2struct(ncfile,ListVarFix1);%read civ1 and fix1 data in the existing netcdf file
76    end
77    if isfield(Data,'Txt')
78        msgbox_uvmat('ERROR',Data.Txt)
79        return
80    end
81    % read Civx data
82    if isfield(Data,'absolut_time_T0')%read civx file
83        var={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F','Civ1_FF';'vec_X','vec_Y','vec_U','vec_V','vec_C','vec_F','vec_FixFlag'};
84        %var=varcivx_generator('velocity','Civ1');%determine the names of constants and variables to read
85        [Data,vardetect,ichoice]=nc2struct(ncfile,var);%read the variables in the netcdf file
86        Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} Data.ListGlobalAttribute {'Civ1_Time','Civ1_Dt'}];
87        Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes
88        Data.Program='civ_uvmat';
89        Data.Civ1_Time=double(Data.absolut_time_T0);
90        Data.Civ1_Dt=double(Data.dt);
91        Data.VarDimName={'nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};
92        Data.VarAttribute{1}.Role='coord_x';
93        Data.VarAttribute{2}.Role='coord_y';
94        Data.VarAttribute{3}.Role='vector_x';
95        Data.VarAttribute{4}.Role='vector_y';
96        Data.VarAttribute{5}.Role='ancillary';
97        Data.VarAttribute{6}.Role='warnflag';
98        Data.VarAttribute{7}.Role='errorflag';
99        Data.CivStage=1;
100    end
101end
102
103%% Fix1
104if isfield (Param,'Fix1')
105    ListFixParam=fieldnames(Param.Fix1);
106    for ilist=1:length(ListFixParam)
107        ParamName=ListFixParam{ilist};
108        ListName=['Fix1_' ParamName];
109        eval(['Data.ListGlobalAttribute=[Data.ListGlobalAttribute ''' ParamName '''];'])
110        eval(['Data.' ListName '=Param.Fix1.' ParamName ';'])
111    end
112%     Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Fix1_WarnFlags','Fix1_TreshCorr','Fix1_TreshVel','Fix1_UpperBoundTest'}];
113%     Data.Fix1_WarnFlags=Param.Fix1.WarnFlags;
114%     Data.Fix1_ThreshCorr=Param.Fix1.ThreshCorr;
115%     Data.Fix1_ThreshVel=Param.Fix1.ThreshVel;
116%     Data.Fix1_UpperBoundTest=Param.Fix1.UpperBoundTest;
117    Data.ListVarName=[Data.ListVarName {'Civ1_FF'}];
118    Data.VarDimName=[Data.VarDimName {'nbvec1'}];
119    nbvar=length(Data.ListVarName);
120    Data.VarAttribute{nbvar}.Role='errorflag';   
121    Data.Civ1_FF=fix_uvmat(Param.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V);
122    Data.CivStage=2;                               
123end   
124%% Patch1
125if isfield (Param,'Patch1')
126    Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}];
127    Data.Patch1_Rho=str2double(Param.Patch1.Rho);
128    Data.Patch1_Threshold=str2double(Param.Patch1.Threshold);
129    Data.Patch1_SubDomain=str2double(Param.Patch1.SubDomain);
130    Data.ListVarName=[Data.ListVarName {'Civ1_U_Diff','Civ1_V_Diff','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites','Civ1_X_tps','Civ1_Y_tps','Civ1_U_tps','Civ1_V_tps'}];
131    Data.VarDimName=[Data.VarDimName {'NbVec1','NbVec1',{'NbSubDomain1','Two'},{'NbSubDomain1','Two'},'NbSubDomain1',...
132             {'NbVec1Sub','NbSubDomain1'},{'NbVec1Sub','NbSubDomain1'},{'Nbtps1','NbSubDomain1'},{'Nbtps1','NbSubDomain1'}}];
133    nbvar=length(Data.ListVarName);
134    Data.VarAttribute{nbvar-1}.Role='vector_x';
135    Data.VarAttribute{nbvar}.Role='vector_y';
136    Data.Civ1_U_Diff=zeros(size(Data.Civ1_X));
137    Data.Civ1_V_Diff=zeros(size(Data.Civ1_X));
138    if isfield(Data,'Civ1_FF')
139        ind_good=find(Data.Civ1_FF==0);
140    else
141        ind_good=1:numel(Data.Civ1_X);
142    end
143    [Data.Civ1_X_SubRange,Data.Civ1_Y_SubRange,Data.Civ1_NbSites,FFres,Ures, Vres,Data.Civ1_X_tps,Data.Civ1_Y_tps,Data.Civ1_U_tps,Data.Civ1_V_tps]=...
144                            patch_uvmat(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain);
145      Data.Civ1_U_Diff(ind_good)=Data.Civ1_U(ind_good)-Ures;
146      Data.Civ1_V_Diff(ind_good)=Data.Civ1_V(ind_good)-Vres;
147      Data.Civ1_FF(ind_good)=FFres;
148      Data.CivStage=3;                             
149end   
150%% write result
151% 'TESTcalc'
152% [DataOut,errormsg]=calc_field('velocity',Data)
153if exist('ncfile','var')
154errormsg=struct2nc(ncfile,Data);
155end
156
157
158%'RUN_FIX': function for fixing velocity fields:
159%-----------------------------------------------
160% RUN_FIX(filename,field,flagindex,thresh_vecC,thresh_vel,iter,flag_mask,maskname,fileref,fieldref)
161%
162%filename: name of the netcdf file (used as input and output)
163%field: structure specifying the names of the fields to fix (depending on civ1 or civ2)
164    %.vel_type='civ1' or 'civ2';
165    %.nb=name of the dimension common to the field to fix ('nb_vectors' for civ1);
166    %.fixflag=name of fix flag variable ('vec_FixFlag' for civ1)
167%flagindex: flag specifying which values of vec_f are removed:
168        % if flagindex(1)=1: vec_f=-2 vectors are removed
169        % if flagindex(2)=1: vec_f=3 vectors are removed
170        % if flagindex(3)=1: vec_f=2 vectors are removed (if iter=1) or vec_f=4 vectors are removed (if iter=2)
171%iter=1 for civ1 fields and iter=2 for civ2 fields
172%thresh_vecC: threshold in the image correlation vec_C
173%flag_mask: =1 mask used to remove vectors (0 else)
174%maskname: name of the mask image file for fix
175%thresh_vel: threshold on velocity, or on the difference with the reference file fileref if exists
176%inf_sup=1: remove values smaller than threshold thresh_vel, =2, larger than threshold
177%fileref: .nc file name for a reference velocity (='': refrence 0 used)
178%fieldref: 'civ1','filter1'...feld used in fileref
179
180function FF=fix_uvmat(Param,F,C,U,V)
181%error=[]; %default
182FF=zeros(size(F));%default
183
184%criterium on warn flags
185if isfield (Param,'WarnFlags')
186    for iflag=1:numel(Param.WarnFlags)
187        FF=(FF==1| F==Param.WarnFlags(iflag));
188    end
189end
190
191%criterium on correlation values
192if isfield (Param,'LowerBoundCorr')
193    FF=FF==1 | C<Param.LowerBoundCorr;
194end
195
196if isfield (Param,'LowerBoundVel')&& ~isequal(Param.LowerBoundVel,0)
197    thresh=Param.LowerBoundVel*Param.LowerBoundVel;
198    FF=FF==1 | (U.*U+V.*V)<thresh;
199end
200if isfield (Param,'UpperBoundVel')&& ~isequal(Param.UpperBoundVel,0)
201    thresh=Param.UpperBoundVel*Param.UpperBoundVel;
202    FF=FF==1 | (U.*U+V.*V)>thresh;
203end
204FF=double(FF);
205%
206% % criterium on velocity values
207% delta_u=Field.U;%default without ref file
208% delta_v=Field.V;
209% if exist('fileref','var') && ~isempty(fileref)
210%     if ~exist(fileref,'file')
211%         error='reference file not found in RUN_FIX.m';
212%         display(error);
213%         return
214%     end
215%     FieldRef=read_civxdata(fileref,[],fieldref);   
216%     if isfield(FieldRef,'FF')
217%         index_true=find(FieldRef.FF==0);
218%         FieldRef.X=FieldRef.X(index_true);
219%         FieldRef.Y=FieldRef.Y(index_true);
220%         FieldRef.U=FieldRef.U(index_true);
221%         FieldRef.V=FieldRef.V(index_true);
222%     end
223%     if ~isfield(FieldRef,'X') || ~isfield(FieldRef,'Y') || ~isfield(FieldRef,'U') || ~isfield(FieldRef,'V')
224%         error='reference file is not a velocity field in RUN_FIX.m '; %bad input file
225%         return
226%     end
227%     if length(FieldRef.X)<=1
228%         errordlg('reference field with one vector or less in RUN_FIX.m')
229%         return
230%     end
231%     vec_U_ref=griddata_uvmat(FieldRef.X,FieldRef.Y,FieldRef.U,Field.X,Field.Y);  %interpolate vectors in the ref field
232%     vec_V_ref=griddata_uvmat(FieldRef.X,FieldRef.Y,FieldRef.V,Field.X,Field.Y);  %interpolate vectors in the ref field to the positions  of the main field     
233%     delta_u=Field.U-vec_U_ref;%take the difference with the interpolated ref field
234%     delta_v=Field.V-vec_V_ref;
235% end
236% thresh_vel_x=thresh_vel;
237% thresh_vel_y=thresh_vel;
238% if isequal(inf_sup,1)
239%     flag5=abs(delta_u)<thresh_vel_x & abs(delta_v)<thresh_vel_y &(flag1~=1)&(flag2~=1)&(flag3~=1)&(flag4~=1);
240% elseif isequal(inf_sup,2)
241%     flag5=(abs(delta_u)>thresh_vel_x | abs(delta_v)>thresh_vel_y) &(flag1~=1)&(flag2~=1)&(flag3~=1)&(flag4~=1);
242% end
243%
244%             % flag7 introduce a grey mask, matrix M
245% if isequal (flag_mask,1)
246%    M=imread(maskname);
247%    nxy=size(M);
248%    M=reshape(M,1,nxy(1)*nxy(2));
249%    rangx0=[0.5 nxy(2)-0.5];
250%    rangy0=[0.5 nxy(1)-0.5];
251%    vec_x1=Field.X-Field.U/2;%beginning points
252%    vec_x2=Field.X+Field.U/2;%end points of vectors
253%    vec_y1=Field.Y-Field.V/2;%beginning points
254%    vec_y2=Field.Y+Field.V/2;%end points of vectors
255%    indx=1+round((nxy(2)-1)*(vec_x1-rangx0(1))/(rangx0(2)-rangx0(1)));% image index x at abcissa vec_x
256%    indy=1+round((nxy(1)-1)*(vec_y1-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y   
257%    test_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside
258%    indx=indx.*test_in+(1-test_in); %replace indx by 1 out of the mask range
259%    indy=indy.*test_in+(1-test_in); %replace indy by 1 out of the mask range
260%    ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector
261%    Mvalues=M(ICOMB);
262%    flag7b=((20 < Mvalues) & (Mvalues < 200))| ~test_in';
263%    indx=1+round((nxy(2)-1)*(vec_x2-rangx0(1))/(rangx0(2)-rangx0(1)));% image index x at abcissa Field.X
264%    indy=1+round((nxy(1)-1)*(vec_y2-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y
265%    test_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside
266%    indx=indx.*test_in+(1-test_in); %replace indx by 1 out of the mask range
267%    indy=indy.*test_in+(1-test_in); %replace indy by 1 out of the mask range
268%    ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector
269%    Mvalues=M(ICOMB);
270%    flag7e=((Mvalues > 20) & (Mvalues < 200))| ~test_in';
271%    flag7=(flag7b|flag7e)';
272% else
273%    flag7=0;
274% end   
275% flagmagenta=flag1|flag2|flag3|flag4|flag5|flag7;
276% fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag
277
278
279
280%------------------------------------------------------------------------
281% patch function
282function [SubRangx,SubRangy,nbpoints,FF,U_smooth,V_smooth,X_tps,Y_tps,U_tps,V_tps] =patch_uvmat(X,Y,U,V,Rho,Threshold,SubDomain)
283%subdomain decomposition
284warning off
285U=reshape(U,[],1);
286V=reshape(V,[],1);
287X=reshape(X,[],1);
288Y=reshape(Y,[],1);
289nbvec=numel(X);
290NbSubDomain=ceil(nbvec/SubDomain);
291MinX=min(X);
292MinY=min(Y);
293MaxX=max(X);
294MaxY=max(Y);
295RangX=MaxX-MinX;
296RangY=MaxY-MinY;
297AspectRatio=RangY/RangX;
298NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);
299NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);
300NbSubDomain=NbSubDomainX*NbSubDomainY;
301SizX=RangX/NbSubDomainX;%width of subdomains
302SizY=RangY/NbSubDomainY;%height of subdomains
303CentreX=linspace(MinX+SizX/2,MaxX-SizX/2,NbSubDomainX);
304CentreY=linspace(MinY+SizY/2,MaxY-SizY/2,NbSubDomainY);
305[CentreX,CentreY]=meshgrid(CentreX,CentreY);
306CentreY=reshape(CentreY,1,[]);
307CentreX=reshape(CentreX,1,[]);
308rho=SizX*SizY*Rho/1000000;%optimum rho increase as the area of the subdomain (division by 10^6 to reach good values with the default GUI input)
309U_tps_sub=zeros(length(X),NbSubDomain);%default spline
310V_tps_sub=zeros(length(X),NbSubDomain);%default spline
311U_smooth=zeros(length(X),1);
312V_smooth=zeros(length(X),1);
313
314nb_select=zeros(length(X),1);
315FF=zeros(length(X),1);
316test_empty=zeros(1,NbSubDomain);
317for isub=1:NbSubDomain
318    SubRangx(isub,:)=[CentreX(isub)-SizX/2 CentreX(isub)+SizX/2];
319    SubRangy(isub,:)=[CentreY(isub)-SizY/2 CentreY(isub)+SizY/2];
320    ind_sel_previous=[];
321    ind_sel=0;
322    while numel(ind_sel)>numel(ind_sel_previous) %increase the subdomain during four iterations at most
323        ind_sel_previous=ind_sel;
324        ind_sel=find(X>SubRangx(isub,1) & X<SubRangx(isub,2) & Y>SubRangy(isub,1) & Y<SubRangy(isub,2));
325        % if no vector in the subdomain, skip the subdomain
326        if isempty(ind_sel)
327            test_empty(isub)=1;   
328            U_tps(1,isub)=0;%define U_tps and V_tps by default
329            V_tps(1,isub)=0;
330            break
331            % if too few selected vectors, increase the subrange for next iteration
332        elseif numel(ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous);
333            SubRangx(isub,1)=SubRangx(isub,1)-SizX/4;
334            SubRangx(isub,2)=SubRangx(isub,2)+SizX/4;
335            SubRangy(isub,1)=SubRangy(isub,1)-SizY/4;
336            SubRangy(isub,2)=SubRangy(isub,2)+SizY/4;
337        else
338            [U_smooth_sub,U_tps_sub]=tps_coeff(X(ind_sel),Y(ind_sel),U(ind_sel),rho);
339            [V_smooth_sub,V_tps_sub]=tps_coeff(X(ind_sel),Y(ind_sel),V(ind_sel),rho);
340            UDiff=U_smooth_sub-U(ind_sel);
341            VDiff=V_smooth_sub-V(ind_sel);
342            NormDiff=UDiff.*UDiff+VDiff.*VDiff;
343            FF(ind_sel)=20*(NormDiff>Threshold);%put FF value to 20 to identify the criterium of elimmination
344            ind_ind_sel=find(FF(ind_sel)==0); % select the indices of ind_sel corresponding to the remaining vectors
345            % no value exceeds threshold, the result is recorded
346            if isequal(numel(ind_ind_sel),numel(ind_sel))
347                U_smooth(ind_sel)=U_smooth(ind_sel)+U_smooth_sub;
348                V_smooth(ind_sel)=V_smooth(ind_sel)+V_smooth_sub;
349                nbpoints(isub)=numel(ind_sel);
350                X_tps(1:nbpoints(isub),isub)=X(ind_sel);
351                Y_tps(1:nbpoints(isub),isub)=Y(ind_sel);
352                U_tps(1:nbpoints(isub)+3,isub)=U_tps_sub;
353                V_tps(1:nbpoints(isub)+3,isub)=V_tps_sub;         
354                nb_select(ind_sel)=nb_select(ind_sel)+1;
355                 display('good')
356                break
357                % too few selected vectors, increase the subrange for next iteration
358            elseif numel(ind_ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous);
359                SubRangx(isub,1)=SubRangx(isub,1)-SizX/4;
360                SubRangx(isub,2)=SubRangx(isub,2)+SizX/4;
361                SubRangy(isub,1)=SubRangy(isub,1)-SizY/4;
362                SubRangy(isub,2)=SubRangy(isub,2)+SizY/4;
363%                 display('fewsmooth')
364                % interpolation-smoothing is done again with the selected vectors
365            else
366                [U_smooth_sub,U_tps_sub]=tps_coeff(X(ind_sel(ind_ind_sel)),Y(ind_sel(ind_ind_sel)),U(ind_sel(ind_ind_sel)),rho);
367                [V_smooth_sub,V_tps_sub]=tps_coeff(X(ind_sel(ind_ind_sel)),Y(ind_sel(ind_ind_sel)),V(ind_sel(ind_ind_sel)),rho);
368                U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+U_smooth_sub;
369                V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;
370                nbpoints(isub)=numel(ind_ind_sel);
371                X_tps(1:nbpoints(isub),isub)=X(ind_sel(ind_ind_sel));
372                Y_tps(1:nbpoints(isub),isub)=Y(ind_sel(ind_ind_sel));
373                U_tps(1:nbpoints(isub)+3,isub)=U_tps_sub;
374                V_tps(1:nbpoints(isub)+3,isub)=V_tps_sub;
375                nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+1;
376                display('good2')
377                break
378            end
379        end
380    end
381end
382ind_empty=find(test_empty);
383%remove empty subdomains
384if ~isempty(ind_empty)
385    SubRangx(ind_empty,:)=[];
386    SubRangy(ind_empty,:)=[];
387    X_tps(:,ind_empty)=[];
388    Y_tps(:,ind_empty)=[];
389    U_tps(:,ind_empty)=[];
390    V_tps(:,ind_empty)=[];
391end
392nb_select(nb_select==0)=1;%ones(size(find(nb_select==0)));
393U_smooth=U_smooth./nb_select;
394V_smooth=V_smooth./nb_select;
395
396
397
398
399
400
401% U_patch = EM * spline_coeff;
402% U_patch=reshape(U_patch,npy,npx);
403% PM = [ones(size(dsites,1),1) dsites];
404% EM = [IM_sites PM];
405% U(test_false)=[];
406% U_nodes=EM * spline_coeff;
407
408%exact = testfunctions(epoints);
409%maxerr = norm(Pf-exact,inf);
410% PlotSurf(xe,ye,Pf,neval,exact,maxerr,[160,20]);
411% PlotError2D(xe,ye,Pf,exact,maxerr,neval,[160,20]);
412
413
414
415  % DM = DistanceMatrix(dsites,ctrs)
416% Forms the distance matrix of two sets of points in R^s,
417% i.e., DM(i,j) = || datasite_i - center_j ||_2.
418% Input
419%   dsites: Mxs matrix representing a set of M data sites in R^s
420%              (i.e., each row contains one s-dimensional point)
421%   ctrs:   Nxs matrix representing a set of N centers in R^s
422%              (one center per row)
423% Output
424
425
426
427
Note: See TracBrowser for help on using the repository browser.