通过 pip 在 macbook air 上安装 pyephem:
pip show pyephem
---
Name: pyephem
Version: 3.7.5.3
Location: /usr/local/lib/python2.7/site-packages
Requires:
我遇到的关键问题是从http://rhodesmill.org/pyephem/tutorial找到的 iss 示例显示:
iss = ephem.readtle("ISS (ZARYA)",
... "1 25544U 98067A 03097.78853147 .00021906 00000-0 28403-3 0 8652",
... "2 25544 51.6361 13.7980 0004256 35.6671 59.2566 15.58778559250029")
gatech.date = '2003/3/23'
iss.compute(gatech)
print("%s %s %s" % (iss.rise_time, iss.transit_time, iss.set_time))
2003/3/23 00:00:50 2003/3/23 00:03:26 2003/3/23 00:06:01
但是对于我的代码在循环中 +1 分钟以获得 Az/El,我得到“无”或明显不正确的结果:
obs = ephem.Observer()
obs.lat = '50.045995'
obs.lon = '-5.177628'
obs.pressure = 0
obs.temp = 0
obs.date = '2015/6/8 19:43:24'
line1 = "ISS (ZARYA)"
line2 = "1 25544U 98067A 03097.78853147 .00021906 00000-0 28403-3 0 8652"
line3 = "2 25544 51.6361 13.7980 0004256 35.6671 59.2566 15.58778559250029"
iss = ephem.readtle(line1, line2, line3)
print("%f %f %f %f" % (iss._epoch,iss._n,iss._inc,iss._raan) ) # Check tle is read
while True:
#mars.compute(obs)
#print("Date/time: %s Mars Az/El %.6f %.6f" % (obs.date, float(mars.az), float(mars.alt)))
iss.compute(obs)
print("Date/time: %s ISS Az/El %.6f %.6f %.6f" % (obs.date, ephem.degree * iss.az, ephem.degree * float(iss.alt), iss.range))
print("%s %s %s" % (iss.rise_time, iss.transit_time, iss.set_time))
obs.date += ephem.minute * 1
time.sleep(1)
结果是:
Date/time: 2015/6/8 19:50:24 ISS Az/El 0.054831 -0.027391 6377154.500000
None None None
Date/time: 2015/6/8 19:51:24 ISS Az/El 0.054831 -0.027391 6377154.500000
None None None
Date/time: 2015/6/8 19:52:24 ISS Az/El 0.054831 -0.027391 6377154.500000
None None None
Date/time: 2015/6/8 19:53:24 ISS Az/El 0.054831 -0.027391 6377154.500000
None None None
我认为这些错误与日期/角度/obs 相关 - 但我仍然希望看到它们移动。我已经检查过转换为各种数据类型的弧度/度数,但看不到错误在哪里。当行星体似乎都工作正常时,任何关于我在这里做错了什么的建议将不胜感激!
最好的,克里斯
更新 1 - obs 中的以下更改不起作用:
obs.lat = float(math.radians(50.045995))
obs.lon = float(math.radians(-5.177628))