Changeset 1137 for trunk/src


Ignore:
Timestamp:
Apr 24, 2024, 7:45:09 PM (10 days ago)
Author:
sommeria
Message:

tps improved by a cosine window in each subdomain. Default size of subdomains reduced for faster computation in the civ interface

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field_tps.m

    r1127 r1137  
    108108
    109109%% loop on subdomains
     110NbSubDomain
    110111for isub=1:NbSubDomain
    111112    nbvec_sub=NbCentre(isub);
    112113    check_range=(Coord_interp >=ones(nb_sites,1)*SubRange(:,1,isub)' & Coord_interp<=ones(nb_sites,1)*SubRange(:,2,isub)');
    113     ind_sel=find(sum(check_range,2)==nb_coord);% select points whose all coordinates are in the prescribed range
    114     nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap)
     114    ind_sel=find(sum(check_range,2)==nb_coord);% select points whose all coordinates are in the prescribed range   
     115    x_width=(SubRange(1,2,isub)-SubRange(1,1,isub))/pi;%width of the subdomain/pi
     116    y_width=(SubRange(2,2,isub)-SubRange(2,1,isub))/pi;%width of the subdomain/pi
     117    CentreX=(SubRange(1,2,isub)+SubRange(1,1,isub))/2;%centre of the subdomain
     118    CentreY=(SubRange(2,2,isub)+SubRange(2,1,isub))/2;
     119    x_dist=(Coord_interp(ind_sel,1)-CentreX)/x_width;% relative x distance to the retangle centre*pi/2
     120    y_dist=(Coord_interp(ind_sel,2)-CentreY)/y_width;% relative ydistance to the retangle centre
     121    weight=cos(x_dist).*cos(y_dist);%weighting fct =1 at the rectangle center and 0 at edge
     122    nbval(ind_sel)=nbval(ind_sel)+weight;% records the number of values for eacn interpolation point (in case of subdomain overlap)
    115123    if check_grid
    116124        EM = tps_eval(Coord_interp(ind_sel,:),Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the velocity from tps 'sources'
     
    122130        switch FieldName{ilist}
    123131            case 'vec(U,V)'
    124                 DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,1);
    125                 DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,2);
     132                DataOut.U(ind_sel)=DataOut.U(ind_sel)+weight.*EM *FieldVar(1:nbvec_sub+3,isub,1);
     133                DataOut.V(ind_sel)=DataOut.V(ind_sel)+weight.*EM *FieldVar(1:nbvec_sub+3,isub,2);
    126134            case 'U'
    127                 DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,1);
     135                DataOut.U(ind_sel)=DataOut.U(ind_sel)+weight.*EM *FieldVar(1:nbvec_sub+3,isub,1);
    128136            case 'V'
    129                 DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,2);
     137                DataOut.V(ind_sel)=DataOut.V(ind_sel)+weight.*EM *FieldVar(1:nbvec_sub+3,isub,2);
    130138            case 'norm(U,V)'
    131                 U=DataOut.U(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,1);
    132                 V=DataOut.V(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,2);
     139                U=DataOut.U(ind_sel)+weight.*EM *FieldVar(1:nbvec_sub+3,isub,1);
     140                V=DataOut.V(ind_sel)+weight.*EM *FieldVar(1:nbvec_sub+3,isub,2);
    133141                DataOut.norm(ind_sel)=sqrt(U.*U+V.*V);
    134142            case 'curl(U,V)'
    135                 DataOut.curl(ind_sel)=DataOut.curl(ind_sel)-EMDY *FieldVar(1:nbvec_sub+3,isub,1)+EMDX *FieldVar(1:nbvec_sub+3,isub,2);
     143                DataOut.curl(ind_sel)=DataOut.curl(ind_sel)-weight.*EMDY *FieldVar(1:nbvec_sub+3,isub,1)+weight.*EMDX *FieldVar(1:nbvec_sub+3,isub,2);
    136144            case 'div(U,V)'
    137                 DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*FieldVar(1:nbvec_sub+3,isub,1)+EMDY *FieldVar(1:nbvec_sub+3,isub,2);
     145                DataOut.div(ind_sel)=DataOut.div(ind_sel)+weight.*EMDX*FieldVar(1:nbvec_sub+3,isub,1)+EMDY *FieldVar(1:nbvec_sub+3,isub,2);
    138146            case 'strain(U,V)'
    139                 DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*FieldVar(1:nbvec_sub+3,isub,1)+EMDX *FieldVar(1:nbvec_sub+3,isub,2);
     147                DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+weight.*EMDY*FieldVar(1:nbvec_sub+3,isub,1)+EMDX *FieldVar(1:nbvec_sub+3,isub,2);
    140148            case 'DUDX(U,V)'
    141                 DataOut.DUDX(ind_sel)=DataOut.DUDX(ind_sel)+EMDX *FieldVar(1:nbvec_sub+3,isub,1);
     149                DataOut.DUDX(ind_sel)=DataOut.DUDX(ind_sel)+weight.*EMDX *FieldVar(1:nbvec_sub+3,isub,1);
    142150            case 'DUDY(U,V)'
    143                 DataOut.DUDY(ind_sel)=DataOut.DUDY(ind_sel)+EMDY*FieldVar(1:nbvec_sub+3,isub,1);
     151                DataOut.DUDY(ind_sel)=DataOut.DUDY(ind_sel)+weight.*EMDY*FieldVar(1:nbvec_sub+3,isub,1);
    144152            case 'DVDX(U,V)'
    145                 DataOut.DVDX(ind_sel)=DataOut.DVDX(ind_sel)+EMDX*FieldVar(1:nbvec_sub+3,isub,2);
     153                DataOut.DVDX(ind_sel)=DataOut.DVDX(ind_sel)+weight.*EMDX*FieldVar(1:nbvec_sub+3,isub,2);
    146154            case 'DVDY(U,V)'
    147                 DataOut.DVDY(ind_sel)=DataOut.DVDY(ind_sel)+EMDY *FieldVar(1:nbvec_sub+3,isub,2);
     155                DataOut.DVDY(ind_sel)=DataOut.DVDY(ind_sel)+weight.*EMDY *FieldVar(1:nbvec_sub+3,isub,2);
    148156        end
    149157    end
  • trunk/src/filter_tps.m

    r1135 r1137  
    9595            break %  go to next subdomain
    9696        % if too few selected vectors, increase the subrange for next iteration
    97         elseif numel(ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous);
     97        elseif numel(ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous)
    9898            SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4;
    9999            SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4;
     
    112112            % if no value exceeds threshold, the result is recorded
    113113            if isequal(numel(ind_ind_sel),numel(ind_sel))
    114                 U_smooth(ind_sel)=U_smooth(ind_sel)+U_smooth_sub;
    115                 V_smooth(ind_sel)=V_smooth(ind_sel)+V_smooth_sub;
     114                x_width=(SubRange(1,2,isub)-SubRange(1,1,isub))/pi;
     115                y_width=(SubRange(2,2,isub)-SubRange(2,1,isub))/pi;
     116                x_dist=(Coord(ind_sel,1)-CentreX(isub))/x_width;% relative x distance to the retangle centre
     117                y_dist=(Coord(ind_sel,2)-CentreY(isub))/y_width;% relative ydistance to the retangle centre
     118                weight=cos(x_dist).*cos(y_dist);%weighting fct =1 at the rectangle center and 0 at edge
     119                U_smooth(ind_sel)=U_smooth(ind_sel)+weight.*U_smooth_sub;
     120                V_smooth(ind_sel)=V_smooth(ind_sel)+weight.*V_smooth_sub;
    116121                NbCentre(isub)=numel(ind_sel);
    117122                Coord_tps(1:NbCentre(isub),:,isub)=Coord(ind_sel,:);
    118123                U_tps(1:NbCentre(isub)+3,isub)=U_tps_sub;
    119124                V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub;
    120                 nb_select(ind_sel)=nb_select(ind_sel)+1;
     125                nb_select(ind_sel)=nb_select(ind_sel)+weight;
    121126                display(['tps done in subdomain # ' num2str(isub)  ' among ' num2str(NbSubDomain)])
    122127                break
    123128            % if too few selected vectors, increase the subrange for next iteration
    124             elseif numel(ind_ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous);
     129            elseif numel(ind_ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous)
    125130                SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4;
    126131                SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4;
     
    129134                [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),U(ind_sel(ind_ind_sel)),rho);
    130135                [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),V(ind_sel(ind_ind_sel)),rho);
    131                 U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+U_smooth_sub;
    132                 V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;
     136                x_width=(SubRange(1,2,isub)-SubRange(1,1,isub))/pi;
     137                y_width=(SubRange(2,2,isub)-SubRange(2,1,isub))/pi;
     138                x_dist=(Coord(ind_sel(ind_ind_sel),1)-CentreX(isub))/x_width;% relative x distance to the retangle centre
     139                y_dist=(Coord(ind_sel(ind_ind_sel),2)-CentreY(isub))/y_width;% relative ydistance to the retangle centre
     140                weight=cos(x_dist).*cos(y_dist);%weighting fct =1 at the rectangle center and 0 at edge
     141                U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+weight.*U_smooth_sub;
     142                V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+weight.*V_smooth_sub;
    133143                NbCentre(isub)=numel(ind_ind_sel);
    134144                Coord_tps(1:NbCentre(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:);
    135145                U_tps(1:NbCentre(isub)+3,isub)=U_tps_sub;
    136146                V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub;
    137                 nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+1;
     147                nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+weight;
    138148                display(['tps redone after elimination of erratic vectors in subdomain # ' num2str(isub) ' among ' num2str(NbSubDomain)])
    139149                break
  • trunk/src/read_field.m

    r1134 r1137  
    203203                        find(strcmp(ParamIn.Coord_x,VarDimName{ilist}))];
    204204                end
    205                 if ~isempty(DimOrder)
     205                if numel(DimOrder)>=ndims(Field.(ListVarName{ilist}))
    206206                    Field.(ListVarName{ilist})=permute(Field.(ListVarName{ilist}),DimOrder);
    207207                    VarDimName{ilist}=VarDimName{ilist}(DimOrder);
  • trunk/src/series/civ_input.m

    r1127 r1137  
    8181    set(handles.CheckThreshold,'Visible','on')
    8282    set(handles.CheckDeformation,'Value',0)% desactivate
     83    set(handles.num_SubDomainSize(1),'String','250')
     84    set(handles.num_SubDomainSize(2),'String','500')
    8385end
    8486switch Param.Action.ActionName
  • trunk/src/series/civ_series.m

    r1131 r1137  
    924924        time_total=toc(tstart);
    925925        disp(['ellapsed time ' num2str(time_total/60,2) ' minutes'])
    926         disp(['time image reading ' num2str(time_input/60,2) ' minutes'])
    927         disp(['time civ1 ' num2str(time_civ1/60,2) ' minutes'])
    928         disp(['time patch1 ' num2str(time_patch1/60,2) ' minutes'])
    929         disp(['time civ2 ' num2str(time_civ2/60,2) ' minutes'])
    930         disp(['time patch2 ' num2str(time_patch2/60,2) ' minutes'])
    931         disp(['time other ' num2str((time_total-time_input-time_civ1-time_patch1-time_civ2-time_patch2)/60,2) ' minutes'])
     926        disp(['time image reading ' num2str(time_input,2) ' s'])
     927        disp(['time civ1 ' num2str(time_civ1,2) ' s'])
     928        disp(['time patch1 ' num2str(time_patch1,2) ' s'])
     929        disp(['time civ2 ' num2str(time_civ2,2) ' s'])
     930        disp(['time patch2 ' num2str(time_patch2,2) ' s'])
     931        disp(['time other ' num2str((time_total-time_input-time_civ1-time_patch1-time_civ2-time_patch2),2) ' s'])
    932932    end
    933933end
  • trunk/src/series/merge_proj.m

    r1135 r1137  
    6868    ParamOut.FieldTransform = 'on';%can use a transform function
    6969    %%%%% list of possible transform functions (needed only for compilation)
    70 %         ListTransform={'phys','phys_polar','sub_field'};%list of possible transform functions (needed only for compilation)
    71         % if 0==1 %never satisfied but trigger compilation with the appropriate transform functions
    72         %     phys
    73         %     phys_polar
    74         %     sub_field
    75         try
    76             for ilist=1:numel(ListTransform)
    77                 eval(ListTransform{ilist})
    78             end
    79         end
     70    if 0==1 %never satisfied but trigger compilation with the appropriate transform functions ('eval' inactive for compilation)
     71        phys
     72        phys_polar
     73        sub_field
     74    end
    8075
    8176    ParamOut.TransformPath=fullfile(fileparts(which('uvmat')),'transform_field');% path to transform functions
     
    192187    currentdir=pwd;
    193188    cd(Param.FieldTransform.TransformPath)
     189    if strcmp(Param.FieldTransform.TransformName,'sub_field')
     190        checksub=2;% the two into field series will be subtracted
     191    end
    194192    transform_fct=str2func(Param.FieldTransform.TransformName);
    195193    cd (currentdir)
     
    199197        end
    200198    end
    201     checksub=nargin(transform_fct);% number of input arguments for the selected transform fct
    202199    if checksub>2 && NbView>2
    203200        disp_uvmat('WARNING',['only the two first input file series will be combined by ' Param.FieldTransform.TransformName],checkrun)
     
    321318       
    322319        %% transform the input field iview (e.g; phys) if requested (no transform involving two input fields at this stage)
    323         checksub=0;
    324         if ~isempty(transform_fct)
     320        if ~isempty(transform_fct)&& checksub==0
    325321            checksub=nargin(transform_fct);
    326             if checksub>=2
     322            if nargin(transform_fct)>=2
    327323                Data{iview}=transform_fct(Data{iview},XmlData{iview});
    328             elseif checksub==1
     324            else
    329325                Data{iview}=transform_fct(Data{iview});
    330326            end
     
    356352
    357353    %% merge the NbView fields
    358 %     if checksub<=2
     354    if checksub==0
    359355        [MergeData,errormsg]=merge_field(Data);%concatene all the input field series by fct merge_data
    360 %     elseif checksub==3
    361 %         MergeData=transform_fct(Data{1},XmlData{1},Data{2}); %combine the two input file series
    362 %    else
    363 %         MergeData=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});%combine the two input file series with calibration parameters
    364 %     end
     356    else
     357        MergeData=transform_fct(Data{1},XmlData{1},Data{2}); %combine the two input file series
     358    % else
     359    %     MergeData=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});%combine the two input file series with calibration parameters
     360    end
    365361    if ~isempty(errormsg)
    366362        disp_uvmat('ERROR',errormsg,checkrun);
  • trunk/src/tps_coeff_field.m

    r1127 r1137  
    4343Smoothing=0;
    4444end
    45 SubDomainNbPoint=1000; %default, estimated nbre of data source points in a subdomain used for tps
     45SubDomainNbPoint=300; %default, estimated nbre of data source points in a subdomain used for tps
    4646if isfield(DataIn,'SubDomain')
    4747    SubDomainNbPoint=DataIn.SubDomain;%old convention
  • trunk/src/uvmat.m

    r1129 r1137  
    36403640        end
    36413641        % case of input vector field, get the scalar used for vector color
    3642         if ~isempty(regexp(FieldName,'^vec('))
     3642        if ~isempty(regexp(FieldName,'^vec(','once'))
    36433643            list_code=get(handles.ColorCode,'String');% list menu fields
    36443644            index_code=get(handles.ColorCode,'Value');% selected string index
Note: See TracChangeset for help on using the changeset viewer.