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

DM-38029: Fix PTC errors and warnings when there is a NaN input flat pair. #173

Merged
merged 4 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/lsst/cp/pipe/ptc/cpExtractPtcTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ def run(self, inputExp, inputDims, taskMetadata):

if self.config.numEdgeSuspect > 0:
isrTask = IsrTask()
self.log.info("Masking %d pixels from the edges of all exposures as SUSPECT.",
self.config.numEdgeSuspect)
self.log.info("Masking %d pixels from the edges of all %ss as SUSPECT.",
self.config.numEdgeSuspect, self.config.edgeMaskLevel)

# Depending on the value of config.matchExposuresType
# 'expTime' can stand for exposure time, flux, or ID.
Expand Down Expand Up @@ -820,7 +820,7 @@ def getReadNoiseFromMetadata(self, taskMetadata, ampName):
readNoises.append(overscanNoise)

if len(readNoises):
readNoise = np.median(np.array(readNoises))
readNoise = np.nanmedian(np.array(readNoises))
else:
self.log.warning("Median readout noise from ISR metadata for amp %s "
"could not be calculated." % ampName)
Expand Down
3 changes: 3 additions & 0 deletions python/lsst/cp/pipe/ptc/cpSolvePtcTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ def _getInitialGoodPoints(means, variances, minVarPivotSearch, consecutivePoints
goodPoints[pivotIndex+1:] = False
break

# Finally, we filter out any infinities or NaNs.
goodPoints[(~np.isfinite(means)) | (~np.isfinite(variances))] = False

return goodPoints

def _makeZeroSafe(self, array, substituteValue=1e-9):
Expand Down
7 changes: 7 additions & 0 deletions tests/test_ptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ def test_covAstier(self):

resultsExtract = extractTask.run(inputExp=expDict, inputDims=expIds,
taskMetadata=[self.metadataContents])

# Force the last PTC dataset to have a NaN, and ensure that the
# task runs (DM-38029). This is a minor perturbation and does not
# affect the output comparison.
resultsExtract.outputCovariances[-2].rawMeans['C:0,0'] = [np.nan]
resultsExtract.outputCovariances[-2].rawVars['C:0,0'] = [np.nan]

resultsSolve = solveTask.run(resultsExtract.outputCovariances,
camera=FakeCamera([self.flatExp1.getDetector()]))

Expand Down