# Getting state vectors from JPL Horizons ephemerides

I'm simulating the Sun-Earth-Moon system by numerical integration of equation of motion. I've confused a little bit in JPL Horizons ephemerides.

Could anyone explain (if possible, on pictures), how to use it to achieve

• Earth coordinates in Sun coordinate system or in Solar system baricenter coordinate system
• Sun coordinates in Solar system baricenter coordinate system
• Moon coordinates in Earth coordinate system
• I've made a small edit to the title to make your question more search-friendly for future readers, since the answers will be helpful for them. – uhoh Oct 30 '18 at 3:31

I'll work one example all the way through, and include the exact output you should get so you can check your results.

Then you can change one item at a time to get the rest of the things you need.

Ephemeris Type

Select the Vector Table:

Target Body

Type the word "Earth" into the search box:

It searches, and finds two options. Choose "Earth Geocenter":

Coordinate Origin

Use observatory code numbers (if you know them) or names. For example, enter "675" to select the Palomar Mountain main site. Or, enter "palomar" for a list of matching sites. Use "Geocentric or code "500" for geocentric. You can also enter Horizons-specific non-topocentric location codes. For example, use "@sun" to place the observer at the center of the sun, "@0" to select the solar-system barycenter, or "Viking 1@499" to select the Viking 1 landing site on Mars (499). To see all sites available for a specific body, use "@body" where body is body ID. For example, "@499" will show all sites on Mars. See the Horizons documentation for more details on center/observer location codes.

"@0" will set your origin to the Solar System Barycenter

Time Span

Table Settings

You need all six values to build your initial state vector: $x, y, z, v_x, v_y, v_z$:

Make all options settings look exactly like this:

Display/Output

Choose HTML so you can see it on your screen. If you like it then change to download/save

If you save the file, and extract the positions of Earth, you get the following. Z stays very close to zero because the reference plane is set to ecliptic.

2458164.500000000, A.D. 2018-Feb-15 00:00:00.0000,
-1.222658746534817E+08,  8.358147121331073E+07, -1.998641833709925E+04,
-1.716151037847111E+01, -2.480720984441618E+01,  2.472874945897985E-03,


If you want to use earth mean equator for the reference plane (which is like the equator of the celestial sphere (declination = 0) then you set it to mean equator:

and you'll get this:

2458164.500000000, A.D. 2018-Feb-15 00:00:00.0000,
-1.222658746534817E+08,  7.669245070020768E+07,  3.322846272752656E+07,
-1.716151037847111E+01, -2.276115369540082E+01, -9.865472560113437E+00,


• For today, in the coordinate system with center in Solar System Baricenter, the Earth coordinates: X =-7.86E-01 Y = 6.00E-01 Z =-1.37E-04 | Sun coordinates: X = 1.55E-03 Y = 6.33E-03 Z =-1.14E-04.... IS IT OK? – Tarlan Mammadzada Feb 14 '18 at 17:44
• I don't know where your numbers come from, and it doesn't matter. The numbers that I show in the answer are the output, and you can see the time and date in the beginning. Horizons is pretty much the best you can get anywhere. These are the right numbers! You can run Horizons again and select AU and AU/day if you want, or you can convert these to AU. – uhoh Feb 14 '18 at 17:49
• @TarlanMammadzada no problem! To get good results integrating orbits near Earth, you'll need time steps of the order of a one or two minutes (or less) because the satellite's period is only ~100 minutes. You can get such small steps from Horizons, or you can get larger steps from Horizons and interpolate them. Some day you will wonder how Horizons works, and so I'll tell you now; it's a very big, beautiful, flexible interpolator, and the tables it interpolates are called ephemerides and/or kernels. – uhoh Feb 14 '18 at 18:16
• Ahhhhhhhhhhhhh! Horizons is SUCH a cool website! How have I not known about this API?! I kind of want to turn this from a CGI/telnet API into a more modern API to be honest. Also... NASA scientists must be acronym gods: Horizons On-Line Ephemeris System "HOLES", heh... – Magic Octopus Urn Aug 28 '18 at 16:24
• How do I change the output to meters? I only see AU and km. – Aaron Franke May 26 at 10:22

Look at the Vector option. For the target, use the "satellite". For the origin, use the appropriate body id, preferably the Barycenter. Some example IDs:

• Solar Barycenter- 0
• Earth Barycenter- 399
• Mars Barycenter- 499
• Just to ensure. I selected Type- Vector, Targer- Earth, Origin- Baricenter. So, is it coordinates of Earth in Baricenter coordinate system? – Tarlan Mammadzada Feb 14 '18 at 13:54
• Yes, that is correct. – PearsonArtPhoto Feb 14 '18 at 22:11