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
Fixed a bug that caused compressed images with TFORM missing the optional '1' prefix to not be readable #15001
Conversation
…onal '1' prefix to not be readable.
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
break | ||
else: | ||
raise RuntimeError(f"Invalid TFORM1: {header['TFORM1']}") | ||
for suffix in range(1, 10): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's possible to have more than 2 columns ? (COMPRESSED_DATA
and GZIP COMPRESSED DATA
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One can also have ZSCALE and ZZERO for instance, and I'm not sure if the standard disallows additional columns that the user might have added - but I've now changed this to use TFIELDS to know how many columns there actually are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unlikely that there would be more columns:
10.1.3. Table columns
Two columns in the FITS binary table are defined below to con-
tain the compressed image tiles; the order of the columns in the
table is not significant.
[...]
COMPRESSED DATA – [variable-length; required]
GZIP COMPRESSED DATA [variable-length; optional]
But using TFIELDS seems a fine solution 👍
dtype = ">i2" | ||
elif tform[2] == "J": | ||
elif tform[1] == "J": | ||
dtype = ">i4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this if/else block can probably be replaced by tform.recformat.dtype
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried this but got some test failures, so I might leave this to another follow-up PR as I need time to investigate what is going wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it's just that it seems we could reuse more code from io.fits.column
for the header parsing and maybe for the verification, but fine to keep this for later.
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @astrofrog !
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
@astrofrog , you changed the API signature in #14821 . So this cannot be backported cleanly without also backporting that one. I am not sure if I want to make assumptions here, so I'll leave the manual backport to you. |
…with TFORM missing the optional '1' prefix to not be readable
…with TFORM missing the optional '1' prefix to not be readable
Manual backport PR: #15014 |
…-v5.3.x Backport PR #15001 on branch v5.3.x (Fixed a bug that caused compressed images with TFORM missing the optional '1' prefix to not be readable)
Fixes #14985