sunkit-image
sunkit-image copied to clipboard
Bug in argument `clip=True` in `sunkit_image.coalignment.apply_shift()`
Provide a general description of the issue or problem.
By default, we set clip=True
in apply_shift()
. However, in lines 357-363 of coalignment.py,
it shifts the reference pixel using the x and y shifts that are just applied to the data array instead of the clipped part of the image. As a result, if the shifted data array is plotted with the new WCS, they cancel each other!!!
if clip:
shifted_data = _clip_edges(shifted_data, yclips, xclips)
new_meta["naxis1"] = shifted_data.shape[1]
new_meta["naxis2"] = shifted_data.shape[0]
# Add one to go from zero-based to one-based indexing
new_meta["crpix1"] = m.reference_pixel.x.value + 1 + xshift[i].value - xshift[0].value
new_meta["crpix2"] = m.reference_pixel.y.value + 1 + yshift[i].value - yshift[0].value
Solution:
Either set clip=False
and clip the Mapsequence later or use
new_meta["crpix1"] = m.reference_pixel.x.value + 1 - int(xclips[0].value)
new_meta["crpix2"] = m.reference_pixel.y.value + 1 - int(yclips[0].value)