Question

Adjusting the observer horizion attribute seems to have no effect on the rise / set times for earth satellites. Additionally, I found this in the libastro code:

/* we don't implement a minimum horizon altitude cutoff
    SiteMinElev = 0;
*/

Is there a reason that horizon cutoff is not implemented? It would be useful for doing satellite elevation masking, for instance.

Was it helpful?

Solution

The good news: satellite rising and setting is not the job of the earthsat.c so the comment that you found in its source code from the libastro author does not indicate that PyEphem lacks the ability to adjust the horizon that it uses for Earth satellites. The rising and setting routines can be found in his riset_cir.c file, if you are curious about how they work.

The bad news: the behavior you are seeing is a bug in PyEphem! While PyEphem does, in fact, try to use the observer's horizon setting when running the Earth-satellite rise-and-set computation, it pulls the horizon from the wrong place. (See the _next_pass() function in _libastro.c for details.) Instead of using the horizon from your observer, it uses the horizon value from the last time you called compute() on the satellite.

I will add this bug to the PyEphem to-do list. Meanwhile, you can force your satellite "see" the horizon value you want it to use by calling sat.compute(observer) first, before then asking about its next pass overhead. Here is an example:

import ephem
iss = ephem.readtle(
    'ISS (ZARYA)',
    '1 25544U 98067A   12286.88755895  .00013766  00000-0  24141-3 0  4559',
    '2 25544  51.6478 256.6034 0017425 159.6565 253.2565 15.50708155796305',
    )
boston = ephem.city('Boston')

rising_time = boston.next_pass(iss)[0]
print 'Horizon =  0 rising:', rising_time

boston.horizon = '-5'
iss.compute(boston)

rising_time = boston.next_pass(iss)[0]
print 'Horizon = -5 rising:', rising_time

This script should show you an earlier rise time, since we have pushed the horizon down beneath the purely geometric horizon, and indeed I get that answer; let me know if you do too!

Horizon =  0 rising: 2012/10/13 05:14:28
Horizon = -5 rising: 2012/10/13 05:12:58
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top