-
-
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
Better astropy.io.fits representation #7648
Comments
About the fitsio-like summary, a similar idea was proposed by @astrofrog in #821, putting each kind of information on a line instead of trying to format a table with variable width. This could indeed make a good repr for HDU objects, and probably also HDUList. In [1]: import fitsio
In [2]: fitsio.FITS('astropy/io/fits/tests/data/o4sp040b0_raw.fits')
Out[2]:
file: astropy/io/fits/tests/data/o4sp040b0_raw.fits
mode: READONLY
extnum hdutype hduname[v]
0 IMAGE_HDU
1 IMAGE_HDU SCI[1]
2 IMAGE_HDU ERR[1]
3 IMAGE_HDU DQ[1]
4 IMAGE_HDU SCI[2]
5 IMAGE_HDU ERR[2]
6 IMAGE_HDU DQ[2]
In [3]: fitsio.FITS('astropy/io/fits/tests/data/o4sp040b0_raw.fits')[1]
Out[3]:
file: astropy/io/fits/tests/data/o4sp040b0_raw.fits
extension: 1
type: IMAGE_HDU
extname: SCI
extver: 1
image info:
data type: u2
dims: [44,62]
In [4]: fitsio.FITS('astropy/io/fits/tests/data/tb.fits')
Out[4]:
file: astropy/io/fits/tests/data/tb.fits
mode: READONLY
extnum hdutype hduname[v]
0 IMAGE_HDU
1 BINARY_TBL
In [5]: fitsio.FITS('astropy/io/fits/tests/data/tb.fits')[1]
Out[5]:
file: astropy/io/fits/tests/data/tb.fits
extension: 1
type: BINARY_TBL
rows: 2
column info:
c1 i4
c2 S3
c3 f4
c4 b1 |
That seems like a very nice solution, and sorry for not finding the original issue about this. I'm happy to get this one closed if it's being tracked there. I have some code that I use to monkeypatch the |
I would be in favor of this, but it would great to have other opinions, pinging @MSeifert04 @drdavella @astrofrog 😉 For |
The default representations for
HDUList
andImageHDU
are not very informative. ForHDUList
it would be nice if it automatically returnedHDUList.info()
. ForImageHDU
a summary à la fitsio with the shape of the image, dtype, number of header keywords, etc would be useful.Also,
HDUList.info()
could use some better formatting: it is sometimes difficult to read when you have things likeThe text was updated successfully, but these errors were encountered: