From 8730aaffd455cdd3071c68a1d56299ac1bece90c Mon Sep 17 00:00:00 2001
From: David Rafferty <drafferty@hs.uni-hamburg.de>
Date: Sat, 11 Jul 2020 17:46:11 +0200
Subject: [PATCH] Fix incorrect filtering with mask images when sources lie
 outside the mask

---
 lsmtool/operations/_filter.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lsmtool/operations/_filter.py b/lsmtool/operations/_filter.py
index e11658e..4f840ab 100644
--- a/lsmtool/operations/_filter.py
+++ b/lsmtool/operations/_filter.py
@@ -482,11 +482,11 @@ def getMaskValues(mask, RARad, DecRad):
         (a, b, _, _) = maskdata.toworld([0, 0, 0, 0])
         (_, _, pixY, pixX) = maskdata.topixel([a, b, decRad, raRad])
         try:
-            if maskval[int(pixY), int(pixX)]:
+            if maskval[int(pixY), int(pixX)] and pixX >= 0 and pixY >=0:
                 vals.append(True)
             else:
                 vals.append(False)
-        except:
+        except IndexError:
             vals.append(False)
 
     return np.array(vals)
-- 
GitLab