简体   繁体   English

在整个天空的网格上绘制FITS图像

[英]Plot a FITS image over a grid of the entire sky

I would like to plot a FITS image over a sketch of the entire sky. 我想在整个天空的草图上绘制FITS图像。

I got this far in plotting the entire sky: 我在绘制整个天空时走得很远:

import matplotlib.pyplot as plt
from astropy.utils.data import get_pkg_data_filename
from astropy.io import fits

image_file = get_pkg_data_filename('tutorials/FITS-images/HorseHead.fits')
image_data = fits.getdata(image_file, ext=0)

plt.subplot(111, projection='aitoff')
plt.grid(True)
plt.imshow(image_data, cmap='gray')
plt.show()

But I can't seem to get the FITS image properly aligned with the grid 但是我似乎无法使FITS图像与网格正确对齐


The above code results in the following 上面的代码导致以下结果 实际结果 But I'm trying to get something more like 但我正在尝试获得更多类似的东西 预期结果 where the blue square is the actual position of the image in image_file 其中蓝色正方形是图像在image_file的实际位置

The image_data is just an array of pixel values, and doesn't actually contain any information about the positions and orientations of the pixels on a sky map. image_data只是像素值的数组,实际上不包含有关天空地图上像素位置和方向的任何信息。 You have to extract that information from the FITS file too. 您也必须从FITS文件中提取该信息。

An example would be (based in information from here and here ): 一个示例是(基于此处此处的信息 ):

import matplotlib.pyplot as plt
from astropy.utils.data import get_pkg_data_filename
from astropy.io import fits
from astropy.wcs import WCS
from astropy.visualization.wcsaxes.frame import EllipticalFrame

image_file = get_pkg_data_filename('tutorials/FITS-images/HorseHead.fits')
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)

# make the axes using the EllipticalFrame class
ax = plt.subplot(projection=wcs, frame_class=EllipticalFrame)

# add the image
im = ax.imshow(image_data, origin='lower')

# add a grid
overlay = ax.get_coords_overlay('fk5')
overlay.grid(color='white', ls='dotted')

马头星云图

As the particular image example doesn't extend across the whole sky you'll only see a small patch (but you can extend the plot using ax.set_xlim() and ax.set_ylim() as required, although I'm not sure what the units are, and it's also worth noting that this image actually just covers a very small patch of sky), but if your image was over the whole sky it would look like an Aitoff projection as shown here . 由于特定的图像示例不会在整个天空中延伸,因此您只会看到一个小补丁(但是您可以根据需要使用ax.set_xlim()ax.set_ylim()来扩展图,尽管我不确定单位是,这也是值得注意的是,该图像实际上只是覆盖天空的一个非常小的补丁),但是如果你的形象是在整个天空它看起来像一个Aitoff投影如图所示这里

I think this only works with the latest version of astropy (v3.1), Matplotlib (v3.0.2), and therefore requires Python >= 3.5. 我认为这仅适用于最新版本的astropy(v3.1),Matplotlib(v3.0.2),因此需要Python> = 3.5。

You may also want to look at healpy , although that can't read in the astropy example FITS file. 您可能还想看一下healpy ,尽管在示例性的FITS文件中无法读取。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM