Lack of agreement with real data
KDarshan20 opened this issue · comments
Hello,
I'm trying to calculate the position of the Moon with the Earth's center as the origin, using this code:
import spiceypy as spice
spice.furnsh("../meta.txt")
# print distance of Moon for every second in the day
for i in range(86400):
date = 2457708.5 + (i / 86400) # 2457708.5 corresponds to 14 November 2016, 00:00 UTC, the date at which the Moon was at its perigee
x, y, z = spice.spkpos("Moon", date, "J2000", "NONE", "Earth")[0][0:3]
print("distance:", ((x ** 2 + y ** 2 + z ** 2) ** 0.5))
meta.txt:
\begindata
KERNELS_TO_LOAD=(
'<path>/de438.bsp')
\begintext
But all the values I get are around 403,087.56 km, while Moon's perigee is around 363,228.9 km.
Where am I wrong?
Hi @KDarshan20,
the date (ephemeris time) shall be expressed as seconds past J2000 TDB (see https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/spkpos.html).
In your code, your are computing times starting at 2000-01-29 22:41:48.500000 UTC, for fractions of a second.
You'll need to convert the Julian Date (or UTC calendar time) you have to seconds past J2000 TDB (use str2et for
that).
Hope this helps.
Jorge
That cleared it.
Thanks for the quick reply!