How to create animations from calexp cutout around the same star?

Hi all,
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)?

Thanks in advance for any suggestions or help :slight_smile:

1 Like

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.

In addition to Merlin’s replies, you can also take a look at a StackClub notebook by Imran Hasan that shows how to make an animation from a set of images using matplotlib.animation: StackClub/Footprints.ipynb at master · LSSTScienceCollaborations/StackClub · GitHub
It runs at the IDF and will not require any additional package installs

This is a great use case and we are working on new tutorials to demonstrate how to efficiently get cutouts centered about an object of interest at various epochs for the upcoming DP0.2 release.

Hi @laura.inno, I did mark one of the responses in this thread as the solution, but please do respond to let us know if it was helpful to your situation?

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.

Did Merlin’s solution above to convert the data type so you can use the warper not work?

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)

Ah. OK. I don’t know that system, but the people who make the co-adds should. The calexps are all warped before combing there.