Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mask convolve issue #80

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading