<div dir="ltr">Just so you know, any file I/O can be done completely in memory with BytesIO:<br><br><br>>>> from <a href="http://astropy.io">astropy.io</a> import fits<br>>>> from astropy.table import Table<br>>>> import io<br>>>> t = Table(names=('a', 'b', 'c'), dtype=('f4', 'i4', 'S2')); t.add_row((1, 2.0, 'x')); t.add_row((4, 5.0, 'y'))<br>>>> buf = io.BytesIO()<br>>>> t.write(buf, format='fits')<br>>>> buf.seek(0)<br>0<br>>>> print(fits.open(buf))<br>[<astropy.io.fits.hdu.image.PrimaryHDU
object at 0x7fb97ee77da0>, <astropy.io.fits.hdu.table.BinTableHDU
object at 0x7fb974a409e8>]<br><br><br>Note that older versions of python use StringIO.StringIO instead of io.BytesIO</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 17, 2014 at 8:55 PM, David Kirkby <span dir="ltr"><<a href="mailto:dkirkby@uci.edu" target="_blank">dkirkby@uci.edu</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Is it possible to create a table as an astropy.table.Table and then convert it to an astropy.fits.io.BinTableHDU suitable for adding to the astropy.io.fits.HDUList of a multi-extension file? <div><br></div><div>I guess that astropy.table.Table.write already implements this but I didn't see how to only generate a new HDU in memory with this API.</div><div><br></div><div>thanks,</div><div>David</div><div><br></div></div>
<br>_______________________________________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/astropy" target="_blank">http://mail.scipy.org/mailman/listinfo/astropy</a><br>
<br></blockquote></div></div>