Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r325 r326 4396 4396 [Data,errormsg]=civ_matlab(Param);% get the grid of x, y positions set for PIV 4397 4397 if ~isempty(errormsg) 4398 msgbox_uvmat('ERROR', Data.Txt)4398 msgbox_uvmat('ERROR',errormsg) 4399 4399 return 4400 4400 end … … 4403 4403 Data.Civ1_V_Diff=Data.Civ1_V_Diff(Data.Civ1_FF==0); 4404 4404 DiffVel(irho)=sqrt(mean(Data.Civ1_U_Diff.*Data.Civ1_U_Diff+Data.Civ1_V_Diff.*Data.Civ1_V_Diff)) 4405 NbSites(irho)=Data.Civ1_NbSites/numel(Data.Civ1_U_Diff); 4405 4406 Param.Patch1.SmoothingParam=2*Param.Patch1.SmoothingParam; 4406 4407 end 4407 4408 figure 4408 plot(SmoothingParam,DiffVel )4409 plot(SmoothingParam,DiffVel,'b',SmoothingParam,NbSites,'r') 4409 4410 set(handles.TestPatch1,'BackgroundColor',[1 0 0]) 4410 4411 else -
trunk/src/civ_matlab.m
r321 r326 68 68 % if exist('ncfile','var')% TEST for use interactively with mouse_motion (no file created) 69 69 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record 70 Data.VarDimName={' nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};70 Data.VarDimName={'NbVec1','NbVec1','NbVec1','NbVec1','NbVec1','NbVec1'}; 71 71 Data.VarAttribute{1}.Role='coord_x'; 72 72 Data.VarAttribute{2}.Role='coord_y'; … … 124 124 else 125 125 Data.ListVarName=[Data.ListVarName {'Civ1_FF'}]; 126 Data.VarDimName=[Data.VarDimName {' nbvec1'}];126 Data.VarDimName=[Data.VarDimName {'NbVec1'}]; 127 127 nbvar=length(Data.ListVarName); 128 128 Data.VarAttribute{nbvar}.Role='errorflag'; … … 133 133 %% Patch1 134 134 if isfield (Param,'Patch1') 135 if check_civx 136 errormsg='Civ Matlab input needed for patch'; 137 return 138 end 135 139 check_patch1=1; 136 140 Param.Patch1 … … 233 237 Data.Civ1_Dt=str2double(par_civ1.Dt); 234 238 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record 235 Data.VarDimName={' nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};239 Data.VarDimName={'NbVec1','NbVec1','NbVec1','NbVec1','NbVec1','NbVec1'}; 236 240 Data.VarAttribute{1}.Role='coord_x'; 237 241 Data.VarAttribute{2}.Role='coord_y'; … … 596 600 if isfield(Param,FlagName{iflag}) && Param.(FlagName{iflag}) 597 601 FF=(FF==1| F==FlagVal(iflag)); 598 % if isfield (Param,'WarnFlags')599 % for iflag=1:numel(Param.WarnFlags)600 % FF=(FF==1| F==Param.WarnFlags(iflag));601 % end602 % end603 602 end 604 603 end … … 618 617 return 619 618 620 %621 % if isfield (Param,'LowerBoundVel')&& ~isequal(Param.LowerBoundVel,0)622 % thresh=Param.LowerBoundVel*Param.LowerBoundVel;623 % FF=FF==1 | (U.*U+V.*V)<thresh;624 % end625 % if isfield (Param,'UpperBoundVel')&& ~isequal(Param.UpperBoundVel,0)626 % thresh=Param.UpperBoundVel*Param.UpperBoundVel;627 % FF=FF==1 | (U.*U+V.*V)>thresh;628 % end629 % if isfield(Param,'MaskName')630 % M=imread(Param.MaskName);631 % nxy=size(M);632 % M=reshape(M,1,[]);633 % rangx0=[0.5 nxy(2)-0.5];634 % rangy0=[0.5 nxy(1)-0.5];635 % vec_x1=X-U/2;%beginning points636 % vec_x2=X+U/2;%end points of vectors637 % vec_y1=Y-V/2;%beginning points638 % vec_y2=Y+V/2;%end points of vectors639 % indx=1+round((nxy(2)-1)*(vec_x1-rangx0(1))/(rangx0(2)-rangx0(1)));% image index x at abcissa vec_x1640 % indy=1+round((nxy(1)-1)*(vec_y1-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y1641 % check_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside642 % indx=indx.*check_in+(1-check_in); %replace indx by 1 out of the mask range643 % indy=indy.*check_in+(1-check_in); %replace indy by 1 out of the mask range644 % ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector645 % Mvalues=M(ICOMB);646 % flag7b=((20 < Mvalues) & (Mvalues < 200))| ~check_in';647 % indx=1+round((nxy(2)-1)*(vec_x2-rangx0(1))/(rangx0(2)-rangx0(1)));% image index x at abcissa vec_x2648 % indy=1+round((nxy(1)-1)*(vec_y2-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y2649 % check_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside650 % indx=indx.*check_in+(1-check_in); %replace indx by 1 out of the mask range651 % indy=indy.*check_in+(1-check_in); %replace indy by 1 out of the mask range652 % ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector653 % Mvalues=M(ICOMB);654 % flag7e=((Mvalues > 20) & (Mvalues < 200))| ~check_in';655 % FF=FF==1 |(flag7b|flag7e)';656 % end657 % % flag7=0;658 % % end659 %660 619 661 620 FF=double(FF); 662 %663 % % criterium on velocity values664 % delta_u=Field.U;%default without ref file665 % delta_v=Field.V;666 % if exist('fileref','var') && ~isempty(fileref)667 % if ~exist(fileref,'file')668 % error='reference file not found in RUN_FIX.m';669 % display(error);670 % return671 % end672 % FieldRef=read_civxdata(fileref,[],fieldref);673 % if isfield(FieldRef,'FF')674 % index_true=find(FieldRef.FF==0);675 % FieldRef.X=FieldRef.X(index_true);676 % FieldRef.Y=FieldRef.Y(index_true);677 % FieldRef.U=FieldRef.U(index_true);678 % FieldRef.V=FieldRef.V(index_true);679 % end680 % if ~isfield(FieldRef,'X') || ~isfield(FieldRef,'Y') || ~isfield(FieldRef,'U') || ~isfield(FieldRef,'V')681 % error='reference file is not a velocity field in RUN_FIX.m '; %bad input file682 % return683 % end684 % if length(FieldRef.X)<=1685 % errordlg('reference field with one vector or less in RUN_FIX.m')686 % return687 % end688 % vec_U_ref=griddata_uvmat(FieldRef.X,FieldRef.Y,FieldRef.U,Field.X,Field.Y); %interpolate vectors in the ref field689 % 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 field690 % delta_u=Field.U-vec_U_ref;%take the difference with the interpolated ref field691 % delta_v=Field.V-vec_V_ref;692 % end693 % thresh_vel_x=thresh_vel;694 % thresh_vel_y=thresh_vel;695 % if isequal(inf_sup,1)696 % flag5=abs(delta_u)<thresh_vel_x & abs(delta_v)<thresh_vel_y &(flag1~=1)&(flag2~=1)&(flag3~=1)&(flag4~=1);697 % elseif isequal(inf_sup,2)698 % flag5=(abs(delta_u)>thresh_vel_x | abs(delta_v)>thresh_vel_y) &(flag1~=1)&(flag2~=1)&(flag3~=1)&(flag4~=1);699 % end700 %701 % % flag7 introduce a grey mask, matrix M702 703 % flagmagenta=flag1|flag2|flag3|flag4|flag5|flag7;704 % fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag705 621 706 622 … … 708 624 %------------------------------------------------------------------------ 709 625 % patch function 626 % OUTPUT: 627 % SubRangx,SubRangy(NbSubdomain,2): range (min, max) of the coordiantes x and y respectively, for each subdomain 628 % nbpoints(NbSubdomain): number of source points for each subdomain 629 % FF: false flags 630 % U_smooth, V_smooth: filtered velocity components at the positions of the initial data 631 % X_tps,Y_tps,U_tps,V_tps: positions and weight of the tps for each subdomain 632 % 633 % INPUT: 634 % X, Y: set of coordinates of the initial data 635 % U,V: set of velocity components of the initial data 636 % Rho: smoothing parameter 637 % Threshold: max diff accepted between smoothed and initial data 638 % Subdomain: estimated number of data points in each subdomain 639 710 640 function [SubRangx,SubRangy,nbpoints,FF,U_smooth,V_smooth,X_tps,Y_tps,U_tps,V_tps] =patch(X,Y,U,V,Rho,Threshold,SubDomain) 711 641 %subdomain decomposition … … 744 674 check_empty=zeros(1,NbSubDomain); 745 675 for isub=1:NbSubDomain 746 SubRangx(isub,:)=[CentreX(isub)- SizX/2 CentreX(isub)+SizX/2];747 SubRangy(isub,:)=[CentreY(isub)- SizY/2 CentreY(isub)+SizY/2];676 SubRangx(isub,:)=[CentreX(isub)-0.55*SizX CentreX(isub)+0.55*SizX]; 677 SubRangy(isub,:)=[CentreY(isub)-0.55*SizY CentreY(isub)+0.55*SizY]; 748 678 ind_sel_previous=[]; 749 679 ind_sel=0; 750 680 while numel(ind_sel)>numel(ind_sel_previous) %increase the subdomain during four iterations at most 751 681 ind_sel_previous=ind_sel; 752 ind_sel=find(X> SubRangx(isub,1) & X<SubRangx(isub,2) & Y>SubRangy(isub,1) & Y<SubRangy(isub,2));682 ind_sel=find(X>=SubRangx(isub,1) & X<=SubRangx(isub,2) & Y>=SubRangy(isub,1) & Y<=SubRangy(isub,2)); 753 683 % if no vector in the subdomain, skip the subdomain 754 684 if isempty(ind_sel) -
trunk/src/uvmat.m
r323 r326 1778 1778 %% read the current input file name(s) and field indices 1779 1779 InputFile=read_GUI(handles.InputFile); 1780 filebase=InputFile.RootPath; %default 1781 if ~isempty(InputFile.SubDir) 1782 InputFile.SubDir=regexprep(InputFile.SubDir,'/|\',''); 1783 % FileName=fullfile(InputFile.RootPath,InputFile.SubDir); 1784 end 1785 if ~isempty(InputFile.RootFile) 1786 InputFile.RootFile=regexprep(InputFile.RootFile,'/|\',''); 1787 filebase=fullfile(filebase,InputFile.RootFile); 1780 InputFile.RootFile=regexprep(InputFile.RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string 1781 InputFile.SubDir=regexprep(InputFile.SubDir,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string 1782 if isempty(InputFile.RootFile) 1783 filebase=InputFile.RootPath; 1784 else 1785 filebase=fullfile(InputFile.RootPath,InputFile.RootFile); 1788 1786 end 1789 1787 FileExt=InputFile.FileExt; 1790 subdir=InputFile.SubDir;1791 1788 % [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles); 1792 1789 NomType=get(handles.NomType,'String'); … … 1815 1812 i1=i1+increment; 1816 1813 i2=i2+increment; 1817 [filename,i1,j1,i2,j2]=name_generator(filebase,i1,j1,FileExt,NomType,comp_input,i2,j2, subdir);1814 [filename,i1,j1,i2,j2]=name_generator(filebase,i1,j1,FileExt,NomType,comp_input,i2,j2,InputFile.SubDir); 1818 1815 if sub_value% set the second field name and indices 1819 1816 i1_1=i1_1+increment; … … 1824 1821 j1=j1+increment; 1825 1822 j2=j2+increment; 1826 [filename,i1,j1,i2,j2]=name_generator(filebase,i1,j1,FileExt,NomType,comp_input,i2,j2, subdir);1823 [filename,i1,j1,i2,j2]=name_generator(filebase,i1,j1,FileExt,NomType,comp_input,i2,j2,InputFile.SubDir); 1827 1824 if sub_value 1828 1825 j1_1=j1_1+increment; … … 3095 3092 SubDir_1=get(handles.SubDir,'String'); 3096 3093 end 3097 if numel(SubDir_1)>=13098 if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))3099 SubDir_1(1)=[]; %suppress possible / or \ separator3100 end3101 FileName_1=fullfile(RootPath_1,SubDir_1);3102 end3103 3094 RootFile_1=get(handles.RootFile_1,'String'); 3095 SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string 3096 FileName_1=fullfile(RootPath_1,SubDir_1); 3104 3097 if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') 3105 3098 RootFile_1=get(handles.RootFile,'String'); 3106 3099 end 3100 RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string 3107 3101 if numel(RootFile_1)>=1 3108 if ~(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))3109 RootFile_1(1)=[];%suppress possible / or \ separator3110 end3111 3102 FileName_1=fullfile(FileName_1,RootFile_1); 3112 3103 end … … 3280 3271 % transform netc type to the corresponding image type 3281 3272 if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')|| isequal(NomType_1,'#_ab')|| isequal(NomType_1,'_i1-i2') 3282 UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory3273 UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the InputFile.SubDir in memory 3283 3274 if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2') 3284 3275 NomTypeNew='_i_j'; … … 3642 3633 RootPath=get(handles.RootPath,'String'); 3643 3634 RootFile=get(handles.RootFile,'String'); 3644 if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) 3645 RootFile(1)=[]; 3646 end 3635 RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string 3647 3636 filebase=fullfile(RootPath,RootFile); 3648 3637 list=get(handles.masklevel,'String'); … … 3657 3646 3658 3647 %display the mask 3659 %update_mask(handles,num_i1,num_j1)3660 3648 figure; 3661 3649 vec=linspace(0,1,256);%define a linear greyscale colormap … … 3671 3659 %------------------------------------------------------------------ 3672 3660 3673 3674 3675 3661 %------------------------------------------------------------------ 3676 3662 % --- Executes on selection change in ListColorScalar: choice of the color code. 3677 %3678 3663 function ListColorScalar_Callback(hObject, eventdata, handles) 3679 3664 %------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.