Skip to content

Modify Image.regrid() to eliminate a redundant warning.

Martin Shepherd requested to merge fix_regrid_warning into master

To create a new Image container for a resampled image, Image.regrid() was calling Image.new_from_obj(). It passed new_from_obj() the original image, so that it could copy header information etc from the original image to the resampled version. However, although new_from_obj() accepts new image arrays, it doesn't allow one to specify a corresponding new wcs object. Instead it installs the wcs object of the original image. This was the wcs object of the original image, and it had different dimensions to the resampled image, so DataArray.set_wcs() generated a warning.

A simple way to resolve this would have been to add an optional wcs object to new_from_obj(). This would have avoided unnecessary code duplication. However a proposal to do this was denied. So instead, Image.regrid() has now been modified to duplicate the part of new_from_obj() that creates the image container, and it passes this a new wcs object.

Merge request reports