我正在尝试创建一个自定义的WCS来将图像的像素坐标转换为世界坐标。
给定一个带有星星的图像,我已经识别了两个星星,所以我可以匹配图像中两个点的像素(x,y)和(RA,DEC)。
现在,我想要的是创建一个具有适当变换矩阵的自定义WCS,因此当我给出任何像素坐标时,它将返回相应的RA和DEC。
我知道astrometry.net是这样做的,并用适当的转换矩阵写了一个fits头。
我的问题是,如何获得此转换矩阵并创建自定义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)为什么我的参考点都不正确?
发布于 2020-08-27 14:06:45
代码是正确的,问题出在Astropy库的版本,参见bug:https://github.com/astropy/astropy/pull/10155。
如果有人遇到这个问题,请确保您使用的不是Astropy 4.0.1。
https://stackoverflow.com/questions/63594323
复制相似问题