Commit 27ca521c authored by Simon Conseil's avatar Simon Conseil

Fix precision issue with WCS.isEqual and add precision keywords

parent 53e3e7fb
Pipeline #3156 failed with stage
in 15 minutes and 20 seconds
......@@ -757,7 +757,7 @@ class WCS:
return np.array([dec, ra]).T
def isEqual(self, other):
def isEqual(self, other, start_atol=1e-6, rot_atol=1e-6):
"""Return True if other and self have the same attributes.
Beware that if the two wcs objects have the same world coordinate
......@@ -768,6 +768,10 @@ class WCS:
----------
other : WCS
The wcs object to be compared to self.
start_atol : float
Absolute tolerance for the test with `WCS.get_start`, in degrees.
start_rot : float
Absolute tolerance for the test with `WCS.get_rot`, in degrees.
Returns
-------
......@@ -777,14 +781,15 @@ class WCS:
"""
if not isinstance(other, WCS):
return False
return (self.sameStep(other) and
self.naxis1 == other.naxis1 and
self.naxis2 == other.naxis2 and
np.allclose(self.get_start(), other.get_start(),
atol=1E-3, rtol=0) and
np.allclose(self.get_rot(), other.get_rot(),
atol=1E-3, rtol=0))
return (
self.sameStep(other) and
self.naxis1 == other.naxis1 and
self.naxis2 == other.naxis2 and
np.allclose(self.get_start(), other.get_start(),
atol=start_atol, rtol=0) and
np.allclose(self.get_rot(), other.get_rot(),
atol=rot_atol, rtol=0)
)
def sameStep(self, other):
"""Return True if other and self have the same pixel sizes.
......
......@@ -787,6 +787,7 @@ def test_align_with_image(hdfs_muse_image, hdfs_hst_image):
im = hst.align_with_image(muse)
assert im.wcs.isEqual(muse.wcs)
assert not im.wcs.isEqual(muse.wcs, start_atol=1e-12)
assert im.shape == muse.shape
dy, dx = im.estimate_coordinate_offset(muse)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment