Skip to content

Commit

Permalink
HLA-1138: Exclude single filter images in the generation of the total…
Browse files Browse the repository at this point in the history
… detection image (#1797)
  • Loading branch information
mdlpstsci committed May 13, 2024
1 parent 204588a commit 8fc110f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ number of the code change for that issue. These PRs can be viewed at:

3.7.1 (unreleased)
======================
- 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]

- Implemented a series of bug fixes for the segmentation catalog [#1793]
- Define the threshold image to be (nsigma * background_rms).
- Fixed bug in the generation of the threshold image - ensure the final
Expand Down
33 changes: 31 additions & 2 deletions drizzlepac/haputils/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ def wcs_drizzle_product(self, meta_wcs):
.. note:: Cosmic-ray identification is NOT performed when creating the total detection image.
"""

# This insures that keywords related to the footprint are generated for this
# specific object to use in updating the output drizzle product.
self.meta_wcs = meta_wcs
Expand All @@ -657,7 +658,35 @@ def wcs_drizzle_product(self, meta_wcs):
)
)

edp_filenames = [element.full_filename for element in self.edp_list]
# Determine if there are any single exposure filter images which
# should NOT be used in the computation of the total detection image in
# order to minimize cosmic ray contamination
#
# Loop over the exposure objects to collect the exposures for each filter
count_dict = {}
for expo in self.edp_list:
count_dict.setdefault(expo.filters, []).append(expo.full_filename)

# Accumulate the exposure file names for only the filters which have
# more than one exposure
exclude_string = []
edp_filenames = []
for key, value in count_dict.items():
if len(value) > 1:
edp_filenames += value
else:
exclude_string.append("Excluding single exposure filter image {} for {}.".format(value, key))

# However, if all the filters only have one exposure, just use all
# the exposures
if not edp_filenames:
for value in count_dict.values():
edp_filenames += value
log.info("All filters are single exposures, so all exposures are included.")
else:
for entry in exclude_string:
log.info(entry)

astrodrizzle.AstroDrizzle(
input=edp_filenames, output=self.drizzle_filename, **drizzle_pars
)
Expand Down Expand Up @@ -803,7 +832,7 @@ def wcs_drizzle_product(self, meta_wcs):
)

edp_filenames = [element.full_filename for element in self.edp_list]

if len(edp_filenames) == 1:
drizzle_pars["resetbits"] = "0" # Use any pixels already flagged as CRs

Expand Down

0 comments on commit 8fc110f

Please sign in to comment.