code: def fit_delta_ts(data, livetime, fit_background=True):
      
  
      data = data / livetime
      start = -(data.shape[1] - 1) / 2
      end = -start + 1
      xs = np.arange(start, end)
  
      rates = []
      sigmas = []
      means = []
      popts = []
      pcovs = []
      for combination in data:
          mean0 = np.argmax(combination) + start
          try:
              if fit_background:
                  popt, pcov = optimize.curve_fit(
                      gaussian,
                      xs,
                      combination,
                      p0=[mean0, 4., 5., 0.1],
                      bounds=([start, 0, 0, 0], [end, 10, 10, 1])
                  )
              else:
                  popt, pcov = optimize.curve_fit(
                      gaussian_wo_offset,
                      xs,
                      combination,
                      p0=[mean0, 4., 5.],
                      bounds=([start, 0, 0], [end, 10, 10])
                  )
          except RuntimeError:
              popt = (0, 0, 0, 0)
          rates.append(popt[2])
          means.append(popt[0])
          sigmas.append(popt[1])
          popts.append(popt)
          pcovs.append(pcov)
      return (
          np.array(rates), np.array(means), np.array(sigmas), np.array(popts),
          np.array(pcovs)
      )
docs: Fits gaussians to delta t for each PMT pair.
  
      Parameters
      ----------
      data: 2d np.array: x = PMT combinations (465), y = time, entry = frequency
      livetime: length of data taking in seconds
      fit_background: if True: fits gaussian with offset, else without offset
  
      Returns
      -------
      numpy arrays with rates and means for all PMT combinations