def get_cutoff_indices(flow, fhigh, df, N):
    """
    Gets the indices of a frequency series at which to stop an overlap
    calculation.

    Parameters
    ----------
    flow: float
        The frequency (in Hz) of the lower index.
    fhigh: float
        The frequency (in Hz) of the upper index.
    df: float
        The frequency step (in Hz) of the frequency series.
    N: int
        The number of points in the **time** series. Can be odd
        or even.

    Returns
    -------
    kmin: int
    kmax: int
    """
    if flow:
        kmin = int(flow / df)
        if kmin < 0:
            err_msg = 'Start frequency cannot be negative. '
            err_msg += 'Supplied value and kmin {} and {}'.format(flow, kmin)
            raise ValueError(err_msg)
    else:
        kmin = 1
    if fhigh:
        kmax = int(fhigh / df)
        if kmax > int((N + 1) / 2.0):
            kmax = int((N + 1) / 2.0)
    else:
        kmax = int((N + 1) / 2.0)
    if kmax <= kmin:
        err_msg = 'Kmax cannot be less than or equal to kmin. '
        err_msg += 'Provided values of freqencies (min,max) were '
        err_msg += '{} and {} '.format(flow, fhigh)
        err_msg += 'corresponding to (kmin, kmax) of '
        err_msg += '{} and {}.'.format(kmin, kmax)
        raise ValueError(err_msg)
    return kmin, kmax
