结合Astropy文件?

2024-09-30 20:26:50 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我保存了一些astropyfits表(它们都有相同的格式、列名等)。我想把所有这些配合文件,并结合起来,使一个大配合文件。你知道吗

目前,我正在和天文学家附加和更新函数无效。你知道吗

任何帮助都将不胜感激。你知道吗


Tags: 文件函数格式天文学家astropyfits
1条回答
网友
1楼 · 发布于 2024-09-30 20:26:50

所以我现在可以用了。我基本上就是这么做的:

# 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)

在我的例子中,每个表的所有列都是相同的。所以我只是循环浏览所有的fits文件,然后一次附加一个。可能还有其他方法,但我发现这是最简单的。你知道吗

相关问题 更多 >