I don't use ds9, but apparently the -mecube
option means "multi-extension cube". The docs say "Load a multi-extension FITS file as a data cube. You're just writing a single array as a data cube. To write it as a multi-extension FITS you might do something like:
hdul = fits.HDUList()
hdul.append(fits.PrimaryHDU())
for img in export_array:
hdul.append(fits.ImageHDU(data=img))
hdul.writeto('output.fits')
(You don't need to call hdul.close()
--that only does anything if the HDUList
was loaded from an existing file and you want to close the underlying file object; it has no effect for an HDUList
created from scratch in memory).
I don't know exactly what ds9 is expecting for loading a multi-extension FITS file as a data cube--this isn't any specific FITS convention and the docs arent't clear. But it's probably something like that.
All that said, according to the ds9 docs you don't need to use this at all. If you don't use the -mecube
option it will just read the 3D array in the primary HDU as a data cube.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…