FITS Binary Table to Astropy Table round trip re-orders COMMENT cards
See original GitHub issueI’m really not sure if this could be considered a true bug or not, but I imagine it will cause some users some frustration. When a FITS Binary file is round-tripped from an Astropy Table back to a FITS file (using Astropy.table.Table.read
and fits.table_to_hdu
) the COMMENT
cards all get shuffled to the bottom of the header. A lot of HST data uses these COMMENT
cards like section titles, not sure if other data tends to do this. I’m using astropy 3.1.dev21825 in this example.
Original, near the top of the header:
Output after round tripping, at the bottom of the header:
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Table Data — Astropy v5.2
The data in a FITS table HDU is basically a record array with added attributes. The metadata (i.e., information about the table data)...
Read more >python 3.x - Re-order cards in a FITS header - Stack Overflow
The problem with FITS is it mixes information that describes the binary structure of the file itself along with metadata in the same...
Read more >TOPCAT - Tool for OPerations on Catalogues And Tables
HISTORY and COMMENT cards are run together as one multi-line value. ... As well as normal binary and ASCII FITS tables, STIL supports...
Read more >STIL - Starlink Tables Infrastructure Library
HISTORY and COMMENT cards are run together as one multi-line value. ... As well as normal binary and ASCII FITS tables, STIL supports...
Read more >Astropy Documentation - Read the Docs
coordinates, and table subpackages integrate better with Quantity, ... Binary installers are available on Windows for Python 2.6, 2.7, 3.1, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Table.meta
is anOrderedDict
by default I think. The issue has more to do with the way COMMENT/HISTORY/BLANK are managed by thefits.Header
code (by default normal cards are inserted before these cards I think, hence the use ofend=True
).Keeping the order (in a way that makes sense) gets complicated when header changes, e.g., add/remove keyword/comment/history/column. Sara and I talked about this and at some point concluded that it is easier to just show people how to re-order their header via some manual scripting. 😬