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.

enter image description here

  • 1
    $\begingroup$ Aside #1: JPL's Horizons hasn't used DE405 for quite some time. It now uses DE431. $\endgroup$ Jan 28, 2017 at 16:07
  • $\begingroup$ @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! $\endgroup$
    – uhoh
    Jan 28, 2017 at 16:12
  • $\begingroup$ Careful there, @uhoh. The DE4xxx nutation model pertains to the Earth, not the Moon. What you want are the three libration terms. $\endgroup$ Jan 29, 2017 at 16:29
  • 1
    $\begingroup$ 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. $\endgroup$ Jan 29, 2017 at 17:06
  • 1
    $\begingroup$ 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. $\endgroup$ Jan 29, 2017 at 17:11

2 Answers 2


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

ts = load.timescale(builtin=True)
t = ts.utc(2019, 12, 20, 11, 5)

eph = load('de421.bsp')
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:



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.

My answer: Use Spice.

Spice provides kernels for the orientations of the Earth and of the Moon with respect to the ICRF as functions of time. From those, you can compute the relative orientation of the Moon with respect to the Earth at any moment in time.

  • $\begingroup$ To use Spice, you'll have to learn to program in C or C++ (or in Fortran, if you really want to torture yourself). Relying strictly on an HTML interface marks you as a noob. Moving up the chain, Python is a nice starter language, but still in the newb territory. (Note the spelling difference. Noob and newb are not alternative spellings of the same thing.) $\endgroup$ Jan 28, 2017 at 3:23
  • $\begingroup$ Unless of course you use Python as the glue that makes C, C++, Fortran, and other languages talk to one another. That's tricky. $\endgroup$ Jan 28, 2017 at 3:24
  • $\begingroup$ I am actually a language nomad. I learned FORTRAN on a Sigma-7, and I have even seen punch card "correction tape" (to cover wrong holes) though I'm not sure if it was real or just a gag. I've touched on C++ a few times over the years as well, but I'm trying to stick with Python - every time I learn a new one I forget the others, and now with this allergy to curly braces I've developed... $\endgroup$
    – uhoh
    Jan 28, 2017 at 3:30
  • 1
    $\begingroup$ That said, I do use Python a lot for short little scripts and for testing out an algorithm. Unless of course the short little script or algorithm involves regular expressions. In that case, I'll revert to my first and only resort, which would be perl. There is no language that beats perl when it comes to regular expressions. $\endgroup$ Jan 28, 2017 at 3:40
  • 1
    $\begingroup$ 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. $\endgroup$ Jan 28, 2017 at 3:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.