Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions python/lsst/meas/algorithms/dynamicDetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,33 +510,37 @@ def detectFootprints(self, exposure, doSmooth=True, sigma=None, clearMask=True,
self.applyTempLocalBackground(exposure, middle, results)
self.finalizeFootprints(maskedImage.mask, results, sigma, factor=factor,
growOverride=growOverride)
self.log.warning("nPeaks/nFootprint = %.2f (max is %.1f)",
results.numPosPeaks/results.numPos,
self.config.maxPeakToFootRatio)
if results.numPosPeaks/results.numPos > self.config.maxPeakToFootRatio:
if results.numPosPeaks/results.numPos > 3*self.config.maxPeakToFootRatio:
factor *= 1.4
else:
factor *= 1.2
if factor > 2.0:
if growOverride is None:
growOverride = 0.75*self.config.nSigmaToGrow
if results.numPos == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catch is fine here but I'm pretty worried about this creating an infinite loop, e.g. if we accidentally get an image of the inside of the dome and no stars. Is there a good way to guarantee this doesn't get stuck?

Secondarily, maybe if the number of footprints is extremely low but not zero, we're better off just punting rather than trying to chase it by adjusting the detection threshold factor? (like, if we have two footprints, is that image really salvageable?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you point out in the ticket, I'll change this to just bail out instead of trying to adapt to what is likely to be a lost cause...

msg = "No footprints were detected, so further processing would be moot"
raise NoWorkFound(msg)
else:
self.log.warning("nPeaks/nFootprint = %.2f (max is %.1f)",
results.numPosPeaks/results.numPos,
self.config.maxPeakToFootRatio)
if results.numPosPeaks/results.numPos > self.config.maxPeakToFootRatio:
if results.numPosPeaks/results.numPos > 3*self.config.maxPeakToFootRatio:
factor *= 1.4
else:
factor *= 1.2
if factor > 2.0:
if growOverride is None:
growOverride = 0.75*self.config.nSigmaToGrow
else:
growOverride *= 0.75
self.log.warning("Decreasing nSigmaToGrow to %.2f", growOverride)
if factor >= 5:
self.log.warning("New theshold value would be > 5 times the initially requested "
"one (%.2f > %.2f). Leaving inFinalize iteration without "
"getting the number of peaks per footprint below %.1f",
factor*self.config.thresholdValue, self.config.thresholdValue,
self.config.maxPeakToFootRatio)
inFinalize = False
else:
growOverride *= 0.75
self.log.warning("Decreasing nSigmaToGrow to %.2f", growOverride)
if factor >= 5:
self.log.warning("New theshold value would be > 5 times the initially requested "
"one (%.2f > %.2f). Leaving inFinalize iteration without "
"getting the number of peaks per footprint below %.1f",
factor*self.config.thresholdValue, self.config.thresholdValue,
self.config.maxPeakToFootRatio)
inFinalize = False
else:
inFinalize = True
self.log.warning("numPosPeaks/numPos (%d) > maxPeakPerFootprint (%.1f). "
"Increasing threshold factor to %.2f and re-running,",
results.numPosPeaks/results.numPos, self.config.maxPeakToFootRatio,
factor)
inFinalize = True
self.log.warning("numPosPeaks/numPos (%d) > maxPeakPerFootprint (%.1f). "
"Increasing threshold factor to %.2f and re-running,",
results.numPosPeaks/results.numPos,
self.config.maxPeakToFootRatio, factor)

self.clearUnwantedResults(maskedImage.mask, results)

Expand Down