Pyephem和Skyfield HA/DEC结果之间的差异

发布于 2025-01-20 06:16:07 字数 1227 浏览 2 评论 0 原文

我正在重构一些使用 PyEphem 的旧代码来使用 Skyfield,并且我发现物体的 GHA/dec 结果略有不同。

def sf(year):
    from skyfield.api import N, W, wgs84
    from skyfield.api import load
    from skyfield.units import Angle

    ts = load.timescale()
    eph = load('de421.bsp')
    greenwich = wgs84.latlon(58.47722 * N, 0.0 * W)
    t = ts.utc(year)
    e = eph['earth'] + greenwich
    v = eph['venus']
    ha = e.at(t).observe(v).hadec()
    gha = Angle(degrees=360.0 + ha[0]._degrees)

    print(f'{gha}, {ha[1]}')


def pe(year):
    import ephem

    greenwich = ephem.Observer()
    greenwich.lon = 0.0
    greenwich.lat = ephem.degrees('51:28:38')
    greenwich.pressure = 0.0
    greenwich.horizon = '-0:34'

    t = ephem.date(str(year))
    v = ephem.Venus()
    greenwich.date = t
    greenwich.epoch = t
    v.compute(greenwich)
    gha = ephem.twopi - v.g_ra + greenwich.sidereal_time()

    print(f'{ephem.degrees(gha)}, {ephem.degrees(v.g_dec)}')


if __name__ == '__main__':
    sf(2016)
    pe(2016)

产生结果:

219deg 41' 57.5", -18deg 37' 03.9"
219:42:15.7, -18:36:56.0

旧的 PyEphem 代码与我面前的航海年历一致。

这绝对是 PEBKAC,但我正在绞尽脑汁地寻找我错过的时间或空间转换。

I'm refactoring some old code that used PyEphem to use Skyfield, and I'm getting a slight difference in the results of the GHA/dec of a body.

def sf(year):
    from skyfield.api import N, W, wgs84
    from skyfield.api import load
    from skyfield.units import Angle

    ts = load.timescale()
    eph = load('de421.bsp')
    greenwich = wgs84.latlon(58.47722 * N, 0.0 * W)
    t = ts.utc(year)
    e = eph['earth'] + greenwich
    v = eph['venus']
    ha = e.at(t).observe(v).hadec()
    gha = Angle(degrees=360.0 + ha[0]._degrees)

    print(f'{gha}, {ha[1]}')


def pe(year):
    import ephem

    greenwich = ephem.Observer()
    greenwich.lon = 0.0
    greenwich.lat = ephem.degrees('51:28:38')
    greenwich.pressure = 0.0
    greenwich.horizon = '-0:34'

    t = ephem.date(str(year))
    v = ephem.Venus()
    greenwich.date = t
    greenwich.epoch = t
    v.compute(greenwich)
    gha = ephem.twopi - v.g_ra + greenwich.sidereal_time()

    print(f'{ephem.degrees(gha)}, {ephem.degrees(v.g_dec)}')


if __name__ == '__main__':
    sf(2016)
    pe(2016)

Yields the results:

219deg 41' 57.5", -18deg 37' 03.9"
219:42:15.7, -18:36:56.0

The old PyEphem code agrees with the Nautical Almanac I have in front of me.

This is definitely a PEBKAC, but I'm scratching my head to find what temporal or spatial transformation I've missed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅忆 2025-01-27 06:16:07

看来您正在向Skyfield索要天文姿势,但Pyephem却担任明显的位置。根据Pyephem文档:

“ G_RA和RA-明显的GeCentric右升华,以时期的日期”

https://rhodesmill.org/pyephem/quick.html#body-compute-date

与Skyfield有关学习相应的明显位置的位置;它不会自动发生:

查看该变化是否消除了坐标之间的大部分差异。

It looks like you are asking Skyfield for astrometric positions, but PyEphem for apparent positions. According to the PyEphem documentation:

"g_ra and ra — Apparent geocentric right ascension for the epoch-of-date"

https://rhodesmill.org/pyephem/quick.html#body-compute-date

Whereas with Skyfield, you have to call the .apparent() method on a position to learn the corresponding apparent position; it does not happen automatically:

https://rhodesmill.org/skyfield/positions.html#barycentric-astrometric-apparent

See if that change eliminates most of the difference between coordinates.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文