From 1d7b7350daf5fc56555f3477356e7ef8d010c47f Mon Sep 17 00:00:00 2001 From: Sam Van Kooten Date: Tue, 26 Nov 2024 11:30:38 -0600 Subject: [PATCH] Be a little more accurate/safe with bounding boxes --- punchbowl/level2/resample.py | 4 ++-- punchbowl/level3/celestial_intermediary.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/punchbowl/level2/resample.py b/punchbowl/level2/resample.py index 97a89972..176ac5f6 100644 --- a/punchbowl/level2/resample.py +++ b/punchbowl/level2/resample.py @@ -53,8 +53,8 @@ def reproject_cube(input_cube: NDCube, output_wcs: WCS, output_shape: tuple[int, # reproject, we don't want it spending time looping over all those empty pixels, calculating coordinates, # etc. So here we find a bounding box around the input in the output frame and crop to that before reprojecting. # To start, here we make a grid of points along the edges of the input image. - xs = np.linspace(1, input_cube.data.shape[-1], 60) - ys = np.linspace(1, input_cube.data.shape[-2], 60) + xs = np.linspace(-1, input_cube.data.shape[-1], 60) + ys = np.linspace(-1, input_cube.data.shape[-2], 60) edgex = np.concatenate((xs, np.full(len(ys), xs[-1]), xs, np.zeros(len(ys)))) edgey = np.concatenate((np.zeros(len(xs)), ys, np.full(len(xs), ys[-1]), ys)) diff --git a/punchbowl/level3/celestial_intermediary.py b/punchbowl/level3/celestial_intermediary.py index a5767b84..a41b45b9 100644 --- a/punchbowl/level3/celestial_intermediary.py +++ b/punchbowl/level3/celestial_intermediary.py @@ -58,8 +58,8 @@ def to_celestial_frame_cutout(data_cube: NDCube, cdelt: float = 0.02) -> NDCube: wcs_out.wcs.crval = ((crval[0] // cdelt) * cdelt) % 360, 0 # Now find the exact bounds of the input image in this output frame, so we can set the output array size - xs = np.linspace(1, data.shape[-1], 30) - ys = np.linspace(1, data.shape[-2], 30) + xs = np.linspace(-1, data.shape[-1], 30) + ys = np.linspace(-1, data.shape[-2], 30) edgex = np.concatenate((xs, np.full(len(ys), xs[-1]), xs, np.zeros(len(ys)))) edgey = np.concatenate((np.zeros(len(xs)), ys, np.full(len(xs), ys[-1]), ys))