Providing a bit of context for John's comments: We pair-coded on this today for a bit. We reconfigured Piff to use a 25-pixel kernelSize (via DM-34531). Unfortunately this did not resolve the "fake metrics are zero" problem, and in fact the pipeline failed to complete: it fails with the errors below:
{{ File "/software/lsstsw/stack_20220421/stack/miniconda3-py38_4.9.2-3.0.0/Linux64/meas_algorithms/gf36ae6ace1+1d7ae49801/python/lsst/meas/algorithms/detection.py", line 688, in detectFootprints
psf = self.getPsf(exposure, sigma=sigma)
File "/software/lsstsw/stack_20220421/stack/miniconda3-py38_4.9.2-3.0.0/Linux64/meas_algorithms/gf36ae6ace1+1d7ae49801/python/lsst/meas/algorithms/detection.py", line 411, in getPsf
size = self.calculateKernelSize(sigma)
File "/software/lsstsw/stack_20220421/stack/miniconda3-py38_4.9.2-3.0.0/Linux64/meas_algorithms/gf36ae6ace1+1d7ae49801/python/lsst/meas/algorithms/detection.py", line 386, in calculateKernelSize
return (int(sigma * self.config.nSigmaForKernel + 0.5)//2)*2 + 1 # make sure it is odd
ValueError: cannot convert float NaN to integer}}
As John mentions, this could have been caught earlier: characterizeImage logs
lsst.characterizeImage INFO: iter 1; PSF sigma=nan, dimensions=(25, 25); median background=770.85
so we should notice and catch when the PSF is providing NaNs.
This is one of several places where the Piff log levels should be adjusted;
lsst.characterizeImage.measurePsf.psfDeterminer INFO: Ill-conditioned matrix (rcond=2.40177e-26): result may not be accurate. might be more severe than INFO?
and lsst.characterizeImage.measurePsf.psfDeterminer gives WARN for total chi-squared and the start of each fitting iteration.
Joshua Meyers and I worked on this a bit in pair coding today. A potential source of the problem is that Piff PSF stamps are smaller (21x21 pixels) than PSFEx. insertFakes.py uses a default calibFluxRadius=12.0, and psf.computeApertureFlux will silently return NaN values when the radius is larger than than the stamp size (which is the case now). In turn the inserted fake magnitudes are likely to be NaN, which would explain why the fakes metrics do not find them. A workaround would be to use a ten-pixel radius by default, but we should also add some additional logging.