Skip to content

Commit

Permalink
Restore old behavior for regression testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Dec 22, 2024
1 parent ed42588 commit 77a8176
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/stcal/alignment/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ def _get_bounding_box_with_offsets(
domain_max = np.max(domain_bounds, axis=1)

native_crpix = ref_wcs.backward_transform(*fiducial)
# DEBUG: code to reproduce old results (for old unit test test_wcs_from_footprints)
native_crpix = (0.0, 0.0)

if crpix is None:
# shift the coordinates by domain_min so that all input footprints
Expand All @@ -214,15 +216,15 @@ def _get_bounding_box_with_offsets(
domain_max += offsets

if shape is None:
shape = tuple(int(dmax + 0.5) for dmax in domain_max[::-1])
bounding_box = tuple(
(-0.5, s - 0.5) for s in shape[::-1]
)
# code to reproduce old results (for old unit test test_wcs_from_footprints)
# shape = tuple(int(dmax + 0.5) for dmax in domain_max[::-1])
# bounding_box = tuple(
# (0.0, dmax) for dmax in domain_max
# (-0.5, s - 0.5) for s in shape[::-1]
# )
# shape = tuple(int(dmax + 0.5) for dmax in domain_max[::-1])
# DEBUG: code to reproduce old results (for old unit test test_wcs_from_footprints)
bounding_box = tuple(
(0.0, dmax) for dmax in domain_max
)
shape = tuple(int(dmax + 0.5) for dmax in domain_max[::-1])

else:
# trim upper bounding box limits
Expand Down
17 changes: 12 additions & 5 deletions tests/test_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,18 @@ def test_wcs_from_footprints(s_regions):

# check that all elements of footprint match the *vertices* of the new
# combined WCS
footprnt = wcs.footprint()
assert all(np.isclose(footprnt[0], wcs(-0.5, -0.5)))
assert all(np.isclose(footprnt[1], wcs(-0.5, 3.5)))
assert all(np.isclose(footprnt[2], wcs(3.5, 3.5)))
assert all(np.isclose(footprnt[3], wcs(3.5, -0.5)))

# footprnt = wcs.footprint()
# assert all(np.isclose(footprnt[0], wcs(-0.5, -0.5)))
# assert all(np.isclose(footprnt[1], wcs(-0.5, 3.5)))
# assert all(np.isclose(footprnt[2], wcs(3.5, 3.5)))
# assert all(np.isclose(footprnt[3], wcs(3.5, -0.5)))

# DEBUG: code to reproduce the old unit test:
assert all(np.isclose(wcs.footprint()[0], wcs(0, 0)))
assert all(np.isclose(wcs.footprint()[1], wcs(0, 4)))
assert all(np.isclose(wcs.footprint()[2], wcs(4, 4)))
assert all(np.isclose(wcs.footprint()[3], wcs(4, 0)))

# check that fiducials match their expected coords in the new combined WCS
assert all(np.isclose(wcs_1(0, 0), wcs(2.5, 1.5)))
Expand Down

0 comments on commit 77a8176

Please sign in to comment.