which successfully produces the correct WCS. I was wondering if this is expected for cutouts, and if there’s a neater way to extract the correct WCS without saving out to a temp file?
The issue is that our WCS objects do not hold the offset of the origin of the image they are attached to; we prefer to put that offset into the image itself only. This saves us from having to create slightly-modified WCS objects whenever we make a subimage, and it allows a lot more code to not care about whether an image has a WCS at all. And putting the offset in both the image and the WCS would open the door to those getting out of sync.
But FITS took the opposite approach: it has no concept of what the origin of an image is (it always assumes it’s (1, 1) - which is notably different from the (0, 0) most Python codes assume), and so we have to move the offset from our image objects into the WCS representation when we write to FITS.
You can also do that yourself, though it’s a little verbose:
That makes sense, thank you! A follow-up question, copyAtShiftedPixelOrigin() seems to expect two arguments: (self: lsst.afw.geom.SkyWcs, shift: lsst.geom.Extent2D). I assume the first argument is just the cutout wcs, but for the second argument, is there a way to convert the Point2I(0, 0) - cutout_image.getXY0() argument to an Extent2D argument? Many thanks!