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
| Name | Symbol | Units | Description |
|---|---|---|---|
| UTC Date–Time | — | datetime | Coordinated Universal Time |
| Latitude | degrees | Observer latitude (+north, −south) | |
| Longitude | degrees | Observer longitude (+east, −west) | |
| Altitude | meters | Observer elevation above sea level | |
| Temperature | °C | Ambient temperature (for refraction correction) | |
| Pressure | hPa | Atmospheric pressure (for refraction correction) |
Outputs
| Name | Symbol | Units | Description |
|---|---|---|---|
| Apparent Solar Zenith Angle | degrees | Angle from vertical to Sun, corrected for refraction | |
| Apparent Solar Azimuth Angle | degrees | Horizontal 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.
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 — Earth’s angular position in its orbital plane
- Heliocentric latitude — Earth’s position above/below the
- Radius vector — 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 () and negate latitude ().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 — change in direction of the tilt of the rotational axis, affects the Sun’s apparent east-west position
- Nutation in obliquity — change in magnitude of the tilt of the rotational axis, affects the tilt of Earth’s equator relative to the ecliptic
5. Aberration
() 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 () and () to the geocentric longitude: . 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 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 (). The apparent ecliptic coordinates (longitude , latitude ) are then converted to using the true . This transformation rotates from the (based on Earth’s ) to the (based on Earth’s equator). Both nutation components affect the final result: is incorporated in the apparent longitude, while enters through the true obliquity. The resulting equatorial coordinates are:- — celestial “longitude” measured along the equator
- — celestial “latitude” above/below the equator
7. Local Hour Angle
Calculate the , 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 and Sun’s right ascension : . 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: (topocentric hour angle)
- Declination: (topocentric declination)
- Observer’s latitude and altitude (determines distance from Earth’s center)
- Local hour angle (Sun’s position relative to observer’s meridian)
- Earth-Sun distance (closer Sun = larger parallax)
9. Zenith and Azimuth Angles
Calculate the zenith angle and azimuth angle in topocentric coordinates by transforming from topocentric equatorial coordinates (, ) to the local horizon frame using the observer’s latitude . 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° = WestImplementation Notes
PlantPredict’s implementation follows the NREL SPA algorithm. Key implementation details:| Aspect | Implementation |
|---|---|
| VSOP87 tables | Full tables from NREL TP-560-34302 (Tables A4.2–A4.3) |
| Nutation terms | 63-term series from NREL TP-560-34302 (Table A4.1) |
| ΔT value | Fixed at 67 seconds |
| Refraction model | Bennett 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.