Skip to content

Commit

Permalink
Inverse wcs bbox (#314)
Browse files Browse the repository at this point in the history
* do not use bounding box when coputing output wcs in resample

* pass arrays to world_to_pixel, not table columns

* temp point to gwcs PR

* temp

* point to gwcs branch

* add change log
  • Loading branch information
nden authored Dec 13, 2024
1 parent 30dd769 commit 876ae23
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions changes/314.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
10 changes: 5 additions & 5 deletions src/stcal/alignment/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 :
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_tweakreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})


Expand Down

0 comments on commit 876ae23

Please sign in to comment.