Skip to content

Commit

Permalink
fix a bug in the previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Dec 17, 2024
1 parent be166e9 commit d113f31
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions gwcs/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,18 @@ def outside_footprint(self, world_arrays):
else:
axis_range = footprint
range = [axis_range.min(), axis_range.max()]
outside = (coord < range[0]) | (coord > range[1])
if axtyp == 'SPATIAL' and str(phys).endswith((".ra", ".lon")):
rmin, rmax = range
if rmax - rmin > 180:

if (axtyp == 'SPATIAL' and str(phys).endswith((".ra", ".lon"))
and range[1] - range[0] > 180):
# most likely this coordinate is wrapped at 360
outside = np.logical_not(outside)
d = np.mean(range)
range = [
axis_range[axis_range < d].max(),
axis_range[axis_range > d].min()
]
outside = (coord >= range[0]) & (coord < range[1])
else:
outside = (coord < range[0]) | (coord > range[1])
if np.any(outside):
if np.isscalar(coord):
coord = np.nan
Expand Down

0 comments on commit d113f31

Please sign in to comment.