function [d,t,mx,my]=get_separation(id,t1,t2,yr)
% [d,t,mx,my]=get_separation(id,t1,t2) computes the 
% separation distance in km between the 
% two drifters given in id between t1 and t2
% in year yr.
% 4/8/01


%load data
load gb10mallA

% convert to drifter days
t1=yd2dd(t1,yr);
t2=yd2dd(t2,yr);

% get data
m=find(z(:,8)==id(1));
z1=z(m,1:3);
k=find(z1(:,1)>=t1 & z1(:,1)<=t2);
z1=z1(k,:);
m=find(z(:,8)==id(2));
z2=z(m,1:3);
k=find(z2(:,1)>=t1 & z2(:,1)<=t2);
z2=z2(k,:);
t=dd2yd(z2(:,1));

% compute separation
mx=(z1(:,2)+z2(:,2))./2;
my=(z1(:,3)+z2(:,3))./2;
d2r=pi./180;
dx=110*sin(d2r*my).*(z1(:,2)-z2(:,2));
dy=110*(z1(:,3)-z2(:,3));
d=sqrt(dx.^2+dy.^2);

subplot(2,1,1)
plot(z1(:,2),z1(:,3),'b',z2(:,2),z2(:,3),'r')
subplot(2,1,2)
plot(t,d)
pause
