-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
astropy.table writes int8 column in boolean in FITS output #11963
Comments
Welcome to Astropy 👋 and thank you for your first issue! A project member will respond to you as soon as possible; in the meantime, please double-check the guidelines for submitting issues and make sure you've provided the requested details. If you feel that this issue has not been responded to in a timely manner, please leave a comment mentioning our software support engineer @embray, or send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail feedback@astropy.org. |
Thank you for the report. This is more specifically a lower-level issue about The FITS standard does not allow for signed bytes in table columns. It is simply not one of the supported data types for FITS tables. Only unsigned bytes are supported. For some historical reason that I can't recall, however, the code interprets an array of signed bytes as a boolean column. I'd have to investigate more to see why that is. I think, at the very least, we could provide a better warning about this. |
In any case, if your goal is to write signed bytes to a FITS table, you will have to change your approach, because it's not something supported by the FITS format, for some reason :/ |
Thanks @embray. For people that are unaware of this "feature" in the FITS standard, it would be completely unexpected that it silently turns integers into booleans. So, yes, I think it would be great if it prompts a warning or error when this happens. |
See also #11996 |
This is incorrect. The FITS standard does allow storing Table should be able to round trip such data through fits. The corresponding keywords for columns of binary tables are |
Edit: checking writing unsigned ints through the table interface, they are used for this. So the same change as in #11996 for image extensions could be made for table extensions. |
From comments on #16502 (which is a duplicate), for tables two changes would need to be made: The mapping is at astropy/astropy/io/fits/column.py Lines 29 to 64 in 8c21018
Detection of signed integer for an unsigned byte could then follow similar logic to that used for the unsigned integer detection bits, at astropy/astropy/io/fits/column.py Lines 1405 to 1425 in 8c21018
|
Description
When writing an astropy Table containing a np.int8 column into a FITS file, that column becomes boolean in the output
System Details
Python 3.8.5 (default, Sep 4 2020, 02:22:02)
[Clang 10.0.0 ]
Numpy 1.20.3
astropy 4.2.1
The text was updated successfully, but these errors were encountered: