% obtain  mean return flow and infragravity velocities flow velocity for the LIP-experiment
%
%
%
%
inst1 = 'EMF00';
ij(1,:) = [1];
ij(2,:) = [2];
id      = [1 2 3 4 5];  % position of pressure sensor 
ib      = [1];  % corresponding bottom profile
xc      = [65 100 130 145 160]; % position of pressure sensor

test = '#2e0000';
testb = '%2e003c';

Tp   = 5; 
nij = length(ij);
for j = 1:1
   if ij(1,j) < 10
      test(5:5) = num2str(ij(1,j))
   else
      test(4:5) = num2str(ij(1,j))
   end
   if ij(2,j) < 10
      test(7:7) = num2str(ij(2,j))
   else
      test(6:7) = num2str(ij(2,j))
   end
   
   for ist=1:5

   % get velocity time series
      if (2*id(ist)-1)<10
       inst1(5:5)= num2str(2*id(ist)-1)
      else
       inst1(4:5)= num2str(2*id(ist)-1)
      end

      [t,g] = get_series(test,inst1,0);
      Um(ist) = mean(g);
      
      % obtain low frequency velocities
      ng = length(g);
      ng1 = floor(ng/10);
      ng2 = ng-ng1;
      dt = t(2)-t(1);
      U = detrend(g(ng1:ng2));
      [u_lo,u_hi] = f_flt(U,1/Tp/2,dt);
      Urms_hi(ist) = std(u_hi);
      Urms_lo(ist) = std(u_lo);
      % velocity moment
      guls(ist) = mean(3*u_lo.*u_hi.^2)+mean(u_lo.^3);
      
  end
      
 
end
 

