# A library for computing the relative position of the sun and the Earth

__In brief:__

A new algorithm, named SG2 (Solar Geometry-2), has been developed to meet the following requirements:

- accuracy of order of 9 10-5 rad (approx. 0.005°, or 19");
- period of validity: 1980-2030
- algorithm approximately 20 times faster than SPA

**An article has been published on the subject: Blanc P. and L. Wald, 2012. "The SG2 algorithm for a fast and accurate computation of the position of the sun for multi-decadal time period", Solar Energy 88, 10 (2012). pp 3072-3083**

The code is available here:

**Methodology**

After a complete state-of-the-art of the literature, the SPA (Solar Position Algorithm, [1], [2]) has been selected as starting point for the developments. It calculates solar zenith and azimuth angles - and other related parameters- in the period of -2000 to 6000 with an accuracy (standard deviation) of 0.0003° (1").

But in practice, the time requested for computation may be excessive. Indeed, approximately 2300 floating operations and more than 300 direct and inverse trigonometric functions are used for one solar position calculation at a given location and time. Such algorithm cannot be used in operation.

The algorithm has thus been confronted to other algorithms in the litterature in order to reduce the number of operations. These algorithms differ in the attained accuracy as a function of the time and in the computation cost. Finally, Armines has undertaken a research in order to derive fast and accurate approximations of the SPA algorithms, which led to the new algorithm named SG2.

The accuracy reached by the new algorithm is twice higher than the one originally planned by the Description of Work of the project. As a consequence and due to the high quality of the results, the work deserves publication in a high-level journal, such as Solar Energy. That is why Armines has opted for a description of the work under the form of a draft of article.

**References**

[1] Reda I., and Adreas A., 2003. Solar position algorithm for solar radiation applications: Technical Report, National Renewable Energy Laboratory, Golden, Colorado, USA. Revised January 2008.

[2] Reda I., and Andreas A., 2004. Solar position algorithm for solar radiation applications: *Solar Energy*, 76(5), 577-589. Corrigendum, 81, 838-838, 2007.

**Interactions with GMES and EnerGEO**

The SG2 library will be suggested for adoption in the framework of the planning of the operations in MACC-2 preparing the GMES Atmospheric Service. The dissemination of SG2 will benefit from the catalog of the FP7 EnerGEO project. Conversely, ENDORSE will contribute to EnerGEO by adding new evidence of the usefulness of this catalog.

NB: Please note that the first version of SG developed in the European Solar Radiation Atlas (2000) on the behalf of the European Commission, is presently used in the MACC project in preparation of the GMES Atmospheric Service.