I was trying to do PSF matching of image cutouts that I made for HSC coadd images but I encountered some error message:
python modelPsfMatchTask.py --template 'stamp-i.fits' --science 'stamp-y.fits’
The error message.
psfMatch INFO: compute Psf-matching kernel
Traceback (most recent call last):
File "modelPsfMatchTask.py", line 160, in <module>
run(args)
File "modelPsfMatchTask.py", line 130, in run
result = psfMatchTask.run(templateExp, scienceExp)
File "modelPsfMatchTask.py", line 45, in run
return ModelPsfMatchTask.run(self, scienceExp, templateExp.getPsf())
File "/Users/aisun/anaconda/envs/lsst/opt/lsst/pipe_base/python/lsst/pipe/base/timer.py", line 121, in wrapper
res = func(self, *args, **keyArgs)
File "/Users/aisun/anaconda/envs/lsst/opt/lsst/ip_diffim/python/lsst/ip/diffim/modelPsfMatch.py", line 278, in run
psfAttr1 = measAlg.PsfAttributes(exposure.getPsf(), width//2, height//2)
File "/Users/aisun/anaconda/envs/lsst/opt/lsst/meas_algorithms/python/lsst/meas/algorithms/algorithmsLib.py", line 788, in __init__
this = _algorithmsLib.new_PsfAttributes(*args)
lsst.pex.exceptions.wrappers.InvalidParameterError:
File "src/CoaddPsf.cc", line 259, in virtual std::shared_ptr<afw::detection::Psf::Image> lsst::meas::algorithms::CoaddPsf::doComputeKernelImage(const afw::geom::Point2D &, const afw::image::Color &) const
Cannot compute CoaddPsf at point (21, 21); no input images at that point. {0}
lsst::pex::exceptions::InvalidParameterError: 'Cannot compute CoaddPsf at point (21, 21); no input images at that point.'
This is how I make the image cutouts:
import lsst.afw.image as afwImage
import lsst.afw.coord as afwCoord
import lsst.afw.geom as afwGeom
def make_cutout(exp, ra, dec, npix=128):
"""
Params
------
exp (afwImage.ExposureF object)
ra (float)
dec (float)
npix=128 (int)
"""
lsstwcs = exp.getWcs()
pointCoord = afwCoord.IcrsCoord(afwGeom.Angle(ra, afwGeom.degrees), afwGeom.Angle(dec, afwGeom.degrees))
x, y = lsstwcs.skyToPixel(pointCoord)
corner = afwGeom.Point2I(int(x - npix // 2), int(y - npix // 2))
bbox = afwGeom.Box2I(afwGeom.Point2I(corner), afwGeom.Extent2I(npix, npix))
stamp = exp.Factory(exp, bbox, afwImage.PARENT, False)
return stamp
It might be that the xy0 of the image cutouts is different from what the psfmatching task expects. Could someone point out how could one fix this? Any suggestion is greatly appreciated.