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
Refactor FITS compressed HDU to subclass ImageHDU #9238
Comments
I think that the root of the issues mentioned in the comments is the need to change CompImageHDU to subclass ImageHDU (instead of BinTableHDU), and handle internally a BinTableHDU (or just its header?), while the opposite is done currently: astropy/astropy/io/fits/hdu/compressed.py Lines 386 to 388 in fea594d
astropy/astropy/io/fits/hdu/compressed.py Lines 1874 to 1877 in fea594d
|
I have been experimenting with refactoring However, one of the things where we might have to break API related to the original issue here is that as def test_compression_header_insert(self):
with fits.open(self.data("comp.fits")) as hdul:
imghdr = hdul[1].header
tblhdr = hdul[1]._header
# First try inserting a restricted keyword
with pytest.warns(UserWarning, match="Keyword 'TFIELDS' is reserved") as w:
imghdr.insert(1000, "TFIELDS") because we wouldn't be subclassing Would we be ok with this change in API or is it crucial that we preserve the warnings at the point where the header keywords are set? (in which case we would need to keep a simplified version of I don't think making this change would really break people's code as such because it just moves the point at which the warning is emitted, but just wanted to check if there are any reasons this could be an issue. |
Do you mean that |
@mhvk - in my refactor, we can completely remove The class used to be needed because the compressed and decompressed header were kept in sync in real time, even though this wasn't strictly needed because the compressed header was private anyway. But it meant that one could do validation as soon as the header was changed. If we now just have a regular Header, and convert it on-the-fly at write time, that's when the warning will happen. As a side note, you mention |
Maybe a better idea would be to generalize this kind of check to the other HDU classes. Currently with |
The header for compressed images has a number of comments noting that its current design, as a subclass of
Header
does not work well at all, and that it would be good to refactor. This came up again while makingHeader
more suitable for subclassing - it brokeCompImageHeader
(#9229). This issue is a reminder to revisitCompImageHeader
.It might be good to try to address compressed images more generally; see #3895
The text was updated successfully, but these errors were encountered: