Skip to content

Commit

Permalink
fix footprint range check for coordinates on the celestial sphere aro…
Browse files Browse the repository at this point in the history
…und (0, 0)
  • Loading branch information
nden committed Dec 16, 2024
1 parent 863b6e4 commit 35860b8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions gwcs/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,11 @@ def outside_footprint(self, world_arrays):
world_arrays = list(world_arrays)

axes_types = set(self.output_frame.axes_type)
footprint = self.footprint()
try:
footprint = self.footprint()
except AttributeError:

Check warning on line 498 in gwcs/wcs.py

View check run for this annotation

Codecov / codecov/patch

gwcs/wcs.py#L498

Added line #L498 was not covered by tests
# SlicedWCS does not implement footrpint
return world_arrays

Check warning on line 500 in gwcs/wcs.py

View check run for this annotation

Codecov / codecov/patch

gwcs/wcs.py#L500

Added line #L500 was not covered by tests
not_numerical = False
if not utils.isnumerical(world_arrays[0]):
not_numerical = True
Expand All @@ -502,13 +506,17 @@ def outside_footprint(self, world_arrays):
ind = np.asarray((np.asarray(self.output_frame.axes_type) == axtyp))

for idim, coord in enumerate(world_arrays):
coord = _tofloat(coord)
if not np.isscalar(coord):
coord = _tofloat(coord.copy())
if np.asarray(ind).sum() > 1:
axis_range = footprint[:, idim]
else:
axis_range = footprint
axis_range = footprint[:, idim]
range = [axis_range.min(), axis_range.max()]
outside = (coord < range[0]) | (coord > range[1])
if axtyp == 'SPATIAL' and isinstance(self.output_frame, cf.CelestialFrame):
range = np.mod(range, 180)
coord = np.mod(coord, 180)
outside = np.logical_or(coord < range[0], coord > range[1])
if np.any(outside):
if np.isscalar(coord):
coord = np.nan
Expand Down

0 comments on commit 35860b8

Please sign in to comment.