Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/lsst/ip/diffim/subtractImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from astropy import units as u
from astropy.stats import gaussian_fwhm_to_sigma
import numpy as np

import lsst.afw.detection as afwDetection
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions python/lsst/ip/diffim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_subtractTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utilsCalculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from astropy.stats import gaussian_sigma_to_fwhm
import numpy as np

import lsst.geom
Expand All @@ -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)

Expand Down
Loading