Kipp&Zonen BSRN Scientific Solar Monitoring System User Manual
Page 182
170
' Calculate hour angle in radians between -Pi and Pi.
Ha = LMST - Ra
IF Ha < -pi THEN Ha = Ha + TwoPi
IF Ha > pi THEN Ha = Ha - TwoPi
' Hour angle in degrees, 0 North
HaDegrees = Ha * ToDegrees + OneEighty
' Local Apparent Tim e or True Solar Tim e in hours.
TST = (Twelve + Ha / pi * Twelve)
' Change latitude to radians.
Lat = Lat * ToRad
' Calculate azim uth and elevation.
El = SIN(Dec) * SIN(Lat) + COS(Dec) * COS(Lat) * COS(Ha)
El = ATN(El / SQR(One - El * El))
'Determ ination of azim uth angle based upon TST
IF TST = Twelve THEN
Az = pi
ELSE
cosaz = (SIN(Dec) * COS(Lat) - COS(Dec) * SIN(Lat) * COS(Ha)) / COS(El)
Az = -ATN(cosaz / SQR(One - cosaz * cosaz)) + pi / Two
IF TST > Twelve THEN Az = TwoPi - Az
END IF
' Calculate refraction correction for US standard atm osphere. Need to have
' El in degrees before calculating correction.
El = El * ToDegrees
IF El > EC1 THEN
Refrac = EC2 * (EC3 + EC4 * El + EC5 * El * El)
Refrac = Refrac / (One + EC6 * El + EC7 * El * El)
ELSE
Refrac = -EC1
END IF
' Note that 3.51561 = 1013.2 mb/288.2 K which is the ratio of the pressure
' and temperature of the US standard atmosphere.
El = El + Refrac
' Elevation in degrees.
' Convert Az and Lat to degrees before returning.
Az = Az * ToDegrees
Lat = Lat * ToDegrees
' MnLon in degrees, GMST in hours, JD in days if 2.4e6 added;
' MnAnom, EcLon, OblqEc, Ra, Dec, LMST, and Ha in radians.
' Calculate the equation of time.
' EOT output in seconds.
Radegrees = Ra * ToDegrees
' Test for phase change between MnLon and Ra
IF (MnLon - Radegrees) > OneEighty THEN Radegrees = Radegrees + ThreeSixty
EOT = (MnLon - Radegrees) * TwoForty
' Format True Solar Time HH:MM:SS.
SHr = INT(TST)
SMn = INT((TST - SHr) * Sixty)
SSc = INT(((TST - SHr) * Sixty - SMn) * Sixty) + One
IF SSc = Sixty THEN SMn = SMn + One: SSc = Zero
IF SMn = Sixty THEN SHr = SHr + One: SMn = Zero
IF SHr = Twentyfour THEN SHr = Zero
IF SHr < Zero THEN SHr = Twentyfour + SHr
IF SMn < Zero THEN SMn = Sixty + SMn
IF SSc < Zero THEN SSc = Sixty + SSc
SolarHr$ = RIGHT$(STR$(SHr), 2)
IF ABS(SHr) < Ten THEN SolarHr$ = "0" + RIGHT$(STR$(SHr), 1)