Skip to content

Commit

Permalink
Remove unnecessary check of fitting status and clarify docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed May 10, 2024
1 parent 8e39c2e commit b02de2e
Showing 1 changed file with 4 additions and 5 deletions.
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

0 comments on commit b02de2e

Please sign in to comment.