1010import dask .array as da
1111import numpy as np
1212from astropy .wcs import WCS
13+ from astropy .wcs .utils import pixel_to_pixel
1314from astropy .wcs .wcsapi import SlicedLowLevelWCS
1415
1516from ..utils import parse_input_data , parse_input_weights , parse_output_projection
@@ -215,12 +216,12 @@ def reproject_and_coadd(
215216 pixel_in = xs , ys
216217 else :
217218 # We use only the corners of cubes and higher dimension datasets
218- pixel_in = list (
219+ pixel_in = next (
219220 zip (* product ([(- 0.5 , shape_out [::- 1 ][i ] - 0.5 ) for i in range (len (shape_out ))]))
220221 )
221- pixel_in = pixel_in [ 0 ] # FIXME
222+ pixel_in = [ np . array ( p ) for p in pixel_in ]
222223
223- pixel_out = wcs_out . world_to_pixel ( * wcs_in . pixel_to_world ( * pixel_in ) )
224+ pixel_out = pixel_to_pixel ( wcs_in , wcs_out , * pixel_in )
224225
225226 # Determine the cutout parameters
226227
@@ -231,7 +232,7 @@ def reproject_and_coadd(
231232 if any ([np .any (np .isnan (c_out )) for c_out in pixel_out ]):
232233 wcs_out_indiv = wcs_out
233234 shape_out_indiv = shape_out
234-
235+ slices_out = [ slice ( 0 , shape_out [ i ]) for i in range ( len ( shape_out ))]
235236 else :
236237 # Determine indices - note the reverse order compared to pixel
237238
@@ -263,10 +264,10 @@ def reproject_and_coadd(
263264
264265 shape_out_indiv = tuple (shape_out_indiv )
265266
266- if isinstance (wcs_out , WCS ):
267- wcs_out_indiv = wcs_out [slices_out ]
268- else :
269- wcs_out_indiv = SlicedLowLevelWCS (wcs_out .low_level_wcs , slices_out )
267+ if isinstance (wcs_out , WCS ):
268+ wcs_out_indiv = wcs_out [slices_out ]
269+ else :
270+ wcs_out_indiv = SlicedLowLevelWCS (wcs_out .low_level_wcs , slices_out )
270271
271272 # TODO: optimize handling of weights by making reprojection functions
272273 # able to handle weights, and make the footprint become the combined
0 commit comments