function [tdoff,m]=plot_integrated_alpha(t,alpha,alpha2,drogue,W);

% plot_integrated_alpha(t,alpha,alpha2,drogue,W);
%
% create a plot of t vs. cumsum(alpha) for
% a drifter, and indicate where the drogue was lost
% according to the DAC.
 
alpha=fillnans(alpha,0); 
alpha2=fillnans(alpha2,0);
t2=t-t(1);
medt=median(diff(t2));
y=cumsum(alpha)*medt;
y2=cumsum(alpha2)*medt;
 
plot(t2(1),y(1),'.w','markersize',1);
hold on;

q=find(W>1 & W<5 & drogue==0); 
plot(t2(q),y(q),'.','color',[1 .9 .9],'markersize',4) 
q=find(W>=5 & W<10 & drogue==0);
plot(t2(q),y(q),'.','color',[1 .6 .6],'markersize',6)
q=find(W>=10 & drogue==0);
plot(t2(q),y(q),'.r','markersize',10)

q=find(W>1 & W<5 & drogue==1); 
plot(t2(q),y(q),'.','color',[.9 .9 1],'markersize',4) 
q=find(W>=5 & W<10 & drogue==1);
plot(t2(q),y(q),'.','color',[.6 .6 1],'markersize',6)
q=find(W>=10 & drogue==1);
plot(t2(q),y(q),'.b','markersize',8)

q=find(W>1 & W<5 & drogue==.5); 
plot(t2(q),y(q),'.','color',[.8 .8 .8],'markersize',4) 
q=find(W>=5 & W<10 & drogue==.5);
plot(t2(q),y(q),'.','color',[.6 .6 .6],'markersize',6)
q=find(W>=10 & drogue==.5);
plot(t2(q),y(q),'.','color',[.4 .4 .4],'markersize',8)

 


%q=find(W>1 & W<5); 
%plot(t2(q),y2(q),'.','color',[1 .9 .9],'markersize',4) 
%q=find(W>=5 & W<10);
%plot(t2(q),y2(q),'.','color',[1 .6 .6],'markersize',6)
%q=find(W>=10);
%plot(t2(q),y2(q),'.r','markersize',10)


% plot reference lines for slope of 0.018 (this is approx.
% what a drogueless drifter shows).
xl=get(gca,'xlim'); yl=get(gca,'ylim');  
for b=0:100:100*floor(max(t2)/100);
    xx=b+0:10:max(t2);
    yy=.018*(xx-xx(1))+min([min(y) min(y2)]);
    plot(xx,yy,'color',[.8 .8 .8])
end;
set(gca,'xlim',xl,'ylim',yl);

% plot zero line
plot([0 max(t2)],[0 0],'k');

hold off;
  
xlabel('days')
ylabel('accumulated anomaly (days)')
 

