Skip to content

Commit

Permalink
Supply position for psf shape computations
Browse files Browse the repository at this point in the history
  • Loading branch information
isullivan committed Nov 15, 2021
1 parent 0fe4319 commit c044b75
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
3 changes: 2 additions & 1 deletion python/lsst/pipe/tasks/assembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,8 @@ def assembleMetadata(self, coaddExposure, tempExpRefList, weightList):
# Likewise, set the PSF of a PSF-Matched Coadd to the modelPsf
# having the maximum width (sufficient because square)
modelPsfList = [tempExp.getPsf() for tempExp in tempExpList]
modelPsfWidthList = [modelPsf.computeBBox().getWidth() for modelPsf in modelPsfList]
modelPsfWidthList = [modelPsf.computeBBox(modelPsf.getAveragePosition()).getWidth()
for modelPsf in modelPsfList]
psf = modelPsfList[modelPsfWidthList.index(max(modelPsfWidthList))]
else:
psf = measAlg.CoaddPsf(coaddInputs.ccds, coaddExposure.getWcs(),
Expand Down
6 changes: 4 additions & 2 deletions python/lsst/pipe/tasks/characterizeImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,10 @@ def run(self, exposure, exposureIdInfo=None, background=None):
)

psf = dmeRes.exposure.getPsf()
psfSigma = psf.computeShape().getDeterminantRadius()
psfDimensions = psf.computeImage().getDimensions()
# Just need a rough estimate; average positions are fine
psfAvgPos = psf.getAveragePosition()
psfSigma = psf.computeShape(psfAvgPos).getDeterminantRadius()
psfDimensions = psf.computeImage(psfAvgPos).getDimensions()
medBackground = np.median(dmeRes.background.getImage().getArray())
self.log.info("iter %s; PSF sigma=%0.2f, dimensions=%s; median background=%0.2f",
i + 1, psfSigma, psfDimensions, medBackground)
Expand Down
12 changes: 9 additions & 3 deletions python/lsst/pipe/tasks/dcrAssembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,9 @@ def prepareDcrInputs(self, templateCoadd, warpRefList, weightList):
visitInfo = warpExpRef.get(tempExpName + "_visitInfo")
psf = warpExpRef.get(tempExpName).getPsf()
visit = warpExpRef.dataId["visit"]
psfSize = psf.computeShape().getDeterminantRadius()*sigma2fwhm
# Just need a rough estimate; average positions are fine
psfAvgPos = psf.getAveragePosition()
psfSize = psf.computeShape(psfAvgPos).getDeterminantRadius()*sigma2fwhm
airmass = visitInfo.getBoresightAirmass()
parallacticAngle = visitInfo.getBoresightParAngle().asDegrees()
airmassDict[visit] = airmass
Expand Down Expand Up @@ -1319,7 +1321,10 @@ def selectCoaddPsf(self, templateCoadd, warpRefList):
# Note: ``ccds`` is a `lsst.afw.table.ExposureCatalog` with one entry per ccd and per visit
# If there are multiple ccds, it will have that many times more elements than ``warpExpRef``
ccds = templateCoadd.getInfo().getCoaddInputs().ccds
psfRefSize = templateCoadd.getPsf().computeShape().getDeterminantRadius()*sigma2fwhm
templatePsf = templateCoadd.getPsf()
# Just need a rough estimate; average positions are fine
tempalteAvgPos = templatePsf.getAveragePosition()
psfRefSize = templatePsf.computeShape(tempalteAvgPos).getDeterminantRadius()*sigma2fwhm
psfSizes = np.zeros(len(ccds))
ccdVisits = np.array(ccds["visit"])
for warpExpRef in warpRefList:
Expand All @@ -1330,7 +1335,8 @@ def selectCoaddPsf(self, templateCoadd, warpRefList):
# Gen 2 API. Delete this when Gen 2 retired
psf = warpExpRef.get(tempExpName).getPsf()
visit = warpExpRef.dataId["visit"]
psfSize = psf.computeShape().getDeterminantRadius()*sigma2fwhm
psfAvgPos = psf.getAveragePosition()
psfSize = psf.computeShape(psfAvgPos).getDeterminantRadius()*sigma2fwhm
psfSizes[ccdVisits == visit] = psfSize
# Note that the input PSFs include DCR, which should be absent from the DcrCoadd
# The selected PSFs are those that have a FWHM less than or equal to the smaller
Expand Down
4 changes: 3 additions & 1 deletion python/lsst/pipe/tasks/selectImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,9 @@ def runDataRef(self, dataRef, coordList, makeDataRefList=True,

# if min/max PSF values are defined, remove images out of bounds
pixToArcseconds = cal.getWcs().getPixelScale().asArcseconds()
psfSize = cal.getPsf().computeShape().getDeterminantRadius()*pixToArcseconds
# Just need a rough estimate; average positions are fine
psfAvgPos = cal.getPsf().getAveragePosition()
psfSize = cal.getPsf().computeShape(psfAvgPos).getDeterminantRadius()*pixToArcseconds
sizeFwhm = psfSize * np.sqrt(8.*np.log(2.))
if self.config.maxPsfFwhm and sizeFwhm > self.config.maxPsfFwhm:
continue
Expand Down
3 changes: 2 additions & 1 deletion tests/surveyPropertyMapsTestUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ def makeMockVisitSummary(visit,
# Generate a PSF and set values accordingly
psf = GaussianPsf(15, 15, psf_sigma)
row.setPsf(psf)
shape = psf.computeShape()
psfAvgPos = psf.getAveragePosition()
shape = psf.computeShape(psfAvgPos)
row['psfSigma'] = psf.getSigma()
row['psfIxx'] = shape.getIxx()
row['psfIyy'] = shape.getIyy()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_coaddInputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def tearDown(self):
del self.exposures

def assertPsfsAlmostEqual(self, psf1, psf2):
im1 = psf1.computeImage()
im2 = psf2.computeImage()
im1 = psf1.computeImage(psf1.getAveragePosition())
im2 = psf2.computeImage(psf2.getAveragePosition())
self.assertImagesAlmostEqual(im1, im2)

def getCoaddPath(self, version):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_processCcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def testProcessCcd(self):

summary = exposure.getInfo().getSummaryStats()

psfShape = exposure.getPsf().computeShape()
psf = exposure.getPsf()
psfAvgPos = psf.getAveragePosition()
psfShape = psf.computeShape(psfAvgPos)
psfIxx = psfShape.getIxx()
psfIyy = psfShape.getIyy()
psfIxy = psfShape.getIxy()
Expand Down

0 comments on commit c044b75

Please sign in to comment.