【发布时间】:2020-03-03 16:16:54
【问题描述】:
所以我保存了一些 Astropy 拟合表(它们都具有相同的格式、列名等)。我想把所有这些 fit 文件合并成一个大的 fit 文件。
目前,我正在使用 astropy.io 的追加和更新功能,但无济于事。
任何帮助将不胜感激。
【问题讨论】:
标签: python append concatenation astropy fits
所以我保存了一些 Astropy 拟合表(它们都具有相同的格式、列名等)。我想把所有这些 fit 文件合并成一个大的 fit 文件。
目前,我正在使用 astropy.io 的追加和更新功能,但无济于事。
任何帮助将不胜感激。
【问题讨论】:
标签: python append concatenation astropy fits
所以我现在可以使用它了。这就是我本质上所做的:
# Read in the fits table you want to append
table = Table.read(input_file, format='fits')
# Read in the large table you want to append to
base_table = Table.read('base_file.fits', format='fits')
# Use Astropy's 'vstack' function and overwrite the file
concat_table = vstack([base_table,append_table])
concat_table.write('base_file.fits', format='fits', overwrite=True)
就我而言,每个表的所有列都是相同的。所以我只是遍历了所有的 fit 文件,并一次添加一个。可能还有其他方法可以做到这一点,但我发现这是最简单的。
【讨论】: