Skip to content

Commit 5d78e00

Browse files
committed
make distortionCorrect() handle existing rectification model properly
1 parent ef0a63e commit 5d78e00

5 files changed

Lines changed: 24 additions & 17 deletions

File tree

geminidr/core/primitives_spect.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,14 @@ def determineDistortion(self, adinputs=None, **params):
15371537
else:
15381538
has_rect_model = True
15391539
in_coords = rect_model(*in_coords)
1540-
ref_coords = rect_model(*ref_coords)
1540+
# For a vertically-dispersed spectrum, the rectification
1541+
# model alters X as a function of Y. Therefore, because
1542+
# incoords and ref_coords have different Y for the same X,
1543+
# putting them *both* through the rectification model will
1544+
# produce different X values, which is not what we want.
1545+
# S0 replace the X values in ref_coords with the ones in
1546+
# in_coords. Coords are *always* (x, y)
1547+
ref_coords[dispaxis] = in_coords[dispaxis]
15411548

15421549
# The model is computed entirely in the pixel coordinate frame
15431550
# of the data, so it could be used as a gWCS object

geminidr/f2/tests/longslit/test_determine_distortion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ def test_regression_for_determine_distortion_using_wcs(
216216
ref_ad = ref_ad_factory(distortion_determined_ad.filename)
217217

218218
# Confirm that the distortion model is placed after the rectification model
219-
assert (distortion_determined_ad.wcs.avilable_frames.index("distortion_corrected") >
220-
distortion_determined_ad.wcs.avilable_frames.index("rectified"))
221-
assert (ref_ad.wcs.avilable_frames.index("distortion_corrected") >
222-
ref_ad.wcs.avilable_frames.index("rectified"))
219+
assert (distortion_determined_ad[0].wcs.available_frames.index("distortion_corrected") >
220+
distortion_determined_ad[0].wcs.available_frames.index("rectified"))
221+
assert (ref_ad[0].wcs.available_frames.index("distortion_corrected") >
222+
ref_ad[0].wcs.available_frames.index("rectified"))
223223

224224
model = distortion_determined_ad[0].wcs.get_transform("pixels", "distortion_corrected")
225225
ref_model = ref_ad[0].wcs.get_transform("pixels", "distortion_corrected")

geminidr/gnirs/tests/crossdispersed/test_determine_distortion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ def test_regression_for_determine_distortion_using_wcs(
6262
ref_ad = ref_ad_factory(distortion_determined_ad.filename)
6363
for ext, ref_ext in zip(distortion_determined_ad, ref_ad):
6464
# Confirm that the distortion model is placed after the rectification model
65-
assert (ext.wcs.avilable_frames.index("distortion_corrected") >
66-
ext.wcs.avilable_frames.index("rectified"))
67-
assert (ref_ext.wcs.avilable_frames.index("distortion_corrected") >
68-
ref_ext.wcs.avilable_frames.index("rectified"))
65+
assert (ext.wcs.available_frames.index("distortion_corrected") >
66+
ext.wcs.available_frames.index("rectified"))
67+
assert (ref_ext.wcs.available_frames.index("distortion_corrected") >
68+
ref_ext.wcs.available_frames.index("rectified"))
6969

7070
model = ext.wcs.get_transform("pixels", "distortion_corrected")
7171
ref_model = ref_ext.wcs.get_transform("pixels", "distortion_corrected")

geminidr/gnirs/tests/longslit/test_determine_distortion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ def test_regression_for_determine_distortion_using_wcs(
117117
ref_ad = ref_ad_factory(distortion_determined_ad.filename)
118118

119119
# Confirm that the distortion model is placed after the rectification model
120-
assert (distortion_determined_ad.wcs.avilable_frames.index("distortion_corrected") >
121-
distortion_determined_ad.wcs.avilable_frames.index("rectified"))
122-
assert (ref_ad.wcs.avilable_frames.index("distortion_corrected") >
123-
ref_ad.wcs.avilable_frames.index("rectified"))
120+
assert (distortion_determined_ad[0].wcs.available_frames.index("distortion_corrected") >
121+
distortion_determined_ad[0].wcs.available_frames.index("rectified"))
122+
assert (ref_ad[0].wcs.available_frames.index("distortion_corrected") >
123+
ref_ad[0].wcs.available_frames.index("rectified"))
124124

125125
model = distortion_determined_ad[0].wcs.get_transform("pixels", "distortion_corrected")
126126
ref_model = ref_ad[0].wcs.get_transform("pixels", "distortion_corrected")

geminidr/niri/tests/longslit/test_determine_distortion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ def test_regression_for_determine_distortion_using_wcs(
9696
ref_ad = ref_ad_factory(distortion_determined_ad.filename)
9797

9898
# Confirm that the distortion model is placed after the rectification model
99-
assert (distortion_determined_ad.wcs.avilable_frames.index("distortion_corrected") >
100-
distortion_determined_ad.wcs.avilable_frames.index("rectified"))
101-
assert (ref_ad.wcs.avilable_frames.index("distortion_corrected") >
102-
ref_ad.wcs.avilable_frames.index("rectified"))
99+
assert (distortion_determined_ad[0].wcs.available_frames.index("distortion_corrected") >
100+
distortion_determined_ad[0].wcs.available_frames.index("rectified"))
101+
assert (ref_ad[0].wcs.available_frames.index("distortion_corrected") >
102+
ref_ad[0].wcs.available_frames.index("rectified"))
103103

104104
model = distortion_determined_ad[0].wcs.get_transform("pixels", "distortion_corrected")
105105
ref_model = ref_ad[0].wcs.get_transform("pixels", "distortion_corrected")

0 commit comments

Comments
 (0)