[AstroPy] astropy.io.fits won't allow me to modify the NAXIS keywords
Adam Ginsburg
adam.g.ginsburg at gmail.com
Mon Oct 23 11:10:27 EDT 2017
> Do you know what would be the best syntax to add a trailing dimension from
> a 2D image? I mean, in a clever way without doubling the memory consumption.
>
>
I'm not sure this is what you meant to ask, but I'll answer:
The simplest way to expand an array's dimensions without expanding its
memory consumption is with an indexing trick. This will turn a 2D array
(assuming the original file was 2D) into a 4D array with dimensions 3 and 4
having size 1:
data = fits.getdata(filename)
data[:, :, None, None]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20171023/a3587c0c/attachment.html>
More information about the AstroPy
mailing list