【问题标题】:Why won't PyEphem calculate the elevation of manually generated objects?为什么 PyEphem 不计算手动生成对象的高度?
【发布时间】:2017-05-17 00:56:26
【问题描述】:

我使用 PyEphem 已经有一段时间了,但是从几天前(可能是几周?)开始,我的一个脚本就不再工作了。该脚本计算小行星的升起和落下时间,这是我使用CALLHORIZONS 从轨道元素创建的。我发现 PyEphem 没有正确计算小行星的高度 - 但是,它正确计算了太阳的高度。

这是一个最小的脚本:

import ephem
import numpy
import callhorizons 

this_target = '3552'
body = callhorizons.query(this_target)
body.set_discreteepochs(2415730.0)
body.get_elements()
this_target = body.export2pyephem()[0]

### works fine for the Sun
#this_target = ephem.Sun()

date = ephem.now()

this_target.compute(date)

obs = ephem.Observer()
obs.epoch = 2000.0
obs.lon = -111.653152/180.*numpy.pi
obs.lat = 35.184108/180.*numpy.pi
obs.elevation = 2738 # m
obs.date = date
obs.horizon = 0.

# if target is '3552', this_target.alt stays constant
for time in numpy.arange(date, date+1, 0.1):
    obs.date = time
    this_target.compute(obs)
    print time, this_target.alt, this_target.ra

### if this_target is '3552', this results in a segmentation fault
print obs.next_rising(this_target)

使用自定义目标(在本例中为3552),PyEphem 不会计算目标的高度,因此在尝试推导该目标的上升/设置时间时会遇到分段错误。

我尝试安装最新版本的 PyEphem (3.7.6.0),但没有帮助。任何人都可以复制(解释?)这个错误吗?

【问题讨论】:

    标签: python-2.7 pyephem


    【解决方案1】:

    考虑到纬度为 35 度,这个天体靠近木星,略高于黄道,并且它的周期为 8 年,它可能会在大约 2 或 3 年之后才升起.

    【讨论】:

    • 当时物体是可观察的,所以这不是原因。此外,它不适用于任何对象。但是,问题已经消失(见下面我的回答)。
    【解决方案2】:

    受 R. J. Mathar 的回答触发,我再次查看此问题,发现问题已消失。我现在使用 Python 2.7 和 3.5 得到了正确的结果;两者都使用 PyEphem 3.7.6.0。

    我很想提供更多关于问题所在的见解,但我不知道。我不确定我的系统上是否有任何重要的变化。这似乎是由某种安装问题引起的。

    【讨论】:

      猜你喜欢
      • 2012-08-29
      • 2016-05-09
      • 2014-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-09
      • 2011-08-08
      相关资源
      最近更新 更多