[AstroPy] Creating file-like object from HDUList?
Ole Streicher
astropy at liska.ath.cx
Thu Sep 7 09:47:15 EDT 2017
Hi,
I have a rather large HDUList that was creating from a memory mapped
fits file by using slices on its data array(s):
from astropy.io import fits
hdul0 = fits.open('datacube.fits', memmap = True) // >> 1GB
hdul1 = fits.HDUList([ fits.PrimaryHDU(header = hdul0[0].header),
fits.ImageHDU(data = hdul0[1].data[:100, :100, :100],
header = hdul0[1].header)])
Is it now possible to create a file-like object opened in read mode without
needing to read everything beforehand? Like here:
res = io.BytesIO()
hdul1.writeto(res)
send_file(res, mime_type="application/fits")
but without creating a large in-memory object with res, and without
temporary storage on disk?
Best regards
Ole
More information about the AstroPy
mailing list