function bindata = clean_sspd(bindata);
% bindata = clean_sspd(bindata)
%
% bindata is 2xN vector of dday and speed_of_sound
%

%Q&D filter to get rid of bad speed_of_sound

threshold = 3;  %m/s cutoff to toss out bad values
dt = 300/86400; %5 minutes


badi = [];
spd_dday = bindata(1,:);
spd = bindata(2,:);
times = [[spd_dday(1) : dt : spd_dday(end)] spd_dday(end)];
for starti = 1:length(times)-1
   ii=find( (spd_dday >= times(starti)) & (spd_dday <= times(starti+1)));
   mm = median(spd(ii));
   badi = [badi ii(find(abs(spd(ii)-mm)>threshold))];
end
if (~isempty(badi))
   bindata(:,badi) = [];
end
