【发布时间】:2022-01-22 16:17:54
【问题描述】:
如果使用 Python2 或 Python3 运行,以下代码会产生两种不同的结果。为什么?
from skyfield.api import wgs84, load
latitude = -35
longitude = 150
altitude = 100
year = 2022
month = 1
day = 21
hour = 14
minute = 6
seconds = 43.941372
ts = load.timescale()
t_meas = ts.utc(year,month,day,hour,minute,seconds)
radar = wgs84.latlon(latitude, longitude, altitude)
radar_ECI = radar.at(t_meas)
print(radar_ECI.position.m)
使用 Skyfield 1.41 输出 [-2804378.01051857 4419981.90545062 -3632070.86144542]
天空场 1.40 的输出 [-2804356.81834716 4419995.31425895 -3632070.90655877]
【问题讨论】:
-
嗯,简短的回答是 Python 3 不向后兼容 Python 2,并且没有声称是。更具体地说,Skyfield 中可能存在一个错误,无法正确解释这些差异。(而且 Python 2 多年来一直没有得到官方支持。)你得到了什么输出?
-
你在两个 Python 环境中都有相同版本的 skyfield 吗?
-
我发现,其实天域的两个版本并不相同。 1.40 版安装在 Python2 上,1.41 版安装在 Python3 上。一旦我升级到 1.41,问题就解决了。
-
@Jonathan 太棒了!你能把它作为答案发布吗?你甚至可以自己接受。
标签: python python-3.x python-2.x skyfield