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.
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:
https://celestrak.org/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!