From ca12fbcfbedff6919caec35e20b94bf2f5964d6c Mon Sep 17 00:00:00 2001 From: Mihai Cara Date: Wed, 18 Dec 2024 12:25:05 -0500 Subject: [PATCH] Allow for small rounding errors in bbox for inverse (#537) --- gwcs/wcs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gwcs/wcs.py b/gwcs/wcs.py index e0cbf191..71c1d8f3 100644 --- a/gwcs/wcs.py +++ b/gwcs/wcs.py @@ -490,11 +490,16 @@ def invert(self, *args, **kwargs): return result def outside_footprint(self, world_arrays): + world_eps = 5.0 * np.finfo(np.float32).eps + eps_p = 1.0 + world_eps + eps_m = 1.0 - world_eps + world_arrays = list(world_arrays) axes_types = set(self.output_frame.axes_type) axes_phys_types = self.world_axis_physical_types footprint = self.footprint() + not_numerical = False if not utils.isnumerical(world_arrays[0]): not_numerical = True @@ -518,9 +523,10 @@ def outside_footprint(self, world_arrays): axis_range[axis_range < d].max(), axis_range[axis_range > d].min() ] - outside = (coord >= range[0]) & (coord < range[1]) + outside = (coord > range[0] * eps_p) & (coord < range[1] * eps_m) else: - outside = (coord < range[0]) | (coord > range[1]) + outside = (coord < range[0] * eps_m) | (coord > range[1] * eps_p) + if np.any(outside): if np.isscalar(coord): coord = np.nan