Skip to main content

Summary

PlantPredict implements the NREL Solar Position Algorithm (SPA), a high-accuracy algorithm for computing the Sun’s apparent position in the sky. The algorithm achieves uncertainties of ±0.0003° for the period −2000 to 6000, making it suitable for precision solar tracking and energy modeling. The implementation follows the NREL Technical Report TP-560-34302 (Reda & Andreas, 2004) with minor simplifications noted below. Due to the complexity of the algorithm, only its outline is described here for the sake of concision. A full description can be found in the NREL technical report mentioned above.

Inputs

NameSymbolUnitsDescription
UTC Date–TimedatetimeCoordinated Universal Time
Latitudeφ\varphidegreesObserver latitude (+north, −south)
Longitudeλ\lambdadegreesObserver longitude (+east, −west)
AltitudehhmetersObserver elevation above sea level
TemperatureTaT_a°CAmbient temperature (for refraction correction)
PressurePPhPaAtmospheric pressure (for refraction correction)

Outputs

NameSymbolUnitsDescription
Apparent Solar Zenith Angleθz\theta_zdegreesAngle from vertical to Sun, corrected for refraction
Apparent Solar Azimuth Angleγs\gamma_sdegreesHorizontal angle from North (clockwise)

Detailed Description

The SPA proceeds through these major steps:

1. Time Calculations

Convert the input UTC datetime to Day (JD) and Julian Ephemeris Day (JDE) for planetary calculations. SPA intentionally uses two time scales:
  • (TT), also referred to as (ET), a uniform time scale independent of variations in Earth rotation speed, used for orbital mechanics. In this time scale, a day is always exactly 24 hours.
  • (UT, approximated here by UTC), a time scale synchronized to the Earth’s variable rotation speed. In this time scale, a day is not always exactly 24 hours.
TT and, thus, JDE are used for the relative positions of the Sun and Earth independent of the rotation of Earth. UT and, thus, JD are used to calculate the position of the Sun in the sky from the point of view of an observer located on the (rotating) surface of the Earth. The offset between these two timescales is ΔT = TT − UT and slowly varies over time (<1 second per year). PlantPredict uses a fixed ΔT of 67 seconds (corresponding to ~2013–2014). This approximation introduces negligible error for typical PV modeling horizons (<30 seconds difference over a 30-year period).

2. Earth’s Heliocentric Position

Calculate Earth’s position relative to the Sun using the theory—a set of polynomial and periodic series that model planetary orbits. This yields:
  • Heliocentric longitude LL — Earth’s angular position in its orbital plane
  • Heliocentric latitude BB — Earth’s position above/below the
  • Radius vector RR — Earth-Sun distance in

3. Geocentric Sun Position

Invert the Earth position to get the Sun position (as seen from Earth’s center). This is a simple coordinate transformation: add 180° to longitude (λecl=L+180°\lambda_{\text{ecl}} = L + 180°) and negate latitude (βecl=B\beta_{\text{ecl}} = -B).

4. Nutation and Obliquity

is the periodic wobble of Earth’s rotational axis due to gravitational torques from the Sun and Moon. The algorithm computes:
  • Nutation in longitude Δψ\Delta\psi — change in direction of the tilt of the rotational axis, affects the Sun’s apparent east-west position
  • Nutation in obliquity Δϵ\Delta\epsilon — change in magnitude of the tilt of the rotational axis, affects the tilt of Earth’s equator relative to the ecliptic
The true ϵ\epsilon (tilt of Earth’s axis, ~23.4°) is then computed by adding nutation in obliquity to the mean obliquity: ϵ=ϵ0+Δϵ\epsilon = \epsilon_0 + \Delta\epsilon. The nutation in longitude is used to correct the Sun apparent coordinates, as detailed below.

5. Aberration

(Δτ\Delta\tau) is the apparent shift in celestial positions caused by Earth’s orbital velocity (~30 km/s) combined with the finite speed of light—it takes approximately 8 minutes for light from the Sun to reach Earth. Light arriving from the Sun appears slightly displaced in the direction of Earth’s motion. In other words, in the Earth reference frame, once light from the Sun reaches the Earth surface, the Sun has already moved from where that light was cast. The correction is small (~20 arcseconds) but significant for high-precision applications.

6. Apparent Sun Coordinates

The apparent Sun longitude is computed by adding in longitude (Δψ\Delta\psi) and (Δτ\Delta\tau) to the geocentric longitude: λecl=λecl+Δψ+Δτ\lambda'_{\text{ecl}} = \lambda_{\text{ecl}} + \Delta\psi + \Delta\tau. The nutation correction accounts for the shift of the —the zero point for measuring celestial longitude. Because the equinox is defined as the intersection of the ecliptic and equator, and nutation wobbles the equator, the equinox shifts along the ecliptic. Adding Δψ\Delta\psi ensures we measure the Sun’s position relative to the “true equinox” (actual position) rather than the “mean equinox” (averaged position). The Sun latitude does not need correction (βecl=βecl\beta'_{\text{ecl}} = \beta_{\text{ecl}}). The apparent ecliptic coordinates (longitude λecl\lambda'_{\text{ecl}}, latitude βecl\beta'_{\text{ecl}}) are then converted to using the true ϵ\epsilon. This transformation rotates from the (based on Earth’s ) to the (based on Earth’s equator). Both nutation components affect the final result: Δψ\Delta\psi is incorporated in the apparent longitude, while Δϵ\Delta\epsilon enters through the true obliquity. The resulting equatorial coordinates are:
  • α\alpha — celestial “longitude” measured along the equator
  • δ\delta — celestial “latitude” above/below the equator

7. Local Hour Angle

Calculate the HH, which measures how far the Sun has traveled past the observer’s meridian. It is obtained from the (GAST) corrected for the observer’s longitude λ\lambda and Sun’s right ascension α\alpha: H=GAST+λαH = \text{GAST} + \lambda - \alpha. GAST measures Earth’s rotational position relative to the stars (specifically, the true vernal equinox), not the Sun. A sidereal day (~23h 56m 4s)—one full 360° rotation relative to the stars—is shorter than a solar day (24h) because Earth’s orbital motion causes the Sun to drift ~1° westward each day, requiring an extra ~4 minutes of rotation to bring the Sun back to the same position. GAST is computed from UTC, corrected for the nutation-induced shift of the true equinox (zero reference).

8. Topocentric Correction (Parallax)

Convert from (Earth-center) to (observer location) coordinates. accounts for the observer being on Earth’s surface rather than at its center—a shift of up to ~9 arcseconds depending on the Sun’s position and observer location. The correction adjusts the equatorial coordinates:
  • Hour angle: H=HΔHH' = H - \Delta H (topocentric hour angle)
  • Declination: δ=δ+Δδ\delta' = \delta + \Delta\delta (topocentric declination)
These corrections depend on:
  • Observer’s latitude φ\varphi and altitude hh (determines distance from Earth’s center)
  • Local hour angle HH (Sun’s position relative to observer’s meridian)
  • Earth-Sun distance RR (closer Sun = larger parallax)

9. Zenith and Azimuth Angles

Calculate the zenith angle θz\theta_z and azimuth angle γs\gamma_s in topocentric coordinates by transforming from topocentric equatorial coordinates (δ\delta', HH') to the local horizon frame using the observer’s latitude φ\varphi. Then apply the atmospheric correction to the zenith angle—the atmosphere bends light, making the Sun appear higher than it geometrically is (lower zenith angle). Finally, convert azimuth to PlantPredict’s convention, measuring azimuth clockwise from North: 0° = North, 90° = East, 180° = South, 270° = West

Implementation Notes

PlantPredict’s implementation follows the NREL SPA algorithm. Key implementation details:
AspectImplementation
VSOP87 tablesFull tables from NREL TP-560-34302 (Tables A4.2–A4.3)
Nutation terms63-term series from NREL TP-560-34302 (Table A4.1)
ΔT valueFixed at 67 seconds
Refraction modelBennett formula with pressure/temperature adjustment
Valid date range−2000 to 6000 (accuracy ±0.0003°)

References

  • Reda, I., & Andreas, A. (2004). Solar Position Algorithm for Solar Radiation Applications. NREL Technical Report NREL/TP-560-34302.
  • Meeus, J. (1998). Astronomical Algorithms (2nd ed.). Willmann-Bell, Inc.
  • Bretagnon, P., & Francou, G. (1988). Planetary theories in rectangular and spherical variables. VSOP 87 solutions. Astronomy and Astrophysics, 202, 309–315.
  • Bennett, G. G. (1982). The Calculation of Astronomical Refraction in Marine Navigation. Journal of Navigation, 35(2), 255–259.