astLib.WCS attribute error

Issue #4 resolved
Joe Lewis created an issue

Python 2.7.1 (and Python 2.7); astLib v 0.8.0; astropy v 1.0.3

lsd_cats.py raises an attribute error in astLibWCS.py when calling the function rad_to_pix in lsd_cat_lib.py

There seems to be no problem with header appending outside of this scenario. Furthermore the astLib library is loading properly (No errors raised on import). Attached is the traceback log (same as the one included in my e-mail).

As mentioned, I have a workaround, so I'm defining the priority as minor.

Comments (5)

  1. Christian Herenz repo owner

    I cannot reproduce this.

    I also have astLib 0.8.0 and astropy 1.0.3 ... strange... The only difference I see is that I have Python 2.7.3 and I'm not running it inside an ipython shell.

    For the sake of most compatibility I will try to get rid of astLib, and use astropy WCS routines - http://docs.astropy.org/en/stable/wcs/index.html ... thanks for reporting.

  2. Joe Lewis reporter

    I still think it might be a problem with my astLib installation, but I don't know how that could be.

    For the record, I was having problems with the mpdaf routine that I used (slight drift of ~1px), so I switched to the astropy conversion tools this morning. Something like this seems to work very well (and is very simple), as a replacement for rad_to_pix and pix_to_rad :

    from astropy.wcs import WCS
    
    def px_wcs(x_px,y_px,hdr):
    
        #Create wcs obj
        wcs_obj=WCS(hdr)
    
        #Convert to (ra,dec)
        (radec) = wcs_obj.wcs_pix2world(x_px,y_px,1)
    
        return(radec[0],radec[1])
    
    def wcs_px(ra,dec,hdr):
    
        #Create wcs obj
        wcs_obj=WCS(hdr)
    
        #Convert to (x,y)
        (xy_data) = wcs_obj.wcs_world2pix(ra,dec,1)
    
        return(xy_data[0], xy_data[1])
    

    If you want, I could fork a new version of lsd_cat_lib.py with these two functions, but given their simplicity I thought you might like to have a quick look and implement it yourself at your own discretion. In its current state, in can only deal with 2D WCS objects, so it needs to try 2D first and then switch to 2D on error or some alternative.

  3. Christian Herenz repo owner

    Just go ahead ... maybe not fork, but branch ... I'll merge than if it works for me. You now have write permissions here...

    This is much simpler - but I remember that it took me some experimenting to find out that 1 needs to be the last argument in the wcs_pix2world routine....

  4. Joe Lewis reporter

    TY, I'll see about that tomorrow morning, I have made the changes that I spoke of.

    Concerning the origin value of 1 or 0, I recall finding (I'll dig it up tomorrow) that the parameter is linked to the formatting of the data. 1 corresponding to fits and numpy.

  5. Log in to comment