Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Undo disable lazy loading hack in stpyfits, maybe #118

Open
pllim opened this issue Apr 3, 2020 · 0 comments
Open

MNT: Undo disable lazy loading hack in stpyfits, maybe #118

pllim opened this issue Apr 3, 2020 · 0 comments

Comments

@pllim
Copy link
Contributor

pllim commented Apr 3, 2020

The hack was put in via 678c4ee when astropy.io.fits went to lazy loading (I think it was astropy/astropy#6082). I found an old note to investigate further, which I never got to. I vaguely remember looking at stpyfits and concluded that some significant refactoring might be necessary if we're going to do this the right way.

However, maybe removing the hack is not worth the time given that everything is working fine and the hack was a simple one-liner. But then again, if this hack breaks in the future or we find that it is no longer sufficient for "big data" or whatever, we might need to revisit, so hopefully this issue will be helpful then.

Notes to reproduce the problem without this hack

Example given by @stsci-hack on 2017-06-13, "The image I used to demonstrate the problem was nothing special, simply a RAW ACS image... This problem was easily reproduced using any RAW FITS file retrieved from the archive."

>>> from stsci.tools import stpyfits as sfits
>>> from drizzlepac import resetbits
>>> r = resetbits.reset_dq_bits('j9bc59wfq_raw.fits',4096, extver=1,extname='DQ')
.../hstdp-2017.2-2/lib/python3.5/site-packages/drizzlepac/resetbits.py
in reset_dq_bits(input, bits, extver, extname)
     150         for extn in extver:
     151             dqarr = p[extname,extn].data
--> 152             dqdtype = dqarr.dtype
     153             # reset the desired bits
     154             p[extname,extn].data = (dqarr &
~bits).astype(dqdtype) # preserve original dtype

AttributeError: 'NoneType' object has no attribute 'dtype'
>>> fimg = sfits.open('j9bc59wfq_raw.fits')
>>> fimg.info()
Filename: j9bc59wfq_raw.fits
No.    Name         Type      Cards   Dimensions   Format
   0  PRIMARY     PrimaryHDU     221   ()
   1  SCI         ImageHDU       146   (200, 200)   int16
   2  ERR         ImageHDU        58   ()
   3  DQ          ImageHDU        50   ()
   4  WCSCORR     BinTableHDU     59   7R x 24C   [40A, I, A, 24A, 24A,
24A, 24A, D, D, D, D, D, D, D, D, 24A, 24A, D, D, D, D, J, 40A, 128A]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant