How to Create .fits file from numpy array

泪湿孤枕 提交于 2020-01-06 07:01:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!