diff --git a/python/lsst/ip/diffim/makeKernel.py b/python/lsst/ip/diffim/makeKernel.py index b5457b68..46dc47c6 100644 --- a/python/lsst/ip/diffim/makeKernel.py +++ b/python/lsst/ip/diffim/makeKernel.py @@ -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 @@ -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.") diff --git a/python/lsst/ip/diffim/subtractImages.py b/python/lsst/ip/diffim/subtractImages.py index 8ef55938..8cf0f76b 100644 --- a/python/lsst/ip/diffim/subtractImages.py +++ b/python/lsst/ip/diffim/subtractImages.py @@ -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)