How do a visualize sources and a source-subtracted model from a calexp + catalog?

I have a calexp and a source catalog from that calexp.

How do I

  1. Overplot the footprints as an overlay in ds9?
  2. Generate a version of the calexp image with the source models subtracted?
  • An image array representing this would be fine. It doesn’t have to be a formally persisted format.

Note, I’m somewhat familiar with the debugging/visualizion tools from the debug options when running processCcd-type analysis. I’m asking about the post-facto case.

I’m afraid there’s nothing high-level for either of these cases.

For Footprints, there’s some good low-level code you can build on top of: you can either put the Footprints in the Mask plane using afw.detection.setMaskFromFootprint, or use afw.display.drawFootprint to draw the individual spans as regions. The latter is a bit easier to use and provides more source-by-source control, but it also tends to obscure a bit of the image.

As for source models, there’s no single model for each object, and the path to plotting any of them is pretty involved:

  • There are the deblended HeavyFootprints, which do have utilities to add and remove them from images. But just removing these from the image won’t tell you about the pixels used to make the measurements, because we actually replace them with noise instead of just subtracting them. You might be able to use meas.base.NoiseReplacer to do that, but it wasn’t designed for interactive visualization and hence it might be a bit clunky, especially if you want to reconstruct the noise with the same random seeds as was used in the original processing.
  • You can subtract each object as if it’s a point source. You can just use Psf.computeImage to get a PSF image you can subtract at each point.
  • If you’ve run the modelfit_CModel algorithm, you can subtract galaxy models with a bit more effort. But I suspect you haven’t run it, since I happen to know it’s not quite working right now.

Hi Michael,
I have a code that overlay sources and detection footprints in ds9

the result is here

hope that helps.

To expand Jim’s first point, you want something like

import lsst.afw.display as afwDisplay
import lsst.afw.display.utils as afwDisplayUtils

disp = afwDisplay.Display(frame=1)

exp = butler.get("calexp", dataId)
srcs = butler.get("src", dataId)

with afwDisplay.Buffering():
   for s in srcs:
       afwDisplayUtils.drawFootprin(s.getFootprint(), display=disp, peaks=True)

(untested, I’m afraid). I’m a bit surprised that you need to do this as the mask should already be set to show most of the same information.

There should be a notebook illustrating this, but I don’t know of a stand-alone example.

Thanks, @RHL

If you or @jbosch could find this notebook and post a link in this thread, that would be great.

I meant, someone should write one! I’ll put it on my list of aeroplane projects.