Changeset 896 for trunk


Ignore:
Timestamp:
May 23, 2015, 5:09:49 PM (10 years ago)
Author:
sommeria
Message:

bug corrected in civ_series/patch

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/filter_tps.m

    r809 r896  
    11%'filter_tps': find the thin plate spline coefficients for interpolation-smoothing
    22%------------------------------------------------------------------------
    3 % [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
     3% [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomainSize,Rho,Threshold)
    44%
    55% OUTPUT:
     
    3737%=======================================================================
    3838
    39 function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
     39function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomainSize,Rho,Threshold)
    4040
    4141%% adjust subdomain decomposition
    4242warning off
    43 NbVec=size(Coord,1);
    44 NbCoord=size(Coord,2);
     43NbVec=size(Coord,1);% nbre of vectors in the field to interpolate
     44NbCoord=size(Coord,2);% space dimension
    4545MinCoord=min(Coord,[],1);%lower coordinate bounds
    4646MaxCoord=max(Coord,[],1);%upper coordinate bounds
    4747Range=MaxCoord-MinCoord;
    4848AspectRatio=Range(2)/Range(1);
    49 NbSubDomain=NbVec/SubDomain;
    50 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);
    51 NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);
    52 NbSubDomain=NbSubDomainX*NbSubDomainY;
     49NbSubDomain=NbVec/SubDomainSize;% estimated number of subdomains
     50NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);% estimated number of subdomains in x
     51NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y
     52NbSubDomain=NbSubDomainX*NbSubDomainY;% new estimated number of subdomains in a matrix shape partition in subdomains
    5353Siz(1)=Range(1)/NbSubDomainX;%width of subdomains
    5454Siz(2)=Range(2)/NbSubDomainY;%height of subdomains
    55 CentreX=linspace(MinCoord(1)+Siz(1)/2,MaxCoord(1)-Siz(1)/2,NbSubDomainX);
    56 CentreY=linspace(MinCoord(2)+Siz(2)/2,MaxCoord(2)-Siz(2)/2,NbSubDomainY);
     55CentreX=linspace(MinCoord(1)+Siz(1)/2,MaxCoord(1)-Siz(1)/2,NbSubDomainX);% X positions of subdomain centres
     56CentreY=linspace(MinCoord(2)+Siz(2)/2,MaxCoord(2)-Siz(2)/2,NbSubDomainY);% Y positions of subdomain centres
    5757[CentreX,CentreY]=meshgrid(CentreX,CentreY);
     58CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres
    5859CentreY=reshape(CentreY,1,[]);% Y positions of subdomain centres
    59 CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres
    6060
    6161%% smoothing parameter
     
    6363
    6464%% default output
    65 SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains
    66 NbCentre=zeros(1,NbSubDomain);%number of interpolated values per subdomain, =0 by default
     65SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the boundaries of subdomains
     66Coord_tps=zeros(1,NbCoord,NbSubDomain);% initialize coordinates of interpolated data
     67U_tps=zeros(1,NbSubDomain);% initialize  interpolated u component
     68V_tps=zeros(1,NbSubDomain);% initialize interpolated v component
     69NbCentre=zeros(1,NbSubDomain);%number of interpolated field values per subdomain, =0 by default
    6770W_tps=[];%default (2 component case)
    6871U_smooth=zeros(NbVec,1); % smoothed velocity U at the initial positions
     
    7376check_empty=zeros(1,NbSubDomain);
    7477
     78
    7579%% calculate tps coeff in each subdomain
    7680for isub=1:NbSubDomain
    77     SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)];
    78     SubRange(2,:,isub)=[CentreY(isub)-0.55*Siz(2) CentreY(isub)+0.55*Siz(2)];
     81    SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)];%bounds of subdomain #isub in x coordinate
     82    SubRange(2,:,isub)=[CentreY(isub)-0.55*Siz(2) CentreY(isub)+0.55*Siz(2)];%bounds of subdomain #isub in y coordinate
    7983    ind_sel_previous=[];
    80     ind_sel=0;
     84    ind_sel=0;%initialize set of vector indices in the subdomain
    8185    %increase iteratively the subdomain if it contains less than SubDomainNbVec/4 source vectors
    8286    while numel(ind_sel)>numel(ind_sel_previous)
    83         ind_sel_previous=ind_sel;
     87        ind_sel_previous=ind_sel;% record the set of selected vector indices for next iteration
    8488        ind_sel=find(Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub));
    85         % if no vector in the subdomain, skip the subdomain
     89        % if no vector in the subdomain  #isub, skip the subdomain
    8690        if isempty(ind_sel)
    8791            check_empty(isub)=1;
    88             U_tps(1,isub)=0;%define U_tps and V_tps by default
    89             V_tps(1,isub)=0;
    90             break
    91             % if too few selected vectors, increase the subrange for next iteration
    92         elseif numel(ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous);
     92            break %  go to next subdomain
     93        % if too few selected vectors, increase the subrange for next iteration
     94        elseif numel(ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous);
    9395            SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4;
    9496            SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4;
     97        % subdomain includes enough vectors, perform tps interpolation
    9598        else
    9699            [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),rho);
    97100            [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel,:),V(ind_sel),rho);
    98             UDiff=U_smooth_sub-U(ind_sel);
    99             VDiff=V_smooth_sub-V(ind_sel);
    100             NormDiff=UDiff.*UDiff+VDiff.*VDiff;
     101            UDiff=U_smooth_sub-U(ind_sel);% difference between interpolated U component and initial value
     102            VDiff=V_smooth_sub-V(ind_sel);% difference between interpolated V component and initial value
     103            NormDiff=UDiff.*UDiff+VDiff.*VDiff;% Square of difference norm
    101104            ind_ind_sel=1:numel(ind_sel);%default
    102105            if exist('Threshold','var')&&~isempty(Threshold)
     
    113116                V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub;
    114117                nb_select(ind_sel)=nb_select(ind_sel)+1;
    115                 display('good')
     118                display(['tps done in subdomain # ' num2str(isub)  ' among ' num2str(NbSubDomain)])
    116119                break
    117                 % if too few selected vectors, increase the subrange for next iteration
    118             elseif numel(ind_ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous);
     120            % if too few selected vectors, increase the subrange for next iteration
     121            elseif numel(ind_ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous);
    119122                SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4;
    120123                SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4;
    121                 % else interpolation-smoothing is done again with the selected vectors
     124            % else interpolation-smoothing is done again with the selected vectors
    122125            else
    123126                [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),U(ind_sel(ind_ind_sel)),rho);
     
    130133                V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub;
    131134                nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+1;
    132                 display('good2')
     135                display(['tps redone after elimination of erratic vectors in subdomain # ' num2str(isub) ' among ' num2str(NbSubDomain)])
    133136                break
    134137            end
     
    144147    U_tps(:,ind_empty)=[];
    145148    V_tps(:,ind_empty)=[];
     149    NbCentre(ind_empty)=[];
    146150end
    147151
  • trunk/src/proj_field.m

    r895 r896  
    12871287                    Dist=Distx.*Distx+Disty.*Disty;
    12881288                    for ivar=1:numel(VarVal)
    1289                         VarVal{ivar}(Dist>2*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data
     1289                        VarVal{ivar}(Dist>4*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data
    12901290                    end 
    12911291                   
     
    13361336                    Dist=Distx.*Distx+Disty.*Disty;
    13371337                    for ivar=1:numel(VarVal)
    1338                         VarVal{ivar}(Dist>2*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data
     1338                        VarVal{ivar}(Dist>4*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data
    13391339                    end 
    13401340                   
  • trunk/src/read_field.m

    r890 r896  
    167167        UName='';
    168168        VName='';
     169        if numel(Field.ListVarName)>NbCoord % if there are variables beyond coord (1 D plots)
    169170        for ilist=1:numel(ListVar)
    170171            Field.VarAttribute{ilist+NbCoord}.Role=Role{ilist};
     
    189190            end
    190191        end
     192
    191193        if ~isempty(NormName)% remove U and V if norm has been calculated and U and V are not needed as variables
    192194            ind_var_U=find(strcmp(UName,ListVar));%check previous listing of variable r.UName
     
    216218            Field.VarAttribute=[cell(1,numel(Field.ListDimName)) Field.VarAttribute]
    217219        end
     220                end
    218221    case 'video'
    219222        if strcmp(class(ParamIn),'VideoReader')
  • trunk/src/read_rdvision.m

    r809 r896  
    9191    data=m.Data;
    9292       %%%%%%%BRICOLAGE in case of unreadable .sqb file
    93 %     ind=[60 63:152];%indices of bin files
    94 %     lengthimage=w*h*bpp;% lengthof an image record on the binary file
     93%      ind=[144 149:646];%indices of bin files
     94%      lengthimage=w*h*bpp;% lengthof an image record on the binary file
    9595%     for ii=1:32*numel(ind)
    9696%         data(ii).offset=mod(ii-1,32)*2*lengthimage+lengthimage;%Dalsa_2
  • trunk/src/series.m

    r895 r896  
    15651565            answer=msgbox_uvmat('INPUT_Y-N','Number of cores =1: select the compiled version .sh for multi-core processing. Proceed with the .m version?');
    15661566            if ~strcmp(answer,'Yes')
    1567                 errormsg='Action launch interrupted';
     1567                errormsg='Action launch interrupted by user';
    15681568                return
    15691569            end
     
    15711571        else
    15721572            answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
     1573            if isempty(answer)
     1574                                errormsg='Action launch interrupted by user';
     1575                return
     1576            end
    15731577            NbCore=str2double(answer{1});
    15741578            extra_oar=answer{2};
  • trunk/src/series/civ_series.m

    r895 r896  
    328328    if ~isempty(RUNHandle)% update the waitbar in interactive mode with GUI series  (checkrun=1)
    329329        update_waitbar(WaitbarHandle,ifield/NbField)
    330         if  get(RUNHandle,'Value')&& ~strcmp(get(RUNHandle,'BusyAction'),'queue')
     330        if  ~strcmp(get(RUNHandle,'BusyAction'),'queue')
    331331            disp('program stopped by user')
    332332            break
     
    355355    % if Civ1 computation is requested
    356356    if isfield (Param.ActionInput,'Civ1')
     357        disp('civ1 started')
    357358        par_civ1=Param.ActionInput.Civ1;
    358359        if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B)
     
    496497    %% Fix1
    497498    if isfield (Param.ActionInput,'Fix1')
     499         disp('fix1 started')
    498500        if ~isfield (Param.ActionInput,'Civ1')% if we use existing Civ1, remove previous data beyond Civ1
    499501            Fix1_attr=find(strcmp('Fix1',Data.ListGlobalAttribute));
     
    519521    %% Patch1
    520522    if isfield (Param.ActionInput,'Patch1')
     523        disp('patch1 started')
    521524        if check_civx
    522525            errormsg='Civ Matlab input needed for patch';
     
    559562        Data.Civ1_V_smooth(ind_good)=Vres;
    560563        Data.Civ1_FF(ind_good)=FFres;
     564        disp('patch1 performed')
    561565    end
    562566   
    563567    %% Civ2
    564568    if isfield (Param.ActionInput,'Civ2')
     569        disp('civ2 started')
    565570        par_civ2=Param.ActionInput.Civ2;
    566571        if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B)
     
    751756        Data.Civ2_C=reshape(ctable,[],1);
    752757        Data.Civ2_F=reshape(F,[],1);
     758        disp('civ2 performed')
    753759    elseif ~isfield(Data,'ListVarName') % we start there, using existing Civ2 data
    754760        if exist('ncfile','var')
     
    773779    %% Fix2
    774780    if isfield (Param.ActionInput,'Fix2')
     781        disp('fix2 started')
    775782        list_param=fieldnames(Param.ActionInput.Fix2)';
    776783        Fix2_param=regexprep(list_param,'^.+','Fix2_$0');% insert 'Fix1_' before  each string in ListFixParam
     
    804811            Data.CivStage=Data.CivStage+1;
    805812        end
    806        
    807813    end
    808814   
    809815    %% Patch2
    810816    if isfield (Param.ActionInput,'Patch2')
     817        disp('patch2 started')
    811818        list_param=fieldnames(Param.ActionInput.Patch2)';
    812819        list_param(strcmp('TestPatch2',list_param))=[];% remove the parameter TestCiv1 from the list
     
    841848        Data.Civ2_FF(ind_good)=FFres;
    842849        Data.CivStage=Data.CivStage+1;
     850        disp('patch2 performed')
    843851    end
    844852   
Note: See TracChangeset for help on using the changeset viewer.