How can I make a Python function return the Moon's gravitational force in a form I can use to calculate orbits?

The Space SE question How much does it cost to land on a lunar mascon? includes the background information below. I am sure it's not too hard to find a link where spherical harmonic coefficients for some model of the Moon's gravity can be found, but the hard part is to turn them into an actual vector force field in units of m/s^2.

Likely the coefficients will be for the gravitational potential, and there will be some method to take the gradient to obtain a field, but I have never been able to make sense of this kind of data. For example see:

These maps of the moon show gravity anomalies measured by NASA's GRAIL mission. (Image credit: NASA/JPL-Caltech/CSM)

From Space.com's Mystery of Moon's Lumpy Gravity Explained, click for full size.

The Bouguer anomaly plots show elevated gravity as much as about 600 mGal. Wikipedia's Gal (unit) explains what this means; 0.6 Gal is 0.006 m/s^2 or almost a half of a percent of the Moon's average gravity, and they extend over quite large distances.

The gal (symbol: Gal), sometimes called galileo after Galileo Galilei, is a unit of acceleration used extensively in the science of gravimetry. The gal is defined as 1 centimeter per second squared (1 cm/s2). The milligal (mGal) and microgal (µGal) are respectively one thousandth and one millionth of a gal.

• Looks like somebody has already done the work, maybe not in python: pgda.gsfc.nasa.gov/products/50. But if i understand you right you could use one of the maps provided as a texture and map a texture position to the reference sphere. That could fit into a function.
– user20217
Apr 6 '20 at 9:26
• @a_donda orbits are in 3D, I need to calculate everywhere from the surface up to hundreds of kilometers above. In free space gravity obeys the Laplace equation ($\nabla^2 \phi=0)$ so the spherical harmonics work everywhere. I suppose that if I had the potential on one smooth surface I could reconstruct the coefficients for the rest of space as answers to my old question Calculating the potential on a surface from the potential on another surface explain,...
– uhoh
Apr 6 '20 at 11:16
• With variations as small as half a percent, the gravity vector is almost perfectly radially inward if you put the moon's center at the coordinate origin. Then, if you have the magnitude of the gravity at some particular height datum (as in the data sets mentioned above), you just need to scale it with $1/r^2$ to get the value at some height above the surface. Apr 6 '20 at 21:29
• @a_donda No. The perturbation from a mass concentration will certainly be important out to a distance of several times it's diameter, and some of these are several hundreds of kilometers in diameter. They were discovered by their substantial perturbations on objects orbiting the Moon and they even resulted in one crashing into the Moon I think. I recommend you take some time to read up on them if you are interested.
– uhoh
Apr 8 '20 at 19:16
• I'd really like to and will keep it in my occipetal lobe. But there is a bunch of other things before me right now ... good luck finding your spells ;-)
– user20217
Apr 8 '20 at 19:32