Skip to content

Commit

Permalink
Allow for small rounding errors in bbox for inverse
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Dec 18, 2024
1 parent 68fcfa8 commit 00dd4ca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gwcs/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 00dd4ca

Please sign in to comment.