Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily disable bounding_box when computing pixmap #9012

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions jwst/resample/resample_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ def calc_gwcs_pixmap(in_wcs, out_wcs, shape=None):
log.debug("Bounding box from WCS: {}".format(in_wcs.bounding_box))

grid = gwcs.wcstools.grid_from_bounding_box(bb)
pixmap = np.dstack(reproject(in_wcs, out_wcs)(grid[0], grid[1]))

orig_bbox = out_wcs.bounding_box
out_wcs.bounding_box = None
try:
pixmap = np.dstack(reproject(in_wcs, out_wcs)(grid[0], grid[1]))
finally:
if orig_bbox is not None:
out_wcs.bounding_box = orig_bbox

return pixmap

Expand Down Expand Up @@ -168,13 +175,10 @@ def reproject(wcs1, wcs2):
# keyword arguments and `with_bounding_box=False` cannot be passsed.
# We delete the bounding box on a copy of the WCS - yes, inefficient.
forward_transform = wcs1.pixel_to_world_values
wcs_no_bbox = deepcopy(wcs2)
wcs_no_bbox.bounding_box = None
backward_transform = wcs_no_bbox.world_to_pixel_values
backward_transform = wcs2.world_to_pixel_values
except AttributeError as err:
raise TypeError("Input should be a WCS") from err


def _reproject(x, y):
sky = forward_transform(x, y)
flat_sky = []
Expand Down
Loading