diff --git a/changes/314.bugfix.rst b/changes/314.bugfix.rst new file mode 100644 index 00000000..589d75d8 --- /dev/null +++ b/changes/314.bugfix.rst @@ -0,0 +1 @@ +Do not evaluate the inverse WCS transform within the bounding box in cases where a resampled WCS is computed. Do not pass table columns to the WCS Shared API. diff --git a/pyproject.toml b/pyproject.toml index 7469834d..ff63825f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ dependencies = [ "numpy >=1.21.2", "opencv-python-headless >=4.6.0.66", "asdf >=2.15.0", - "gwcs >= 0.18.1", + "gwcs @ git+https://github.com/nden/gwcs.git@inverse-bbox", "tweakwcs >=0.8.8", "requests >=2.22", ] diff --git a/src/stcal/alignment/util.py b/src/stcal/alignment/util.py index 90eb9420..4c61ff97 100644 --- a/src/stcal/alignment/util.py +++ b/src/stcal/alignment/util.py @@ -394,7 +394,7 @@ def compute_scale( msg = "If input WCS is spectral, a disp_axis must be given" raise ValueError(msg) - crpix = np.array(wcs.invert(*fiducial)) + crpix = np.array(wcs.invert(*fiducial, with_bounding_box=False)) delta = np.zeros_like(crpix) spatial_idx = np.where(np.array(wcs.output_frame.axes_type) == "SPATIAL")[0] @@ -441,7 +441,7 @@ def compute_fiducial(wcslist: list, (low, high) values. The bounding_box is in the order of the axes, axes_order. For two inputs and axes_order(0, 1) the bounding box can be either ((xlow, xhigh), (ylow, yhigh)) or [[xlow, xhigh], [ylow, yhigh]]. - + Returns ------- fiducial : np.ndarray @@ -704,7 +704,7 @@ def wcs_from_sregions( footprints : list of np.ndarray or list of str If list elements are numpy arrays, each should have shape (N, 2) and contain (RA, Dec) vertices demarcating the footprint of the input WCSs. - If list elements are strings, each should be the S_REGION header keyword + If list elements are strings, each should be the S_REGION header keyword containing (RA, Dec) vertices demarcating the footprint of the input WCSs. ref_wcs : @@ -756,8 +756,8 @@ def wcs_from_sregions( The WCS object corresponding to the combined input footprints. """ - footprints = [_sregion_to_footprint(s_region) - if isinstance(s_region, str) else s_region + footprints = [_sregion_to_footprint(s_region) + if isinstance(s_region, str) else s_region for s_region in footprints] fiducial = _calculate_fiducial(footprints, crval=crval) diff --git a/tests/test_tweakreg.py b/tests/test_tweakreg.py index 335c62c6..de6fdabb 100644 --- a/tests/test_tweakreg.py +++ b/tests/test_tweakreg.py @@ -244,7 +244,7 @@ def input_catalog(datamodel): cat = amutils.get_catalog(fiducial[0], fiducial[1], search_radius=radius, catalog=TEST_CATALOG) - x, y = w.world_to_pixel(cat["ra"], cat["dec"]) + x, y = w.world_to_pixel(cat["ra"].value, cat["dec"].value) return Table({"x": x, "y": y})