Search code examples
pythonpyephem

pyephem next_pass function returns different result


I'm creating an app to predict satellites visible passes. In the app, I use 'if' statement to decide whether or not a satellite would be visible.

like follows;

if satellite.neverup is False and satellite.circumpolar is False:
    observer.next_pass(satellite)

This computation works fine for most of LEO satellites. However, I found some curious results. The next_pass function used before satellite.compute(observer) and after return different values.

Following code reproduce the result.

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)

Results are follows;

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)

How can I avoid this result changing? Where am I wrong?

Thank you in advance.


Solution

  • After playing around for a while, and using other TLE's, a thought I have is that neverup is not properly accounting for your horizon. Perhaps it is using 00:00:00 to define the boolean; if you change the horizon to 30:00:00 the output becomes:

    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]
    (2014/9/20 12:06:25, 191:15:15.1, 2014/9/20 12:08:23, 82:43:37.8, 2014/9/20 12:10:20, 1:10:09.6)
    

    For further debugging, we can print the altitude of the satellite at the next pass shown here. i.e.

    info = site.next_pass(target)
    site.date = info[0]
    target.compute(site)
    print target.alt
    

    this gives:

    31:07:31.3
    

    Now if we change the altitude to something like 34:00:00, we get your list of None's back.

    My guess is that neverup is not taking your defined horizon into account, but next_pass is.