Changeset 1142 for trunk


Ignore:
Timestamp:
May 5, 2024, 12:29:30 PM (8 months ago)
Author:
sommeria
Message:

filter parameter improved in filter_tps

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/filter_tps.m

    r1141 r1142  
    66% SubRange(NbCoord,2,NbSubdomain): range (min, max) of the coordinates x and y respectively, for each subdomain
    77% NbCentre(NbSubdomain): number of source points for each subdomain
    8 % FF: false flags
     8% FF: false flags preserved from the input, or equal to 20 for vectors excluded by the difference with the smoothed field
    99% U_smooth, V_smooth: filtered velocity components at the positions of the initial data
    1010% Coord_tps(NbCentre,NbCoord,NbSubdomain): positions of the tps centres
    11 % U_tps,V_tps: weight of the tps for each subdomain
     11% U_tps,V_tps: weight of the tps centers for each subdomain
    1212% to get the interpolated field values, use the function calc_field.m
    1313%
     
    6262%% smoothing parameter: CHANGED 03 May 2024 TO GET RESULTS INDEPENDENT OF SUBDOMAINSIZE
    6363%smoothing=Siz(1)*Siz(2)*FieldSmooth/1000%optimum smoothing increase as the area of the subdomain (division by 1000 to reach good values with the default GUI input)
    64 smoothing=sqrt(Siz(1)*Siz(2)/SubDomainSize)*FieldSmooth;%optimum smoothing increase as the typical mesh size =sqrt(SizX*SizY/SubDomainSize)^1/2
     64NbVecSub=NbVec/NbSubDomain;% refined estimation of the nbre of vectors per subdomain
     65smoothing=sqrt(Siz(1)*Siz(2)/NbVecSub)*FieldSmooth;%optimum smoothing increase as the typical mesh size =sqrt(SizX*SizY/NbVecSub)^1/2
    6566%% default output
    6667SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the boundaries of subdomains
     
    8081%% calculate tps coeff in each subdomain
    8182for isub=1:NbSubDomain
    82     isub
    8383    SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)];%bounds of subdomain #isub in x coordinate
    8484    SubRange(2,:,isub)=[CentreY(isub)-0.55*Siz(2) CentreY(isub)+0.55*Siz(2)];%bounds of subdomain #isub in y coordinate
     
    8989        ind_sel_previous=ind_sel;% record the set of selected vector indices for next iteration
    9090        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));
    91         numel(ind_sel)
     91        %disp([numel(ind_sel) ' vectors in subdomain #' num2str(isub)])
    9292        % if no vector in the subdomain  #isub, skip the subdomain
    9393        if isempty(ind_sel)
     
    124124                V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub;
    125125                nb_select(ind_sel)=nb_select(ind_sel)+weight;
    126                 display(['tps done in subdomain # ' num2str(isub)  ' among ' num2str(NbSubDomain)])
     126                display(['tps done with ' num2str(numel(ind_sel)) ' vectors in subdomain # ' num2str(isub)  ' among ' num2str(NbSubDomain)])
    127127                break
    128128            % if too few selected vectors, increase the subrange for next iteration
     
    146146                V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub;
    147147                nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+weight;
    148                 display(['tps redone after elimination of erratic vectors in subdomain # ' num2str(isub) ' among ' num2str(NbSubDomain)])
     148                display(['tps redone with ' num2str(numel(ind_sel)) ' vectors after elimination of ' num2str(numel(ind_ind_sel)) ' erratic vectors in subdomain # ' num2str(isub) ' among ' num2str(NbSubDomain)])
    149149                break
    150150            end
  • trunk/src/series/test_patch_tps.m

    r1141 r1142  
    3333%              .FieldName: name(s) of the field
    3434%              .VelType: velocity type
    35 %              .FieldName_1: name of the second field in case of two input series
    36 %              .VelType_1: velocity type of the second field in case of two input series
    37 %              .Coord_y: name of y coordinate variable
    38 %              .Coord_x: name of x coordinate variable
    3935
    4036%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    110106            case {4,5}
    111107                CivStage='civ2';
    112                 MaxDiff=1.5; SubDomainSize=500; FieldSmooth=2; %default
     108                MaxDiff=1.5; SubDomainSize=250; FieldSmooth=5; %default
    113109            case 6
    114110                CivStage='civ2';
     
    211207
    212208%% Prepare the structure of output netcdf file
    213 DataOut.ListGlobalAttribute={'CivStage'};
     209DataOut.ListGlobalAttribute={'CivStage','SubDomainSize','MaxDiff','CoordUnit'};
    214210DataOut.CivStage=Param.InputFields.VelType;
    215 DataOut.ListVarName=[{'FieldSmooth','Diff_rms','NbExclude','FF','X','Y'} Ustr Vstr] ;
    216 DataOut.VarDimName=[{'FieldSmooth','FieldSmooth','FieldSmooth','NbVec','NbVec','NbVec'} Dimstr Dimstr];
     211DataOut.SubDomainSize=SubDomainSize;
     212DataOut.MaxDiff=MaxDiff;
     213DataOut.CoordUnit='pixel';
     214DataOut.ListVarName=[{'FieldSmooth','Diff_rms','NbExclude','X','Y'} Ustr Vstr] ;
     215DataOut.VarDimName=[{'FieldSmooth','FieldSmooth','FieldSmooth','NbVec','NbVec'} Dimstr Dimstr];
    217216DataOut.VarAttribute{4}.Role='falseflag';
    218217DataOut.FieldSmooth=FieldSmooth;
     
    249248        DataOut.Diff_rms(irho)=sqrt(mean(U_Diff.*U_Diff+V_Diff.*V_Diff)/2);
    250249        DataOut.NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
     250        U_smooth(ind_false)=NaN;
     251        V_smooth(ind_false)=NaN;
    251252        DataOut.(['U_' str_i{irho}])=U_smooth;
    252253        DataOut.(['V_' str_i{irho}])=V_smooth;
    253         DataOut.FF(ind_false)=FieldSmooth(irho);
     254        % DataOut.FF(ind_false)=FieldSmooth(irho);
    254255    end
    255256    time=toc
Note: See TracChangeset for help on using the changeset viewer.