How sun position is calculated
Almost everything about the weather is a forecast. The sun's position is not. It follows from orbital mechanics that were nailed down centuries ago, which means it can be computed exactly, offline, for any point on Earth and any date you like.
On this page
It comes down to two angles
Where the sun appears from a given spot is described by two numbers:
- Altitude (or elevation): how far above the horizon it is, from 0° at the horizon to 90° straight overhead.
- Azimuth: its compass bearing, measured clockwise from north — 90° is due east, 180° due south, 270° due west.
Both fall out of a single spherical-trigonometry identity, given your latitude and two intermediate quantities: the sun's declination and its hour angle.
The core formula.
sin(altitude) = sin(latitude) · sin(declination) + cos(latitude) · cos(declination) · cos(hour angle)
Everything else in a sun calculator exists to produce good values for declination and hour angle, and to convert the result into something human.
Declination: where the sun is in the year
Earth's axis is tilted about 23.44° relative to its orbit, and that tilt stays pointed in the same direction in space as we go round. The consequence is that the sun appears to move north and south through the year, and declination is the name for that: the latitude at which the sun is directly overhead at noon on a given day.
It runs from +23.44° at the June solstice (overhead at the Tropic of Cancer), through 0° at each equinox (overhead at the equator), to −23.44° at the December solstice. Nothing else in the calculation drives seasons; declination is the season.
Because Earth's orbit is a slight ellipse rather than a circle, the sun does not move through declination at a uniform rate — which is where the next two complications come from.
Hour angle: where the sun is in the day
Hour angle measures how far the Earth has rotated past the moment the sun crossed your meridian. It is zero at true solar noon, negative before, positive after, and it advances at exactly 15° per hour, because the Earth turns 360° in 24 hours.
The subtlety is that solar noon is not clock noon, for two separate reasons. The first is longitude: time zones are wide political bands, so unless you happen to sit on your zone's central meridian, your solar noon is offset by four minutes for every degree you are east or west of it. The second is the equation of time.
The equation of time
A clock ticks at a constant rate. The sun does not. Earth moves faster along its orbit when nearer the sun in January and slower in July, and the tilt of the axis further skews how that motion projects onto the celestial equator. Together these mean true solar noon drifts against clock noon through the year, by up to about 16 minutes each way.
The correction is called the equation of time. It reaches roughly −14 minutes in mid-February and +16 minutes in early November, and passes through zero four times a year. It is also the reason a sundial and a wristwatch disagree, and the reason the earliest sunset of the year does not fall on the shortest day — in the UK it happens around 12 December, a good week before the solstice.
Trace the sun's position at the same clock time every day for a year and you get a figure of eight in the sky, the analemma. Its tall axis is declination; its width is the equation of time.
Refraction and why sunrise is a lie
The atmosphere bends light. Near the horizon, where you are looking through the greatest thickness of air, that bending amounts to about 0.57° — slightly more than the sun's own apparent diameter. So when you see the sun's lower edge touch the horizon at sunset, the sun geometrically has already set.
Published sunrise and sunset times account for this by defining the event as the moment the sun's upper limb appears, with a standard refraction allowance. That is why almanacs use a solar zenith angle of 90.833° rather than a clean 90°. The effect is not trivial: it adds several minutes to the length of every day, and at high latitudes near the solstice it can add far more.
It also means published times assume a flat sea-level horizon and standard atmospheric conditions. On a hill, on a cold morning, or with mountains to the east, the sun will not do what the table says.
What is still assumed
The calculation is exact within its own frame, but the frame contains assumptions that a careful reader should know:
- A flat, unobstructed horizon. Every published sunrise time is for an ideal sea horizon. Your real horizon has hills, houses and trees in it, and they routinely cost more daylight than any of the corrections above. This is why the tools here let you set a skyline angle.
- Standard refraction. Temperature inversions can shift apparent sunrise by minutes, and no calculator can know your local air column.
- A point observer at ground level. Altitude extends your horizon: from a high vantage point the sun rises earlier and sets later than any table will tell you.
- Low-precision solar formulae. The algorithm used here — the NOAA formulation of Meeus's low-precision method — is accurate to roughly one arc minute for years 1800 to 2100. That is around a hundredth of the sun's apparent width, and far below the uncertainty introduced by your own horizon.
The honest summary: sun geometry is one of the few things about the outdoors that can be stated without hedging. Everything uncertain about how much light you actually get lives in the atmosphere and in the objects around you — which is why the useful tools are the ones that let you describe those objects.