diff --git a/python/lsst/ip/diffim/subtractImages.py b/python/lsst/ip/diffim/subtractImages.py
index 073bb78c..2cebb25c 100644
--- a/python/lsst/ip/diffim/subtractImages.py
+++ b/python/lsst/ip/diffim/subtractImages.py
@@ -20,6 +20,7 @@
# along with this program. If not, see .
from astropy import units as u
+from astropy.stats import gaussian_fwhm_to_sigma
import numpy as np
import lsst.afw.detection as afwDetection
@@ -612,10 +613,9 @@ def runKernelSourceDetection(self, template, science):
"""
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)
+ sigma=gaussian_fwhm_to_sigma*self.sciencePsfSize)
sources = self.makeKernel.selectKernelSources(template, science,
candidateList=candidateList,
preconvolved=False,
diff --git a/python/lsst/ip/diffim/utils.py b/python/lsst/ip/diffim/utils.py
index dc8d28fc..c7bc12b3 100644
--- a/python/lsst/ip/diffim/utils.py
+++ b/python/lsst/ip/diffim/utils.py
@@ -27,13 +27,16 @@
]
import itertools
-import numpy as np
import os
import requests
-import lsst.geom as geom
+
+from astropy.stats import gaussian_sigma_to_fwhm
+import numpy as np
+
import lsst.afw.detection as afwDetection
import lsst.afw.image as afwImage
import lsst.afw.math as afwMath
+import lsst.geom as geom
from lsst.pex.exceptions import InvalidParameterError, RangeError
import lsst.pipe.base
from lsst.utils.logging import getLogger
@@ -129,12 +132,12 @@ def getPsfFwhm(psf, average=True, position=None):
if position is None:
position = psf.getAveragePosition()
shape = psf.computeShape(position)
- sigmaToFwhm = 2*np.log(2*np.sqrt(2))
if average:
- return sigmaToFwhm*shape.getTraceRadius()
+ return gaussian_sigma_to_fwhm*shape.getTraceRadius()
else:
- return [sigmaToFwhm*np.sqrt(shape.getIxx()), sigmaToFwhm*np.sqrt(shape.getIyy())]
+ return [gaussian_sigma_to_fwhm*np.sqrt(shape.getIxx()),
+ gaussian_sigma_to_fwhm*np.sqrt(shape.getIyy())]
def evaluateMeanPsfFwhm(exposure: afwImage.Exposure,
diff --git a/tests/test_subtractTask.py b/tests/test_subtractTask.py
index 9052f719..dbf31271 100644
--- a/tests/test_subtractTask.py
+++ b/tests/test_subtractTask.py
@@ -980,7 +980,7 @@ def test_metadata_metrics(self):
self.assertTrue(np.isnan(maglim_template_offimage))
# Test that given the provided fallbackPsfSize, the diffim limiting
# magnitude is calculated correctly.
- maglim_template_offimage = 28.3173123103493
+ maglim_template_offimage = 28.182284789714952
fluxlim_template_offimage = (maglim_template_offimage*u.ABmag).to_value(u.nJy)
maglim_offimage = (np.sqrt(fluxlim_science**2 + fluxlim_template_offimage**2)*u.nJy).to(u.ABmag).value
self.assertEqual(subtractTask_offimage.metadata['diffimLimitingMagnitude'], maglim_offimage)
diff --git a/tests/test_utilsCalculations.py b/tests/test_utilsCalculations.py
index b9be3a8d..d41320ea 100644
--- a/tests/test_utilsCalculations.py
+++ b/tests/test_utilsCalculations.py
@@ -19,6 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+from astropy.stats import gaussian_sigma_to_fwhm
import numpy as np
import lsst.geom
@@ -45,13 +46,12 @@ def test_angleMean(self):
def test_getPsfFwhm(self):
"""Calculation of FWHM from a realization of the PSF
"""
- sigmaToFwhm = 2*np.log(2*np.sqrt(2))
def make_and_check_psf(xKsize, yKsize, sigma):
psf = measAlg.SingleGaussianPsf(xKsize, yKsize, sigma)
psfSize = getPsfFwhm(psf)
psfSize2d = getPsfFwhm(psf, average=False)
- self.assertFloatsAlmostEqual(sigma*sigmaToFwhm, psfSize, rtol=0.01)
+ self.assertFloatsAlmostEqual(gaussian_sigma_to_fwhm*sigma, psfSize, rtol=0.01)
self.assertFloatsAlmostEqual(psfSize, psfSize2d[0], rtol=0.01)
self.assertFloatsAlmostEqual(psfSize, psfSize2d[1], rtol=0.01)