python - 如何在新的拟合文件中将两个 FITS 表合并为一个表?

标签 python fits pyfits

我有两个拟合文件数据(file1.fits 和 file2.fits)。第一个 (file1.fits) 包含 80,700 行重要数据,另一个包含 140,000 行。它们都有相同的 header 。

$ 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

如何将 file1.fits 和 file2.fits 合并到新的拟合文件 (newfile.fits) 中,其标题与旧文件相同,并且 newfile.fits 的总行数为 80,700+ 140,000 = 220,700 ?

最佳答案

我尝试过 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')

它似乎适用于 NASA 的样本。

关于python - 如何在新的拟合文件中将两个 FITS 表合并为一个表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39120050/

相关文章:

python - Pandas 使用日期作为索引加入/合并 2 个数据帧

python - 使用 2 个 FITS 文件将像素转换为波长

python - 在 python 中如何将 ascii 表转换为适合表?

python - 使用 numpy 和 pyfits 在 Python 中缩小图像数组的更快方法

python - TensorFlow random_shuffle_queue 已关闭且元素不足

Python 错误 "ImportError: No module named"

python - 如何将 `str.format` 直接用作 `__repr__` ?

python - 在 python 中打开并显示适合图像

image - 使用指定边界裁剪非常大的适合文件

python - 在 python 中折叠/展平 FITS 数据立方体