From 66b8ef68f6585759c89631f029ad56804eeb5e11 Mon Sep 17 00:00:00 2001 From: "Bruno O. Sanchez" Date: Tue, 13 Feb 2024 11:26:20 -0500 Subject: [PATCH] attempting to fix a mas issue --- properimage/single_image.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/properimage/single_image.py b/properimage/single_image.py index b4e7f2c..82783df 100644 --- a/properimage/single_image.py +++ b/properimage/single_image.py @@ -320,6 +320,11 @@ def mask(self, mask): self.__data = ma.masked_invalid( self.__data.data ) + + else: + masked = ma.masked_greater(self.__data, 65000.0) + if not np.sum(~masked.mask) < 1000.0: + self.__data = masked except IOError: self.__data = ma.masked_invalid(self.__data) else: @@ -335,12 +340,16 @@ def mask(self, mask): # this procedure makes the mask grow seven times, using 2 or more # neighbor pixels masked. This is useful for avoiding ripples from fft - for i_enlarge in range(7): - enlarged_mask = convolve_scp( - self.__data.mask.astype(int), np.ones((3, 3)) - ) - enlarged_mask = enlarged_mask.astype(int) > 2 - self.__data.mask = ma.mask_or(self.__data.mask, enlarged_mask) + if self.__data.mask.shape != (): + for i_enlarge in range(7): + enlarged_mask = convolve_scp( + self.__data.mask.astype(int), np.ones((3, 3)) + ) + enlarged_mask = enlarged_mask.astype(int) > 2 + self.__data.mask = ma.mask_or(self.__data.mask, enlarged_mask) + else: + self.__data.mask = np.zeros_like(self.__data.data) + @property def background(self): @@ -476,7 +485,7 @@ def best_sources(self): ] if len(best_srcs) < 5: - self.warning( + logger.warning( "Best sources are too few- Using everything we have!" ) best_srcs = srcs