有没有一种方法可以创建带有星形的.fit镶嵌图?

时间:2020-06-12 18:58:20

标签: python astropy fits

我想使用唯一的.fits文件中的不同HDU来创建镶嵌,就像使用SAOimage DS9并选择“文件>打开方式>镶嵌WCS”时一样。当我使用astropy搜索如何执行此操作时,遇到了reproject,并尝试按照https://reproject.readthedocs.io/en/stable/mosaicking.html的教程进行操作。但是,我似乎无法使其适用于我。

打开文件时,我有一个HDUList对象,因此我尝试遵循“ reproject_and_coadd”文档(https://reproject.readthedocs.io/en/stable/api/reproject.mosaicking.reproject_and_coadd.html#reproject.mosaicking.reproject_and_coadd),并使用了本教程中未使用的其他一些参数。这是我一直在尝试使用的代码:

<link rel="stylesheet" type="text/css" href="">

f的输出是以下列表(当我输入(f)时,我说这是一个HDUList):

f = fits.open(input_file, memmap=True)
print(f)
array, footprint = reproject_and_coadd(input_data=f, output_projection=f[5].header, hdu_in=f[0].header, reproject_function=reproject_interp)
f.close()

我当前遇到的错误是:

[<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个图块,只需获取tile11和tile12。我是.fits的新手,所以这也很酷。

谢谢!

1 个答案:

答案 0 :(得分:1)

只记得我前一段时间曾提过这个问题!我发现了我的问题所在。

考虑到.fits文件有9个图块,可以使用以下方法创建完整的镶嵌图:

f = fits.open(filename, memmap=True)
orig_header = f[0].header

# full mosaic: f[1:10]; mosaic from tile11 and tile12: f[1:3]
wcs_out, shape_out = find_optimal_celestial_wcs(f[1:10]) # has only CompImageHDU files

array, footprint = reproject_and_coadd(f[1:10], wcs_out, shape_out=shape_out, reproject_function=reproject_interp)

array是马赛克,然后可以使用matplotlib进行绘制。 reproject_and_coadd函数占用大量内存。