function [ydi,s,d,xi,yi,xmi,ymi]=drifter_divergence(drift);

yd0=max(drift.yd(1),drift.ydm(1));
yd1=min(drift.yd(end),drift.ydm(end));
dt=1/24;

ydi=yd0:dt:yd1;


xmi=interp1(drift.ydm(1:end-1),drift.xm(1:end-1),ydi);
ymi=interp1(drift.ydm(1:end-1),drift.ym(1:end-1),ydi);
xi=interp1(drift.yd,drift.x,ydi);
yi=interp1(drift.yd,drift.y,ydi);

i=sqrt(-1);
s=abs(xi+i*yi-(xmi+i*ymi));
%plot(ydi,s);
%d=(s-s(1))/(ydi-min(ydi(1)));
d=(s(end)-s(1))/(ydi(end)-ydi(1));