files = dirs('binfiles/*spd.bin');

for filei = 1:length(files)
   file = files(filei).name;
   bindata = read_bin(['binfiles/',file]);
   clf;plot(bindata(1,:), bindata(2,:),'k')
   yl(mean(bindata(2,:)) + [-10,10])
   xl(min(bindata(1,:)) , max(bindata(1,:)))

   badi = [];
   spd_dday = bindata(1,:);
   spd = bindata(2,:);
   times = [[spd_dday(1) : 300/86400 : 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)>3))];
   end
   if (~isempty(badi))
      bindata(:,badi) = [];
      hold on
      plot(bindata(1,:), bindata(2,:),'g')
   end
   paused
end
