def truncate_impulse(impulse, ntaps, window='<STR_LIT>'):
out = impulse.copy()<EOL>trunc_start = int(ntaps / <NUM_LIT:2>)<EOL>trunc_stop = out.size - trunc_start<EOL>window = signal.get_window(window, ntaps)<EOL>out[<NUM_LIT:0>:trunc_start] *= window[trunc_start:ntaps]<EOL>out[trunc_stop:out.size] *= window[<NUM_LIT:0>:trunc_start]<EOL>out[trunc_start:trunc_stop] = <NUM_LIT:0><EOL>return out<EOL>
Smoothly truncate a time domain impulse response

    Parameters
    ----------
    impulse : `numpy.ndarray`
        the impulse response to start from

    ntaps : `int`
        number of taps in the final filter

    window : `str`, `numpy.ndarray`, optional
        window function to truncate with, default: ``'hanning'``
        see :func:`scipy.signal.get_window` for details on acceptable formats

    Returns
    -------
    out : `numpy.ndarray`
        the smoothly truncated impulse response