Skip to content

Commit

Permalink
Fix crashes when FLUX keyword is not set in header.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Dec 7, 2023
1 parent 2f39c65 commit 4345504
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion python/lsst/cp/pipe/ptc/cpExtractPtcTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,11 @@ def run(self, inputExp, inputDims, taskMetadata, inputPhotodiodeData=None):
# 'expTime' can stand for exposure time, flux, or ID.
for expTime in inputExp:
exposures = inputExp[expTime]
if len(exposures) == 1:
if not np.isfinite(expTime):
self.log.warning("Illegal/missing %s found (%f). Dropping exposure %d",
self.config.matchExposuresType, expTime, exposures[0][1])
continue
elif len(exposures) == 1:
self.log.warning("Only one exposure found at %s %f. Dropping exposure %d.",
self.config.matchExposuresType, expTime, exposures[0][1])
continue
Expand Down
9 changes: 8 additions & 1 deletion python/lsst/cp/pipe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,14 @@ def arrangeFlatsByExpFlux(exposureList, exposureIdList, fluxKeyword):
assert len(exposureList) == len(exposureIdList), "Different lengths for exp. list and exp. ID lists"
for expRef, expId in zip(exposureList, exposureIdList):
# Get flux from header, assuming it is in the metadata.
expFlux = expRef.get().getMetadata()[fluxKeyword]
try:
expFlux = expRef.get().getMetadata()[fluxKeyword]
except KeyError:
# If it's missing from the header, continue; it will
# be caught and rejected when pairing exposures.
expFlux = None
if expFlux is None:
expFlux = np.nan
listAtExpFlux = flatsAtExpFlux.setdefault(expFlux, [])
listAtExpFlux.append((expRef, expId))

Expand Down

0 comments on commit 4345504

Please sign in to comment.