FITS: flexible image transport system
HDU(header and data unit):
1、头文件(header)
2、数据单元(data)
SIMPLE: 标准FITS(T)
BITPX: 图像数据格式 -32单精度 -64双精度
NAXIS: 图像数据矩阵的维数
NAXISi: 每个维度的大小
END:
fits文件查看:
from astropy.io import fits
hdu=fits.open('1195+285U.fits')
hdu.info() #查看文件基本信息
hdu[0] #主单元
hdu[1] #第一个扩展单元
hdu[0].header #查看头文件
hdu[0].header['SIMPLE']
hdu[0].header.comments['SIMPLE']
hdu[1].data[0] #查看数据单元
hdu[1].data[0][0]
hdu[1].data.field(0)
hdu[1].data.names
hdu[1].data.field('FLUX1')
fits文件读写:
from astropy.io import fits
import os
hud=fits.open('1195+285U.fits')
img=hud[0].data
path='C:/Users/Administrator/Desktop/'
'''if os.path.exists(path+'1.fits'):
os.remove(path+'1.fits')'''
grey=fits.PrimaryHDU(img)
greyHDU=fits.HDUList([grey])
greyHDU.writeto(path+'1.fits')
hdu[1] error