Skip to content

Commit

Permalink
attempting to fix a mas issue
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoSanchez committed Feb 13, 2024
1 parent ba0e6d6 commit c37009a
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions properimage/single_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c37009a

Please sign in to comment.