Skip to content

Commit

Permalink
Pass PSF sigma in to fallback source detector.
Browse files Browse the repository at this point in the history
This is necessary in rare cases when convolving the template if building the kernel fails, and the fallback source detector attempts to calculate the template PSF at a chip gap.
  • Loading branch information
isullivan committed Nov 28, 2024
1 parent 32906f2 commit d50a149
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/lsst/ip/diffim/makeKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def getSelectSources(self, exposure, sigma=None, doSmooth=True, idFactory=None):
return selectSources

def makeCandidateList(self, convolved, reference, kernelSize,
candidateList, preconvolved=False):
candidateList, preconvolved=False, sigma=None):
"""Make a list of acceptable KernelCandidates.
Generate a list of candidate sources for Psf-matching, remove sources
Expand Down Expand Up @@ -309,7 +309,7 @@ def makeCandidateList(self, convolved, reference, kernelSize,
If ``candidateList`` is empty after sub-selection.
"""
if candidateList is None:
candidateList = self.getSelectSources(reference, doSmooth=not preconvolved)
candidateList = self.getSelectSources(reference, doSmooth=not preconvolved, sigma=sigma)
if len(candidateList) < 1:
raise RuntimeError("No kernel candidates after detection and measurement.")

Expand Down
8 changes: 7 additions & 1 deletion python/lsst/ip/diffim/subtractImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,14 @@ def runConvolveTemplate(self, template, science, selectSources):
if self.config.allowKernelSourceDetection:
self.log.warning("Error encountered trying to construct the matching kernel"
f" Running source detection and retrying. {e}")
kernelSize = self.makeKernel.makeKernelBasisList(
self.templatePsfSize, self.sciencePsfSize)[0].getWidth()
sigmaToFwhm = 2*np.log(2*np.sqrt(2))
candidateList = self.makeKernel.makeCandidateList(template, science, kernelSize,
candidateList=None,
sigma=self.sciencePsfSize/sigmaToFwhm)
kernelSources = self.makeKernel.selectKernelSources(template, science,
candidateList=None,
candidateList=candidateList,
preconvolved=False)
kernelResult = self.makeKernel.run(template, science, kernelSources,
preconvolved=False)
Expand Down

0 comments on commit d50a149

Please sign in to comment.