Changeset 761 for trunk/src/series


Ignore:
Timestamp:
May 1, 2014, 8:28:05 AM (11 years ago)
Author:
sommeria
Message:

turb_stat corrected
civ corrected to allow civ2 from an existing civ1 series

Location:
trunk/src/series
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/civ_input.m

    r758 r761  
    143143        iview_image=2;%line # for the input images
    144144    case 'civxdata'% case of  civx data,
    145         NomTypeNc=NomTypeInput;
    146         ind_opening=FileInfo.CivStage;
    147         set(handles.Program,'Value',3) %select Cix by default
    148145        msgbox_uvmat('ERROR','old civX convention, use the GUI civ')
     146        return
     147    otherwise
     148        msgbox_uvmat('ERROR','civ_series needs images or civ data as input')
    149149        return
    150150end
  • trunk/src/series/civ_series.m

    r758 r761  
    9797end
    9898if isfield(Param,'InputTable')
    99     [tild,i_series,tild,j_series]=get_file_series(Param);
     99   [tild,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);   
    100100    % iview_nc=0;% series index (iview) for an input nc file (for civ2 or patch2)
    101101    iview_A=0;% series index (iview) for the first image series
     
    107107    end
    108108    if strcmp(Param.ActionInput.ListCompareMode,'shift')
    109         iview_B=iview_A+1; % the second image series is on the next line of the tinput table
     109        iview_B=iview_A+1; % the second image series is on the next line of the input table
    110110    end
    111111    if iview_A~=0
     
    132132                PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;
    133133            end
    134             [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=...
    135                 find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
    136             if ~isempty(PairCiv2)
    137                 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=...
    138                     find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
    139                 check_bounds=check_bounds | check_bounds_Civ2;
    140             end
    141             i1_series_Civ1=i1_series_Civ1(~check_bounds);
    142             i2_series_Civ1=i2_series_Civ1(~check_bounds);
    143             j1_series_Civ1=j1_series_Civ1(~check_bounds);
    144             j2_series_Civ1=j2_series_Civ1(~check_bounds);
     134            if iview_A==1% if Civ1 is performed
     135                [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=...
     136                    find_pair_indices(PairCiv1,i1_series{1},j1_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
     137                if ~isempty(PairCiv2)
     138                    [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=...
     139                        find_pair_indices(PairCiv2,i1_series{1},j1_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
     140                    check_bounds=check_bounds | check_bounds_Civ2;
     141                end
     142            else% we start from an existing Civ1 file
     143                i1_series_Civ1=i1_series{1};
     144                i2_series_Civ1=i2_series{1};
     145                j1_series_Civ1=j1_series{1};
     146                j2_series_Civ1=j2_series{1};
     147                NomTypeNc=Param.InputTable{1,4};
     148                if ~isempty(PairCiv2)
     149                    [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds,NomTypeNc]=...
     150                        find_pair_indices(PairCiv2,i1_series{2},j1_series{2},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
     151%                     check_bounds=check_bounds | check_bounds_Civ2;
     152                end
     153            end
     154%             i1_series_Civ1=i1_series_Civ1(~check_bounds);
     155%             i2_series_Civ1=i2_series_Civ1(~check_bounds);
     156%             j1_series_Civ1=j1_series_Civ1(~check_bounds);
     157%             j2_series_Civ1=j2_series_Civ1(~check_bounds);
    145158        case 'displacement'
    146159            i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i_series{1}));
    147160            i2_series_Civ1=i_series{1};i2_series_Civ2=i_series{1};
    148161            j1_series_Civ1=ones(size(i_series{1}));% first j index is 1
    149             if isempty(j_series{1})
     162            if isempty(j1_series_Civ1)
    150163                j2_series_Civ1=ones(size(i_series{1}));
    151164            else
    152                 j2_series_Civ1=j_series{1};
     165                j2_series_Civ1=j1_series_Civ1;
    153166            end
    154167            i1_series_Civ2=i1_series_Civ1;
     
    170183            NomTypeNc=NomType_A;
    171184    end
    172     if isempty(j_series{1})
     185    if isempty(j1_series_Civ1)
    173186        FrameIndex_A_Civ1=i1_series_Civ1;
    174187        FrameIndex_B_Civ1=i2_series_Civ1;
     188        j1_series_Civ1=ones(size(i1_series_Civ1));
     189        j2_series_Civ1=ones(size(i1_series_Civ1));
    175190    else
    176191        FrameIndex_A_Civ1=j1_series_Civ1;
     
    178193    end
    179194    if ~isempty(PairCiv2)
    180         i1_series_Civ2=i1_series_Civ2(~check_bounds);
    181         i2_series_Civ2=i2_series_Civ2(~check_bounds);
    182         j1_series_Civ2=j1_series_Civ2(~check_bounds);
    183         j2_series_Civ2=j2_series_Civ2(~check_bounds);
    184         if isempty(j_series{1})
     195%         i1_series_Civ2=i1_series_Civ2(~check_bounds);
     196%         i2_series_Civ2=i2_series_Civ2(~check_bounds);
     197%         j1_series_Civ2=j1_series_Civ2(~check_bounds);
     198%         j2_series_Civ2=j2_series_Civ2(~check_bounds);
     199        if isempty(j1_series_Civ2)
    185200            FrameIndex_A_Civ2=i1_series_Civ2;
    186201            FrameIndex_B_Civ2=i2_series_Civ2;
     
    300315        break
    301316    end
     317    if iview_A==1% if Civ1 is performed
     318        Civ1Dir=OutputDir;
     319    else
     320        Civ1Dir=Param.InputTable{1,2};
     321    end
    302322    if strcmp(Param.ActionInput.ListCompareMode,'PIV')
    303         ncfile=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),...
     323        ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),...
    304324            j1_series_Civ1(ifield),j2_series_Civ1(ifield));
    305325    else
    306         ncfile=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],...
     326        ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],...
    307327            j1_series_Civ1(ifield),j2_series_Civ1(ifield));
    308328    end
     
    400420            CivFile=Param.Patch1.CivFile;
    401421        end
    402         Data=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format
    403         if isfield(Data,'Txt')
    404             errormsg=Data.Txt;
     422        [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format
     423        if ~isempty(errormsg)
    405424            disp_uvmat('ERROR',errormsg,checkrun)
    406425            return
     
    410429            [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file
    411430        else
    412             Data=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file
     431            [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file
    413432        end
    414433    end
     
    526545        NbSubDomain=size(Data.Civ1_SubRange,3);
    527546        % get the guess from patch1
    528         for isub=1:NbSubDomain
    529             nbvec_sub=Data.Civ1_NbCentres(isub);
    530             ind_sel=find(GridX>=Data.Civ1_SubRange(1,1,isub) & GridX<=Data.Civ1_SubRange(1,2,isub) & GridY>=Data.Civ1_SubRange(2,1,isub) & GridY<=Data.Civ1_SubRange(2,2,isub));
    531             epoints = [GridX(ind_sel) GridY(ind_sel)];% coordinates of interpolation sites
     547        for isub=1:NbSubDomain% for each sub-domain of Patch1
     548            nbvec_sub=Data.Civ1_NbCentres(isub);% nbre of Civ1 vectors in the subdomain
     549            ind_sel=find(par_civ2.Grid(:,1)>=Data.Civ1_SubRange(1,1,isub) & par_civ2.Grid(:,1)<=Data.Civ1_SubRange(1,2,isub) &...
     550                par_civ2.Grid(:,2)>=Data.Civ1_SubRange(2,1,isub) & par_civ2.Grid(:,2)<=Data.Civ1_SubRange(2,2,isub));
     551            epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites
    532552            ctrs=Data.Civ1_Coord_tps(1:nbvec_sub,:,isub) ;%(=initial points) ctrs
    533553            nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap)
     
    552572        par_civ2.SearchBoxSize(2)=2*iby2+9;
    553573        par_civ2.SearchBoxShift=[Shiftx(nbval>=1)./nbval(nbval>=1) Shifty(nbval>=1)./nbval(nbval>=1)];
    554         par_civ2.Grid=[GridX(nbval>=1)-par_civ2.SearchBoxShift(:,1)/2 GridY(nbval>=1)-par_civ2.SearchBoxShift(:,2)/2];% grid taken at the extrapolated origin of the displacement vectors
     574        par_civ2.Grid=[par_civ2.Grid(nbval>=1,1)-par_civ2.SearchBoxShift(:,1)/2 par_civ2.Grid(nbval>=1,2)-par_civ2.SearchBoxShift(:,2)/2];% grid taken at the extrapolated origin of the displacement vectors
    555575        if par_civ2.CheckDeformation
    556576            par_civ2.DUDX=DUDX./nbval;
  • trunk/src/series/turb_stat.m

    r751 r761  
    184184U2Mean_1=0;
    185185V2Mean_1=0;
    186 checkgrid=0;% test for a structured grid for input field
     186Counter_1=0;
     187
    187188%%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    188189for index=1:NbField
     
    201202        Uprev=Field.U;
    202203        Vprev=Field.V;
    203     end
    204     FF=isnan(Field.U)|Field.U<-60|Field.U>30;% threshold on U
     204        FFprev=Field.FF;
     205    end
     206    FF=isnan(Field.U);%|Field.U<-60|Field.U>30;% threshold on U
    205207    DataOut.Counter=DataOut.Counter+ (~FF);% add 1 to the couter for non NaN point
     208    Counter_1=Counter_1+(~FF & ~FFprev);
    206209    Field.U(FF)=0;% set to 0 the nan values
    207210    Field.V(FF)=0;
     
    215218    Uprev=Field.U; %store for next iteration
    216219    Vprev=Field.V;
     220    FFprev=FF;
    217221end
    218222%%%%%%%%%%%%%%%% end loop on field indices %%%%%%%%%%%%%%%%
     
    224228V2Mean=V2Mean./DataOut.Counter; % normalize the mean
    225229UVMean=UVMean./DataOut.Counter; % normalize the mean
    226 U2Mean_1=U2Mean_1./DataOut.Counter; % normalize the mean
    227 V2Mean_1=V2Mean_1./DataOut.Counter; % normalize the mean
     230U2Mean_1=U2Mean_1./Counter_1; % normalize the mean
     231V2Mean_1=V2Mean_1./Counter_1; % normalize the mean
    228232DataOut.u2Mean=U2Mean-DataOut.UMean.*DataOut.UMean; % normalize the mean
    229233DataOut.v2Mean=V2Mean-DataOut.VMean.*DataOut.VMean; % normalize the mean
Note: See TracChangeset for help on using the changeset viewer.