Skip to content

Commit

Permalink
DM-42776: Add star count number to the metadata of bright star stamps…
Browse files Browse the repository at this point in the history
… and extended PSF models
  • Loading branch information
bazkiaei committed Feb 4, 2024
1 parent 410a08b commit 838865a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/lsst/pipe/tasks/extended_psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,15 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
"No detector groups were provided to MeasureExtendedPsfTask; computing a single, "
"constant extended PSF model over all available observations."
)
self.metadata["psfStarCount"] = 0
for brightStarStamps in bss_ref_list:
stamps = brightStarStamps.get()
self.metadata["psfStarCount"] += len(stamps)
output_e_psf = ExtendedPsf(self.stack_bright_stars.run(bss_ref_list))
else:
output_e_psf = ExtendedPsf()
region_ref_list = self.select_detector_refs(bss_ref_list)
self.metadata["psfStarCount"] = {}
for region_name, ref_list in region_ref_list.items():
if not ref_list:
# no valid references found
Expand All @@ -566,6 +571,10 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
region_name,
)
continue
self.metadata["psfStarCount"][region_name] = 0
for brightStarStamps in ref_list:
stamps = brightStarStamps.get()
self.metadata["psfStarCount"][region_name] += len(stamps)
ext_psf = self.stack_bright_stars.run(ref_list, region_name)
output_e_psf.add_regional_extended_psf(
ext_psf, region_name, self.detectors_focal_plane_regions[region_name]
Expand Down
8 changes: 8 additions & 0 deletions python/lsst/pipe/tasks/processBrightStars.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ def run(self, inputExposure, refObjLoader=None, dataId=None, skyCorr=None):
badMaskPlanes=self.config.badMaskPlanes,
discardNanFluxObjects=(self.config.discardNanFluxStars),
)
# Store the count number of valid stars that overlap the exposure.
self.metadata["validStarCount"] = len(brightStarStamps)
# Do not create empty FITS files if there aren't any normalized stamps.
if not brightStarStamps._stamps:
self.log.info("No normalized stamps exist for this exposure.")
Expand Down Expand Up @@ -402,6 +404,12 @@ def extractStamps(
refCatBright.remove_rows(badRows)
gMags = list(refCatBright["mag"][:])
ids = list(refCatBright["id"][:])

# Store the count number of all stars (within the given magnitude
# range) that overlap the exposure.
# TODO: Make sure self._getCutout only misses stars that don't have any
# valid pixel overlapped with the exposure.
self.metadata["allStarCount"] = len(starStamps)
return Struct(starStamps=starStamps, pixCenters=pixCenters, gMags=gMags, gaiaIds=ids)

def _getCutout(self, inputExposure, coordPix: Point2D, stampSize: list[int]):
Expand Down

0 comments on commit 838865a

Please sign in to comment.