Changeset 243 for trunk/src/civ_uvmat.m
- Timestamp:
- Apr 19, 2011, 5:41:35 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ_uvmat.m
r242 r243 129 129 ind_good=1:numel(Data.Civ1_X); 130 130 end 131 Data.Civ1_X 131 132 [Ures, Vres,FFres]=... 132 133 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); … … 269 270 %------------------------------------------------------------------------ 270 271 % patch function 271 function [U_ smooth,V_smooth,FF] =patch_uvmat(X,Y,U,V,Rho,Threshold,SubDomain)272 function [U_patch,V_patch,FF,SubRangx,SubRangy,X_ctrs,Y_ctrs] =patch_uvmat(X,Y,U,V,Rho,Threshold,SubDomain) 272 273 %subdomain decomposition 273 274 warning off 275 U=reshape(U,[],1); 276 V=reshape(V,[],1); 277 X=reshape(X,[],1); 278 Y=reshape(Y,[],1); 274 279 nbvec=numel(X); 275 NbSubDomain=ceil(nbvec/SubDomain) ;276 MinX=min(X) ;277 MinY=min(Y) ;278 MaxX=max(X) ;279 MaxY=max(Y) ;280 NbSubDomain=ceil(nbvec/SubDomain) 281 MinX=min(X) 282 MinY=min(Y) 283 MaxX=max(X) 284 MaxY=max(Y) 280 285 RangX=MaxX-MinX; 281 286 RangY=MaxY-MinY; 282 AspectRatio=RangY/RangX ;287 AspectRatio=RangY/RangX 283 288 NbSubDomainX=ceil(sqrt(NbSubDomain/AspectRatio)) 284 289 NbSubDomainY=ceil(sqrt(NbSubDomain*AspectRatio)) … … 291 296 SubIndexY=ceil((Y-MinY)/SizY); 292 297 rho=RangX*RangY*Rho;%optimum rho increase as teh area of the subdomain 293 U_tps=zeros(length(X)+3,1);%default spline 294 V_tps=zeros(length(X)+3,1);%default spline 298 U_tps=zeros(length(X),NbSubDomainY,NbSubDomainX);%default spline 299 V_tps=zeros(length(X),NbSubDomainY,NbSubDomainX);%default spline 300 X_dist=zeros(length(X),NbSubDomainY,NbSubDomainX);%default spline 301 Y_dist=zeros(length(X),NbSubDomainY,NbSubDomainX);%default spline 302 U_smooth=zeros(length(X),NbSubDomainY,NbSubDomainX); 303 V_smooth=zeros(length(X),NbSubDomainY,NbSubDomainX); 304 dist_ctre=zeros(length(X),NbSubDomainY,NbSubDomainX); 305 FF=zeros(length(X),1); 295 306 for isubx=1:NbSubDomainX 296 307 for isuby=1:NbSubDomainY 297 SubRangx(isuby,isubx,:)=[CentreX(isubx)-SizX/2 CentreX(isubx)+SizX/2] 298 SubRangy(isuby,isubx,:)=[CentreY(isubx)-SizY/2 CentreY(isubx)+SizY/2] 308 SubRangx(isuby,isubx,:)=[CentreX(isubx)-SizX/2 CentreX(isubx)+SizX/2]; 309 SubRangy(isuby,isubx,:)=[CentreY(isubx)-SizY/2 CentreY(isubx)+SizY/2]; 299 310 for iter=1:3 %increase the subdomain during three iterations at most 300 311 ind_sel=find(X>SubRangx(isuby,isubx,1) & X<SubRangx(isuby,isubx,2) & Y>SubRangy(isuby,isubx,1) & Y<SubRangy(isuby,isubx,2)); 301 [U_smooth(ind_sel)]=tps_uvmat(X(ind_sel),Y(ind_sel),U(ind_sel),rho); 302 [V_smooth(ind_sel)]=tps_uvmat(X(ind_sel),Y(ind_sel),V(ind_sel),rho); 303 iter 304 numel(ind_sel) 312 size(ind_sel) 305 313 if numel(ind_sel)<SubDomain/4;% too few selected vectors, increase the subrange for next iteration 306 314 SubRangx(isuby,isubx,1)=SubRangx(isuby,isubx,1)-SizX/4; … … 309 317 SubRangy(isuby,isubx,2)=SubRangy(isuby,isubx,2)+SizY/4; 310 318 else 311 UDiff=U_smooth(ind_sel)-U(ind_sel); 312 VDiff=U_smooth(ind_sel)-U(ind_sel); 319 [U_smooth_sub,U_tps_sub]=tps_uvmat(X(ind_sel),Y(ind_sel),U(ind_sel),rho); 320 [V_smooth_sub,V_tps_sub]=tps_uvmat(X(ind_sel),Y(ind_sel),V(ind_sel),rho); 321 size(U_smooth_sub) 322 size(U(ind_sel)) 323 UDiff=U_smooth_sub-U(ind_sel); 324 VDiff=V_smooth_sub-V(ind_sel); 313 325 NormDiff=UDiff.*UDiff+VDiff.*VDiff; 314 326 FF(ind_sel)=20*(NormDiff>Threshold);%put FF value to 20 to identify the criterium of elimmination 315 ind_ind_false=find(FF(ind_sel)~=0); 316 ind_ind_sel=find(FF(ind_sel)==0); 317 U_smooth(ind_sel(ind_ind_false))=zeros(numel(ind_ind_false),1); 318 V_smooth(ind_sel(ind_ind_false))=zeros(numel(ind_ind_false),1); 319 [U_smooth(ind_sel(ind_ind_sel))]=tps_uvmat(X(ind_sel(ind_ind_sel)),Y(ind_sel(ind_ind_sel)),U(ind_sel(ind_ind_sel)),rho); 320 [V_smooth(ind_sel(ind_ind_sel))]=tps_uvmat(X(ind_sel(ind_ind_sel)),Y(ind_sel(ind_ind_sel)),V(ind_sel(ind_ind_sel)),rho); 321 if numel(ind_ind_sel)<SubDomain/4;% too few selected vectors, increase the subrange for next iteration 327 ind_ind_sel=find(FF(ind_sel)==0); 328 if isequal(numel(ind_ind_sel),numel(ind_sel)) 329 U_smooth(ind_sel,isuby,isubx)=U_smooth_sub; 330 V_smooth(ind_sel,isuby,isubx)=V_smooth_sub; 331 break 332 elseif numel(ind_ind_sel)<SubDomain/4;% too few selected vectors, increase the subrange for next iteration 322 333 SubRangx(isuby,isubx,1)=SubRangx(isuby,isubx,1)-SizX/4; 323 334 SubRangx(isuby,isubx,2)=SubRangx(isuby,isubx,2)+SizX/4; 324 335 SubRangy(isuby,isubx,1)=SubRangy(isuby,isubx,1)-SizY/4; 325 336 SubRangy(isuby,isubx,2)=SubRangy(isuby,isubx,2)+SizY/4; 326 else 327 break 328 end 337 else 338 [U_smooth(ind_sel(ind_ind_sel),isuby,isubx),U_tps(ind_sel(ind_ind_sel),isuby,isubx),U_tps3(isuby,isubx)]=tps_uvmat(X(ind_sel(ind_ind_sel)),Y(ind_sel(ind_ind_sel)),U(ind_sel(ind_ind_sel)),rho); 339 [V_smooth(ind_sel(ind_ind_sel),isuby,isubx),V_tps(ind_sel(ind_ind_sel),isuby,isubx),V_tps3(isuby,isubx)]=tps_uvmat(X(ind_sel(ind_ind_sel)),Y(ind_sel(ind_ind_sel)),V(ind_sel(ind_ind_sel)),rho); 340 break 341 end 329 342 end 330 end 331 %intrpolate to new points XI, YI 332 % X_ctrs{isuby,isubx}=X(ind_sel(ind_ind_sel));%positions of tps sources for the subdomain i,j 333 % Y_ctrs{isuby,isubx}=Y(ind_sel(ind_ind_sel)); 334 end 335 end 336 343 end 344 X_ctrs(isuby,isubx)=mean(X(ind_sel));%gravity centre of selected points 345 Y_ctrs(isuby,isubx)=mean(Y(ind_sel));%positions of tps sources for the subdomain i, 346 dist_ctre(ind_sel,isuby,isubx)=sqrt(abs(((X(ind_sel)-X_ctrs(isuby,isubx)).*(X(ind_sel)-X_ctrs(isuby,isubx)))+((Y(ind_sel)-Y_ctrs(isuby,isubx)).*(Y(ind_sel)-Y_ctrs(isuby,isubx))))); 347 end 348 end 349 U_patch=sum(sum(U_smooth.*dist_ctre,3),2)./sum(sum(dist_ctre,3),2); 350 V_patch=sum(sum(V_smooth.*dist_ctre,3),2)./sum(sum(dist_ctre,3),2); 337 351 338 352 %------------------------------------------------------------------------ … … 340 354 % X,Y initial coordiantes 341 355 % XI vector, YI column vector for the grid of interpolation points 342 function [U_smooth,U_tps ]=tps_uvmat(X,Y,U,rho)356 function [U_smooth,U_tps,U_tps3]=tps_uvmat(X,Y,U,rho) 343 357 %------------------------------------------------------------------------ 344 358 %rho smoothing parameter … … 378 392 EM = [IM_sites PM]; 379 393 U_smooth=EM *U_tps; 394 U_tps3=U_tps(end-2:end); 395 U_tps=U_tps(1:end-3); 380 396 381 397
Note: See TracChangeset
for help on using the changeset viewer.