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

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