【发布时间】:2014-09-22 12:41:17
【问题描述】:
我正在创建一个应用来预测卫星可见通道。 在应用程序中,我使用“if”语句来决定卫星是否可见。
如下;
if satellite.neverup is False and satellite.circumpolar is False:
observer.next_pass(satellite)
这种计算适用于大多数 LEO 卫星。
然而,我发现了一些奇怪的结果。在satellite.compute(observer)之前和之后使用的next_pass函数返回不同的值。
以下代码重现结果。
import ephem
line_0 = '0 SL-3 R/B'
line_1 = '1 12904U 81103B 14252.72400340 .00001812 00000-0 13444-3 0 5754'
line_2 = '2 12904 081.1813 349.2718 0030677 147.5032 212.8569 15.02708918340741'
target = ephem.readtle(line_0,line_1,line_2)
site = ephem.Observer()
site.lon = '151:43:00'
site.lat = '-27:26:00'
site.elevation = 400
site.name = 'test facility'
site.horizon = '40:00:00'
site.date = '2014/9/20 00:29:10'
print ephem.__version__
print site.next_pass(target)
target.compute(site)
print [target.neverup,target.circumpolar]
print site.next_pass(target)
结果如下;
3.7.5.3
(2014/9/20 01:55:43, 303:49:09.6, 2014/9/20 00:25:02, 30:44:01.7, 2014/9/20 00:30:10, 164:08:09.1)
[False, False]
(None, None, None, None, None, None)
如何避免这种结果发生变化? 我哪里错了?
提前谢谢你。
【问题讨论】:
-
不相关:使用
if not x:而不是if x is False: