How to get earth-inertial or earth-centered coordinates of objects from PyEphem?
Asked Answered
T

1

3

I would like to get coordinates of objects in various XYZ coordinates, not where they appear in the sky. I'm interested in:

  1. ECE: "Earth Centered Inertial" (not rotation with the earth)

  2. ECEF: "Earth Centered Earth-Fixed" (not inertial, also called "Earth Centered Rotational"

  3. and some kind of solar system or ecliptic coordinates (sun or barycenter centered).

I've installed PyEphem, run a few examples, and have started to understand what's under the hood, but so far the examples I've found seem to focus on how things appear in the sky.

Either a link to a useful "how to" or a simple example would be helpful. Right now I don't see where to go with the standard options:

In [55]: mars.
mars.a_dec              mars.g_dec              mars.radius
mars.a_epoch            mars.g_ra               mars.rise_az
mars.a_ra               mars.hlat               mars.rise_time
mars.alt                mars.hlon               mars.set_az
mars.az                 mars.hlong              mars.set_time
mars.circumpolar        mars.mag                mars.size
mars.compute            mars.name               mars.sun_distance
mars.copy               mars.neverup            mars.transit_alt
mars.dec                mars.parallactic_angle  mars.transit_time
mars.earth_distance     mars.phase              mars.writedb
mars.elong              mars.ra

In [55]: mars.
Tindall answered 30/12, 2015 at 13:14 Comment(0)
R
6

The old C library that PyEphem is a wrapper around does not, alas, always use (x, y, z) coordinates internally, and when it does it does not expose them so that Python can see what they were — the (x, y, z) coordinates are discarded once the angles have been computed.

For a newer astronomy library by the same author (as it happens, me!) that has been completely rewritten so that (x, y, z) coordinates are indeed available every step of the way, try taking a look at Skyfield:

http://rhodesmill.org/skyfield/

In particular, look at how attributes like .position.km and .position.au let you get any position and decompose it into (x, y, z) Cartesian coordinates:

http://rhodesmill.org/skyfield/positions.html

Result answered 30/12, 2015 at 15:9 Comment(3)
Well this is clearly the correct answer!! Somehow I found the de405 package but totally missed Skyfield. This looks fantastic - and elegant too! Thanks for the quick response too.Tindall
I was thinking of cross-posting this question in Space.SE since there may be more people who have an appetite for (x, y, z). Currently there are zero questions (and only 7 for PyEphem).Tindall
I've been enjoying SkyField tremendously! I've asked a new question hereTindall

© 2022 - 2024 — McMap. All rights reserved.