Skip to content

Commit

Permalink
toasty/multi_wcs.py: fix vertical flip, I hope
Browse files Browse the repository at this point in the history
  • Loading branch information
pkgw committed Oct 8, 2020
1 parent 94d8c50 commit 73c69b6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions toasty/multi_wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ def create_descriptor(loader_data):
desc.jmax = min(self._combined_shape[0], int(np.ceil(yc_out.max() + 0.5)))

# Compute the sub-tiling now so that we can count how many total
# tiles we'll need to process.
# tiles we'll need to process. Note that the combined WCS coordinate
# system has y=0 on the bottom, whereas the tiling coordinate system
# has y=0 at the top. So we need to invert the coordinates
# vertically when determining the sub-tiling.

if desc.imax < desc.imin or desc.jmax < desc.jmin:
raise Exception(f'segment {desc.ident} maps to zero size in the global mosaic')

desc.sub_tiling = self._tiling.compute_for_subimage(
desc.imin,
desc.jmin,
self._combined_shape[0] - desc.jmax,
desc.imax - desc.imin,
desc.jmax - desc.jmin,
)
Expand Down Expand Up @@ -209,7 +212,9 @@ def _tile_serial(self, pio, reproject_function, cli_progress, **kwargs):
**kwargs
)

image = Image.from_array(ImageMode.F32, array.astype(np.float32))
# Once again, FITS coordinates have y=0 at the bottom and our
# coordinates have y=0 at the top, so we need a vertical flip.
image = Image.from_array(ImageMode.F32, array.astype(np.float32)[::-1])

for pos, width, height, image_x, image_y, tile_x, tile_y in desc.sub_tiling.generate_populated_positions():
iy_idx = slice(image_y, image_y + height)
Expand Down Expand Up @@ -284,7 +289,9 @@ def _mp_tile_worker(queue, pio, reproject_function, kwargs):
**kwargs
)

image = Image.from_array(ImageMode.F32, array.astype(np.float32))
# Once again, FITS coordinates have y=0 at the bottom and our
# coordinates have y=0 at the top, so we need a vertical flip.
image = Image.from_array(ImageMode.F32, array.astype(np.float32)[::-1])

for pos, width, height, image_x, image_y, tile_x, tile_y in desc.sub_tiling.generate_populated_positions():
iy_idx = slice(image_y, image_y + height)
Expand Down

0 comments on commit 73c69b6

Please sign in to comment.