首页 > 解决方案 > 为什么在天文学中从地球坐标转换到银河中心坐标不能保持距离?

问题描述

我正在将GCRS对象转换为以银河为中心的坐标,并发现在此转换下不会保留两点之间的距离。

import astropy.units
import astropy.coordinates
import astropy.time
from numpy.linalg import norm

t = astropy.time.Time('1999-01-01T00:00:00.123456789')

def earth2galaxy(lat):
    '''                                                                         
    Convert an Earth coordinate to a galactocentric coordinate.                 
    '''
    # get GCRS coordinates                                                      
    earth = astropy.coordinates.EarthLocation(lat=lat*astropy.units.deg,
                                            lon=0,
                                            height=0)
    pos, _ = earth.get_gcrs_posvel(obstime=t)
    cartrep = astropy.coordinates.CartesianRepresentation(pos.xyz,
                                                          unit=astropy.units.m)

    gcrs = astropy.coordinates.GCRS(cartrep)

    # convert GCRS to galactocentric                                            
    gc = gcrs.transform_to(astropy.coordinates.Galactocentric)

    return earth, gcrs, gc

earthA, gcrsA, gcA = earth2galaxy(0)
earthB, gcrsB, gcB = earth2galaxy(0.01)

print(norm(earthA-earthB))
print(norm(gcrsA.cartesian.xyz-gcrsB.cartesian.xyz))
print(norm(gcA.cartesian.xyz-gcB.cartesian.xyz))

这段代码给出

1105.74275693
1105.74275232
971.796949054

我发现这对于较大的距离(例如 10 度的纬度偏移)不是问题。

我以前是通过--给定点AB--转换点来解决这个问题AC = A + c*AB,其中c一些很大的数字。然后我将B'通过撤消此缩放来恢复转换B' = A' + A'C' / c。但是,感觉我应该解决问题的实际根源而不是这种解决方法。

标签: pythondebuggingastropy

解决方案


这可能只是一个浮点精度问题。如果我查看笛卡尔值,对于GCRS 框架,它们是有序的,并且是有序的,但对于银河框架,它们x分别yz有序的,和。1e61e61e21e201e101e17

1e-15给定8 字节浮点数 ( )的精度numpy.finfo('f8').eps,这意味着x银河坐标的 - 值只能精确到大约1e5(米)。然后采用规范(以x- 值不确定性占主导地位),也会导致订单1e5米的准确性,远远超过实际分离。

计算值仍然彼此接近这一事实在很大程度上是运气(尽管它有一个潜在的原因,例如偏差有点平均)。

这也与您没有看到较大偏移量的问题(或较少问题)的事实一致。尽管我自己进行了测试,但我仍然看到了不同之处1e4~ 1e5)。准确地说,使用 0 和 10 纬度,我得到:

GCRS:     1104451.74511518
Galactic: 1108541.8206286128

如果我的假设是正确的,那么我的建议很简单:为您的坐标使用适当的坐标系,并考虑相关的不确定性(机器精度和所用坐标系的不确定性)。


推荐阅读