code: def truncate_impulse(impulse, ntaps, window='hanning'):
      
      out = impulse.copy()
      trunc_start = int(ntaps / 2)
      trunc_stop = out.size - trunc_start
      window = signal.get_window(window, ntaps)
      out[0:trunc_start] *= window[trunc_start:ntaps]
      out[trunc_stop:out.size] *= window[0:trunc_start]
      out[trunc_start:trunc_stop] = 0
      return out
docs: 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