%% $Date: 2012-07-06 17:42:54#$
%% $Revision: 148 $
\index{solar\_vector\_reda}
\algdesc{Solar Vector Calculation (Reda-Andreas)}
{ %%%%%% Algorithm name %%%%%%
solar\_vector\_reda
}
{ %%%%%% Algorithm summary %%%%%%
This algorithm calculates the current solar vector based on time, latitude and longitude inputs.
It accepts optional pressure and temperature arguments to correct for atmospheric refraction
effects. The zenith and azimuth angle calculated by this algorithm have uncertainties equal to
$\pm 0.0003^\circ$ in the period from the year -2000 to 6000. 

}
{ %%%%%% Category %%%%%%
Radiation
}
{ %%%%%% Inputs %%%%%%
Date\_time & Vector & ISO String of current date/time in UTC [yyyymmddThhmmss] \\
$lat$ & Vector & Latitude [degrees] \\
$long$ & Vector & Longitude [degrees] \\
$E$ & Vector & Elevation [m] \\
$P$ & Vector, Optional & Local pressure [hPa] \\
$T$ & Vector, Optional & Local temperature [$^{\circ}$C] 
}
{ %%%%%% Outputs %%%%%%
$\theta$ & Vector & Solar Zenith [degrees] \\
$\Phi$ & Vector & Solar Azimuth [degrees] 
}
{ %%%%%% Formula %%%%%%
\begin{enumerate}
\item Calculate Julian and Julian Ephemeris Day, Century and Millennium:
\begin{enumerate}
  \item Calculate Julian Day ($JD$):
  \begin{displaymath}
  JD = \text{INT}(365.25 (Y + 4716)) + \text{INT}(30.6001 (M + 1)) + D + B -1524.5
  \end{displaymath}
  %
  where:
  \begin{itemize}
    \item INT is the integer of the calculated terms (e.g. 8.7 = 8, 8.2 = 8, etc)
    \item $Y$ is the year
    \item $M$ is the month of the year. If $M <= 2$ then $Y = Y - 1$ and $M = M + 12$
    \item $D$ is the day of the month with decimal time (i.e. with fractions of the day 
    being represented after the decimal point.)
    \item $B$ is equal to 0 for the Julian Calendar, and equal to $(2 - A + $ INT$(A/4))$ for the
    Gregorian calendar, where $A = $ INT$(Y/100)$
  \end{itemize}
  \item Calculate Julian Ephemeris Day ($\multvar{JDE}$):
  \begin{displaymath}
  \multvar{JDE} = JD + \frac{\Delta T}{86400}
  \end{displaymath}
  Where $\Delta T$ is the difference between the Earth rotation time and the Terrestrial Time.
  It can be calculated following the NASA ``Polynomial expressions for $delta\_T$ ($\Delta T$)`` \cite{REDA1}.

  \item Calculate Julian Century ($JC$) and the Julian Ephemeris Century ($JCE$) for the 2000 standard epoch:
  \begin{gather*}
  \multvar{JC} = \frac{\multvar{JD} - 2451545}{36525} \\
  \multvar{JCE} = \frac{\multvar{JDE} - 2451545}{36525}
  \end{gather*}

  \item Calculate the Julian Ephemeris Millennium ($JME$) for the 2000 standard epoch:
  \begin{displaymath}
  \multvar{JME} = \frac{\multvar{JCE}}{10}
  \end{displaymath}

\end{enumerate}


\item Calculate Earth heliocentric longitude, latitude and radius vector ($L$, $B$, and $R$):
  \begin{enumerate}
    \item Calculate $L0_i$ and $L0$:
    \begin{gather*}
    L0_i = A_i \cos(B_i + C_i \times \multvar{JME}) \\
    L0 = \sum \limits_{i=0}^n L0_i
    \end{gather*}
%
    Where the terms $A_i$, $B_i$ and $C_i$ are based on values found in table A4.2 of the algorithm
    literature \cite{Reda}.

    \item Calculate the terms L1, L2, L3, L4 and L5 by using these same equations, but using the
    appropriate terms from the table.

    \item Calculate the Earth heliocentric longitude (in radians):
    %
    \begin{displaymath}
    L = 10^{-8} (L0 + L1 \times \multvar{JME} + L2 \times \multvar{JME}^2 + L3 \times \multvar{JME}^3 + L4 \times \multvar{JME}^4 + L5 \times \multvar{JME}^5)
    \end{displaymath}

    \item Convert $L$ to degrees and limit between 0$^\circ$ and 360$^\circ$.

    \item Calculate the Earth heliocentric latitude $B$ by using table A4.2 and repeating
    steps (a)-(c) using the appropriate values. Then convert $B$ to degrees. Note that there are no $B2$ through $B5$.

    \item Calculate the Earth radius vector $R$ (in AU) in a similar manner by repeating steps (a)-(c)
    and using the appropriate values from table A4.2.

  \end{enumerate}
  
\item Calculate the geocentric longitude and latitude ($\Theta$ and $\beta$):

\begin{gather*}
\Theta = L + 180 \\
\beta = - B 
\end{gather*}
%
Where $\Theta$ must be limited between 0$^\circ$ and 360$^\circ$.

\item Calculate the nutation in longitude and obliquity ($\Delta \psi$ and $\Delta \epsilon$):
  \begin{enumerate}
  \item Calculate the mean elongation of the moon from the sun (in degrees):
      \begin{displaymath}
      X_0 = 297.85036 + 445267.11480 \multvar{JCE} - 0.0019142 \multvar{JCE}^2 + \frac{\multvar{JCE}^3}{189474}
      \end{displaymath}

    \item Calculate the mean anomaly of the sun (in degrees):
      \begin{displaymath}
	X_1 = 357.52772 + 35999.050340 \multvar{JCE} - 0.0001603 \multvar{JCE}^2 - \frac{\multvar{JCE}^3}{300000}
      \end{displaymath}

    \item Calculate the mean anomaly of the moon (in degrees):
      \begin{displaymath}
      X_2 = 134.96298 + 477198.867398 \multvar{JCE} + 0.0086972 \multvar{JCE}^2 + \frac{\multvar{JCE}^3}{56250}
      \end{displaymath}

    \item Calculate the moon's argument of latitude (in degrees):
      \begin{displaymath}
      X_3 = 93.27191 + 483202.017538 \multvar{JCE} - 0.0036825 \multvar{JCE}^2 + \frac{\multvar{JCE}^3}{327270}
      \end{displaymath}

    \item Calculate the longitude of the ascending node of the moon's mean orbit on the ecliptic,
	  measured from the mean equinox of the date (in degrees):
	\begin{displaymath}
	X_4 = 125.04452 - 1934.136261 \multvar{JCE} + 0.0020708 \multvar{JCE}^2 + \frac{\multvar{JCE}^3}{450000}
	\end{displaymath}

    \item For each row in table A4.3, calculate the terms $\Delta \psi$ and $\Delta \epsilon$ (in
	  0.0001 of arc seconds):
	\begin{gather*}
	\Delta \psi_i = (a_i + b_i \multvar{JCE}) \sin{\left(\sum \limits_{j=0}^4 X_j Y_{i, j}\right)} \\
	\Delta \epsilon_i = (c_i + d_i \multvar{JCE}) \cos{\left(\sum \limits_{j=0}^4 X_j Y_{i, j}\right)} 
	\end{gather*}
      where:
	\begin{itemize}
	  \item $a_i$, $b_i$, $c_i$ and $d_i$ are the values listed in the $i$th row and columns a, b
		c and d in Table A4.3.
	  \item $X_j$ are the $X$ values calculated above
	  \item $Y_{i, j}$ are the values in row $i$ and $j$th Y column in table A4.3. 
	\end{itemize}

      \item Calculate the nutation in longitude and obliquity (in degrees):
	\begin{gather*}
	  \Delta \psi = \frac{\sum \limits_{i=0}^{63} \Delta \psi_i}{36000000} \\
	  \Delta \epsilon = \frac{\sum \limits_{i=0}^{63} \Delta \epsilon_i}{36000000}
	\end{gather*}
  \end{enumerate}

\item Calculate the true obliquity of the ecliptic (in degrees):
\begin{align*}
U &= JME / 10 \\
\epsilon_0 &= 84381.448 - 4680.93 U - 1.55 U^2 + 1999.25 U^3 - 51.38 U^4 \\
           & \qquad {} - 249.67 U^5 - 39.05 U^6 + 7.12 U^7 + 27.87 U^8 + 5.79 U^9 + 2.45 U^{10} \\
\epsilon &= \epsilon_0 / 3600 + \Delta \epsilon
\end{align*}

\item Calculate the aberration correction (in degrees):
\begin{displaymath}
\Delta \tau = - \frac{20.4898}{3600 R}
\end{displaymath}

\item Calculate the apparent sun longitude (in degrees):
\begin{displaymath}
\lambda = \Theta + \Delta \psi + \Delta \tau
\end{displaymath}

\item Calculate the apparent sidereal time at Greenwich at any given time (in degrees):
\begin{gather*}
\nu_0 = 280.46061837 + 360.98564736629 (JD - 2451545) + 0.000387933 JC^2 - \frac{JC^3}{38710000} \\
\nu = \nu_0 + \Delta \psi \cos{\epsilon}
\end{gather*}
where $\nu_0$ must be limited to the range from 0$^\circ$ to 360$^\circ$.

\item Calculate the geocentric sun right ascension (in degrees):
\begin{displaymath}
\alpha = \frac{180}{\pi} \tan^{-1}{\left(\frac{\sin{\lambda} \cos{\epsilon} - \tan{\beta} \sin{\epsilon}}{\cos{\lambda}}\right)}
\end{displaymath}
where, as before, $\alpha$ must be limited to the range from 0$^\circ$ to 360$^\circ$.

\item Calculate the geocentric sun declination $\delta$ (in degrees):
\begin{displaymath}
\delta = \frac{180}{\pi} \sin^{-1}(\sin{\beta} \cos{\epsilon} + \cos{\beta}\sin{\epsilon}\sin{\lambda})
\end{displaymath}

\item Calculate the observer local hour angle (in degrees):
\begin{displaymath}
  H = \nu + long - \alpha
\end{displaymath}
Limit $H$ from 0$^\circ$ to 360$^\circ$, and note that in this algorithm $H$ is measured westward from south.

\item Calculate the topocentric sun right ascension and declination (in degrees):
  \begin{enumerate}
  \item Calculate the equatorial horizontal parallax of the sun (in degrees):
      \begin{displaymath}
      \xi = \frac{8.794}{3600 R}
      \end{displaymath}
  \item Calculate the terms $u$ (in radians), $x$ and $y$:
      \begin{gather*}
      u = \tan^{-1}(0.99664719 \tan{lat}) \\
      x = \cos{u} + \frac{E}{6378140} \cos{lat} \\
      y = 0.99664719 \sin{u} + \frac{E}{6378140} \sin{lat}
      \end{gather*}
    \item Calculate the parallax in the sun right ascension (in degrees):
      \begin{displaymath}
      \Delta \alpha = \frac{180}{\pi} \tan^{-1}\left(\frac{-x \sin{\xi} \sin{H}}{\cos{\delta} - x \sin{\xi} \cos{H}} \right)
      \end{displaymath}

    \item Calculate the topocentric sun right ascension and declination (in degrees):
      \begin{gather*}
      \alpha' = \alpha + \Delta \alpha \\
      \delta' = \tan^{-1} \left( \frac{(\sin{\delta} - y \sin{\xi}) \cos{\Delta \alpha}}{\cos{\delta} - x \sin{\xi} \cos{H}} \right)
      \end{gather*}
  \end{enumerate}

\item Calculate the topocentric local hour angle (in degrees):
\begin{displaymath}
H' = H - \Delta \alpha
\end{displaymath}

\item Calculate the topocentric zenith angle (in degrees):
  \begin{enumerate}


    \item Calculate the topocentric elevation angle without atmospheric correction (in degrees):
    \begin{displaymath}
    e_0 = \frac{180}{\pi} \sin^{-1} (\sin{lat} \sin{\delta'} + \cos{lat} \cos{\delta'} \cos{H'})
    \end{displaymath}
    
    \item Calculate the atmospheric refraction correction (in degrees):
    \begin{displaymath}
    \Delta e = \frac{P}{1010} \frac{283}{(T + 273)} \frac{1.02}{60 \tan{\left(e_0 + \frac{10.3}{e_0 + 5.11}\right)}}
    \end{displaymath}

    Note that this step is skipped if temperature and pressure are not provided by the user. Also note that the argument for the
    tangent is computed in degrees. A conversion to radians may be needed if required by your computer or calculator. 

    \item Calculate the topocentric elevation angle (in degrees):
    \begin{displaymath}
    e = e_0 + \Delta e
    \end{displaymath}

    \item Calculate the topocentric zenith angle (in degrees):
    \begin{displaymath}
    \theta = 90 - e
    \end{displaymath}

  \end{enumerate}

\item Calculate the topocentric azimuth angle (in degrees):
\begin{displaymath}
\Phi = \frac {180}{\pi} \tan^{-1}{\left(\frac{\sin{H'}}{\cos{H'} \sin{lat} - \tan{\delta'}\cos{lat}}\right)} + 180
\end{displaymath}
Limit $\Phi$ from 0$^\circ$ to 360$^\circ$. Note that $\Phi$ is measured eastward from north.

\end{enumerate}
}
{ %%%%%% Author %%%%%%


}
{ %%%%%% References %%%%%% 
Reda and Andreas, ``Solar Position Algorithm for Solar Radiation Applications,'' National Renewable Energy Laboratory, Revised 2008, accessed February 14, 2012, \href{http://www.nrel.gov/docs/fy08osti/34302.pdf}{http://www.nrel.gov/docs/fy08osti/34302.pdf}. \cite{Reda}
}


