问题
I am currently trying to convert a .cr2 into .fits file. I am currently unable to create .fits as any file I create doesn't open or work because of the wrong shape of fits.
I have tried using the solution Write 3d Numpy array to FITS file with Astropy but, still, it doesn't work.
import numpy as np
from astropy.io import fits
im = imageio.imread(r'E:\FYP\cr.cr2', format="RAW-FI")
a = np.array(im)
print (a.shape)
hdu = fits.PrimaryHDU(a)
hdulist = fits.HDUList([hdu])
hdulist.writeto(r'E:\FYPcr.fits')
It successfully creates the .fits file but, gives an error when opened "Cannot read fits file". Whenever I try to open a fits file created from another software it opens without any problem.
来源:https://stackoverflow.com/questions/57846507/how-to-create-fits-file-from-numpy-array