I’m computing the distance to the Moon in two ways, that I think should yield the same result. However, there’s a 150m difference. Am I overlooking something?
from astropy.time import Time
from astropy.coordinates import GCRS, get_moon, EarthLocation, solar_system_ephemeris
import astropy.units as u
solar_system_ephemeris.set("de430");
t0 = Time("2021-10-08T12:00")
loc = EarthLocation(lat=52*u.deg, lon=6*u.deg)
res1 = get_moon(t0, location=loc).distance
# 361084.21km
res2 = (get_moon(t0).cartesian - loc.get_gcrs(t0).cartesian).norm()
# 361084.05km
res1 - res2
res1 - res2
# 0.15716625km
Although it is not noted in the docstring for get_moon(), that function returns the apparent position of the Moon as seen by the observer, which depends on the Moon-observer light travel time. (It is noted in the docstring of get_body(), which get_moon() calls.) Thus, get_moon(t0, location=loc) and get_moon(t0) actually refer to different locations, and the milliseconds of difference in light travel time likely accounts for the difference you are seeing because the Moon moves at ~29 km/s.