When extracting the psf (lsst.afw.detection.detectionLib.Psf) as an image (Psf.computeImage().getArray()) in each band for a set of calexps (lsst.afw.image.imageLib.ExposureF), while the calexps are spatially aligned, the psf images are not (and in fact they are often different sizes). This is an issue when trying to use the new deblender that operates on de-convolved templates, resulting in color gradients that do not exist.
The dirty way to fix this is to calculate the maximum pixel in each psf image and project them onto a common image, trimming the pixels in each psf outside of the common psf image. But I don’t know enough about how the psfs are generated in the first place, and what invalid assumptions I might be making while implementing this procedure. So I was wondering if there is a more mathematically rigorous solution (that ideally is implemented in the code already!). Does anyone know of such a thing?
I don’t understand why they are not spatially aligned – the computeImage() method takes a PointD and if the centroids are aligned so should be the PSFs. If you mean that they are not aligned to the pixel grid, then round all pixel coordinates to int. The sizes is more of a pain, but find the largest and pad.
You can use computeKernelImage(pos) to give you the PSF centered on the center of the pixel which is appropriate for convolution. I also don’t know why you couldn’t trim the PSF image by a few pixels given that we use a large box size of 41x41 before warping.
I agree that this is a nuisance as opposed to a real problem, but @swinbank suggested that there might be something already built in the stack to do this, and if not a ticket should probably be created to add this functionality to afw since these seems like something that would be useful to other people to have too.
I also wanted to make sure that I wasn’t overlooking something, so that if (for example) a difference in psf peak position was reflecting a chromatic aberration present in the stacks then when I recenter the psf based on the position of the peak it would cause a color gradient in the model.