ij(1,:) = [1 2 3 4  6 7 8  ];
ij(2,:) = [2 3 4 5  7 8 9 ];
id      = [2 3 4 5  7 8 9 ];  % position of pressure sensor 
ib      = [1 2 3 4  6 7 8 9  ];  % corresponding bottom profile
xc      = [65 100 115 130   145  152  160  ]; % position of carriage


for j = 1:7
test = '#2e0000';
    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


[t,emf11] = get_series(test,'EMF13',1);
[t,obs1] = get_series(test,'OBS03',1);
[obs1_lo,obs1_hi] = f_flt(obs1,1,1/10);
[obs1_lo2,obs1_hi] = f_flt(obs1_lo,.1,1/10);

% 2% rule
nc = length(obs1);
cs1 = sort(obs1_lo);
offset = cs1(floor(nc/50))

s_hi(j)= sum((obs1_hi(1:end)-offset).*detrend(emf11(1:end)))*(t(2)-t(1))
s_lo(j)= sum((obs1_lo2(1:end)-offset).*detrend(emf11(1:end)))*(t(2)-t(1))
s_mean(j)= mean(emf11)*mean(obs1-offset)*(t(end)-t(1))

end

plot(xc,s_hi,xc,s_lo,xc,s_mean)