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

stpyfits incompatible with Astropy 3.2 #98

Closed
pllim opened this issue Jun 11, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@pllim
Copy link
Contributor

commented Jun 11, 2019

This is most probably caused by astropy/astropy#8502 . In stpyfits, it inherits _ImageBaseHDU and then assumes the header has a copy() method, which is no longer true.

class _ConstantValueImageBaseHDU(fits.hdu.image._ImageBaseHDU):
"""
A class that extends the `astropy.io.fits.hdu.base._BaseHDU` class to extend its
behavior to implement STScI specific extensions to `astropy.io.fits`.
The `astropy.io.fits.hdu.base._BaseHDU class` is:
"""
__doc__ += fits.hdu.image._ImageBaseHDU.__doc__
def __init__(self, data=None, header=None, do_not_scale_image_data=False,
uint=False, **kwargs):
if header and 'PIXVALUE' in header and header['NAXIS'] == 0:
header = header.copy()

I think the fix here is to force the header to not lazy load (diligent load?) first before doing the copy.

Example failure log: https://travis-ci.org/spacetelescope/stsci.tools/jobs/543835788

@pllim pllim added bug 🔥 labels Jun 11, 2019

@saimn

This comment has been minimized.

Copy link
Contributor

commented Jun 11, 2019

With the new version in Astropy the header is not supposed to be modified at this stage. Because when instantiating the HDU object, the full header has not yet been parsed, only a minimal header has been parsed for the HDUs creation.
So one possible solution could be to delay the stuff done here to when the full header is loaded, which could possibly be done by overriding the _DelayedHeader descriptor (more specifically its __get__ method).
Another option could be to do this manually, moving the code to a "modify_header" method which would be called once when header or data is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.