5

I have searched through a large number of PyEphem webpages, downloaded code, and investigated objects, but I have not found a way to get the earth-centered rectangular coordinates of an earth satellite in some nominally inertial coordinate system. Have I missed something obvious? I am looking for the 'traditional' x, y, z and x-dot, y-dot, z-dot. Many Thanks for any suggestions.

1 Answers1

5

Good question!

The satellite position routines inside of libastro do use x y z coordinates internally, but libastro throws them away before Python gets a chance to see them. I could have tried patching libastro and then PyEphem to make the data available, but while researching your question, I found that magnificent recent work has been done to update the SGP4 satellite tracking algorithm and provide it with a test suite:

http://www.celestrak.com/publications/AIAA/2006-6753/

Spurred by this discovery, I have done something far better: I have spent the weekend creating a new pure-Python sgp4 package based on this reference implementation!

http://pypi.python.org/pypi/sgp4

Soon I will build a whole astronomy library named Skyfield around this satellite prediction engine, but for the moment you should be able to download it directly from the Python Package Index (the link above) and call it raw in order to get your traditional coordinates:

from sgp4.earth_gravity import wgs72
from sgp4.io import twoline2rv

line1 = ('1 00005U 58002B   00179.78495062  '
         '.00000023  00000-0  28098-4 0  4753')
line2 = ('2 00005  34.2682 348.7242 1859667 '
         '331.7664  19.3264 10.82419157413667')

satellite = twoline2rv(line1, line2, wgs72)
position, velocity = satellite.propagate(
    2000, 6, 29, 12, 50, 19)

Please try it out and let me know if it works on your machine!

Brandon Rhodes
  • 69,820
  • 15
  • 101
  • 136
  • Brandon, You have done extraordinary work in a very short time. Bravo!! – user1619972 Aug 31 '12 at 12:49
  • 1
    I downloaded the tar file and I puzzled over how to install it. In desperation, I checked http://docs.python.org/install/index.html and found a straightforward description of what might be done to setup the program. To my amazement, the operation completed with no error messages and the sgp4 routines worked to produce results very close to those that you gave. I wonder what accounts for the very minor deviations from the results you gave. In any event, well done, thank you for a helping hand. Jim Ritter – user1619972 Sep 03 '12 at 17:09
  • Did this ever end up getting added into pyephem? From reading the documentation, I don't see a way to extract rectangular coordinates from a body in pyephem. – jtebert May 04 '18 at 20:15
  • @Pterosaur — No, it didn't wind up being a good fit for the C-language astronomy library that's always been the calculation engine behind PyEphem. Instead, I wrote a new Python-language vector-based astronomy library named Skyfield and used this module there. Thanks for asking! (I've edited my answer to now mention the correct library.) – Brandon Rhodes May 12 '18 at 12:17