Skip to content

Commit

Permalink
Address reviewers comments. Simplify the code and test.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Dec 18, 2024
1 parent 45be2c7 commit 5b5184f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
11 changes: 3 additions & 8 deletions src/stcal/alignment/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ def _calculate_offsets(fiducial: tuple,
~astropy.modeling.Model
A model with the offsets to be added to the WCS's transform.
tuple
A tuple of offset *values* that are to be *subtracted* from input
coordinates (negative values of offsets in the returned transform).
Note: these are equivalent to an effective 0-indexed "crpix".
Notes
-----
If ``crpix=None``, then ``fiducial``, ``wcs``, and ``axis_min_values`` must be
Expand All @@ -257,7 +252,7 @@ def _calculate_offsets(fiducial: tuple,
# assume 0-based CRPIX
offset1, offset2 = crpix

return astmodels.Shift(-offset1, name="crpix1") & astmodels.Shift(-offset2, name="crpix2"), (offset1, offset2)
return astmodels.Shift(-offset1, name="crpix1") & astmodels.Shift(-offset2, name="crpix2")


def _calculate_new_wcs(wcs: gwcs.wcs.WCS,
Expand Down Expand Up @@ -309,7 +304,7 @@ def _calculate_new_wcs(wcs: gwcs.wcs.WCS,
input_frame=wcs.input_frame,
)
axis_min_values, bbox = _get_axis_min_and_bounding_box(footprints, wcs_new)
offsets, shifts = _calculate_offsets(
offsets = _calculate_offsets(
fiducial=fiducial,
wcs=wcs_new,
axis_min_values=axis_min_values,
Expand All @@ -320,7 +315,7 @@ def _calculate_new_wcs(wcs: gwcs.wcs.WCS,
output_bounding_box = bbox
else:
output_bounding_box = []
for axis_range, minval, shift in zip(bbox, axis_min_values, shifts):
for axis_range, minval, shift in zip(bbox, axis_min_values, crpix):
output_bounding_box.append(
(
axis_range[0] + shift + minval,
Expand Down
5 changes: 1 addition & 4 deletions tests/test_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ def _create_wcs_object_without_distortion(
pscale,
shape,
):
# subtract 1 to account for pixel indexing starting at 0
shift = models.Shift(0) & models.Shift(0)

scale = models.Scale(pscale[0]) & models.Scale(pscale[1])

tan = models.Pix2Sky_TAN()
Expand All @@ -41,7 +38,7 @@ def _create_wcs_object_without_distortion(
180,
)

det2sky = shift | scale | tan | celestial_rotation
det2sky = scale | tan | celestial_rotation
det2sky.name = "linear_transform"

detector_frame = cf.Frame2D(name="detector", axes_names=("x", "y"), unit=(u.pix, u.pix))
Expand Down

0 comments on commit 5b5184f

Please sign in to comment.