code: def sharp_round(data, density, kskip, xc, yc, s2m, s4m, nxk, nyk,
                  datamin, datamax):
      
  
      # Compute the first estimate of roundness:
      sum2 = np.sum(s2m*density)
      sum4 = np.sum(s4m*abs(density))
      if sum2 == 0.0:
          round = 0.0
      elif sum4 <= 0.0: # eps?
          round = None
      else:
          round = 2.0 * sum2 / sum4
  
      # Eliminate the sharpness test if the central pixel is bad:
      mid_data_pix = data[yc, xc]
      mid_dens_pix = density[yc, xc]
      if mid_data_pix > datamax:
          return True, round, None
      if mid_data_pix < datamin:
          return False, round, None
  
      ########################
      # Sharpness statistics:
  
      satur = np.max(kskip*data) > datamax
  
      # Exclude pixels (create a mask) outside the [datamin, datamax] range:
      uskip = np.where((data >= datamin) & (data <= datamax), 1, 0)
      # Update the mask with the "skipped" values from the convolution kernel:
      uskip *= kskip
      # Also, exclude central pixel:
      uskip[yc, xc] = 0
  
      npixels = np.sum(uskip)
      if (npixels < 1 or mid_dens_pix <= 0.0):
          return satur, round, None
  
      sharp = (mid_data_pix - np.sum(uskip*data)/npixels) / mid_dens_pix
      #sharp = (mid_data_pix - np.mean(uskip*data)) / mid_dens_pix
  
      return satur, round, sharp
docs: sharp_round -- Compute first estimate of the roundness and sharpness of the
      detected objects.
  
      A Python translation of the AP_SHARP_ROUND IRAF/DAOFIND function.