Astrometry shift in Image.add / image.rebin functions
When "adding" an image onto another with a different WCS solution, a small shift appears. I attach a simple example.
white.fits is an empty image with a WCS solution having a non-zero angle
segnumconv.fits is an almost-empty image having one bright source located at p=-44.53460598, q=342.18104771 (in degrees). The WCS solution has a zero rotation angle (North is up and East is left).
The following operations:
from mpdaf.obj import Image
im=Image('white.fits')
seg=Image('segnumconv.fits')
im.add(seg)
im.write('white_seg.fits')
produces an output image white_seg.fits with the bright object, but now located at coordinates p=-44.53476443, q=342.18179618, about 10 pixels away from the expected location.
I looked into the code. The first step is to rotate the image. After rotation there is no shift in the position of the star. Then there is a rebin of the rotated image. After rebinning there seems to be a shift in the coordinates for the center of the object. So, perhaps, the issue is in the rebinning of an image which has a rotation in the WCS coordinates.
Attached image shows the original segnumconv.fits image, the rotated+rebinned image showing a shift, and the final image showing a shift. The crosshair is "locked" on the same WCS in each image.
Could it be our usual friend "cos(delta)" ?