使用pyephem计算卫星何时越过经度

时间:2013-03-11 12:14:33

标签: python latitude-longitude pyephem

我很难弄清楚如何计算卫星何时越过特定经度。能够提供时间段和TLE并且能够返回卫星在指定时间段内穿过给定经度的所有时间将是很好的。 pyephem支持这样的东西吗?

2 个答案:

答案 0 :(得分:6)

当卫星穿过特定的经度时,用户可能会询问很多可能的情况;当它到达特定的纬度时;当它达到一定高度或下降到最低海拔时;当它的速度最大或最小时 - PyEphem不会尝试为它们提供内置函数。相反,它提供了一个newton()函数,可让您找到要在卫星属性和要搜索的属性的预定值之间进行的任何比较的过零点。

请注意,SciPy Python库包含几个非常仔细的搜索函数,这些函数比PyEphem的newton()函数复杂得多,以防您处理特别糟糕的函数:

http://docs.scipy.org/doc/scipy/reference/optimize.html

以下是搜索卫星时的方法 - 在本例中,ISS - 通过特定经度,以显示一般技术。这不是最快的方法 - 特别是,如果我们非常小心的话,可以加速逐分钟的搜索 - 但它写得非常通用且非常安全,以防除了经度之外还有其他值你也想搜索。我试图添加文档和注释来解释发生了什么,以及为什么我使用znorm而不是返回简单的区别。如果这个脚本适合你,请告诉我,并清楚地解释它的方法!

import ephem

line0 = 'ISS (ZARYA)             '
line1 = '1 25544U 98067A   13110.27262069  .00008419  00000-0  14271-3 0  6447'
line2 = '2 25544  51.6474  35.7007 0010356 160.4171 304.1803 15.52381363825715'

sat = ephem.readtle(line0, line1, line2)
target_long = ephem.degrees('-83.8889')

def longitude_difference(t):
    '''Return how far the satellite is from the target longitude.

    Note carefully that this function does not simply return the
    difference of the two longitudes, since that would produce a
    terrible jagged discontinuity from 2pi to 0 when the satellite
    crosses from -180 to 180 degrees longitude, which could happen to be
    a point close to the target longitude.  So after computing the
    difference in the two angles we run degrees.znorm on it, so that the
    result is smooth around the point of zero difference, and the
    discontinuity sits as far away from the target position as possible.

    '''
    sat.compute(t)
    return ephem.degrees(sat.sublong - target_long).znorm

t = ephem.date('2013/4/20')

# How did I know to make jumps by minute here?  I experimented: a
# `print` statement in the loop showing the difference showed huge jumps
# when looping by a day or hour at a time, but minute-by-minute results
# were small enough steps to bring the satellite gradually closer to the
# target longitude at a rate slow enough that we could stop near it.
#
# The direction that the ISS travels makes the longitude difference
# increase with time; `print` statements at one-minute increments show a
# series like this:
#
# -25:16:40.9
# -19:47:17.3
# -14:03:34.0
# -8:09:21.0
# -2:09:27.0
# 3:50:44.9
# 9:45:50.0
# 15:30:54.7
#
# So the first `while` loop detects if we are in the rising, positive
# region of this negative-positive pattern and skips the positive
# region, since if the difference is positive then the ISS has already
# passed the target longitude and is on its way around the rest of
# the planet.

d = longitude_difference(t)

while d > 0:
    t += ephem.minute
    sat.compute(t)
    d = longitude_difference(t)

# We now know that we are on the negative-valued portion of the cycle,
# and that the ISS is closing in on our longitude.  So we keep going
# only as long as the difference is negative, since once it jumps to
# positive the ISS has passed the target longitude, as in the sample
# data series above when the difference goes from -2:09:27.0 to
# 3:50:44.9.

while d < 0:
    t += ephem.minute
    sat.compute(t)
    d = longitude_difference(t)

# We are now sitting at a point in time when the ISS has just passed the
# target longitude.  The znorm of the longitude difference ought to be a
# gently sloping zero-crossing curve in this region, so it should be
# safe to set Newton's method to work on it!

tn = ephem.newton(longitude_difference, t - ephem.minute, t)

# This should be the answer!  So we print it, and also double-check
# ourselves by printing the longitude to see how closely it matches.

print 'When did ISS cross this longitude?', target_long
print 'At this specific date and time:', ephem.date(tn)

sat.compute(tn)

print 'To double-check, at that time, sublong =', sat.sublong

运行此脚本时得到的输出表明,当ISS达到目标经度时,它确实找到了时刻(在合理的容差范围内):

When did ISS cross this longitude? -83:53:20.0
At this specific date and time: 2013/4/20 00:18:21
To double-check, at that time, sublong = -83:53:20.1

答案 1 :(得分:0)

程序计算经度的通过时间与实际时间之间存在时间差。我已经使用美国国家航空航天局的LIS系统(位于ISS内)对其进行了检查,以查找闪电。 而且我发现,在欧洲某些轨道上,程序计算通过的时间比实际时间提前了30秒。在哥伦比亚,某些轨道的前进时间约为3分钟(也许是因为哥伦比亚的1度经度(Km)比欧洲的1度经度大)。但是这个问题只发生在两个特定的轨道上!经过法国,在西西里落下的那座。那是经过美国并在古巴落下的那一架。 为什么会这样呢? 在我的小齿轮上,我认为ephem.newton算法或TLE可能存在一些错误,通常它读取白天在晚上00:00:00创建的一个(白天,而不是实际),因为ISS每天创建3-4个TLE),或者使用sat.sublong函数来计算错误的卫星最低点。 是否有人对此问题有想法或解释? 为什么会发生? PS:我需要确定要进行检查,因为我需要知道ISS何时越过区域(用于检测区域内的闪电)。如果程序在某些轨道上计算出的时间比实际时间提前,则sat.sublong函数会计算出它在该区域之外(它尚未到达该区域),但是程序会显示它在该区域内区域。因此,在某些情况下,实时时间与程序计算的时间不匹配。 非常感谢您的宝贵时间!