Menu

#17 WCSError when used in Ginga tests

v1.0_(example)
closed
None
1
2019-12-04
2019-12-01
No

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

Related

Bugs: #17

Discussion

  • Matt Hilton

    Matt Hilton - 2019-12-02

    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:


    [bugs:#17] https://sourceforge.net/p/astlib/bugs/17/ WCSError when
    used in Ginga tests

    Status: open
    Group: v1.0_(example)
    Created: Sun Dec 01, 2019 01:24 PM UTC by Ole Streicher
    Last Updated: Sun Dec 01, 2019 01:24 PM UTC
    Owner: nobody

    Hi,
    I just created a new Debian package for the new release 0.11.2 and
    uploaded it to Debian unstable
    https://packages.debian.org/source/unstable/astlib. This version is
    then tested against the packages which use it. In that specific case,
    it is tested in Ginga https://ejeschke.github.io/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'</wcs_astlib.astlibwcs>

     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 0x7f2f78358110="" object="" at="">,x = 0,y = 0</astlib.astwcs.wcs>

     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></function></function></lambda></function>

     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'</wcs_astlib.astlibwcs>

     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
    https://ci.debian.net/data/autopkgtest/testing/amd64/g/ginga/3549977/log.gz.
    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
    https://ci.debian.net/data/autopkgtest/testing/amd64/g/ginga/3549977/log.gz.
    Please mention me (olebole) if you open an issue there so that I stay
    on track with the problem.
    Best regards
    Ole


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/astlib/bugs/17/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     

    Related

    Bugs: #17

  • Matt Hilton

    Matt Hilton - 2019-12-04

    I'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:


    [bugs:#17] https://sourceforge.net/p/astlib/bugs/17/ WCSError when
    used in Ginga tests

    Status: open
    Group: v1.0_(example)
    Created: Sun Dec 01, 2019 01:24 PM UTC by Ole Streicher
    Last Updated: Sun Dec 01, 2019 01:24 PM UTC
    Owner: nobody

    Hi,
    I just created a new Debian package for the new release 0.11.2 and
    uploaded it to Debian unstable
    https://packages.debian.org/source/unstable/astlib. This version is
    then tested against the packages which use it. In that specific case,
    it is tested in Ginga https://ejeschke.github.io/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'</wcs_astlib.astlibwcs>

     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 0x7f2f78358110="" object="" at="">,x = 0,y = 0</astlib.astwcs.wcs>

     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></function></function></lambda></function>

     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'</wcs_astlib.astlibwcs>

     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
    https://ci.debian.net/data/autopkgtest/testing/amd64/g/ginga/3549977/log.gz.
    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
    https://ci.debian.net/data/autopkgtest/testing/amd64/g/ginga/3549977/log.gz.
    Please mention me (olebole) if you open an issue there so that I stay
    on track with the problem.
    Best regards
    Ole


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/astlib/bugs/17/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     

    Related

    Bugs: #17

  • Matt Hilton

    Matt Hilton - 2019-12-04
    • status: open --> closed
    • assigned_to: Matt Hilton
     
  • Matt Hilton

    Matt Hilton - 2019-12-04

    Fixed in 0.11.3 (now passes Ginga tests)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.