NREL's Solar Position Algorithm (SPA)

This algorithm calculates the solar zenith and azimuth angles in the period from the year -2000 to 6000, with uncertainties of +/- 0.0003 degrees based on the date, time, and location on Earth. (Reference: Reda, I.; Andreas, A., Solar Position Algorithm for Solar Radiation Applications, Solar Energy. Vol. 76(5), 2004; pp. 577-589). The software has not been tested on a variety of platforms and is not guaranteed to work on yours. It is provided here as a convenience.

This algorithm is available in ANSI C and CRBasic; how to use this algorithm and a description of the variables is included in the spa.h header file (for C) and spa_tester.cr1x (for CRBasic). Further information on this algorithm is available in the following NREL technical report:

Reda, I.; Andreas, A. (2003). Solar Position Algorithm for Solar Radiation Applications. 55 pp.; NREL Report No. TP-560-34302, Revised January 2008. (1.9 MB PDF Document)


Distributed by the National Renewable Energy Laboratory
Solar Radiation Research Laboratory
June 2003

Copyright © 2008-2011 Alliance for Sustainable Energy, LLC, All Rights Reserved
The Solar Position Algorithm ("Software") is code in development prepared by employees of the Alliance for Sustainable Energy, LLC, (hereinafter the "Contractor"), under Contract No. DE-AC36-08GO28308 ("Contract") with the U.S. Department of Energy (the "DOE"). The United States Government has been granted for itself and others acting on its behalf a paid-up, non-exclusive, irrevocable, worldwide license in the Software to reproduce, prepare derivative works, and perform publicly and display publicly. Beginning five (5) years after the date permission to assert copyright is obtained from the DOE, and subject to any subsequent five (5) year renewals, the United States Government is granted for itself and others acting on its behalf a paid-up, non-exclusive, irrevocable, worldwide license in the Software to reproduce, prepare derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so. If the Contractor ceases to make this computer software available, it may be obtained from DOE's Office of Scientific and Technical Information's Energy Science and Technology Software Center (ESTSC) at P.O. Box 1020, Oak Ridge, TN 37831-1020. THIS SOFTWARE IS PROVIDED BY THE CONTRACTOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRACTOR OR THE U.S. GOVERNMENT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER, INCLUDING BUT NOT LIMITED TO CLAIMS ASSOCIATED WITH THE LOSS OF DATA OR PROFITS, WHICH MAY RESULT FROM AN ACTION IN CONTRACT, NEGLIGENCE OR OTHER TORTIOUS CLAIM THAT ARISES OUT OF OR IN CONNECTION WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
The Software is being provided for internal, noncommercial purposes only and shall not be re-distributed. Please contact Jean Schulte in the NREL Commercialization and Technology Transfer Office for information concerning a commercial license to use the Software.
As a condition of using the Software in an application, the developer of the application agrees to reference the use of the Software and make this Notice readily accessible to any end-user in a Help|About screen or equivalent manner.


SPA for CRBasic (Campbell Scientific CR6 and CR1000X data loggers only):

Note: An online SPA calculator that uses the C source code is also available.

To download SPA.C or SPA_Enc.CR1X, please accept the license terms above and submit the following information:
We will not share this information with other companies or agencies outside the US Department of Energy.

For questions about the solar position algorithm contact: Ibrahim Reda
For questions about this website or the source code contact: Afshin Andreas
[NREL] [MIDC] [SPA Calculator]