Write 3d Numpy array to FITS file with Astropy
问题 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