在图像中绘制多个字段
Plot several fields in an image
如何在单个图像中绘制多个 FITS 字段?每个 FITS 文件覆盖天空的相邻部分。
HDU 的data
字段只包含图像。因此,要在正确的坐标处绘制每个图像,我需要从 header
字段获取信息。但是我如何在 pyplot 上传递该信息?
我尝试了以下方法,使用 astropy.WCS
以便在绘图中使用来自 headers 的信息
import matplotlib.pyplot as plt
from astropy.io import fits
from astropy.wcs import WCS
image_files = ['file1.fits', 'file2.fits']
for image_file in image_files:
image_header = fits.open(image_file)[0].header # extract header info
image_data = fits.getdata(image_file, ext=0)
# use the WCS class to get coordinate info and projection axes to use
wcs = WCS(image_header)
ax = plt.subplot(projection=wcs)
im = ax.imshow(image_data, origin='lower')
这只显示最后一张图片。
我期待这样的事情:
其中图像的两个部分来自不同的适合文件,这些文件是
和
我发现 Montage software. There is a Python wrapper for it called montage-wrapper
. The mosaic 函数通过并置多个 FITS 图像来生成新的 FITS 图像。然后可以读取和绘制新的 FITS 文件。
import montage_wrapper as montage
montage.mosaic(input_directory, output_directory)
hdu = fits.open(filename)
image_header = hdu[0].header
image_data = hdu[0].data
wcs = WCS(image_header)
ax = plt.subplot(projection=wcs)
im = ax.imshow(image_data, origin='lower')
plt.show()
其中 input_directory
包含 file1.fits
和 file2.fits
。
如何在单个图像中绘制多个 FITS 字段?每个 FITS 文件覆盖天空的相邻部分。
HDU 的data
字段只包含图像。因此,要在正确的坐标处绘制每个图像,我需要从 header
字段获取信息。但是我如何在 pyplot 上传递该信息?
我尝试了以下方法,使用 astropy.WCS
以便在绘图中使用来自 headers 的信息
import matplotlib.pyplot as plt
from astropy.io import fits
from astropy.wcs import WCS
image_files = ['file1.fits', 'file2.fits']
for image_file in image_files:
image_header = fits.open(image_file)[0].header # extract header info
image_data = fits.getdata(image_file, ext=0)
# use the WCS class to get coordinate info and projection axes to use
wcs = WCS(image_header)
ax = plt.subplot(projection=wcs)
im = ax.imshow(image_data, origin='lower')
这只显示最后一张图片。
我期待这样的事情:
其中图像的两个部分来自不同的适合文件,这些文件是
和
我发现 Montage software. There is a Python wrapper for it called montage-wrapper
. The mosaic 函数通过并置多个 FITS 图像来生成新的 FITS 图像。然后可以读取和绘制新的 FITS 文件。
import montage_wrapper as montage
montage.mosaic(input_directory, output_directory)
hdu = fits.open(filename)
image_header = hdu[0].header
image_data = hdu[0].data
wcs = WCS(image_header)
ax = plt.subplot(projection=wcs)
im = ax.imshow(image_data, origin='lower')
plt.show()
其中 input_directory
包含 file1.fits
和 file2.fits
。