Astronomy
Solar Angles
Earth-Sun Relationship
Geolocation
Trigonometry

How to calculate the angle between a place on Earth and the Sun?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

When people ask for the angle between a location on Earth and the Sun, they usually mean the solar elevation angle or its complement, the solar zenith angle. That angle depends on latitude, date, and local solar time, because the Sun's apparent position changes throughout both the day and the year.

The Core Geometry

The standard formula for solar elevation uses:

  • latitude phi
  • solar declination delta
  • hour angle H

The elevation angle alpha satisfies:

text
sin(alpha) = sin(phi) * sin(delta) + cos(phi) * cos(delta) * cos(H)

Where:

  • 'phi is the observer latitude'
  • 'delta is the Sun's declination for the date'
  • 'H is the hour angle, measured from local solar noon'

Once you have alpha, the solar zenith angle is:

text
zenith = 90 - alpha

Declination and Hour Angle

For a practical approximation, solar declination can be estimated from the day of year:

text
delta ~= 23.44 * sin(360 / 365 * (N - 81))

where N is the day number in the year and the angle is interpreted in degrees before converting to radians for computation.

The hour angle is:

text
H = 15 * (solar_time - 12)

At local solar noon, H is zero. Two hours before solar noon, H is -30 degrees. Two hours after, it is +30 degrees.

A Python Example

python
1import math
2
3
4def solar_elevation(latitude_deg, declination_deg, solar_time_hours):
5    phi = math.radians(latitude_deg)
6    delta = math.radians(declination_deg)
7    hour_angle = math.radians(15 * (solar_time_hours - 12))
8
9    sin_alpha = (
10        math.sin(phi) * math.sin(delta)
11        + math.cos(phi) * math.cos(delta) * math.cos(hour_angle)
12    )
13
14    alpha = math.degrees(math.asin(sin_alpha))
15    return alpha
16
17
18latitude = 34.0
19declination = 0.0
20solar_time = 10.0
21
22elevation = solar_elevation(latitude, declination, solar_time)
23zenith = 90 - elevation
24
25print(f"Elevation: {elevation:.2f} degrees")
26print(f"Zenith: {zenith:.2f} degrees")

This example uses an equinox-like declination of 0 degrees. For real applications, you would compute declination from the date and convert civil clock time into local solar time more carefully.

Why Local Solar Time Matters

Clock time is not always the same as solar time. Time zones, daylight saving time, and longitude within the time zone all affect the difference.

If you use plain wall-clock time without correction, the resulting angle may be noticeably off. That is fine for a rough educational estimate, but not for precise solar-panel or astronomical work.

Practical Interpretation

The elevation angle tells you how high the Sun is above the horizon:

  • near 0 degrees means sunrise or sunset
  • around 90 degrees means the Sun is nearly overhead
  • negative values mean the Sun is below the horizon

That makes the value useful in:

  • solar energy estimation
  • shadow calculations
  • daylight planning
  • astronomical observation

Common Pitfalls

The biggest mistake is confusing elevation angle with zenith angle. They are related, but they are not the same quantity.

Another mistake is using local clock time instead of local solar time. For rough estimates it may be acceptable, but it reduces accuracy.

A third issue is forgetting to convert degrees to radians before calling trigonometric functions in code.

Summary

  • The usual target quantity is solar elevation or solar zenith angle.
  • The calculation depends on latitude, solar declination, and hour angle.
  • Elevation can be computed from a standard trigonometric formula.
  • Solar time matters if you want accurate results.
  • Be explicit about whether you want elevation above the horizon or zenith from the vertical.

Course illustration
Course illustration

All Rights Reserved.