【问题标题】:Astropy WCS transfromation matrixAstropy WCS 变换矩阵
【发布时间】:2020-12-15 01:24:15
【问题描述】:

我正在尝试创建一个自定义 WCS 来将图像的像素坐标转换为世界坐标。

给定一张带有星星的图像,我已经确定了 2 颗星星,因此我可以将图像中两个点的像素 (x,y) 与 (RA,DEC) 匹配。

我现在想要的是创建一个具有适当变换矩阵的自定义 WCS,因此当我给出任何像素坐标时,它将返回相应的 RA 和 DEC。

我知道 astrometry.net 会这样做,并使用适当的转换矩阵编写适合标题。

我的问题是,我怎样才能得到这个转换矩阵并创建我的自定义 WCS 对象?

谢谢。

编辑: 这是我正在尝试的代码:

from astropy.coordinates import SkyCoord
import astropy.units as u
from astropy.wcs import WCS
from astropy.wcs.utils import fit_wcs_from_points
import numpy as np
# I have the following stars identified in my image (andromeda):
#  (X, Y)       --> (RA in degrees, DEC in degrees) --> HIP_ID
#  (640, 555)   --> (17.43421495, 35.61993419)      --> 5447
#  (1076, 32)  --> (2.09777329, 29.08952671)        --> 607
#  (161, 903)  --> (30.9751282, 42.32944223)        --> 9640
#  (932, 327)  --> (9.83272908, 30.86056254)        --> 3092
stars = SkyCoord(ra=[17.43421495, 2.09777329, 30.9751282, 9.83272908], 
                 dec=[35.61993419, 29.08952671, 42.32944223, 30.86056254], 
                 unit=u.deg)
stars
pixels_x = np.array([640, 1076, 161, 932])
pixels_y = np.array([555, 32, 903, 327])
wcs = fit_wcs_from_points((pixels_x, pixels_y), stars); wcs
wcs.wcs_pix2world(np.array([[640]]),np.array([555]),0)

为什么我连参考点都不正确?

【问题讨论】:

  • 你能分享一些你已经拥有的代码和你想要的输出吗?
  • 你试过fits_wcs_from_points吗?您可以将一些点的x、y和ra、dec坐标以及变换类型传递给它,它会确定变换参数并构造一个WCS
  • @Let'stry 我已经添加了一些代码,Iguananaut 再次感谢您的帮助,这个功能确实是我需要的。

标签: python astropy astronomy


【解决方案1】:

代码正确,问题是Astropy库的版本,见bug:https://github.com/astropy/astropy/pull/10155

如果有人遇到此问题,请确保您使用的不是 Astropy 4.0.1。

【讨论】:

  • 你能详细说明一下吗?我相信你是对的,这解决了你的问题,但从你的问题中并不清楚这首先与你的问题有关。
  • 说实话,我不知道问题的细节,比我上面链接的PR的描述要多。但是我们与 Astropy Slack 频道的一些人进行了测试,其中一个人发现了这个特定版本中的问题,因此只需更改上面的代码版本,即可返回参考点的正确值(这是预期的结果)。
猜你喜欢
  • 2013-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多