FITS python

1070 ワード

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