Astropy WCS 转换矩阵
Astropy WCS transfromation matrix
我正在尝试创建自定义 WCS 以将图像的像素坐标转换为世界坐标。
给定一张有星星的图像,我已经识别出 2 颗星星,所以我可以将图像中两个点的像素 (x,y) 匹配到 (RA,DEC)。
我现在想要的是创建一个具有适当变换矩阵的自定义 WCS,因此当我提供任何像素坐标时,它将 return 相应的 RA 和 DEC。
我知道 astrometry.net 做到了,并用适当的变换矩阵写了一个拟合 header。
我的问题是,我怎样才能得到这个转换矩阵并创建我的自定义 WCS object?
谢谢。
编辑:
这是我正在尝试的代码:
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)
为什么我连参考点都不对?
代码正确,问题是Astropy库的版本问题,见bug:https://github.com/astropy/astropy/pull/10155.
如果有人遇到这个问题,请确保您使用的不是 Astropy 4.0.1。
我正在尝试创建自定义 WCS 以将图像的像素坐标转换为世界坐标。
给定一张有星星的图像,我已经识别出 2 颗星星,所以我可以将图像中两个点的像素 (x,y) 匹配到 (RA,DEC)。
我现在想要的是创建一个具有适当变换矩阵的自定义 WCS,因此当我提供任何像素坐标时,它将 return 相应的 RA 和 DEC。
我知道 astrometry.net 做到了,并用适当的变换矩阵写了一个拟合 header。
我的问题是,我怎样才能得到这个转换矩阵并创建我的自定义 WCS object?
谢谢。
编辑: 这是我正在尝试的代码:
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)
为什么我连参考点都不对?
代码正确,问题是Astropy库的版本问题,见bug:https://github.com/astropy/astropy/pull/10155.
如果有人遇到这个问题,请确保您使用的不是 Astropy 4.0.1。