Skip to content
All posts

How is Sunrise Calculated? (Refraction, Algorithms, and Math)

9 min readUpdated Jul 30, 2026

Sunrise is the moment the top edge of the sun’s disk touches the horizon. That simple definition hides a surprising amount of math. To predict when sunrise happens at any location on any date, you need the observer’s coordinates, the sun’s position in space, and a correction for how Earth’s atmosphere bends light.

Here is how that calculation works, from the geometry to the final clock time.


The Upper Limb Definition of Sunrise

Sunrise over the mountains in Telluride, Colorado

Sunrise in Telluride Colorado

Sunrise does not mean the center of the sun sits on the horizon. By international convention, sunrise occurs when the upper limb (the top edge) of the sun’s disk first appears above the geometric horizon. The sun’s apparent radius is about 16 arcminutes. So the sun’s center is still 16 arcminutes below the horizon at the official moment of sunrise.

This distinction matters because it shifts the calculated time by roughly one minute compared to a center-of-disk definition. Every sunrise and sunset time you see published uses this upper limb standard. It also shifts the direction the sun comes up from, which is why sunrise is only due east about twice a year.


Atmospheric Refraction: Why You See the Sun Early

Earth’s atmosphere bends sunlight. When the sun is near the horizon, its light passes through the thickest layer of air. This bending (called atmospheric refraction) lifts the sun’s apparent position by about 34 arcminutes on average.

In practical terms, you see the sun before it has geometrically cleared the horizon. At the moment of visible sunrise, the true center of the sun still sits about 50 arcminutes below the horizon: 34 arcminutes from refraction plus 16 arcminutes for the solar radius. To learn more about how these astronomical definitions work together, check our reference page. If you would rather not implement any of this yourself, the free JSON API returns these times for any coordinate and date.

Refraction varies with temperature and air pressure. On a cold, high-pressure morning, the atmosphere bends light more, and sunrise appears slightly earlier. Standard calculations use the average value of 34 arcminutes rather than adjusting for daily weather.


The 90.833 Degree Zenith Angle

Combining the upper limb offset (16 arcminutes) and atmospheric refraction (34 arcminutes) gives a total correction of 50 arcminutes, which equals 0.833 degrees. Standard sunrise algorithms set the solar zenith angle to 90.833 degrees instead of a flat 90.

In other words, sunrise is defined as the moment when the sun’s geometric center reaches a zenith angle of 90.833 degrees. This single number bakes in both the refraction adjustment and the upper limb convention. Every major source, including NOAA’s solar calculator and the U.S. Naval Observatory, uses this value.


Solar Noon and the Equation of Time

Before you can find sunrise, you need to know when the sun crosses the local meridian (solar noon). Solar noon is not always 12:00 on your clock. Two factors cause it to drift:

  1. Earth’s elliptical orbit: Earth moves faster when closer to the sun (perihelion in early January) and slower when farther away (aphelion in early July). This speeds up or slows down the sun’s apparent motion across the sky.
  2. Axial tilt (obliquity): Earth’s 23.44 degree tilt means the sun’s path along the ecliptic is angled relative to the celestial equator. The sun’s east-west speed varies as it moves north and south through the seasons.

The Equation of Time captures both effects in a single correction. It ranges from about minus 14 minutes to plus 16 minutes over the course of a year. On days when the Equation of Time is positive, solar noon arrives before clock noon, and sunrise shifts earlier too.


The Sunrise Formula Step by Step

Here is a simplified walkthrough of the math behind sunrise. Most online calculators (including the one on this site) follow this sequence:

1. Gather Your Inputs

  • Latitude (φ): Your north-south position on Earth, in degrees.
  • Longitude: Your east-west position, used to convert solar time to clock time.
  • Day of year (n): January 1 = day 1, December 31 = day 365 (or 366).

2. Calculate the Sun’s Declination (δ)

The sun’s declination is how far north or south of the celestial equator the sun sits on a given date. A common approximation is:

δ = 23.44 × sin[(360/365) × (n + 284)]

This value swings from +23.44 degrees at the summer solstice to minus 23.44 degrees at the winter solstice.

That approximation (Cooper’s equation) is good to within about half a degree, which is fine for a rough sunrise time but not for precision work. Production calculators use a longer Fourier series instead. NOAA’s runs to seven terms and pairs it with a matching series for the Equation of Time.

3. Solve for the Hour Angle (ω)

The hour angle tells you how far (in degrees) the sun must travel from the meridian to reach the horizon. The core equation is:

cos(ω) = [sin(−0.833°) − sin(φ) × sin(δ)] / [cos(φ) × cos(δ)]

The −0.833° in the numerator is the combined refraction and upper limb correction discussed above. If this formula returns a value outside the range of −1 to 1, the sun does not rise (or does not set) at that latitude on that date. This is how you detect polar day or polar night.

4. Convert to Clock Time

Earth rotates 15 degrees per hour. Divide the hour angle by 15 to get hours before solar noon. Then apply three adjustments:

  1. Subtract the hour angle (in hours) from 12:00 solar noon.
  2. Apply the Equation of Time correction for the date.
  3. Adjust for the difference between your longitude and your time zone’s reference meridian.

As NOAA’s formula sheet puts it: sunrise (UTC minutes) = 720 − 4 × (longitude + hour angle) − Equation of Time.

Two things about that formula trip people up. Longitude is positive to the east of the Prime Meridian, so a US longitude goes in as a negative number. And the result is UTC, not local time, so you still have to apply your time zone offset and any daylight saving.


A Worked Example

Running the NOAA sheet end to end for New York City on 21 June 2027. Latitude 40.7128, longitude -74.0060, day of year 172.

Step Value
Fractional year γ 2.9436 rad
Equation of time -1.33 min
Solar declination 23.452°
Hour angle 113.217°
Solar noon 16:57 UTC (12:57 PM EDT)
Sunrise 09:24 UTC (5:24 AM EDT)
Sunset 00:30 UTC on 22 June (8:30 PM EDT)

Three things fall out of that worth noting.

Day length comes free once you have the hour angle: 2 × 113.217 / 15 = 15.10 hours, or 15h 06m. No second calculation needed.

Sunset lands on the following calendar day in UTC. That catches a lot of people writing this in code for the first time, and it produces off-by-one-day bugs for every location west of Greenwich.

Solar noon is 12:57 PM local, not 12:00, and almost all of that is bookkeeping. A full hour of it is daylight saving. Strip that off and solar noon is 11:57 AM standard time, three minutes early, because New York sits about a degree east of its zone’s 75°W reference meridian. The equation of time claws back about a minute of that in the other direction.

The times above land within a minute or two of what a full Meeus implementation gives, which is what NOAA says about the simplified sheet. If you need better than that, you need the longer algorithm, not a better arrangement of this one.

If you would rather not implement any of it, the free JSON API on this site returns the same figures:

GET https://api.sunrisesunset.io/json?lat=40.7128&lng=-74.0060&date=2027-06-21

Factors That Shift Sunrise Time

Beyond the core formula, several real-world factors push sunrise earlier or later:

  • Latitude: Near the equator, sunrise changes little across the year. At high latitudes, the difference between summer and winter sunrise can be several hours (or the sun may not rise at all).
  • Longitude within a time zone: Two cities in the same time zone can have sunrise times that differ by 30 minutes or more if one sits on the eastern edge and the other on the western edge.
  • Elevation: Standing higher gives you a longer line of sight to the horizon. A person on a mountaintop sees the sun before someone at sea level. Our guide on how elevation affects sunrise and sunset times explains the geometry behind this correction.
  • Local weather: Temperature inversions and humidity change the refractive index of the atmosphere. On rare occasions this can shift the visible sunrise by a minute or two compared to the standard prediction.

Common Algorithms and Tools

Several well-known algorithms power sunrise calculators around the world:

  • NOAA Solar Calculator: Uses equations from Jean Meeus’ book “Astronomical Algorithms.” Accurate to within about one minute for most locations.
  • U.S. Naval Observatory (USNO): Publishes annual tables and an online calculator. Their data is the standard reference for many government agencies.
  • The Almanac for Computers algorithm: A simplified 1990 USNO routine, widely circulated through Ed Williams’ aviation formulary and reimplemented in dozens of libraries. It uses the same 90.833 degree zenith and lands within a minute or two of NOAA’s.
  • SunriseSunset.io: Our own calculator uses NOAA-based equations and accounts for latitude, longitude, elevation, and time zone automatically.

All of these tools share the same core math. The differences come from how precisely they model the sun’s orbital elements and how they handle edge cases like polar regions.


Frequently Asked Questions

Does elevation affect sunrise time?

Yes. Higher elevation drops your visible horizon below level, so you see the sun sooner. At 1,000 meters (about 3,280 feet) above sea level, sunrise comes roughly 5 minutes earlier at mid-latitudes and about 4 minutes earlier near the equator.

The effect grows with the square root of height, not in proportion to it, so any “one minute per X meters” rule is wrong by construction. It also requires your horizon to be far below you; on a high plateau you get none of it. The numbers are worked through in how elevation affects sunset times.

Why is the sun red or orange at sunrise?

When the sun is near the horizon, its light passes through a much thicker slice of atmosphere than at midday. Shorter wavelengths (blue and violet) scatter away, leaving longer wavelengths (red and orange) to reach your eyes. Dust, smoke, and humidity can intensify the color.

Why does sunrise time change throughout the year?

Earth’s axis is tilted 23.44 degrees relative to its orbital plane. As Earth orbits the sun, this tilt changes the sun’s declination. In summer, the sun rises earlier because it follows a higher, longer arc across the sky. In winter, the arc is lower and shorter, so sunrise comes later.

How accurate are sunrise calculators?

Most modern calculators (NOAA, USNO, SunriseSunset.io) are accurate to within one to two minutes under normal atmospheric conditions. Extreme weather, unusual terrain, or very high latitudes can increase the error. No calculator accounts for local obstructions like mountains or buildings blocking your specific horizon.

What is the difference between sunrise and dawn?

Sunrise is the instant the top edge of the sun appears above the horizon. Dawn (also called twilight) starts earlier, when the sky first begins to brighten. Civil dawn begins when the sun is 6 degrees below the horizon. Nautical dawn starts at 12 degrees below, and astronomical dawn at 18 degrees below. The same twilight stages apply in reverse at sunrise.