def get_gps_start_and_stop(template_params, maxsegl):
    """Return the gps start and and end times that will encompass the best matching
    template

    Parameters
    ----------
    template_params: dict
        dictionary of the best matching template parameters
    maxself: float
        maximum segment length

    Returns
    -------
    times: list
        list containing the gps start and gps end times
    """
    from pycbc.waveform import get_td_waveform
    hp, hc = get_td_waveform(approximant='IMRPhenomD', mass1=
        template_params['mass_1'], mass2=template_params['mass_2'], spin1z=
        template_params['spin_1z'], spin2z=template_params['spin_2z'],
        f_lower=20.0, delta_t=1.0 / 4096)
    duration = hp.duration
    if duration < 8.0:
        duration = 8.0
    gps_start = template_params['gps_time'] - maxsegl * 0.75
    gps_end = template_params['gps_time'] + maxsegl * 0.25
    return gps_start, gps_end
