Skip to content

Commit

Permalink
SVM: Reconcile removal of bad segments from segmentation image with r…
Browse files Browse the repository at this point in the history
…emoval of corresponding rows from the "total" or white light source catalog (#1771)
  • Loading branch information
mdlpstsci authored Mar 22, 2024
1 parent 7cfa680 commit eb89067
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
13 changes: 7 additions & 6 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ number of the code change for that issue. These PRs can be viewed at:



3.7.1 (unreleased)
=====================
3.7.0rc2 (22-Mar-2024) Infrastructure Build
===========================================

- Force the identified bad rows to be removed from the total (aka white light)
source catalog before the corresponding bad segments are removed from the
segmentation image. [#1771]

- Reverted PR #1222 allowing pixels to be filled with available data where WHT=0. [#1767]

- Improved calculation of S_REGION using dialation and erosion. [#1762]

- Skycell added to flt(c) and drz(c) science headers for the pipeline and svm products. [#1729]


3.7.0rc1 (22-Feb-2024) Infrastructure Build
===========================================

- Update project.toml file to specify numpy>=1.18, <2.0 [#1743]

- Update project.toml file to specify python_requires>=3.10 [#1737]
Expand Down Expand Up @@ -61,6 +61,7 @@ number of the code change for that issue. These PRs can be viewed at:
- Initial setup for Architectural Design Records used to keep track of top-level
thinking behind the code. [#1697]


3.6.2 (27-Nov-2023)
===================

Expand Down
16 changes: 6 additions & 10 deletions drizzlepac/haputils/catalog_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This script contains code to support creation of photometric sourcelists using two techniques:
aperture photometry and segmentation-map based photometry."""

import copy
import math
import sys
Expand Down Expand Up @@ -1874,20 +1873,13 @@ def identify_sources(self, **pars):
# the segmentation image too
good_rows = []
good_segm_rows_by_label = []
bad_segm_rows_by_label = []
updated_table = None
for i, old_row in enumerate(total_measurements_table):
if np.isfinite(old_row["xcentroid"]):
good_rows.append(old_row)
good_segm_rows_by_label.append(total_measurements_table['label'][i])
else:
bad_segm_rows_by_label.append(total_measurements_table['label'][i])
updated_table = Table(rows=good_rows, names=total_measurements_table.colnames)
if self.diagnostic_mode and bad_segm_rows_by_label:
log.info("Bad segments removed from segmentation image for Total detection image {}.".format(self.imgname))

# Remove the bad segments from the image
self.segm_img.remove_labels(bad_segm_rows_by_label, relabel=True)
updated_table = Table(rows=good_rows, names=total_measurements_table.colnames)

# Need to keep an updated copy of the total image SourceCatalog object for use when
# making measurements in the filtered images
Expand All @@ -1901,7 +1893,11 @@ def identify_sources(self, **pars):
# (create_catalog_products()). This is the way the independent catalogs of total and filter products
# process the same segmentation image.
# BEWARE: self.sources for "segmentation" is a SegmentationImage, but for "point" it is an Astropy table
self.sources = copy.deepcopy(self.segm_img)
# Keep only the good segments from the image
self.segm_img.keep_labels(good_segm_rows_by_label, relabel=True)

# Make a deep copy of the total "white light" segmentation image
self.sources = self.segm_img.copy()

log.info("Done identifying sources in total detection image for the segmentation catalog.")
log.info("")
Expand Down

0 comments on commit eb89067

Please sign in to comment.