Project: datamanagement
Issue DM-4743: Make deblender more robust against weird PSF dimensions
[~boutigny] reports two problems with PSF dimension calculations in the deblender that result in fatal errors, because earlier checks for bad dimensions intended to cause more graceful failures are incomplete. The first appears to happen when the PSF dimensions are highly non-square, and the image width is smaller than 1.5x FWHM while the image height is more than 1.5x FWHM (or the opposite). {code:hide-linenum} measureCoaddSources FATAL: Failed on dataId={'filter': 'i', 'tract': 1, 'patch': '8,2'}:   File "src/image/Image.cc", line 92, in static typename lsst::afw::image::ImageBase::_view_t lsst::afw: :image::ImageBase::_makeSubView(const lsst::afw::geom::Extent2I&, const lsst::afw::geom::Extent2I&, cons t typename lsst::afw::image::detail::types_traits::view_t&) [with PixelT = double]     Box2I(Point2I(-2,2),Extent2I(11,11)) doesn't fit in image 7x15 {0} lsst::pex::exceptions::LengthError: 'Box2I(Point2I(-2,2),Extent2I(11,11)) doesn't fit in image 7x15' Traceback (most recent call last):   File "/sps/lsst/Library/lsstsw/stack/Linux64/pipe_base/2015_10.0-3-g24e103a/python/lsst/pipe/base/cmdLineTask.py", line 321, in __call__     result = task.run(dataRef, **kwargs)   File "/sps/lsst/dev/lsstprod/clusters/my_packages/pipe_tasks/python/lsst/pipe/tasks/multiBand.py", line 552, in run     self.deblend.run(exposure, sources, exposure.getPsf())   File "/sps/lsst/Library/lsstsw/stack/Linux64/pipe_base/2015_10.0-3-g24e103a/python/lsst/pipe/base/timer.py", line 118, in wrapper     res = func(self, *args, **keyArgs)   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/deblend.py", line 231, in run     self.deblend(exposure, sources, psf)   File "/sps/lsst/Library/lsstsw/stack/Linux64/pipe_base/2015_10.0-3-g24e103a/python/lsst/pipe/base/timer.py", line 118, in wrapper     res = func(self, *args, **keyArgs)   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/deblend.py", line 308, in deblend     clipStrayFluxFraction=self.config.clipStrayFluxFraction,   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/baseline.py", line 354, in deblend     psf, pk, sigma1, patchEdges)   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/baseline.py", line 1073, in _handle_flux_at_edge     psfim = psfim.Factory(psfim, Sbox, afwImage.PARENT, True)   File "/sps/lsst/Library/lsstsw/stack/Linux64/afw/2015_10.0-8-g4057726/python/lsst/afw/image/imageLib.py", line 4630, in Factory     return ImageD(*args)   File "/sps/lsst/Library/lsstsw/stack/Linux64/afw/2015_10.0-8-g4057726/python/lsst/afw/image/imageLib.py", line 4472, in __init__     this = _imageLib.new_ImageD(*args) LengthError:   File "src/image/Image.cc", line 92, in static typename lsst::afw::image::ImageBase::_view_t lsst::afw::image::ImageBase::_makeSubView(const lsst::afw::geom::Extent2I&, const lsst::afw::geom::Extent2I&, const typename lsst::afw::image::detail::types_traits::view_t&) [with PixelT = double]     Box2I(Point2I(-2,2),Extent2I(11,11)) doesn't fit in image 7x15 {0} lsst::pex::exceptions::LengthError: 'Box2I(Point2I(-2,2),Extent2I(11,11)) doesn't fit in image 7x15' {code} The second problem may occur when the overlap region between a PSF image and the data image it corresponds to is only 1 pixel in either dimension. In any case, there's a gap in the graceful-failure logic that could let such a problem through, which would result in received error message: {code:hide-linenum} measureCoaddSources FATAL: Failed on dataId={'filter': 'i', 'tract': 1, 'patch': '8,1'}: Traceback (most recent call last):   File "/sps/lsst/Library/lsstsw/stack/Linux64/pipe_base/2015_10.0-3-g24e103a/python/lsst/pipe/base/cmdLineTask. py", line 321, in __call__     result = task.run(dataRef, **kwargs)   File "/sps/lsst/dev/lsstprod/clusters/my_packages/pipe_tasks/python/lsst/pipe/tasks/multiBand.py", line 552, i n run     self.deblend.run(exposure, sources, exposure.getPsf())   File "/sps/lsst/Library/lsstsw/stack/Linux64/pipe_base/2015_10.0-3-g24e103a/python/lsst/pipe/base/timer.py", l ine 118, in wrapper     res = func(self, *args, **keyArgs)   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/de blend.py", line 231, in run     self.deblend(exposure, sources, psf)   File "/sps/lsst/Library/lsstsw/stack/Linux64/pipe_base/2015_10.0-3-g24e103a/python/lsst/pipe/base/timer.py", l ine 118, in wrapper     res = func(self, *args, **keyArgs)   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/de blend.py", line 308, in deblend     clipStrayFluxFraction=self.config.clipStrayFluxFraction,   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/ba seline.py", line 312, in deblend     tinyFootprintSize=tinyFootprintSize)   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/ba seline.py", line 575, in _fitPsfs     **kwargs)   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/ba seline.py", line 752, in _fitPsf     sx1, sx2, sx3, sx4 = _overlap(xlo, xhi, px0+1, px1-1)   File "/sps/lsst/Library/lsstsw/stack/Linux64/meas_deblender/2015_10.0-3-ga5a97e7/python/lsst/meas/deblender/ba seline.py", line 721, in _overlap     (xlo <= xhi)  and (xmin <= xmax)) AssertionError {code}
Story points: 2