code: def time_coincidence(t1, t2, window, slide_step=0):
      
      if slide_step:
          fold1 = t1 % slide_step
          fold2 = t2 % slide_step
      else:
          fold1 = t1
          fold2 = t2
  
      sort1 = fold1.argsort()
      sort2 = fold2.argsort()
      fold1 = fold1[sort1]
      fold2 = fold2[sort2]
  
      if slide_step:
          fold2 = numpy.concatenate([fold2 - slide_step, fold2, fold2 + slide_step])
          sort2 = numpy.concatenate([sort2, sort2, sort2])
  
      left = numpy.searchsorted(fold2, fold1 - window)
      right = numpy.searchsorted(fold2, fold1 + window)
  
      idx1 = numpy.repeat(sort1, right-left)
      idx2 = [sort2[l:r] for l,r in zip(left, right)]
  
      if len(idx2) > 0:
          idx2 = numpy.concatenate(idx2)
      else:
          idx2 = numpy.array([], dtype=numpy.int64)
  
      if slide_step:
          diff = ((t1 / slide_step)[idx1] - (t2 / slide_step)[idx2])
          slide = numpy.rint(diff)
      else:
          slide = numpy.zeros(len(idx1))
  
      return idx1.astype(numpy.uint32), idx2.astype(numpy.uint32), slide.astype(numpy.int32)
docs: Find coincidences by time window
  
      Parameters
      ----------
      t1 : numpy.ndarray
          Array of trigger times from the first detector
      t2 : numpy.ndarray
          Array of trigger times from the second detector
      window : float
          The coincidence window in seconds
      slide_step : optional, {None, float}
          If calculating background coincidences, the interval between background
          slides in seconds.
  
      Returns
      -------
      idx1 : numpy.ndarray
          Array of indices into the t1 array.
      idx2 : numpy.ndarray
          Array of indices into the t2 array.
      slide : numpy.ndarray
          Array of slide ids