python - 为什么在天文学中从地球坐标转换到银河中心坐标不能保持距离?
问题描述
我正在将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 度的纬度偏移)不是问题。
我以前是通过--给定点A
和B
--转换点来解决这个问题A
的C = A + c*AB
,其中c
一些很大的数字。然后我将B'
通过撤消此缩放来恢复转换B' = A' + A'C' / c
。但是,感觉我应该解决问题的实际根源而不是这种解决方法。
解决方案
这可能只是一个浮点精度问题。如果我查看笛卡尔值,对于GCRS 框架,它们是有序的,并且是有序的,但对于银河框架,它们x
分别y
是z
有序的,和。1e6
1e6
1e2
1e20
1e10
1e17
1e-15
给定8 字节浮点数 ( )的精度numpy.finfo('f8').eps
,这意味着x
银河坐标的 - 值只能精确到大约1e5
(米)。然后采用规范(以x
- 值不确定性占主导地位),也会导致订单1e5
米的准确性,远远超过实际分离。
计算值仍然彼此接近这一事实在很大程度上是运气(尽管它有一个潜在的原因,例如偏差有点平均)。
这也与您没有看到较大偏移量的问题(或较少问题)的事实一致。尽管我自己进行了测试,但我仍然看到了不同之处1e4
~ 1e5
)。准确地说,使用 0 和 10 纬度,我得到:
GCRS: 1104451.74511518
Galactic: 1108541.8206286128
如果我的假设是正确的,那么我的建议很简单:为您的坐标使用适当的坐标系,并考虑相关的不确定性(机器精度和所用坐标系的不确定性)。
推荐阅读
- python - 如何根据偏移量和方向在 Python 中对列表进行排序?
- python - xarray 坐标相关计算
- jquery - 在反应中使用 jquery 的第三方库的动画
- python - 在 requirements.txt 中不包含我自己的包的最佳方法是什么?
- javascript - 具有重复属性名称的嵌套 JSON 数组访问
- transactions - 雪花存储过程和事务:文档不清楚?
- amazon-web-services - 无法创建角色 AWSCodePipelineServiceRole
- google-analytics - 如何在谷歌分析中制作一个匹配段?
- php - 如何在 Ajax JsonList 中传递下拉菜单值以将值保存在数据库中?
- go - 为什么哈希这么慢?