Sun position
Sun position algorithm
sky0.h File Reference

sky0.h - astronomical coordinate conversion for NREL Sun Position Algorithm More...

Go to the source code of this file.

Data Structures

struct  Sky0_Nut1980
 Nutation angles and obliquity. More...
 

Functions

void sky0_nutationSpa (double t_cy, Sky0_Nut1980 *nut)
 Calculates the nutation in longitude and obliquity, according to the algorithm set out in the NREL SPA document. More...
 
void sky0_epsilonSpa (double t_cy, Sky0_Nut1980 *nut)
 Calculate the obliquity of the ecliptic and the equation of the equinoxes. More...
 
double sky0_gmSiderealTimeSpa (double du)
 Calculate the Greenwich mean sidereal time using the algorithm from the NREL SPA document. More...
 
void sky0_appToTirs (const V3D_Vector *appV, double j2kUT1_d, double eqEq_rad, V3D_Vector *terInterV)
 Convert a position in geocentric apparent coordinates to geocentric coordinates in the Terrestrial Intermediate Reference System. More...
 

Detailed Description

sky0.h - astronomical coordinate conversion for NREL Sun Position Algorithm

Author
David Hoadley

This is one of three alternative modules: sky0.h / sky0.c, sky1.h / sky1.c and sky2.h / sky2.c. They contain routines for transforming astronomical positions from frame to another: precession, nutation, sidereal time etc. and they reflect changes in the International Astronomical Union's precession and nutation theory. The differences are:

  • sky0.h / sky0.c: nutation, obliquity and sidereal time routines from the NREL Solar Position Algorithm document. These are based on the IAU 1980 nutation theory.
  • sky1.h / sky1.c: precession, nutation and their associated rotation matrices, obliquity and sidereal time. These are the IAU 1980 precession and nutation theory.
  • sky2.h / sky2.c: precession, nutation and their associated rotation matrices, obliquity and sidereal time. These are the newer IAU 2000 precession and nutation theory.

This module (sky0.h / sky0.c) contains only those routines necessary for supporting the NREL Solar Position Algorithm and Moon Position algorithms. Basically this is a subset of the routines in the sky1.h / sky1.c module. Precession is omitted, and the nutation routine uses only the largest 63 terms of the IAU 1980 nutation algorithm.


Definition in file sky0.h.

Function Documentation

◆ sky0_nutationSpa()

void sky0_nutationSpa ( double  t_cy,
Sky0_Nut1980 nut 
)

Calculates the nutation in longitude and obliquity, according to the algorithm set out in the NREL SPA document.

This is a simplified version of the IAU 1980 Nutation Theory. Calculates first the fundamental nutation arguments, and then a series of terms. There are 106 terms in the full series, but this routine uses only the largest 63 of those terms.

Parameters
[in]t_cycenturies since J2000.0, TT timescale
[out]nutfield nut->dPsi_rad - Nutation in longitude Δψ (radian)
field nut->dEps_rad - Nutation in obliquity Δε (radian)
References:
Reda, I. and Andreas, A. (2003), "Solar Position Algorithm for Solar Radiation Applications", National Renewable Energy Laboratory, NREL publication no. NREL/TP-560-34302, section 3.4. However, the theory on which it is based, and the full sequence of terms, can be found in:
Final report of the IAU Working Group on Nutation, chairman P.K.Seidelmann, 1980, published in Celestial Mechanics, Vol 27, pp79-106, 1982.
also Kaplan,G.H. USNO circular no. 163, pp A3-6, 1981.
Supplement to the Astronomical Almanac 1984.
When to call this function
It is quite likely that you will not need to call this function directly. It is used in the Solar Position Algorithm and the Moon Position Algorithm, so if you call sun_nrelApparent() or sun_nrelTopocentric(), or call moon_nrelApparent() or moon_nrelTopocentric(), those routines will call this routine for you. Likewise, if you are tracking the Sun or Moon using the skyfast module, the call to skyfast_init() will call either sun_nrelApparent() or moon_nrelApparent(), and therefore call this routine for you.
The values calculated by this routine change only slowly. So if you are calling it yourself, you can call it infrequently. Intervals of up to an hour between calls will not introduce much error.

Definition at line 222 of file sky0.c.

◆ sky0_epsilonSpa()

void sky0_epsilonSpa ( double  t_cy,
Sky0_Nut1980 nut 
)

Calculate the obliquity of the ecliptic and the equation of the equinoxes.

Parameters
[in]t_cycenturies since J2000.0, TT timescale
[in,out]nut[in] field nut->dPsi_rad - Nutation in longitude Δψ, as returned by function sky0_nutationSpa() (radian)
[in] field nut->dEps_rad - Nutation in obliquity Δε, as returned by function sky0_nutationSpa() (radian)
[out] field nut->eps0_rad - Mean obliquity of the ecliptic ε0 (radian)
[out] field nut->eqEq_rad - Equation of the equinoxes = Δψ * cos(ε0 + Δε) (radian) Note: not seconds
Reference
Reda, I. and Andreas, A. (2003), "Solar Position Algorithm for Solar Radiation Applications", National Renewable Energy Laboratory, NREL publication no. NREL/TP-560-34302, section 3.5.1
When to call this function
It is quite likely that you will not need to call this function directly. It is used in the Solar Position Algorithm and the Moon Position Algorithm, so if you call sun_nrelApparent() or sun_nrelTopocentric(), or call moon_nrelApparent() or moon_nrelTopocentric(), those routines will call this routine for you. Likewise, if you are tracking the Sun or Moon using the skyfast module, the call to skyfast_init() will call either sun_nrelApparent() or moon_nrelApparent(), and therefore call this routine for you.
The values calculated by this routine change only slowly. So if you are calling it yourself, you can call it infrequently. Intervals of up to an hour between calls will not introduce much error.

Definition at line 334 of file sky0.c.

◆ sky0_gmSiderealTimeSpa()

double sky0_gmSiderealTimeSpa ( double  du)

Calculate the Greenwich mean sidereal time using the algorithm from the NREL SPA document.

This is basically the IAU 1982 algorithm, but the various constants have been scaled in degrees.

Returns
Greenwich Mean Sidereal Time (radian)
Parameters
[in]dudays since J2000.0, UT1 timescale
Reference
Reda, I. and Andreas, A. (2003), "Solar Position Algorithm for Solar Radiation Applications", National Renewable Energy Laboratory, NREL publication no. NREL/TP-560-34302, section 3.8.1 & 3.8.2
When to call this function
If you are tracking a celestial object, you need not call this function directly. So long as you call sky0_appToTirs() every time around your control loop, it will call this function for you.

Definition at line 392 of file sky0.c.

◆ sky0_appToTirs()

void sky0_appToTirs ( const V3D_Vector appV,
double  j2kUT1_d,
double  eqEq_rad,
V3D_Vector terInterV 
)

Convert a position in geocentric apparent coordinates to geocentric coordinates in the Terrestrial Intermediate Reference System.

This is the first stage of converting apparent coordinates to topocentric coordinates. The resulting vector depends upon the current rotational position of the Earth. (For the second stage, to obtain topocentric coordinates, call routine sky_siteTirsToTopo()).

Parameters
[in]appVPosition vector of apparent place (unit vector in equatorial coordinates)
[in]j2kUT1_ddays since J2000.0, UT1 timescale, as returned by function sky_updateTimes() in the j2kUT1_d field of the Sky_Times struct.
[in]eqEq_radEquation of the equinoxes (radian), as returned by function sky0_epsilonSpa() in the eqEq_rad field of the Sky0_Nut1980 struct.
[out]terInterVPosition vector in Terrestrial Intermediate Ref System
When to call this function
When you have the position of a celestial object expressed in Apparent coordinates, use this function to convert it to Terrestrial coordinates at the relevant rotational position of the earth. (Effectively you are converting from Right Ascension and Declination to the negative of the Greenwich Hour Angle and Declination.) If you are running a control loop to enable continuous tracking of this object, you will need to call this function (once) every time around your control loop.
Follow this function with a call to sky_siteTirsToTopo() to obtain the object's position in topocentric coordinates at the observing site.

Examples
demo4_multiple_sites.c.

Definition at line 432 of file sky0.c.