读取多扩展名的问题。适合文件

发布于 2025-02-06 15:36:25 字数 704 浏览 3 评论 0原文

我正在尝试阅读/打开一些多extension .fits文件。但是我打开它们有问题。这是我用来打开的COD的一部分。适用于同一文件夹中的文件:

imgs = sorted(glob.glob('location_of_the_files/*.fits'))


for location in imgs:   
    hdul = fits.open(imgs) 
    original = hdul[1].data
    model = hdul[2].data
    residual = hdul[3].data

运行此文件时,我会得到此信息:

OSError: File-like object does not have a 'write' method, required for mode 'ostream'.

我尝试在Internet上检查,但我不明白发生了什么。 关于如何解决这个问题有帮助吗?

在尝试使用此代码打开单个.fits文件时

hdul = fits.open("location_of_the_files/image_data.fits")

original = hdul[1].data 
model = hdul[2].data
residual = hdul[3].data

,请务必提及。 一切都没有任何问题。 。

谢谢。

I am trying to read/open some multi-extension .fits files. But I have a problem opening them. Here is the part of the cod I am using to open .fits files located in the same folder:

imgs = sorted(glob.glob('location_of_the_files/*.fits'))


for location in imgs:   
    hdul = fits.open(imgs) 
    original = hdul[1].data
    model = hdul[2].data
    residual = hdul[3].data

When running this I am getting this:

OSError: File-like object does not have a 'write' method, required for mode 'ostream'.

I try to check on the internet, but I do not understand what is going on.
Any help on how to solve this?

Maybe it is important to mention when trying to open single .fits file with this code everything works without any problem:

hdul = fits.open("location_of_the_files/image_data.fits")

original = hdul[1].data 
model = hdul[2].data
residual = hdul[3].data

If needed let me know and I can upload .fits files (in that case, please just tell me how to do this here).

Thanks.

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

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

发布评论

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

评论(1

春夜浅 2025-02-13 15:36:25

我想您试图做这样的事情:

for location in imgs:   
    with fits.open(location) as hdul:
       original = hdul[1].data
       model = hdul[2].data
       residual = hdul[3].data
   ...

注意位置而不是imgs作为open> open方法的参数。

I suppose that you were trying to do something like this:

for location in imgs:   
    with fits.open(location) as hdul:
       original = hdul[1].data
       model = hdul[2].data
       residual = hdul[3].data
   ...

Note the location instead of imgs as an argument of open method.

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