WCSError when used in Ginga tests
Brought to you by:
mattyowl
Hi,
I just created a new Debian package for the new release 0.11.2 and uploaded it to Debian unstable. This version is then tested against the packages which use it. In that specific case, it is tested in Ginga, where some tests involve astlib. These tests however now fail with the new release. Specifically:
____________________________ test_scalar_3d[astlib] ____________________________ self = <wcs_astlib.AstLibWCS object at 0x7f2f78358e10>, idxs = [0, 0, 0] coords = 'data' def pixtoradec(self, idxs, coords='data'): if coords == 'fits': # Via astWCS.NUMPY_MODE, we've forced pixels referenced from 0 idxs = tuple(map(lambda x: x - 1, idxs)) try: > ra_deg, dec_deg = self.wcs.pix2wcs(idxs[0], idxs[1]) /usr/lib/python3/dist-packages/ginga/util/wcsmod/wcs_astlib.py:72: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <astLib.astWCS.WCS object at 0x7f2f78358110>, x = 0, y = 0 def pix2wcs(self, x, y): """[…]""" if self.useAstropyWCS == False: […] else: # astropy.wcs shim > WCSCoords = self.AWCS.wcs_pix2world(x, y, self._apywcsOrigin) /usr/lib/python3/dist-packages/astLib/astWCS.py:336: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = WCS Keywords Number of WCS axes: 3 CTYPE : 'RA---SIN' 'DEC--SIN' 'VOPT' CRVAL : -51.2820847959 60.1538880206 -2...1.0 0.0 PC3_1 PC3_2 PC3_3 : 0.0 0.0 1.0 CDELT : -0.007165998823 0.007165998823 4199.999809 NAXIS : 100 100 args = (0, 0, 0), kwargs = {} def wcs_pix2world(self, *args, **kwargs): if self.wcs is None: raise ValueError("No basic WCS settings were created.") return self._array_converter( lambda xy, o: self.wcs.p2s(xy, o)['world'], > 'output', *args, **kwargs) /usr/lib/python3/dist-packages/astropy/wcs/wcs.py:1390: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = WCS Keywords Number of WCS axes: 3 CTYPE : 'RA---SIN' 'DEC--SIN' 'VOPT' CRVAL : -51.2820847959 60.1538880206 -2...1.0 0.0 PC3_1 PC3_2 PC3_3 : 0.0 0.0 1.0 CDELT : -0.007165998823 0.007165998823 4199.999809 NAXIS : 100 100 func = <function WCS.wcs_pix2world.<locals>.<lambda> at 0x7f2f74c28ef0> sky = 'output', ra_dec_order = False, args = (0, 0, 0) _return_list_of_arrays = <function WCS._array_converter.<locals>._return_list_of_arrays at 0x7f2f788838c0> _return_single_array = <function WCS._array_converter.<locals>._return_single_array at 0x7f2f788830e0> def _array_converter(self, func, sky, *args, ra_dec_order=False): """[…]""" […] if len(args) == 2: […] return _return_single_array(xy, origin) elif len(args) == self.naxis + 1: […] return _return_list_of_arrays(axes, origin) raise TypeError( "WCS projection has {0} dimensions, so expected 2 (an Nx{0} array " "and the origin argument) or {1} arguments (the position in each " "dimension, and the origin argument). Instead, {2} arguments were " "given.".format( > self.naxis, self.naxis + 1, len(args))) E TypeError: WCS projection has 3 dimensions, so expected 2 (an Nx3 array and the origin argument) or 4 arguments (the position in each dimension, and the origin argument). Instead, 3 arguments were given. /usr/lib/python3/dist-packages/astropy/wcs/wcs.py:1312: TypeError During handling of the above exception, another exception occurred: modname = 'astlib' @pytest.mark.parametrize('modname', _wcsmods) def test_scalar_3d(modname): if modname not in img_dict: pytest.skip("WCS '{}' not available".format(modname)) img = img_dict[modname]['3d'] idxs = (0, 0, 0) ra_deg_v1 = -50.569931842112965 dec_deg_v1 = 59.79236398619401 vel_v1 = -159000.00382 if modname == 'astlib': with pytest.raises(wcsmod.common.WCSError): img.spectral_coord(idxs) else: c = img.spectral_coord(idxs) if modname == 'starlink': assert_allclose(c, vel_v1 * 1e-3) elif modname == 'astropy_ape14': # TODO: Remove rtol with load_header() is fixed. assert_allclose(c, vel_v1, rtol=0.03) else: assert_allclose(c, vel_v1) # 0.01% agreement is good enough across different libraries. # RA can be off by 360 degrees and still be valid. > c = img.pixtoradec(*idxs[:2]) /usr/lib/python3/dist-packages/ginga/tests/test_wcs.py:348: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3/dist-packages/ginga/AstroImage.py:388: in pixtoradec ra_deg, dec_deg = self.wcs.pixtoradec(args, coords=coords) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <wcs_astlib.AstLibWCS object at 0x7f2f78358e10>, idxs = [0, 0, 0] coords = 'data' def pixtoradec(self, idxs, coords='data'): if coords == 'fits': # Via astWCS.NUMPY_MODE, we've forced pixels referenced from 0 idxs = tuple(map(lambda x: x - 1, idxs)) try: ra_deg, dec_deg = self.wcs.pix2wcs(idxs[0], idxs[1]) except Exception as e: self.logger.error("Error calculating pixtoradec: %s" % (str(e))) > raise common.WCSError(e) E ginga.util.wcsmod.common.WCSError: WCS projection has 3 dimensions, so expected 2 (an Nx3 array and the origin argument) or 4 arguments (the position in each dimension, and the origin argument). Instead, 3 arguments were given. /usr/lib/python3/dist-packages/ginga/util/wcsmod/wcs_astlib.py:76: WCSError ------------------------------ Captured log call ------------------------------- wcs_astlib.py 75 ERROR Error calculating pixtoradec: WCS projection has 3 dimensions, so expected 2 (an Nx3 array and the origin argument) or 4 arguments (the position in each dimension, and the origin argument). Instead, 3 arguments were given.
Full test log here. This is a regression; it has been working with astlib version 0.10.2 before.
If this is a bug in Ginga, please tell me, or open an issue on the Ginga Github repository. Please mention me (olebole) if you open an issue there so that I stay on track with the problem.
Best regards
Ole
Thanks, I'll take a look and get back to you in a day or two
On 2019/12/01 15:24, Ole Streicher wrote:
Related
Bugs:
#17I've uploaded a new version 0.11.3 to PyPI that passes the ginga tests
(sorry for the bug).
Cheers
Matt
On 2019/12/01 15:24, Ole Streicher wrote:
Related
Bugs:
#17Fixed in 0.11.3 (now passes Ginga tests)