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.
r'E\FYPcr.fits', since otherwise the `\` can be misinterpreted as part of an escape sequence. See this answer for more details. It's probably not your problem but stranger things have happened.magick input.cr2 output.fitsReplacemagickwithconvertif using v6 rather than v7.print(a.shape)but you didn't actually tell us what it is. Maybe CCDStack can't work with arbitrary-dimensional FITS data.