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

WIP: HLA-1251: Include "modest" sized sources on the deblend list #1801

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ number of the code change for that issue. These PRs can be viewed at:

3.7.1 (unreleased)
======================
- Added the modest and smaller sized segments (segments < kernel size) to
the list of segments to be deblended. These segments were inadvertently
left off the deblending list when the code was updated to handle enormously
large segments. [#1801]

- Exclude single filter images from the generation of the total detection
image to minimize cosmic ray contamination, unless there are only single
filter images in the visit. [#1797]
Expand Down
13 changes: 12 additions & 1 deletion drizzlepac/haputils/catalog_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2794,6 +2794,10 @@ def _evaluate_segmentation_image(self, segm_img, image_data, big_island_only=Fal
segm_img.big_segments = None
big_segments = np.where(segm_img.areas >= deb_limit)[0] + 1 # Segment labels are 1-based

# Get the labels of the modest sized segments as these should also be
# deblended as necessary
modest_segments = np.where(segm_img.areas < deb_limit)[0] + 1

# The biggest_source may be > max_biggest_source indicating there are "big islands"
# and is_poor_quality should be set to True. The is_poor_quality is only an indicator that
# a different kernel type or background computation could be tried for improved results.
Expand Down Expand Up @@ -2841,10 +2845,17 @@ def _evaluate_segmentation_image(self, segm_img, image_data, big_island_only=Fal
segm_img.big_segments = big_segments
else:
segm_img.big_segments = None
log.info("Total number of sources suitable for deblending: {}".format(len(big_segments)))
log.info("Total number of big sources suitable for deblending: {}".format(len(big_segments)))
else:
log.info("There are no big segments larger than the deblending limit.")

# Add the modest sized segments to the deblending array
if modest_segments.size > 0 and segm_img.big_segments is not None:
segm_img.big_segments = np.concatenate((segm_img.big_segments, modest_segments))
elif modest_segments.size > 0:
segm_img.big_segments = modest_segments
log.info("Total number of all sources suitable for deblending: {}".format(len(segm_img.big_segments)))

# Always compute the source_fraction so the value can be reported. Setting the
# big_island_only parameter allows control over whether the source_fraction should
# or should not be ignored.
Expand Down
1 change: 1 addition & 0 deletions tests/hap/test_alignpipe_randomlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def pytest_generate_tests(metafunc):
@pytest.mark.bigdata
@pytest.mark.slow
@pytest.mark.unit
@pytest.mark.skip(reason="Test designed to run *large* numbers of datasets for alignment statistics.")
def test_alignpipe_randomlist(tmpdir, dataset):
""" Tests which validate whether mosaics can be aligned to an astrometric standard.

Expand Down