FITS Table columns read as 2D arrays
See original GitHub issueDescription
The following code:
from astropy.io import fits
from astropy.table import Table
with fits.open('whatever.fits') as f:
d = Table.read(f)
print(d['SUPRA'].shape)
outputs (1294, 1)
in v4.2.1 and (1294,)
in v3.1.2.
This makes quite a bit of our previous code non-backwards compatible.
Expected behavior
I expected (1294,)
as in previous versions.
Actual behavior
Output is (1294, 1)
with v4.2.1.
Steps to Reproduce
See code above.
System Details
Linux-5.11.0-25-generic-x86_64-with-glibc2.29
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0]
Numpy 1.20.2
astropy 4.2.1
Scipy 1.6.2
Matplotlib 3.4.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Table Data — Astropy v5.2
Metadata of a Table. The data in a FITS table HDU is basically a record array with added attributes. The metadata (i.e., information...
Read more >How to convert a two column fits table into a 2D array in python
Try to access the .data property of the table, should be an array. See also Converting astropy.table.columns to a numpy array.
Read more >Multi-dimensional arrays in variable-length array columns of a ...
Being able to write any n-dimensional arrays to a VLA column, writing that to a file and then successfully reading the column (round-trip)....
Read more >6.7.4 Read and Write Column Data Routines - HEASARC
These routines return the values of the table column array elements. Any undefined array elements will have the corresponding flagvals element set equal...
Read more >Viewing and manipulating data from FITS tables
We can extract data from the table by referencing the column name. For example, I'll make a histogram for the galaxy stellar masses...
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 FreeTop 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
Top GitHub Comments
So the behavior of astropy here is correct and following the standard.
The Problem is not TFORM, but TDIM.
An empty TDIM is a 0D element, so the whole column is 1D. A TDIM of
(1)
means that each element is a 1d array of 1 element, so the whole column becomes 2D.Please fix the code producing your files if having 2d columns is not the intention. The FITS standard is pretty clear on this: