我有一个.fits文件的URL,希望能够像在本地一样读入Python。我尝试过以下方式:
import urllib2 as url, astropy.io.fits as fits
target_url = 'https://s3.amazonaws.com/bdnyc/spex_prism_U50171_0835%2B19_chiu06.fits'
obj = url.urlopen(target_url)
dat = fits.open(obj)
但是我得到了一个IOError错误:文件对象没有“write”方法,需要模式“ostream”。
即使我在fits.open()中设置了mode='readonly',它也说无法向文件对象写入。
有没有一种方法可以从URL打开.fits文件?或者将urlopen()返回的.fits文件字节转换回HDUList?
fits.open()
中。尽管我认为应该支持传递一个urlopen对象,但从未得到支持。如果没有别的原因,那么您收到的错误信息是具有误导性的。我已经为此开了一个问题:https://github.com/astropy/astropy/issues/4165 - Iguananaut