[AstroPy] AstroPy Digest, Vol 151, Issue 3

Ivan Valtchanov ivvv68 at gmail.com
Wed Apr 17 14:32:16 EDT 2019


Hi Christoph,

You cannot use BinTableHDU to create an astropy.tableTable object. When you
try to do this you get this error:

table = Table(hdu[1])

 Data type <class 'astropy.io.fits.hdu.table.BinTableHDU'> not allowed to
init Table

But this one works,

table = Table(hdu[1].data)

although I don't think it's documented in  astropy.table docs.
<http://docs.astropy.org/en/stable/table/> I could not find it easily.

Cheers,
Ivan


On Wed, 17 Apr 2019 at 19:41, Christoph Deil <deil.christoph at googlemail.com>
wrote:

> Hi Rick,
>
> if you want a astropy.table.Table object, use Table.read.
>
> You can pass it a filename, but you can also pass an astropy.io.fits.BinTableHDU
> object,
> If for some reason you already have it in memory.
>
> I agree it’s weird that Table.read does this, adding a
> astropy.io.fits.hdu_to_table function would make this easier to discover.
> Maybe file an issue with Astropy with that suggestion?
>
> Christoph
>
> On 17. Apr 2019, at 18:52, Benjamin Weiner <bjw at as.arizona.edu> wrote:
>
> Ugh, I mistyped a variable name, my example should be
> hdulist = fits.open('myfilename.fits')
> mydata = hdulist[1].data   # makes a table from the data in extension 1
>
>
>
> On Wed, Apr 17, 2019 at 9:51 AM Benjamin Weiner <bjw at as.arizona.edu>
> wrote:
>
>> Hello Rick,
>>
>> You should be able to read a FITS binary table with something like:
>>
>> from astropy.io import fits
>> hdulist = fits.open('myfilename.fits')
>> mydata = hdu[1].data   # makes a table from the data in extension 1
>>
>> This is covered in the astropy.io.fits documentation at
>> http://docs.astropy.org/en/stable/io/fits/
>>
>> Cheers,
>> Ben Weiner
>>
>> Date: Wed, 17 Apr 2019 15:43:56 +0200
>>> From: "Frederic V. Hessman" <hessman at astro.physik.uni-goettingen.de>
>>> To: astropy at python.org
>>> Subject: [AstroPy] HDU to Table
>>>
>>> There's the convenience function
>>>
>>>         astropy.io.fits.table_to_hdu (astropy.table.Table) ->
>>> astropy.io.fits.BinTableHDU
>>>
>>> but where's
>>>
>>>         astropy.io.fits.hdu_to_table(astropy.io.fits.BinTableHDU) ->
>>> astropy.table.Table ?
>>>
>>> Surely people are writing AND reading binary tables.....!    I want to
>>> dump IFU spectra into a single FITS binary table file and then easily read
>>> them back in again.
>>>
>>> My internet searches haven't yielded anything equivalent.  Of course,
>>> one can write the reverse conversion (one can write anything/everything),
>>> but this should be a standard FITS/Table function.
>>>
>>> Rick
>>>
>>>
>>> ------------------------------------------------------------------------------------------------
>>> Dr. Frederic V. Hessman     Hessman at Astro.physik.Uni-Goettingen.DE
>>> Institut f?r Astrophysik          Tel.  +49-551-39-5052
>>> Friedrich-Hund-Platz 1         Fax +49-551-39-5043
>>> 37077 Goettingen                 Room F04-133
>>> http://www.Astro.physik.Uni-Goettingen.de/~hessman
>>> <http://www.astro.physik.uni-goettingen.de/~hessman>
>>>
>>> -------------------------------------------------------------------------------------------------
>>> MONET: a MOnitoring NEtwork of Telescopes
>>> http://monet.Uni-Goettingen.de <http://monet.uni-goettingen.de/>
>>>
>>> -------------------------------------------------------------------------------------------------
>>>
>>>
>> --
>> Benjamin Weiner
>> Staff Scientist / Associate Astronomer, MMT / Steward Observatory
>> bjw at as.arizona.edu
>> http://mingus.mmto.arizona.edu/~bjw/ <http://mingus.as.arizona.edu/~bjw/>
>>
>
>
> --
> Benjamin Weiner
> Staff Scientist / Associate Astronomer, MMT / Steward Observatory
> bjw at as.arizona.edu
> http://mingus.mmto.arizona.edu/~bjw/ <http://mingus.as.arizona.edu/~bjw/>
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20190417/fd3c7021/attachment.html>


More information about the AstroPy mailing list