def epoch_ranges(epochs):
    """Optimise time intervals to make the most of different epochs of TLE pairs

    Creates a list with of times [epoch_range], pairs of successive elements
    of which correspond to time intervals at which a particular epoch has best
    accuracy, before the next epoch becomes more accurate. This is done to
    ensure that the most relevanrt TLE is used in the analysis.

    .. code-block:: python

        from embers.sat_utils.sat_ephemeris import load_tle, epoch_ranges
        sats, epochs = load_tle('~/embers-data/TLE/21576.txt')
        epoch_range = epoch_ranges(epochs)

    :param epochs: List of epochs from :func:`~embers.sat_utils.sat_ephemeris.load_tle`

    :return:
        epoch_range: List of times, between which each pair of TLEs is most accurate

    """

    # Midpoints between epochs of successive TLEs
    midpoints = list((epochs[1:] + epochs[:-1]) / 2)
    epoch_range = [epochs[0]] + midpoints + [epochs[-1]]

    return epoch_range