From 3fddc7c7affe08851e6c369492b7666e7eac09b3 Mon Sep 17 00:00:00 2001
From: David Rafferty <drafferty@hs.uni-hamburg.de>
Date: Mon, 9 Nov 2020 16:01:06 +0100
Subject: [PATCH] Adjust size weighting

---
 lsmtool/operations/group.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lsmtool/operations/group.py b/lsmtool/operations/group.py
index 41d7cb2..c0c262f 100644
--- a/lsmtool/operations/group.py
+++ b/lsmtool/operations/group.py
@@ -260,7 +260,8 @@ def group(LSM, algorithm, targetFlux=None, weightBySize=False, numClusters=100,
             if weightBySize:
                 sizes = LSM.getPatchSizes(units='arcsec', weight=True, applyBeam=applyBeam)
                 sizes[sizes < 1.0] = 1.0
-                medianSize = np.median(sizes)
+                bright_ind = np.where(fluxes >= targetFlux)
+                medianSize = np.median(sizes[bright_ind])
                 weights = medianSize / sizes
                 weights[weights > 1.0] = 1.0
                 weights[weights < 0.5] = 0.5
-- 
GitLab