function [date,hp,mx,gd] = badpoints(data,pps_range)

% function [date,hp,mx,gd] = badpoints(data,pps_range)
% 
% Removes bad pps points from data, according to pps_range in us.
% Output gives date and all three GPS channels. Plots also 
% corresponding outputs. 
% By (jen) 29.9.1999.
%
% In future this should also do 'loadall' based on mjd_range!


hp = data(:,4);
mx = data(:,2);
gd = data(:,6);
date = data(:,1);
clear data;

% Cut dates and bad PPS values
ind = find((hp > min(pps_range))&(hp < max(pps_range))...
	& (mx > min(pps_range))&(mx < max(pps_range))...
	& (gd > min(pps_range))&(gd < max(pps_range)));

hp = hp(ind);
mx = mx(ind);
gd = gd(ind);
date = date(ind) - 50000; % Cut and normalize to MJD 50000

figure(1)
plot(date, hp,date,mx,date,gd);
title(['EFOS9 vs. GPS 1PPS delay' ]);
xlabel('Time since MJD = 50000');
ylabel(['Delay in [us]']);
grid

 
%endfunction
