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

Remove unnecessary check of fitting status and clarify docstring #2492

Merged
merged 1 commit into from
May 10, 2024
Merged
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
9 changes: 4 additions & 5 deletions glue/plugins/wcs_autolinking/wcs_autolinking.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ def as_affine_link(self, n_samples=1000, tolerance=1):

For now this will only work for datasets in which two pixel coordinates
are linked.

The deviation to be compared to the tolerance is measured in the frame
of reference of the second dataset.
"""

if len(self.cids1) != 2 or len(self.cids2) != 2:
Expand Down Expand Up @@ -277,11 +280,7 @@ def transform_offset(offsets):
pixel1_tr = pixel1[0] - offsets[0], pixel1[1] - offsets[1]
return np.hypot(pixel2[0] - pixel1_tr[0], pixel2[1] - pixel1_tr[1])

best, status = leastsq(transform_offset, (0, 0))

if status not in [1, 2, 3, 4]:
raise NoAffineApproximation(f'Could not find a good affine approximation to '
f'WCSLink with tolerance={tolerance}, as fitting failed')
best, _ = leastsq(transform_offset, (0, 0))

max_deviation = np.max(transform_offset(best))

Expand Down
Loading