Skip to content

Commit cba91f6

Browse files
committed
Fix tests
1 parent 7cf3d6e commit cba91f6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

reproject/mosaicking/coadd.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import dask.array as da
1111
import numpy as np
1212
from astropy.wcs import WCS
13+
from astropy.wcs.utils import pixel_to_pixel
1314
from astropy.wcs.wcsapi import SlicedLowLevelWCS
1415

1516
from ..utils import parse_input_data, parse_input_weights, parse_output_projection
@@ -226,12 +227,12 @@ def reproject_and_coadd(
226227
pixel_in = xs, ys
227228
else:
228229
# We use only the corners of cubes and higher dimension datasets
229-
pixel_in = list(
230+
pixel_in = next(
230231
zip(*product([(-0.5, shape_out[::-1][i] - 0.5) for i in range(len(shape_out))]))
231232
)
232-
pixel_in = pixel_in[0] # FIXME
233+
pixel_in = [np.array(p) for p in pixel_in]
233234

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)
235236

236237
# Determine the cutout parameters
237238

@@ -242,7 +243,7 @@ def reproject_and_coadd(
242243
if any([np.any(np.isnan(c_out)) for c_out in pixel_out]):
243244
wcs_out_indiv = wcs_out
244245
shape_out_indiv = shape_out
245-
246+
slices_out = [slice(0, shape_out[i]) for i in range(len(shape_out))]
246247
else:
247248
# Determine indices - note the reverse order compared to pixel
248249

@@ -274,10 +275,10 @@ def reproject_and_coadd(
274275

275276
shape_out_indiv = tuple(shape_out_indiv)
276277

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)
281282

282283
# TODO: optimize handling of weights by making reprojection functions
283284
# able to handle weights, and make the footprint become the combined

0 commit comments

Comments
 (0)