[AstroPy] Creating file-like object from HDUList?

Kelle Cruz kellecruz at gmail.com
Mon Sep 25 13:39:09 EDT 2017


Hi Ole and Benjamin,

We discussed this question at the recent Coordination Meeting and the short
answer is “we don’t have a solution at the moment”.

However, the general consensus is that this question would be worth posting
in the Python in Astronomy Facebook group, which has many members (>2,500)
and is quite active:
https://www.facebook.com/groups/astropython/

Ole, if you don’t Facebook, would you mind if I posted it?

(And if y’all have a sec, please consider checking to see if any of your
colleagues/FB friends have requested to join — current members can approve
join requests of their friends. And if you need someone added, please send
me an email directly or a FB message with their FB username.)

Kelle

On Fri, Sep 15, 2017 at 2:57 PM, Benjamin Alan Weaver <baweaver at lbl.gov>
wrote:

> Hello y'all,
>
> I'd be interested in an answer to this question as well.
>
> Kia ora koutou,
> Benjamin Alan Weaver
>
> On Thu, Sep 7, 2017 at 6:47 AM, Ole Streicher <astropy at liska.ath.cx>
> wrote:
>
>> 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
>>
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at python.org
>> https://mail.python.org/mailman/listinfo/astropy
>>
>
>
>
> --
> With great responsibility seldom comes great power.
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
>
>


-- 
Kelle Cruz, PhD — http://kellecruz.com/
917.725.1334 — Hunter: x16486 — AMNH: x7930
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20170925/84b791f8/attachment.html>


More information about the AstroPy mailing list