What's a good way of debugging poor PSF estimation

The image processing, and particularly the key first step of CR rejection, relies on a rough estimate of the PSF. This step often can go wrong and is confusing for new users. What’s a good way of debugging the PSF estimation stage?

To what extent have you observed that this is a problem? The PSF estimation should not be very sensitive to the initial estimate (this was improved in the recent rewrite of ProcessCcdTask). If further improvements are indeed needed, some data showing the problem would be very useful (e.g. images and some idea of what initial PSF worked and did not work).

Put the following in a file called debug.py somewhere on your PYTHONPATH, and run your CmdLineTask with the --debug command-line option. This should result in images and plots being displayed as you go through.

try:
    import lsstDebug

    print "Importing debug settings..."
    def DebugInfo(name):
        di = lsstDebug.getInfo(name)        # N.b. lsstDebug.Info(name) would call us recursively
        if name in (
#            "lsst.meas.algorithms.secondMomentStarSelector",
#            "lsst.meas.algorithms.pcaPsfDeterminer",
            "lsst.meas.extensions.psfex.psfexPsfDeterminer",
            ):
            di.display = True
            di.displayExposure = True
            di.displayPsfCandidates = True
            di.displayIterations = True
            di.displayPsfComponents = True
            di.displayPsfMosaic = True
            di.displayPsfSpatialModel = True
            di.matchKernelAmplitudes = False
            di.keepMatplotlibPlots = True
            di.showBadCandidates = True
            di.normaliseResiduals = True
            di.pause = True
        elif name in (
            "lsst.meas.algorithms.objectSizeStarSelector"
            ):
            di.display = True
            di.displayExposure = True
            di.plotMagSize = True
        return di

    lsstDebug.Info = DebugInfo

except ImportError:
    print >> sys.stderr, "Unable to import lsstDebug;  not setting display intelligently"
1 Like

As a follow up: if you want to use this functionality elsewhere, or you’re not running a CmdLineTask, there’s more documentation on this debug mechanism here:

https://lsst-web.ncsa.illinois.edu/doxygen/x_masterDoxyDoc/base_debug.html

1 Like