为什么投影插曲在WCS的特点是在matplotlib错了地方?

问题描述 投票:1回答:1

我有一个文件,配合有关的天体。我可以绘制它是这样的:

from astropy.io import fits
from astropy.wcs import WCS

hdul = fits.open(fitsfilename)[0]

wcs = WCS(hdul.header)
fig = plt.figure(figsize=(12,12))
fig.add_subplot(111, projection=wcs)
plt.imshow(hdul.data)

这工作,并产生了很好的图:

enter image description here

我想一些附加功能添加到这个情节,这是行不通的。例如可以尝试将圆添加到119°,-67°30' 。我通过扩展的代码:

plt.scatter([119],[-67.5],c='r',s=500)

我得到的是:

enter image description here

这实在不是我们想要的,圆大约是118°5' ,-67°5' ,而不是它应该是(119°,-67°30' )。

什么我收到错误,或者有什么好修复这个问题?


注:当我运行wcs = WCS(hdul.header),我得到一个警告:

警告:VerifyWarning:验证报告的错误:[astropy.io.fits.verify]警告:VerifyWarning:卡 'A_2_0' 不适用于标准(无效的字符串值: '3.29341755408e-05')。固定“A_2_0”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:注:astropy.io.fits使用从零开始的索引。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'A_1_1' 不是FITS标准(无效值字符串: '1.51709339878e-05')。固定“A_1_1”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'A_0_2' 不​​是FITS标准(无效值字符串: '5.17973753556e-06')。固定“A_0_2”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'B_2_0' 不是FITS标准(无效值字符串: '2.97627426087e-06')。固定“B_2_0”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'B_1_1' 不是FITS标准(无效值字符串: '2.71948126373e-05')。固定“B_1_1”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'B_0_2' 不​​是FITS标准(无效值字符串: '1.66848449653e-05')。固定“B_0_2”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'AP_1_0' 不是FITS标准(无效值字符串: '1.79541533196e-06')。固定“AP_1_0”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'AP_0_1' 不是FITS标准(无效值字符串: '9.20624843151e-07')。固定“AP_0_1”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'AP_2_0' 不是FITS标准(无效值字符串: '-3.29292923201e-05')。固定“AP_2_0”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'AP_1_1' 不是FITS标准(无效值字符串: '-1.51738446887e-05')。固定“AP_1_1”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'AP_0_2' 不​​是FITS标准(无效值字符串: '-5.18321445978e-06')。固定“AP_0_2”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'BP_1_0' 不是FITS标准(无效值字符串: '8.99029048217e-07')。固定“BP_1_0”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'BP_0_1' 不是FITS标准(无效值字符串: '1.15967736014e-06')。固定“BP_0_1”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'BP_2_0' 不是FITS标准(无效值字符串: '-2.97837492348e-06')。固定“BP_2_0”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'BP_1_1' 不是FITS标准(无效值字符串: '-2.71998518336e-05')。固定“BP_1_1”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'BP_0_2' 不​​是FITS标准(无效值字符串: '-1.66872388359e-05')。固定“BP_0_2”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'WCSR_PRJ' 不是FITS标准(无效值字符串: '3.6679e-07')。固定“WCSR_PRJ”卡,以满足FITS标准。 [astropy.io.fits.verify]警告:VerifyWarning:卡 'WCSR_PIX' 不是FITS标准(无效值字符串: '8.2565e-05')。固定“WCSR_PIX”卡,以满足FITS标准。 [astropy.io.fits.verify]

所以这可能是相关的;如何解决它仍持有疑问。

python python-3.x matplotlib projection astropy
1个回答
1
投票

world coordinates绘制,你需要指定transform,例如:

ax = fig.gca()
ax.scatter([34], [3.2], transform=ax.get_transform('world'))

一般来说,你可以忽略这些FITS头警告,因为没有千篇一律的头牌也都涉及到WCS(据我所知)。

© www.soinside.com 2019 - 2024. All rights reserved.