Ignore:
Timestamp:
Feb 28, 2017, 10:41:54 AM (8 years ago)
Author:
sommeria
Message:

correlation_time and correlation_x corrected

File:
1 edited

Legend:

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

    r1001 r1002  
    5757%=======================================================================
    5858
    59 function ParamOut=turb_stat(Param)
     59function ParamOut=turb_correlation_time(Param)
    6060
    6161%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
     
    6363    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
    6464    ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    65     ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
     65    ParamOut.NbSlice=1; %nbre of slices ('off' by default)
    6666    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    6767    ParamOut.FieldName='one';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     
    277277        FFCorr=false(NpTime+1,npy,npx);
    278278    end
     279    Field.U=Field.U-UMean;
     280    Field.V=Field.V-VMean;
    279281    FF=isnan(Field.U);%|Field.U<-60|Field.U>30;% threshold on U
    280282    Field.U(FF)=0;% set to 0 the nan values,'delta_x'
    281283    Field.V(FF)=0;
    282     Field.U=Field.U-UMean;
    283     Field.V=Field.V-VMean;
    284284    if index<=NpTime+1
    285         U_shift(index,:,:)=Field.U;
    286         V_shift(index,:,:)=Field.V;
    287         FF_shift(index,:,:)=FF;
     285        U_shift(NpTime+2-index,:,:)=Field.U;
     286        V_shift(NpTime+2-index,:,:)=Field.V;
     287        FF_shift(NpTime+2-index,:,:)=FF;
    288288    else
    289         U_shift=circshift(U_shift,[-1 0 0]); %shift U by ishift along the first index
    290         V_shift=circshift(V_shift,[-1 0 0]); %shift U by ishift along the first index
    291         FF_shift=circshift(FF_shift,[-1 0 0]); %shift U by ishift along the first index
    292         U_shift(NpTime+1,:,:)=Field.U;
    293         V_shift(NpTime+1,:,:)=Field.V;
    294         FF_shift(NpTime+1,:,:)=FF;
    295     end
    296     for ishift=1:NpTime% calculate the field U shifted
    297         UUCorr(ishift,:,:)=Field.U.*U_shift(ishift,:,:);
    298         VVCorr(ishift,:,:)=Field.V.*V_shift(ishift,:,:);
    299         UVCorr(ishift,:,:)=Field.U.*V_shift(ishift,:,:);
    300         FFCorr(ishift,:,:)=FF | FF_shift;
     289        U_shift=circshift(U_shift,[1 0 0]); %shift U by ishift along the first index
     290        V_shift=circshift(V_shift,[1 0 0]); %shift U by ishift along the first index
     291        FF_shift=circshift(FF_shift,[1 0 0]); %shift U by ishift along the first index
     292        U_shift(1,:,:)=Field.U;
     293        V_shift(1,:,:)=Field.V;
     294        FF_shift(1,:,:)=FF;
     295    end
     296    for ishift=1:NpTime+1% calculate the field U shifted
     297        UUCorr(ishift,:,:)=Field.U.*squeeze(U_shift(ishift,:,:));
     298        VVCorr(ishift,:,:)=Field.V.*squeeze(V_shift(ishift,:,:));
     299        UVCorr(ishift,:,:)=Field.U.*squeeze(V_shift(ishift,:,:));
     300        FFCorr(ishift,:,:)=FF | squeeze(FF_shift(ishift,:,:));
    301301    end
    302302    DataOut.UUCorr=DataOut.UUCorr+UUCorr;
     
    306306end
    307307%%%%%%%%%%%%%%%% end loop on field indices %%%%%%%%%%%%%%%%
    308 % DataOut.UUCorr=DataOut.UUCorr./DataOut.Counter;
    309 % DataOut.VVCorr=DataOut.VVCorr./DataOut.Counter;
    310 % DataOut.VUVCorr=DataOut.UVCorr./DataOut.Counter;
    311 %DataOut.Counter(DataOut.Counter==0)=1;% put counter to 1 when it is zero
     308DataOut.Counter(DataOut.Counter==0)=1;% put counter to 1 when it is zero (to avoid NaN)
     309DataOut.UUCorr=DataOut.UUCorr./DataOut.Counter;
     310DataOut.VVCorr=DataOut.VVCorr./DataOut.Counter;
     311DataOut.UVCorr=DataOut.UVCorr./DataOut.Counter;
     312
    312313% DataOut.UMean=DataOut.UMean./DataOut.Counter; % normalize the mean
    313314% DataOut.VMean=DataOut.VMean./DataOut.Counter; % normalize the mean
Note: See TracChangeset for help on using the changeset viewer.