We are trying to get animated frame from different observations (calexp) corresponding to the same object in the sky (i.e. include some chosen coordinates).
As an example of what we want to do, you can think about the notebook tutorial 09 on how to extract the light curve of a variable star, but we want to use the image of the star in each individual calexp to create an animation of its variation - instead of just using the extracted magnitude.
We are able to obtain all the calexp exposures that include the given star at different epochs (this will of course include calexp with different ids and numbers of “visits” and “detector”). Then, in order to put them together and obtain a video, we need to align the different exposures - or more specifically some smaller cutout centred on the star.
In order to do so, I was hoping to use the task lsst.afw.math._warper, but I get an error, as this task wants sc=ExposureD as input, while the cutouts are sc=ExposureF, and I get an error (warpExposure(): incompatible function arguments. The following argument types are supported:
1. (destExposure: lsst.afw.image.exposure.ExposureD, srcExposure: lsst.afw.image.exposure.ExposureD, control: lsst.afw.math.WarpingControl, padValue: lsst.afw.image.pixel.SinglePixelD = <lsst.afw.image.pixel.SinglePixelD object at 0x7fae48d0eaf0>) → int).
Is there a way to still use the warper ? Or is there a better/simpler way to do interpolation of the cutouts in order to align them (and, for instance, co-add them)?
Not necessarily the best solution to the full problem here, but if you want to just get types which are compatible, your calexp ExposureF has a .convertD() method which should allow you to pass it to the warper.
As for the animation itself, I regularly use ffmpeg to produce animations of static images. It’s not currently in the distribution, but I hope to have it added soon (though no guarantees about if/when), but in the meantime it should easily install on top of the stack with conda install ffmpeg -c conda-forge.
Hi @MelissaGraham, Many thanks! Both suggestions by @merlin were very useful. The main issue I was trying to solve was slightly different though: we have indeed used one example in the tutorials to select the cutouts from the calexp that include enough area around the selected coordinates, but then we need to align the exposures to have them all with the same orientation. This task should be relatively simple, given that the calexp images have the wcs, so they should carry information on the sky angle to put the image in the standard astronomical frame (North on top, east to the left) but we could not find a simple way to do it! We now use the interpolation task of astropy (griddata) to put all the cutouts in the same reference system. It works, but it is quite expensive in terms on calculation, and we need to give up the headers of the images. Is there a better way to do it? If not, we would be happy to share our notebook for this task.
It worked to convert the data type, but it was not enough to make the warper working: I still got the error: TypeError: warpExposure(): incompatible function arguments. I think the remaining problem lies in the warpingControl input, which I defined by trying something taken from other notebooks: warpingControl = lsst.afw.math.WarpingControl( “lanczos4”, “”, 0, 10)