Issues with GetTemplateTask after EDP2

Hello! I ran into an issue as I was running GetTemplateTask on the DP2 deep coadds. I was assuming that the code I had written for DP1 would carry over to EDP2 but then I learnt that the format of the deep coadds are now of the type ‘lsst.images.cells._coadd.CellCoadd’. However this format is incompatible for lsst.ip.diffim.GetTemplateTask and I’m the code that I had written for DP1 is not running. I would appreciate if someone suggests a fix for this. Thanks a lot!

getTemplateTask = GetTemplateTask()
            new_image = getTemplateTask.run(
            coaddExposure={tract_number:[coadd_get[filt]]},
            bbox=Box2I(small_box),wcs=new_wcs,
            dataIds={tract_number:[did_get[filt]]},
            physical_filter=filt,)

AttributeError: 'CellCoadd' object has no attribute 'get'

There are two underlying problems here.

Firstly the API changed about 18 months ago so that the coaddExposures parameter is now called coaddExposureHandles – I’m surprised you aren’t getting an error message about that. I am also slightly confused in that your code is using coaddExposure when the parameter used to be called coaddExposures. This was done to reduce memory usage since that task now only reads the pixel data when it needs it rather than reading all the pixels up front.

Since coaddExposureHandles takes deferred handles from butler you need to get those using butler.getDeferred instead of butler.get.

Also many of the existing Tasks do not work with the new python image types. A CellCoadd can not be used where the API wants an ExposureF. You can get an ExposureF by passing in storageClass="Exposure" to your get or getDeferred call.