我试图从我的系统打开一个fitsfile我打开我的目录,我调用一个星号但是当我打开这个fitsfile时,我得到一个错误
Directory=r"C:/Users/sam/Desktop/23may.list", "r"
star1=("EFOSC.2021-05-24T06:02:52.743.fits",)
hdu = fits.open (Directory + star1)
hdr = hdu[0].header
dat = hdu[0].data
zp = hdr['CRVAL1']
stw = hdr['CD1_1']
误差
----> 1 hdu = fits.open (Directory + star1)
OSError: File-like object does not have a 'write' method, required for mode 'ostream'.
我不知道我该做什么
>>> print(Directory + star1)
('C:/Users/sam/Desktop/23may.list', 'r', 'EFOSC.2021-05-24T06:02:52.743.fits')
这看起来不像fits.open()
所期望的。正确地构造文件路径就可以了。
>>> fitsname = 'numpy/core/tests/data/recarray_from_file.fits'
>>> hdu = fits.open(fitsname)
>>> type(hdu[0].header)
<class 'astropy.io.fits.header.Header'>