10
10
import dask .array as da
11
11
import numpy as np
12
12
from astropy .wcs import WCS
13
+ from astropy .wcs .utils import pixel_to_pixel
13
14
from astropy .wcs .wcsapi import SlicedLowLevelWCS
14
15
15
16
from ..utils import parse_input_data , parse_input_weights , parse_output_projection
@@ -226,12 +227,12 @@ def reproject_and_coadd(
226
227
pixel_in = xs , ys
227
228
else :
228
229
# We use only the corners of cubes and higher dimension datasets
229
- pixel_in = list (
230
+ pixel_in = next (
230
231
zip (* product ([(- 0.5 , shape_out [::- 1 ][i ] - 0.5 ) for i in range (len (shape_out ))]))
231
232
)
232
- pixel_in = pixel_in [ 0 ] # FIXME
233
+ pixel_in = [ np . array ( p ) for p in pixel_in ]
233
234
234
- pixel_out = wcs_out . world_to_pixel ( * wcs_in . pixel_to_world ( * pixel_in ) )
235
+ pixel_out = pixel_to_pixel ( wcs_in , wcs_out , * pixel_in )
235
236
236
237
# Determine the cutout parameters
237
238
@@ -242,7 +243,7 @@ def reproject_and_coadd(
242
243
if any ([np .any (np .isnan (c_out )) for c_out in pixel_out ]):
243
244
wcs_out_indiv = wcs_out
244
245
shape_out_indiv = shape_out
245
-
246
+ slices_out = [ slice ( 0 , shape_out [ i ]) for i in range ( len ( shape_out ))]
246
247
else :
247
248
# Determine indices - note the reverse order compared to pixel
248
249
@@ -274,10 +275,10 @@ def reproject_and_coadd(
274
275
275
276
shape_out_indiv = tuple (shape_out_indiv )
276
277
277
- if isinstance (wcs_out , WCS ):
278
- wcs_out_indiv = wcs_out [slices_out ]
279
- else :
280
- wcs_out_indiv = SlicedLowLevelWCS (wcs_out .low_level_wcs , slices_out )
278
+ if isinstance (wcs_out , WCS ):
279
+ wcs_out_indiv = wcs_out [slices_out ]
280
+ else :
281
+ wcs_out_indiv = SlicedLowLevelWCS (wcs_out .low_level_wcs , slices_out )
281
282
282
283
# TODO: optimize handling of weights by making reprojection functions
283
284
# able to handle weights, and make the footprint become the combined
0 commit comments