code: def apply_nsigma_separation(fitind,fluxes,separation,niter=10):
      
      for n in range(niter):
          if len(fitind) < 1:
              break
          fitarr = np.array(fitind,np.float32)
          fluxarr = np.array(fluxes,np.float32)
          inpind = np.argsort(fitarr[:,1])
          npind = fitarr[inpind]
          fluxind = fluxarr[inpind]
          fitind = npind.tolist()
          fluxes = fluxind.tolist()
          dx = npind[1:,0] - npind[:-1,0]
          dy = npind[1:,1] - npind[:-1,1]
          dr = np.sqrt(np.power(dx,2)+np.power(dy,2))
          nsame = np.where(dr <= separation)[0]
          if nsame.shape[0] > 0:
              for ind in nsame[-1::-1]:
                  #continue # <- turn off filtering by source separation
                  del fitind[ind]
                  del fluxes[ind]
          else:
              break
      return fitind,fluxes
docs: Remove sources which are within nsigma*fwhm/2 pixels of each other, leaving
      only a single valid source in that region.
  
      This algorithm only works for sources which end up sequentially next to each other
      based on Y position and removes enough duplicates to make the final source list more
      managable.  It sorts the positions by Y value in order to group those at the
      same positions as much as possible.