Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 有没有一种方法可以让马赛克与astropy相匹配?_Python_Astropy_Fits - Fatal编程技术网

Python 有没有一种方法可以让马赛克与astropy相匹配?

Python 有没有一种方法可以让马赛克与astropy相匹配?,python,astropy,fits,Python,Astropy,Fits,我想在一个独特的.fits文件中使用不同的HDU创建一个马赛克,就像使用SAOimage DS9并选择文件>打开为>马赛克WCS时一样。当我搜索如何使用astropy实现这一点时,我遇到了reproject,并试图在上遵循教程。然而,我似乎无法让它为我工作 打开文件时,我有一个HDUList对象,因此我尝试按照reproject_和coadd文档进行操作,并使用教程中未使用的一些其他参数。这是我一直尝试使用的代码: f=fits.openinput\u文件,memmap=True printf

我想在一个独特的.fits文件中使用不同的HDU创建一个马赛克,就像使用SAOimage DS9并选择文件>打开为>马赛克WCS时一样。当我搜索如何使用astropy实现这一点时,我遇到了reproject,并试图在上遵循教程。然而,我似乎无法让它为我工作

打开文件时,我有一个HDUList对象,因此我尝试按照reproject_和coadd文档进行操作,并使用教程中未使用的一些其他参数。这是我一直尝试使用的代码:

f=fits.openinput\u文件,memmap=True printf 数组,footprint=reproject\u和\u coaddinput\u data=f,output\u projection=f[5]。标头,hdu\u in=f[0]。标头,reproject\u函数=reproject\u interp f、 接近 当我执行typef时,f的输出如下所示,我得到它表示它是一个HDUList:

[<astropy.io.fits.hdu.image.PrimaryHDU object at 0x7fdcc468aa50>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x7fdcc462aa10>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x7fdcc4632690>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x7fdcc462a110>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x7fdcc4638310>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x7fdcc463bf50>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x7fdcc4642b90>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x7fdcc4649810>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x7fdcc464e4d0>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x7fdcc4655150>]
如果有人能帮助我,我会非常高兴:

此外,如果可能的话,是否有一种方法可以打开两个组件图像并用它们制作马赛克?因此,不要一次打开所有9个瓷砖,只需获取瓷砖11和瓷砖12。我是一个新来捣乱的人。适合,所以这也会很酷知道


谢谢

刚刚想起我刚才提过这个问题!我发现了我的问题所在

考虑到.fits文件有9个平铺,可以使用以下方法创建完整的马赛克:

f=fits.openfilename,memmap=True 原始页眉=f[0]。页眉 全马赛克:f[1:10];瓷砖11和瓷砖12的马赛克:f[1:3] wcs_out,shape_out=find_optimal_sessional_wcsf[1:10]只有CompImageHDU文件 数组,footprint=reproject_和coaddf[1:10],wcs_out,shape_out=shape_out,reproject_函数=reproject_interp
其中array是马赛克,可以使用matplotlib绘制马赛克。尽管reproject_和_coadd函数非常占用内存。

我不熟悉这个库,但根据文档,如果输入_文件是FITS文件,则hdu_in参数应该是要使用的hdu的索引或EXTNAME,而不是头。
WARNING: FITSFixedWarning: The WCS transformation has more axes (2) than the image it is associated with (0) [astropy.wcs.wcs]
Traceback (most recent call last):
  File "/home/oi/border.py", line 74, in make_pieces
    array, footprint = reproject_and_coadd(input_data=f[1:9], output_projection=f[0].header, hdu_in=f[0].header, reproject_function=reproject_interp)
  File "/home/oi/anaconda3/lib/python3.7/site-packages/reproject/mosaicking/coadd.py", line 91, in reproject_and_coadd
    shape_out=shape_out)
  File "/home/oi/anaconda3/lib/python3.7/site-packages/reproject/utils.py", line 98, in parse_output_projection
    raise ValueError("The shape of the output image should not be an "
ValueError: The shape of the output image should not be an empty tuple