我有一个PyEphem库的问题。
简而言之,我必须根据不同观测者的TLE计算卫星的通行证,因为它们必须与之通信。但为了确保他们能够与卫星通信,他们可以指定他们想要的最小仰角。
我在用这个家伙。地平线,以精确的仰角我想为特定的观察者。
我的代码
def test_ephem_horizon():
str1 = 'SWISSCUBE'
str2 = '1 35932U 09051B 15278.30192626 .00000528 00000-0 13209-3 0 9992'
str3 = '2 35932 98.4206 37.8361 0007688 9.6843 350.4501 14.55537404319986'
#satellite
swisscube = ephem.readtle(str1, str2, str3)
#observer
guy = ephem.Observer()
guy.lon, guy.lat = '18.6107', '53.0217'
guy.date = datetime.datetime.now()
print "datetime.now(): " , guy.date
##################################### FIRST CASE #####################################################
degrees=10
minutes=0
seconds=0
elevation_angle_str = str(degrees) + ':' + str(minutes) + ':' + str(seconds)
guy.horizon = elevation_angle_str
swisscube.compute(guy)
passes = []
passes.append(passListToDic(guy.next_pass(swisscube)))
nb_passes = 30
for i in range(0, nb_passes):
guy.date = passes[i]['set_time'].datetime() + datetime.timedelta(hours=0, minutes=1)
temp_pass = guy.next_pass(swisscube)
print 'horizon: ', guy.horizon, ' passe[', i, ']: ', passes[i]
passes.append(passListToDic(temp_pass))
##################################### SECOND CASE #####################################################
degrees=45
minutes=0
seconds=0
elevation_angle_str = str(degrees) + ':' + str(minutes) + ':' + str(seconds)
guy.horizon = elevation_angle_str
swisscube.compute(guy)
passes = []
passes.append(passListToDic(guy.next_pass(swisscube)))
elevation_angle_str = str(degrees) + ':' + str(minutes) + ':' + str(seconds)
nb_passes = 30
for i in range(0, nb_passes):
guy.date = passes[i]['set_time'].datetime() + datetime.timedelta(hours=0, minutes=1)
temp_pass = guy.next_pass(swisscube)
print 'horizon: ', guy.horizon, ' passe[', i, ']: ', passes[i]
passes.append(passListToDic(temp_pass))
return passes
def passListToDic(_pass):
return {'rise_time': _pass[0], 'rise_azimuth': _pass[1], 'max_alt_time': _pass[2],
'max_alt': _pass[3], 'set_time': _pass[4], 'set_azimuth': _pass[5]}
if __name__ == '__main__':
test_ephem_horizon()
检查结果如下:
datetime.now(): 2015/10/6 17:26:14
horizon: 10:00:00.0 passe[ 0 ]: {'rise_time': 2015/10/6 21:27:34, 'max_alt': 11:05:25.5, 'max_alt_time': 2015/10/6 21:28:55, 'rise_azimuth': 63:13:09.7, 'set_time': 2015/10/6 21:30:16, 'set_azimuth': 30:12:12.2}
horizon: 10:00:00.0 passe[ 1 ]: {'rise_time': 2015/10/6 23:01:06, 'max_alt': 50:50:24.1, 'max_alt_time': 2015/10/6 23:05:43, 'rise_azimuth': 142:00:00.4, 'set_time': 2015/10/6 23:10:22, 'set_azimuth': 352:46:19.8}
horizon: 10:00:00.0 passe[ 2 ]: {'rise_time': 2015/10/7 00:39:47, 'max_alt': 26:27:07.4, 'max_alt_time': 2015/10/7 00:43:48, 'rise_azimuth': 209:21:48.1, 'set_time': 2015/10/7 00:47:52, 'set_azimuth': 324:33:00.2}
horizon: 10:00:00.0 passe[ 3 ]: {'rise_time': 2015/10/7 12:32:41, 'max_alt': 51:37:50.4, 'max_alt_time': 2015/10/7 12:37:25, 'rise_azimuth': 23:25:50.2, 'set_time': 2015/10/7 12:42:07, 'set_azimuth': 177:08:21.7}
horizon: 10:00:00.0 passe[ 4 ]: {'rise_time': 2015/10/7 14:10:56, 'max_alt': 28:06:15.8, 'max_alt_time': 2015/10/7 14:15:01, 'rise_azimuth': 357:46:42.2, 'set_time': 2015/10/7 14:19:06, 'set_azimuth': 242:05:31.8}
horizon: 10:00:00.0 passe[ 5 ]: {'rise_time': 2015/10/7 22:09:02, 'max_alt': 21:26:22.3, 'max_alt_time': 2015/10/7 22:12:37, 'rise_azimuth': 104:56:52.7, 'set_time': 2015/10/7 22:16:14, 'set_azimuth': 7:39:29.7}
horizon: 10:00:00.0 passe[ 6 ]: {'rise_time': 2015/10/7 23:45:14, 'max_alt': 72:08:14.0, 'max_alt_time': 2015/10/7 23:50:00, 'rise_azimuth': 171:06:17.4, 'set_time': 2015/10/7 23:54:49, 'set_azimuth': 341:24:44.1}
horizon: 10:00:00.0 passe[ 7 ]: {'rise_time': 2015/10/8 01:27:02, 'max_alt': 11:38:22.2, 'max_alt_time': 2015/10/8 01:28:43, 'rise_azimuth': 255:09:20.2, 'set_time': 2015/10/8 01:30:25, 'set_azimuth': 296:53:48.9}
horizon: 10:00:00.0 passe[ 8 ]: {'rise_time': 2015/10/8 11:39:58, 'max_alt': 19:34:40.0, 'max_alt_time': 2015/10/8 11:43:29, 'rise_azimuth': 42:56:40.7, 'set_time': 2015/10/8 11:46:58, 'set_azimuth': 136:13:53.0}
horizon: 10:00:00.0 passe[ 9 ]: {'rise_time': 2015/10/8 13:16:59, 'max_alt': 70:27:01.0, 'max_alt_time': 2015/10/8 13:21:49, 'rise_azimuth': 11:41:28.5, 'set_time': 2015/10/8 13:26:36, 'set_azimuth': 206:26:00.0}
horizon: 10:00:00.0 passe[ 10 ]: {'rise_time': 2015/10/8 14:56:14, 'max_alt': 14:37:51.1, 'max_alt_time': 2015/10/8 14:58:50, 'rise_azimuth': 342:09:46.7, 'set_time': 2015/10/8 15:01:27, 'set_azimuth': 276:26:32.5}
horizon: 10:00:00.0 passe[ 11 ]: {'rise_time': 2015/10/8 22:52:05, 'max_alt': 43:05:25.7, 'max_alt_time': 2015/10/8 22:56:35, 'rise_azimuth': 135:49:13.8, 'set_time': 2015/10/8 23:01:08, 'set_azimuth': 355:08:58.4}
horizon: 10:00:00.0 passe[ 12 ]: {'rise_time': 2015/10/9 00:30:18, 'max_alt': 31:15:34.8, 'max_alt_time': 2015/10/9 00:34:33, 'rise_azimuth': 202:07:27.1, 'set_time': 2015/10/9 00:38:51, 'set_azimuth': 328:02:20.7}
horizon: 10:00:00.0 passe[ 13 ]: {'rise_time': 2015/10/9 12:23:35, 'max_alt': 43:14:41.9, 'max_alt_time': 2015/10/9 12:28:13, 'rise_azimuth': 26:11:34.5, 'set_time': 2015/10/9 12:32:48, 'set_azimuth': 170:40:22.3}
horizon: 10:00:00.0 passe[ 14 ]: {'rise_time': 2015/10/9 14:01:39, 'max_alt': 32:31:47.4, 'max_alt_time': 2015/10/9 14:05:56, 'rise_azimuth': 0:22:27.4, 'set_time': 2015/10/9 14:10:13, 'set_azimuth': 235:38:45.9}
horizon: 10:00:00.0 passe[ 15 ]: {'rise_time': 2015/10/9 22:00:17, 'max_alt': 18:42:23.0, 'max_alt_time': 2015/10/9 22:03:34, 'rise_azimuth': 97:46:38.3, 'set_time': 2015/10/9 22:06:52, 'set_azimuth': 10:50:40.6}
horizon: 10:00:00.0 passe[ 16 ]: {'rise_time': 2015/10/9 23:36:01, 'max_alt': 85:20:39.1, 'max_alt_time': 2015/10/9 23:40:49, 'rise_azimuth': 164:54:12.6, 'set_time': 2015/10/9 23:45:39, 'set_azimuth': 343:53:08.6}
horizon: 10:00:00.0 passe[ 17 ]: {'rise_time': 2015/10/10 01:16:53, 'max_alt': 14:03:31.7, 'max_alt_time': 2015/10/10 01:19:24, 'rise_azimuth': 242:02:05.4, 'set_time': 2015/10/10 01:21:56, 'set_azimuth': 306:07:41.7}
horizon: 10:00:00.0 passe[ 18 ]: {'rise_time': 2015/10/10 11:31:07, 'max_alt': 16:32:27.3, 'max_alt_time': 2015/10/10 11:34:11, 'rise_azimuth': 48:01:28.1, 'set_time': 2015/10/10 11:37:15, 'set_azimuth': 127:20:19.7}
horizon: 10:00:00.0 passe[ 19 ]: {'rise_time': 2015/10/10 13:07:48, 'max_alt': 83:09:23.6, 'max_alt_time': 2015/10/10 13:12:39, 'rise_azimuth': 14:03:31.5, 'set_time': 2015/10/10 13:17:29, 'set_azimuth': 200:20:30.1}
horizon: 10:00:00.0 passe[ 20 ]: {'rise_time': 2015/10/10 14:46:46, 'max_alt': 16:47:51.7, 'max_alt_time': 2015/10/10 14:49:48, 'rise_azimuth': 346:18:53.3, 'set_time': 2015/10/10 14:52:50, 'set_azimuth': 268:16:04.5}
horizon: 10:00:00.0 passe[ 21 ]: {'rise_time': 2015/10/10 22:43:06, 'max_alt': 36:47:48.6, 'max_alt_time': 2015/10/10 22:47:28, 'rise_azimuth': 129:34:16.0, 'set_time': 2015/10/10 22:51:53, 'set_azimuth': 357:34:10.4}
horizon: 10:00:00.0 passe[ 22 ]: {'rise_time': 2015/10/11 00:20:53, 'max_alt': 37:03:59.7, 'max_alt_time': 2015/10/11 00:25:18, 'rise_azimuth': 195:12:03.6, 'set_time': 2015/10/11 00:29:47, 'set_azimuth': 331:13:22.2}
horizon: 10:00:00.0 passe[ 23 ]: {'rise_time': 2015/10/11 12:14:30, 'max_alt': 36:23:39.9, 'max_alt_time': 2015/10/11 12:18:59, 'rise_azimuth': 29:07:50.6, 'set_time': 2015/10/11 12:23:26, 'set_azimuth': 164:01:11.1}
horizon: 10:00:00.0 passe[ 24 ]: {'rise_time': 2015/10/11 13:52:22, 'max_alt': 37:52:25.2, 'max_alt_time': 2015/10/11 13:56:50, 'rise_azimuth': 2:51:43.8, 'set_time': 2015/10/11 14:01:16, 'set_azimuth': 229:20:06.2}
horizon: 10:00:00.0 passe[ 25 ]: {'rise_time': 2015/10/11 21:51:35, 'max_alt': 16:19:41.3, 'max_alt_time': 2015/10/11 21:54:31, 'rise_azimuth': 90:09:14.5, 'set_time': 2015/10/11 21:57:27, 'set_azimuth': 14:26:33.1}
horizon: 10:00:00.0 passe[ 26 ]: {'rise_time': 2015/10/11 23:26:51, 'max_alt': 81:09:10.9, 'max_alt_time': 2015/10/11 23:31:38, 'rise_azimuth': 158:45:08.8, 'set_time': 2015/10/11 23:36:28, 'set_azimuth': 346:17:49.7}
horizon: 10:00:00.0 passe[ 27 ]: {'rise_time': 2015/10/12 01:07:00, 'max_alt': 16:47:21.3, 'max_alt_time': 2015/10/12 01:10:05, 'rise_azimuth': 231:48:00.3, 'set_time': 2015/10/12 01:13:11, 'set_azimuth': 312:30:33.1}
horizon: 10:00:00.0 passe[ 28 ]: {'rise_time': 2015/10/12 11:22:23, 'max_alt': 13:52:16.0, 'max_alt_time': 2015/10/12 11:24:53, 'rise_azimuth': 54:26:46.6, 'set_time': 2015/10/12 11:27:22, 'set_azimuth': 117:03:52.0}
horizon: 10:00:00.0 passe[ 29 ]: {'rise_time': 2015/10/12 12:58:37, 'max_alt': 83:24:53.9, 'max_alt_time': 2015/10/12 13:03:28, 'rise_azimuth': 16:27:45.1, 'set_time': 2015/10/12 13:08:19, 'set_azimuth': 194:13:19.5}
Traceback (most recent call last):
File "C:/Users/Sebastien/PycharmProjects/drs/scripts/test_lib_orbi.py", line 179, in <module>
test_ephem_horizon()
File "C:/Users/Sebastien/PycharmProjects/drs/scripts/test_lib_orbi.py", line 159, in test_ephem_horizon
passes.append(passListToDic(guy.next_pass(swisscube)))
File "C:UsersSebastiendevdrslibsite-packagesephem__init__.py", line 509, in next_pass
return _libastro._next_pass(self, body)
ValueError: that satellite seems to stay always below your horizon
当我使用10度视界时,它运行得很好,但如果我使用39度以上的视界,我就会出现以下错误:
ValueError: that satellite seems always stay below your horizon
但是正如你在结果中看到的,我们有许多通道的最大高度超过45度。所以通常情况下,我应该得到45度地平线以上的卫星的结果。
为什么我得到这个错误?
谢谢
PyEphem使用的旧libastro
中的上升和设置例程不是非常持久-它们首先尝试找到最高高度,但如果第一个顶点太低而无法满足您设置的条件,则会引发您所看到的错误。我的猜测是,搜索程序正在寻找列表中的第一个顶点,其中最大高度为11°,然后因为这小于45°,它放弃并抛出错误。
如果你想看到更详细的算法来研究它的行为,你可以在这里找到它:
https://github.com/brandon-rhodes/pyephem/blob/master/libastro-3.7.7/riset_cir.c L160