Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JP-3129: Fix WCS correction validation #7494

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ tweakreg
additional user-provided rotations and scale corrections to an imaging
WCS of a calibrated image. [#7430]

- Fixed a bug due to which alignment may be aborted due to corrections
being "too large" yet compatible with step parameters. [#7494]

undersampling_correction
------------------------

Expand Down
12 changes: 7 additions & 5 deletions jwst/tweakreg/tests/test_multichip_jwst.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,16 @@ def test_multichip_alignment_step(monkeypatch):
step = tweakreg_step.TweakRegStep()
step.fitgeometry = 'general'
step.nclip = 0
# Increase matching tolerance to pass 'fit_quality_is_good' test.
# Increase matching tolerance to pass '_is_wcs_correction_small' test.
# This test would detect large corrections and therefore
# would flag the quality of the fit as "bad" and therefore, it will not
# apply computed corrections ('fit_quality_is_good' test was designed by
# apply computed corrections ('_is_wcs_correction_small' test was designed by
# Warren for evaluating "quality of fit" for HAP).
Comment on lines +395 to 399
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still valid?

step.tolerance = 2
# Alternatively, disable this 'fit_quality_is_good' test:
# step.fit_quality_is_good = lambda x, y: True
step.tolerance = 0.1
step.use2dhist = True
step.searchrad = 20
# Alternatively, disable this '_is_wcs_correction_small' test:
# step._is_wcs_correction_small = lambda x, y: True

mr, m1, m2 = step.process(mc)

Expand Down
8 changes: 6 additions & 2 deletions jwst/tweakreg/tweakreg_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,11 @@ def process(self, input):

def _is_wcs_correction_small(self, wcs, twcs):
"""Check that the newly tweaked wcs hasn't gone off the rails"""
tolerance = 10.0 * self.tolerance * u.arcsec
if self.use2dhist:
max_corr = 2 * (self.searchrad + self.tolerance) * u.arcsec
else:
max_corr = 2 * (max(abs(self.xoffset), abs(self.yoffset)) +
self.tolerance) * u.arcsec

ra, dec = wcs.footprint(axis_type="spatial").T
tra, tdec = twcs.footprint(axis_type="spatial").T
Expand All @@ -500,7 +504,7 @@ def _is_wcs_correction_small(self, wcs, twcs):

separation = skycoord.separation(tskycoord)

return (separation < tolerance).all()
return (separation < max_corr).all()

def _imodel2wcsim(self, image_model):
# make sure that we have a catalog:
Expand Down