尝试使用 WCSaxes 和 Astroquery 过度绘制 TESS 和 2MASS 图像

问题描述

我正在尝试在与 TESS 图像相同的投影上绘制 2MASS 图像。我曾经使用 pywcsgrid2 执行此操作,但我似乎无法再安装它。所以我正在尝试使用 Astropy WCSAxes

TESS 图像和 2MASS 图像均使用 Astroquery 函数(分别为 TESScut 和 SkyView)检索。我可以在其适当的 WCS 轴上单独创建每个图像的图。但是,当我尝试使用 TESS WCS(作为轮廓或图像本身)将 2MASS 图像绘制到轴上时,它会将图像缩小到左下角。有人能告诉我我做错了什么,或者 WCS 是否有什么问题。

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import colors
from astroquery.skyview import SkyView
from astropy.wcs import WCS
import astropy.io.fits as fits
import astropy.units as u
from astropy.coordinates import SkyCoord
from astroquery.mast import Tesscut

test_tic = 113449635
cutout_coord = SkyCoord(113.29538299104,-35.48102008076,unit=u.degree)
dir_ffi = "./temp/"
tess_data = Tesscut.download_cutouts(cutout_coord,size=20,path=dir_ffi)

tess_file = tess_data[2][0]

def extract_wcs(dataheader):
    """
    Generate WCS for a TESS or K2 TPF. dataheader is the header of extension #1
    """
    w5 = WCS(naxis=2)

    w5.wcs.crpix = [dataheader["1CRPX5"],dataheader["2CRPX5"]]
    w5.wcs.cdelt = np.array([dataheader["1CDLT5"],dataheader["2CDLT5"]])
    w5.wcs.crval = [dataheader["1CRVL5"],dataheader["2CRVL5"]]
    w5.wcs.ctype = [dataheader["1CTYP5"],dataheader["2CTYP5"]]
    w5.wcs.pc = [[dataheader["11PC5"],dataheader["12PC5"]],[dataheader["21PC5"],dataheader["22PC5"]]]
    return w5


with fits.open(tess_file) as hdu:

    # not a coadd,but reducing code for the sake of the MWE
    coadd = hdu[1].data["FLUX"][100]
    dataheader = hdu[1].header
    w3 = extract_wcs(dataheader)

# This works just fine
plt.subplot(projection=w3)
plt.imshow(coadd,origin="lower",norm=colors.Lognorm())
plt.xlabel('RA')
plt.ylabel('Dec')
plt.show()

# Get 2MASS K image
twomass_images = SkyView.get_images(position=cutout_coord,survey=['2MASS-K'],pixels=500)
pix_2mass = twomass_images[0][0].data
hdr_2mass = twomass_images[0][0].header
wcs_2mass = WCS(hdr_2mass)

print(w3)
print(wcs_2mass)

# Try to plot the TESS image in the background,with 2MASS overlaid as a contour
# This yields oversized axes with the image in the lower left corner
ax = plt.subplot(projection=w3)
ax.imshow(coadd,norm=colors.Lognorm(),zorder=-10)
ax.contour(pix_2mass,transform=ax.get_transform(wcs_2mass),colors='k',zorder=5)
plt.xlabel('RA')
plt.ylabel('Dec')
plt.show()


# Try to plot the 2MASS image in the background,on the TESS WCS
# This yields oversized axes with the image in the lower left corner
ax = plt.subplot(projection=w3)
ax.imshow(pix_2mass,zorder=-10,transform=ax.get_transform(wcs_2mass))
plt.xlabel('RA')
plt.ylabel('Dec')
plt.show()


enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)