Ephemeris for lunar body-centered body-fixed coordinates?

I'm going to try to do a modest simulation of the Moon's libration as seen from the Earth (geocenter), similar to the technical one's I've shown in this question. I'll do it in Python and render it in Blender.

I'm familliar with getting Ephemeris type data from JPL Horizons and from Skyfield, both of which use the JPL Development Ephemerides (e.g. DE405,...), (see also Horizon's Ephemerides page and links therein). From those I generate local tables and interpolate them for animations and other non-critical calculations.

I know that at least some of the DE's contain lunar body motion (e.g. in DE405, but in DE406 it comes separately? Also discussed here) as Loading Auxiliary Files/Dynamic Frames, but without first-hand knowledge of reading the Spice Kernel's directly, is there a way I can get something close through Horizons? For example, with the position of a fixed position on the Moon with respect to Earth's Geocenter, or vice-versa in addition to the motion of the two centers I could reconstruct it well enough for a fairly accurate animation. However, this is as far as I've gotten - I don't know how to specify a lat/lon position on the Moon.

I could fudge it by just spinning the moon on its axis at a fixed rotational angular velocity, but if it's possible to get a handle on the actual lunar rigid body motion, that would be much more helpful to me in the long run.

• Aside #1: JPL's Horizons hasn't used DE405 for quite some time. It now uses DE431. – David Hammen Jan 28 '17 at 16:07
• @DavidHammen DE405 showed up when I searched for "nutation" a long time ago, I included the DE405/DE406 pair to say sometimes it's in the DE, sometimes it isn't. If it's included in the DE431 proper, great! – uhoh Jan 28 '17 at 16:12
• Careful there, @uhoh. The DE4xxx nutation model pertains to the Earth, not the Moon. What you want are the three libration terms. – David Hammen Jan 29 '17 at 16:29
• Also, if you want the Moon, it's probably better to use DE421, which is now eight years old. Apparently it does a better job with regard to lunar orientation that do the more recent versions, whose primary purpose was improve accuracy with regard to Mars, Jupiter, and Pluto. – David Hammen Jan 29 '17 at 17:06
• A not so easy way to check if a DE4xxx model contains Earth nutations and lunar librations is to look at the last two columns in the second row of the GROUP 1050 entry in the ASCII header file for that model. The model does not provide Earth nutations if the penultimate (second to last, or twelfth) element is zero, and it does not provide lunar librations of the last (thirteenth) element is zero. – David Hammen Jan 29 '17 at 17:11

Using Spice data files, the Skyfield library for Python can now report lunar libration as the sub-longitude and sub-latitude of the point on the Moon facing the Earth. To take an example from its documentation:

from skyfield.api import PlanetaryConstants, load

t = ts.utc(2019, 12, 20, 11, 5)

earth, moon = eph['earth'], eph['moon']

pc = PlanetaryConstants()

frame = pc.build_frame_named('MOON_ME_DE421')

p = (earth - moon).at(t)
lat, lon, distance = p.frame_latlon(frame)
lon_degrees = (lon.degrees - 180.0) % 360.0 - 180.0
print('Libration in latitude: {:.3f}'.format(lat.degrees))
print('Libration in longitude: {:.3f}'.format(lon_degrees))


Further documentation is here:

https://rhodesmill.org/skyfield/planetary.html#computing-lunar-libration

I'm going to jump in and give an answer before Mark Adler jumps in and tells you to use Spice in lieu of some (quite possibly outdated) Development Ephemeris.

• OTOH, the perl expression @foo{@foo} = (1) x scalar @foo is quite mind boggling. Just because I know what this means and that this wipes out multiple lines of code does not mean that everyone should know what that means. Quite the opposite. Perl is only second to APL with respect to write-only languages. That said, I wouldn't be surprised one bit if there's a perl module out there somewhere that provides Spice functionality. – David Hammen Jan 28 '17 at 3:43