The position of the Sun in the sky is a function of both the time and the geographic location of observation on Earth's surface. As Earth orbits the Sun over the course of a year, the Sun appears to move with respect to the fixed stars on the celestial sphere, along a circular path called the ecliptic.
Earth's rotation about its axis causes diurnal motion, so that the Sun appears to move across the sky in a Sun path that depends on the observer's geographic latitude. The time when the Sun transits the observer's meridian depends on the geographic longitude.
To find the Sun's position for a given location at a given time, one may therefore proceed in three steps as follows:
calculate the Sun's position in the ecliptic coordinate system,
convert to the equatorial coordinate system, and
convert to the horizontal coordinate system, for the observer's local time and location. This is the coordinate system normally used to calculate the position of the Sun in terms of solar zenith angle and solar azimuth angle, and the two parameters can be used to depict the Sun path.
This calculation is useful in astronomy, navigation, surveying, meteorology, climatology, solar energy, and sundial design.
These equations, from the Astronomical Almanac,
can be used to calculate the apparent coordinates of the Sun, mean equinox and ecliptic of date, to a precision of about 0°.01 (36′′), for dates between 1950 and 2050. These equations are coded into a Fortran 90 routine in Ref. and are used to calculate the solar zenith angle and solar azimuth angle as observed from the surface of the Earth.
Start by calculating n, the number of days (positive or negative, including fractional days) since Greenwich noon, Terrestrial Time, on 1 January 2000 (J2000.0). If the Julian date for the desired time is known, then
The mean longitude of the Sun, corrected for the aberration of light, is:
The mean anomaly of the Sun (actually, of the Earth in its orbit around the Sun, but it is convenient to pretend the Sun orbits the Earth), is:
Put and in the range 0° to 360° by adding or subtracting multiples of 360° as needed.