docs: def background_estimator(bdata):
      """Estimate the background in a 2D array"""
  
      crowded = False
  
      std = numpy.std(bdata)
      std0 = std
      mean = bdata.mean()
      while True:
          prep = len(bdata)
          numpy.clip(bdata, mean - 3 * std, mean + 3 * std, out=bdata)
          if prep == len(bdata):
              if std < 0.8 * std0:
                  crowded = True
              break
          std = numpy.std(bdata)
          mean = bdata.mean()
  
      if crowded:
          median = numpy.median(bdata)
          mean = bdata.mean()
          std = bdata.std()
          return 2.5 * median - 1.5 * mean, std
  
      return bdata.mean(), bdata.std()