Commit 4c3aeb3d authored by Simon Conseil's avatar Simon Conseil

Merge branch 'wcs-isequal' into 'master'

Fix precision issue with WCS.isEqual and add precision keywords

See merge request !164
parents 53e3e7fb ab92a079
Pipeline #3158 passed with stage
in 16 minutes and 33 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.
......@@ -777,14 +781,18 @@ class WCS:
if not isinstance(other, WCS):
return False
if not self.sameStep(other):
return False
if self.naxis1 != other.naxis1 or self.naxis2 != other.naxis2:
return False
if not np.allclose(self.get_start(), other.get_start(),
atol=start_atol, rtol=0):
return False
if not np.allclose(self.get_rot(), other.get_rot(),
atol=rot_atol, rtol=0):
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 True
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)
......@@ -17,7 +17,6 @@ deps =
py{36,37}: regions
py35: astropy>=2.0,<3.0
py35: numpy>=1.14,<1.15
py36: astropy>=3.0,<3.1
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