I have a 3D NumPy array (i.e. (10, 256, 256)) representing 256x256 images. I would like to write this array to a FITS file using astropy.io.fits so that I can open the file using ds9 -mecube and move through the frames. My attempt is shown below
export_array = numpy.array(images) #Create an array from a list of images
print export_array.shape ## (10, 256, 256)
hdu = fits.PrimaryHDU(export_array)
hdulist = fits.HDUList([hdu])
hdulist.writeto(out_file_name)
hdulist.close()
This will give me a FITS file which does in fact contain the 3D array. However if I open with ds9 -mecube I can only see the first image. Is there anyway to create the FITS file with this functionality using astropy.io.fits? Or is there perhaps some functionality with ds9 that I am missing?