2
e = ephem.readtle(...)
e.compute('2012/02/04 07:55:00')

As far as I can see there's only e.elevation as a measure of distance which is relative to the sea level. At the moment I'm using a.elevation/1000 + 6371 to estimate the distance from the center of the earth.

I'm pretty sure that the exact earth center distance at the requested point in time is needed for the ephemeris calculations. Is this distance somewhere exposed and if not, why not and can that be changed?

letmaik
  • 3,348
  • 1
  • 36
  • 43

1 Answers1

1

I had thought that the answer would involving having to expose an ellipsoidal model of the earth from deep inside of the C code to Python to get you the information you need. But, having just gone through the Earth-satellite code, it turns out that the way that it converts the satellite's distance from the Earth center to its height is simply (from earthsat.c):

#if SSPELLIPSE
#else
    *Height = r - EarthRadius;
#endif

Apparently the programmer planned to someday implement an ellipsoidal earth, and had an #if statement ready to guard the new code, but never wrote any.

So you can convert the height (“elevation”) back to a distance from the Earth's center by adding the value EarthRadius which is defined as:

#define EarthRadius 6378.16             /* Kilometers           */

Since the elevation is, I believe, in meters, you will want to multiply EarthRadius by 1000.0 or else divide the elevation by 1000.0 to get the right result.

Brandon Rhodes
  • 83,755
  • 16
  • 106
  • 147
  • Ok, that's a start. What about exposing `r` directly? I don't really want to depend on such implementation detail which might change in the future. – letmaik Oct 22 '13 at 09:11