function qc_sst2(ID,filename);

%   function qc_sst2(ID,filename);
% after identifying a suspicious drifter SST
% record with qc_sst, the next question is:
%    how does the sst compare with sst from nearby
%    drifters, if any?
% This routine plots the sst time series of drifter
% with id=="ID", and adds points for other drifters
% which passed within dx degrees at the same time.

eval(['load ',filename,' lon lat t id sst sst_*']);
dx=[1 2 5];

figure(1);clf;
q=find(id==ID);
plot(lon(q),lat(q));
hold on;
plot(lon(q(1)),lat(q(1)),'.k','markersize',25);
overlay;asprat;
axis([min(lon(q))-2 max(lon(q))+2 ...
        min(lat(q))-2 max(lat(q))+2]);
figure(2);clf;

marksz=[15 10 5];   % marker sizes corresponding to dx

qq=find(id==ID);
q=find(lat<min(lat(qq))-max(dx) | lat>max(lat(qq))+max(dx));
truncatedrift;
qq=find(id==ID);
q=find(lon<min(lon(qq))-max(dx) | lon>max(lon(qq))+max(dx));
truncatedrift;
qq=find(id==ID);
q=find(t<min(t(qq)) | t>max(t(qq)));
truncatedrift;

q=find(id==ID);
t2=t(q);sst2=sst(q);
q=find(diff(t2)>median(diff(t2)));
q=[0;q;length(t2)];
plot(t2(1)/365.24+1979,sst2(1),'.w');
hold on;
for i=2:length(q);
    a=q(i-1)+1:q(i);
    plot(t2(a)/365.24+1979,sst2(a),'color',[.5 .5 .5], ...
        'linewidth',2);
end;
ttl=['Drifter ',num2str(ID),' (dark grey)'];

% plot Reynolds SST interpolated to drifter pos
q=find(id==ID);
t2=t(q);sst2=sst_rey(q);
q=find(diff(t2)>median(diff(t2)));
q=[0;q;length(t2)];
for i=2:length(q);
    a=q(i-1)+1:q(i);
    plot(t2(a)/365.24+1979,sst2(a),'color',[.8 .8 .8], ...
        'linewidth',2);
end;
ttl=[ttl,', Reynolds (lt.grey)'];
if exist('sst_tmi')
    q=find(id==ID);
    t2=t(q);sst2=sst_tmi(q);
    q=find(diff(t2)>median(diff(t2)));
    q=[0;q;length(t2)];
    for i=2:length(q);
        a=q(i-1)+1:q(i);
        plot(t2(a)/365.24+1979,sst2(a),'k');
    end;
    ttl=[ttl,', TMI (black)'];
end;
title(ttl,'fontsize',12)

compothers=input('Show nearby drifters? (y/n) ','s');
if (strcmp(compothers,'n'))
    hold off;
    return;
end;

q=find(id==ID & abs(sst-sst_rey)>2);
for i=1:length(q);
    q2=find(t==t(q(i)) & id~=ID);
    del=sqrt( (lon(q2)-lon(q(i))).^2 + ...
        (lat(q2)-lat(q(i))).^2 );
    for k=1:length(dx)
        qq=find(del<dx(k));
        if (length(qq))
            plot(t(q2(qq))/365.24+1979,sst(q2(qq)), ...
                '.k','markersize',marksz(k));
        end;
    end;
end;

hold off;
ttl=[ttl,', nearby drifters (dots)'];
title(ttl,'fontsize',12);

        
