Find bad time ranges from distribution of candidates.

    ignoret is list of tuples [(t0, t1), (t2, t3)] defining ranges to ignore.
    threshold is made above std of candidate distribution in time.
    Returns the time (in seconds) and counts for bins above threshold.

def findhight(data, ignoret=None, threshold=20):
    """ Find bad time ranges from distribution of candidates.

    ignoret is list of tuples [(t0, t1), (t2, t3)] defining ranges to ignore.
    threshold is made above std of candidate distribution in time.
    Returns the time (in seconds) and counts for bins above threshold.
    """

    time = np.sort(data['time'])

    ww = np.ones(len(time), dtype=bool)  # initialize pass filter
    if ignoret:
        for (t0, t1) in ignoret:
            ww = ww & np.where( (time < t0) | (time > t1), True, False )

    bins = np.round(time[ww]).astype('int')
    counts = np.bincount(bins)
    high = np.where(counts > np.median(counts) + threshold*counts.std())[0]

    return high, counts[high]