如何使用循环对多个天文表进行 vstack

发布于 2025-01-18 02:39:30 字数 274 浏览 4 评论 0原文

我有一个Astropy表的列表,我想使用循环来vstack。

这就是我所拥有的:

tables = []

for i in range(len(sortedfiles)):
    tables.append(openfits(sortedfiles[i]))

它创建一个列表,每个元素都是Astropy表。我总共有144个这样的表。

我想垂直堆叠它们,所以我实际上只有一个Astropy桌子,但是我想不出正确的循环。有什么想法吗? tia

I have a list of astropy tables and I want to vstack them all using a loop.

This is what I have:

tables = []

for i in range(len(sortedfiles)):
    tables.append(openfits(sortedfiles[i]))

which creates a list where each element is an astropy table. I have a total of 144 such tables.

I want to vertically stack them so I have effectively just the one astropy table but I cannot think of the right kind of loop. Any ideas? TIA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凝望流年 2025-01-25 02:39:30

你很近!剩下的就是:

from astropy.table import vstack
table_stacked = vstack(tables)

您所做的工作是为了读取table列表的所有表,然后在末尾进行单个vstack操作是正确的方法。请勿在循环中使用vstack,因为这会慢。

You are very close! All that is left is:

from astropy.table import vstack
table_stacked = vstack(tables)

What you have done to read all the tables up front to a list of Table followed by a single vstack operation at the end is the right way. Do not use vstack within the loop since this will be slower.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文