spacetelescope / drizzlepac

AstroDrizzle for HST images.
https://drizzlepac.readthedocs.io
BSD 3-Clause "New" or "Revised" License
50 stars 39 forks source link

Drizzlepac needs to be tested thoroughly with Astropy 5.0 to resolve issues #1200

Closed stscijgbot-hstdp closed 1 year ago

stscijgbot-hstdp commented 2 years ago

Issue HLA-670 was created on JIRA by Michele De La Pena:

Astropy 5.0 came out on 15 November 2021.  It has already been observed that Drizzlepac 3.3.1 (and earlier versions) now has a bug when reading a binary table stored in a FITS file. The code must be thoroughly tested to fix issues and ensure the results are compatible to previously produced results when upgrading to use Astropy 5.0.  The current known issue of reading a binary table from an association FITS file is documented here.

Using Astropy 4.3.1

from astropy.io import fits hdu = fits.open("ibvz01020_asn.fits") newdata = hdu[1].data.tolist() newdata [(b'IBVZ01XTQ ', b'EXP-DTH ', 84), (b'IBVZ01XUQ ', b'EXP-DTH ', 84), (b'IBVZ01XVQ ', b'EXP-DTH ', 84), (b'IBVZ01020 ', b'PROD-DTH ', 84)] val=newdata[0][0].decode(encoding='UTF-8').strip() val 'IBVZ01XTQ'

===> The data consists of byte literals which must be decoded. Also, the "tolist" generated a list of tuples.

 

Using Astropy 5.0

from astropy.io import fits hdu = fits.open("ibvz01020_asn.fits") newdata = hdu[1].data.tolist() newdata [['IBVZ01XTQ ', 'EXP-DTH ', True], ['IBVZ01XUQ ', 'EXP-DTH ', True], ['IBVZ01XVQ ', 'EXP-DTH ', True], ['IBVZ01020 ', 'PROD-DTH ', True]] val=newdata[0][0].decode(encoding='UTF-8').strip() Traceback (most recent call last): File "", line 1, in AttributeError: 'str' object has no attribute 'decode'

===> The data now consists of strings.  The solution is to remove the decode as the values are now string literals and NOT byte literals.  Also, the "tolist" generated a list of lists.

val=newdata[0][0].strip() val 'IBVZ01XTQ'

stscijgbot-hstdp commented 1 year ago

Comment by Warren Hack on JIRA:

Drizzlepac PR #⁠1292 has been filed to correct the issue documented here.  In addition, the code was searched for other instances of binary table data was decoded as noted above, and this PR catches the only known instance in the package.  This PR did allow the ASN to be processed from the Python command line by calling astrodrizzle.AstroDrizzle("ibvz01020_asn.fits").   

Finally, none of the Pytest tests failed with astropy 5.0.1 prior to this fix, indicating that there should be no other operationally significant cases of astropy 5.0 problems lingering in this package.