From 221520de2f3fd5eaf8b957d55be4dae9ba4f9758 Mon Sep 17 00:00:00 2001 From: Mihai Cara Date: Thu, 19 Dec 2024 15:33:26 -0500 Subject: [PATCH] make code guard against bbox completely in negative region --- src/stcal/alignment/util.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/stcal/alignment/util.py b/src/stcal/alignment/util.py index 3372b858..3cf69bad 100644 --- a/src/stcal/alignment/util.py +++ b/src/stcal/alignment/util.py @@ -332,7 +332,20 @@ def _calculate_new_wcs(wcs: gwcs.wcs.WCS, int(axs[1] - axs[0] + 0.5) for axs in output_bounding_box[::-1] ] else: - shape = [int(axs[1] + 1.5) for axs in output_bounding_box[::-1]] + shape = [] + for k, axs in enumerate(output_bounding_box[::-1]): + upper = int(axs[1] + 0.5) + if upper < 1: + log.warning( + "Input images do not overlap with created WCS. " + "Consider adjusting crval and/or crpix values." + ) + log.warning( + "Setting minimum array dimension for axis %d to 10." + % (len(output_bounding_box) - k) + ) + upper = 10 + shape.append(upper) wcs_new.pixel_shape = shape[::-1] wcs_new.array_shape = shape