【发布时间】: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 再次感谢您的帮助,这个功能确实是我需要的。