2

So I've been collating FITS table data into an HDUlist in astropy.io.fits. I would like to provide labels to the objects in the list such that they are easily distinguishable, and not just:

No.    Name         Type      Cards   Dimensions   Format
0    PRIMARY     PrimaryHDU     349   ()              
1                BinTableHDU     41   130R x 11C   [1E, 1E, 1E, 1J, 1J, 1J, 1J, 1E, 1E, 1J, 1J]   
2                BinTableHDU     41   105R x 11C   [1E, 1E, 1E, 1J, 1J, 1J, 1J, 1E, 1E, 1J, 1J]   
3                BinTableHDU     41   130R x 11C   [1E, 1E, 1E, 1J, 1J, 1J, 1J, 1E, 1E, 1J, 1J]   
4                BinTableHDU     41   105R x 11C   [1E, 1E, 1E, 1J, 1J, 1J, 1J, 1E, 1E, 1J, 1J]   
5                BinTableHDU     41   130R x 11C   [1E, 1E, 1E, 1J, 1J, 1J, 1J, 1E, 1E, 1J, 1J]   
6                BinTableHDU     41   105R x 11C   [1E, 1E, 1E, 1J, 1J, 1J, 1J, 1E, 1E, 1J, 1J]   

This goes on for quite a while - a typical list, in my case, contains 54 BinTableHDU files.

I was wondering whether it was possible to add some sort of further label or identifier such that it can be made immediately obvious to anybody using the code as to what exactly is in each table? Thanks.

George P
  • 69
  • 1
  • 1
  • 8

1 Answers1

2

Yes, you can do this by simply setting the name attribute on HDU objects, e.g:

In [9]: hdulist[1].name = "Camelot"

In [10]: hdulist.info()
Filename: (No file associated with this HDUList)
No.    Name         Type      Cards   Dimensions   Format
0    PRIMARY     PrimaryHDU       4   ()              
1    CAMELOT     ImageHDU         6   ()              
astrofrog
  • 32,883
  • 32
  • 90
  • 131