Changeset 326


Ignore:
Timestamp:
Dec 8, 2011, 8:28:38 AM (9 years ago)
Author:
sommeria
Message:

bug corrected in patch matlab. regexrep introduced in uvmat

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r325 r326  
    43964396        [Data,errormsg]=civ_matlab(Param);% get the grid of x, y positions set for PIV
    43974397        if ~isempty(errormsg)
    4398             msgbox_uvmat('ERROR',Data.Txt)
     4398            msgbox_uvmat('ERROR',errormsg)
    43994399            return
    44004400        end
     
    44034403        Data.Civ1_V_Diff=Data.Civ1_V_Diff(Data.Civ1_FF==0);
    44044404        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);
    44054406        Param.Patch1.SmoothingParam=2*Param.Patch1.SmoothingParam;
    44064407    end
    44074408    figure
    4408     plot(SmoothingParam,DiffVel)
     4409    plot(SmoothingParam,DiffVel,'b',SmoothingParam,NbSites,'r')
    44094410    set(handles.TestPatch1,'BackgroundColor',[1 0 0])
    44104411else
  • trunk/src/civ_matlab.m

    r321 r326  
    6868    %     if exist('ncfile','var')% TEST for use interactively with mouse_motion (no file created)
    6969    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'};
    7171    Data.VarAttribute{1}.Role='coord_x';
    7272    Data.VarAttribute{2}.Role='coord_y';
     
    124124    else
    125125        Data.ListVarName=[Data.ListVarName {'Civ1_FF'}];
    126         Data.VarDimName=[Data.VarDimName {'nbvec1'}];
     126        Data.VarDimName=[Data.VarDimName {'NbVec1'}];
    127127        nbvar=length(Data.ListVarName);
    128128        Data.VarAttribute{nbvar}.Role='errorflag';   
     
    133133%% Patch1
    134134if isfield (Param,'Patch1')
     135    if check_civx
     136        errormsg='Civ Matlab input needed for patch';
     137        return
     138    end
    135139    check_patch1=1;
    136140    Param.Patch1
     
    233237    Data.Civ1_Dt=str2double(par_civ1.Dt);
    234238    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'};
    236240    Data.VarAttribute{1}.Role='coord_x';
    237241    Data.VarAttribute{2}.Role='coord_y';
     
    596600    if isfield(Param,FlagName{iflag}) && Param.(FlagName{iflag})
    597601        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 %     end
    602 % end
    603602    end
    604603end
     
    618617return
    619618
    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 % end
    625 % if isfield (Param,'UpperBoundVel')&& ~isequal(Param.UpperBoundVel,0)
    626 %     thresh=Param.UpperBoundVel*Param.UpperBoundVel;
    627 %     FF=FF==1 | (U.*U+V.*V)>thresh;
    628 % end
    629 % 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 points
    636 %    vec_x2=X+U/2;%end points of vectors
    637 %    vec_y1=Y-V/2;%beginning points
    638 %    vec_y2=Y+V/2;%end points of vectors
    639 %    indx=1+round((nxy(2)-1)*(vec_x1-rangx0(1))/(rangx0(2)-rangx0(1)));% image index x at abcissa vec_x1
    640 %    indy=1+round((nxy(1)-1)*(vec_y1-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y1   
    641 %    check_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside
    642 %    indx=indx.*check_in+(1-check_in); %replace indx by 1 out of the mask range
    643 %    indy=indy.*check_in+(1-check_in); %replace indy by 1 out of the mask range
    644 %    ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector
    645 %    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_x2
    648 %    indy=1+round((nxy(1)-1)*(vec_y2-rangy0(1))/(rangy0(2)-rangy0(1)));% image index y at ordinate vec_y2
    649 %    check_in=~(indx < 1 |indy < 1 | indx > nxy(2) |indy > nxy(1)); %=0 out of the mask image, 1 inside
    650 %    indx=indx.*check_in+(1-check_in); %replace indx by 1 out of the mask range
    651 %    indy=indy.*check_in+(1-check_in); %replace indy by 1 out of the mask range
    652 %    ICOMB=((indx-1)*nxy(1)+(nxy(1)+1-indy));%determine the indices in the image reshaped in a Matlab vector
    653 %    Mvalues=M(ICOMB);
    654 %    flag7e=((Mvalues > 20) & (Mvalues < 200))| ~check_in';
    655 %    FF=FF==1 |(flag7b|flag7e)';
    656 % end
    657 % %    flag7=0;
    658 % % end   
    659 %
    660619
    661620FF=double(FF);
    662 %
    663 % % criterium on velocity values
    664 % delta_u=Field.U;%default without ref file
    665 % 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 %         return
    671 %     end
    672 %     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 %     end
    680 %     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 file
    682 %         return
    683 %     end
    684 %     if length(FieldRef.X)<=1
    685 %         errordlg('reference field with one vector or less in RUN_FIX.m')
    686 %         return
    687 %     end
    688 %     vec_U_ref=griddata_uvmat(FieldRef.X,FieldRef.Y,FieldRef.U,Field.X,Field.Y);  %interpolate vectors in the ref field
    689 %     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     
    690 %     delta_u=Field.U-vec_U_ref;%take the difference with the interpolated ref field
    691 %     delta_v=Field.V-vec_V_ref;
    692 % end
    693 % 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 % end
    700 %
    701 %             % flag7 introduce a grey mask, matrix M
    702 
    703 % flagmagenta=flag1|flag2|flag3|flag4|flag5|flag7;
    704 % fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag
    705621
    706622
     
    708624%------------------------------------------------------------------------
    709625% 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
    710640function [SubRangx,SubRangy,nbpoints,FF,U_smooth,V_smooth,X_tps,Y_tps,U_tps,V_tps] =patch(X,Y,U,V,Rho,Threshold,SubDomain)
    711641%subdomain decomposition
     
    744674check_empty=zeros(1,NbSubDomain);
    745675for 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];
    748678    ind_sel_previous=[];
    749679    ind_sel=0;
    750680    while numel(ind_sel)>numel(ind_sel_previous) %increase the subdomain during four iterations at most
    751681        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));
    753683        % if no vector in the subdomain, skip the subdomain
    754684        if isempty(ind_sel)
  • trunk/src/uvmat.m

    r323 r326  
    17781778%% read the current input file name(s) and field indices
    17791779InputFile=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);
     1780InputFile.RootFile=regexprep(InputFile.RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
     1781InputFile.SubDir=regexprep(InputFile.SubDir,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
     1782if isempty(InputFile.RootFile)
     1783    filebase=InputFile.RootPath;
     1784else
     1785    filebase=fullfile(InputFile.RootPath,InputFile.RootFile);
    17881786end
    17891787FileExt=InputFile.FileExt;
    1790 subdir=InputFile.SubDir;
    17911788% [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
    17921789NomType=get(handles.NomType,'String');
     
    18151812     i1=i1+increment;
    18161813     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);
    18181815     if sub_value% set the second field name and indices
    18191816        i1_1=i1_1+increment;
     
    18241821    j1=j1+increment;
    18251822    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);
    18271824    if sub_value
    18281825        j1_1=j1_1+increment;
     
    30953092    SubDir_1=get(handles.SubDir,'String');
    30963093end
    3097 if numel(SubDir_1)>=1
    3098     if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
    3099         SubDir_1(1)=[]; %suppress possible / or \ separator
    3100     end
    3101     FileName_1=fullfile(RootPath_1,SubDir_1);
    3102 end
    31033094RootFile_1=get(handles.RootFile_1,'String');
     3095SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
     3096FileName_1=fullfile(RootPath_1,SubDir_1);
    31043097if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
    31053098    RootFile_1=get(handles.RootFile,'String');
    31063099end
     3100RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
    31073101if numel(RootFile_1)>=1
    3108     if ~(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
    3109         RootFile_1(1)=[];%suppress possible / or \ separator
    3110     end
    31113102    FileName_1=fullfile(FileName_1,RootFile_1);
    31123103end
     
    32803271    % transform netc type to the corresponding image type
    32813272    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 memory   
     3273        UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the InputFile.SubDir in memory   
    32833274        if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')
    32843275            NomTypeNew='_i_j';
     
    36423633RootPath=get(handles.RootPath,'String');
    36433634RootFile=get(handles.RootFile,'String');
    3644 if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
    3645         RootFile(1)=[];
    3646 end
     3635RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
    36473636filebase=fullfile(RootPath,RootFile);
    36483637list=get(handles.masklevel,'String');
     
    36573646
    36583647%display the mask
    3659 %update_mask(handles,num_i1,num_j1)
    36603648figure;
    36613649vec=linspace(0,1,256);%define a linear greyscale colormap
     
    36713659%------------------------------------------------------------------
    36723660
    3673 
    3674 
    36753661%------------------------------------------------------------------
    36763662% --- Executes on selection change in ListColorScalar: choice of the color code.
    3677 %
    36783663function ListColorScalar_Callback(hObject, eventdata, handles)
    36793664%------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.