Using the JPL Horizons app at https://ssd.jpl.nasa.gov/horizons/app.html#/ would someone help to calculate the distance between the Sun and the Earth say 1 May 2023 00:00 UT? I used the following for the calculation.

  • 1 Ephemeris Type: Vector Table
  • 2 Target Body: Sun
  • 3 Coordinate Center: Bangalore India
  • 4 Time Specification: 2023-05-01 00:00-2023-05-30 00:00
  • 5 Table Settings: 6: '1-way light-time + range + range-rate'

For 6, we obtained the value RG= 1.506919214640888E+08 kms, or, 1.5069E+08/1.4960E+08 = 1.007 AU (Here, 1.4960E+08 is 1 AU). Thus, on May 1, 2023, the distance between the Sun and the Earth was 1.007 A.U., right?

This is to make sure that the parameter is calculated correctly.

  • 3
    $\begingroup$ The would be the distance between Bangalore and the Sun. If you want the distance to the center of the Earth use @399 as the coordinate center. $\endgroup$ Commented May 19, 2023 at 16:12
  • $\begingroup$ Fine, thank you. $\endgroup$
    – Smarty
    Commented May 20, 2023 at 6:18
  • 1
    $\begingroup$ I proceeded with the suggestion, and 399 as the Coordinate Center fetched Kushiro (observatory) [code: 399]. Thank you. $\endgroup$
    – Smarty
    Commented May 20, 2023 at 14:36
  • 1
    $\begingroup$ The Kushiro Observatory is 399@399. For the geocenter, use @399 or 500@399. Here's a Horizons API query $\endgroup$
    – PM 2Ring
    Commented May 22, 2023 at 3:56

1 Answer 1


Without all the details and especially without the output included in the question, it's hard to say for sure that you've done things exactly correctly.

However I think you're certainly close!

This Python script uses the Skyfield package and the DE421 Development Ephemeris While JPL's Horizons doesn't use exactly this same ephemeris, results will be very very close.

On May 1st 2023, with Bangalore at 12.979N, 77.592E I get a distance to the Sun of 1.007313284 AU or 150691922.3 km. You will get slightly different numbers if you used a slightly different lat/lon, or if you included the light-time correction, I didn't use Skyfield's 'apparent()' method that does a few more corrections.

distance from Bangalore to the Sun in May 2023 using Skyfield

from skyfield.api import Loader, Topos
import numpy as np
import matplotlib.pyplot as plt

load = Loader('~/Documents/fishing/SkyData') # avoid multiple copies of large files
ts = load.timescale()
eph = load('de421.bsp')

earth, sun, moon = [eph[x] for x in ('earth', 'sun', 'moon')]

latlon = 12.979, 77.592
bangalore = Topos(latitude_degrees = latlon[0],
                  longitude_degrees = latlon[1])

days = np.arange(1, 31)

times = ts.utc(2023, 5, days, 0, 0, 0) # 2023-05-01 00:00-2023-05-30 00:00

sun_astrometric = (earth + bangalore).at(times).observe(sun)

both = sun_astrometric.distance().au, sun_astrometric.distance().km

i_annotate = [0, 4, 9, 14, 19, 24, 29]

annots = [[str(val) for val in thing[i_annotate].round(n)]
          for (thing, n) in zip(both, (9, 1))]

annots = np.array(annots)

fig, axes = plt.subplots(2, 1)

goodies = axes, both, ('AU', 'km'), annots

for ax, distance, label, anns in zip(*goodies):
    ax.plot(days, distance)
    for ann, day, dist in zip(anns, days[i_annotate], distance[i_annotate]):
        ax.annotate(ann, (day, dist))
        ax.plot(day, dist, 'ok')
    ax.set_ylabel(label, fontsize=12)

axes[1].set_xlabel('days in May 2023', fontsize=12)

suptitle = ('distance from Bangalore ' + str(latlon) +
            ' to the Sun May 2023 (00:00)')


fig.subplots_adjust(left=0.13, right=0.86)
  • 1
    $\begingroup$ The Skyfield Code has rendered the plot beautifully. If we need to use to code for 500@399, how does the Code need to be modified, thank you. $\endgroup$
    – Smarty
    Commented May 22, 2023 at 13:56
  • $\begingroup$ @Smarty for 500@399 = Earth's geocenter, in the line that beings sun_astrometric = just change (earth + bangalore) to earth. it's really that easy :-) Oh, and of course change the plot label text from "Bangalore" to "Geocenter". You can also create Skyfield's artificial satellite objects in orbit around Earth from TLEs and use (earth + ISS) just for example. $\endgroup$
    – uhoh
    Commented May 22, 2023 at 14:37
  • $\begingroup$ Thus, the following should be deleted, right: latlon = 12.979, 77.592 bangalore = Topos(latitude_degrees = latlon[0], longitude_degrees = latlon[1]), and this code need to me modified assuptitle = ('distance from Bangalore ' + ' to the Sun May 2023 (00:00)'). $\endgroup$
    – Smarty
    Commented May 23, 2023 at 14:36
  • $\begingroup$ @Smarty you can delete them or comment them out or leave them in place - they don't have any effect since bangalore is not used. In fact they might not even get executed if their output is not used; Python is pretty smart sometimes. $\endgroup$
    – uhoh
    Commented May 23, 2023 at 17:44
  • $\begingroup$ How to obtain the heliocentric ecliptic coordinate of the Earth on this instant, i.e., 2023-05-01 00:00-2023-05-30 00:00? $\endgroup$
    – Smarty
    Commented Sep 27, 2023 at 9:48

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.