2016-08-24 91 views
0

我有兩個適合文件數據(file1.fits和file2.fits)。第一個(file1.fits)包含80,700個重要的數據行,另一個是140,000行。他們倆都有相同的標題。如何將兩個FITS表合併到新的適合文件中的單個表中?

$ python 
>>> import pyfits 
>>> f1 = pyfits.open('file1.fits') 
>>> f2 = pyfits.open('file2.fits') 
>>> event1 = f1[1].data 
>>> event2 = f2[1].data 
>>> len(event1) 
80700 
>>> len(event2) 
140000 

我怎樣才能用相同的標題爲舊的和newfile.fits行的總數相結合file1.fits和file2.fits到新的擬合文件(newfile.fits)是80,700+ 140000 = 220,700?

+1

從第2行開始執行重要數據並繼續執行? –

+1

你可以從https://stackoverflow.com/questions/33850641/how-to-merge-two-table-with-pyfits獲得靈感? –

+0

謝謝@ Tiger-222 –

回答

1

我試着用astropy

from astropy.table import Table, hstack 

t1 = Table.read('file1.fits', format='fits') 
t2 = Table.read('file2.fits', format='fits') 
new = hstack([t1, t2]) 
new.write('combined.fits') 

這似乎與美國航空航天局的樣品的工作。