FITS python

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

参考文章:http://blog.sina.com.cn/s/blog_cfb724900102uz4p.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章