troubleshooting Question

# Zenith Angle relation to Hour Angle

asked on
Math / Science
3 Comments1 Solution555 ViewsLast Modified:
I am continuing to develop a java desktop (jar) program which shows radiation received from sun on a panel whith various tilt and headings. The program is actually working Ok but I spent quite a bit of time messing with two different algorithms for hour angles.
The  problem is that one algorithm returns an hour angle which turns out to agree with hour angles published in the Astronomical Almanac, so long as I divide the result by 15. For example the published hour angle for October 4th at 10AM local for an  observer located at 25 south latitude at Greenwich meridian turns out to be -1.8164 which is correct. However I dont have any algorithm for getting the correct azimuth and zenith of the sun which should be 56.02 and 33.37 respectively. The algorithm included with the code gives an incorrect result of 20.81 for zenith.
Another algorithm gives me an hour angle of -27.22 which is incorrect but  this oddly produces the correct azimuth and zenith.
The algorithm used in each case for getting the zenith is:
cosZenith = sinDeclination * sinLongitude + cosDeclination * cosLongitude * cosHourAngle;
Like I said above the correct hour angle gives incorrect zenith.
Briefly the correct hour angle is produced by subtracting the RightAscension from the local mean time.
The other java class is more involved and calculates equation of time as below. The return value is used to calculate the hour angle.
//***********************************************************************/
//* Name:    calcEquationOfTime                                    */
//* Type:    Function                                          */
//* Purpose: calculate the difference between true solar time and mean      */
//*            solar time                                    */
//* Arguments:                                                */
//*   t : number of Julian centuries since J2000.0                  */
//* Return value:                                          */
//*   equation of time in minutes of time                        */
//***********************************************************************/

public static double calcEquationOfTime(double t){
double epsilon = calcObliquityCorrection(t);
double l0 = calcGeomMeanLongSun(t);
double e = calcEccentricityEarthOrbit(t);
calcGeomMeanAnomalySun(t);
double y = tan(rads*epsilon/2.0);
y *= y;
double sin2l0 = sin(2.0 * rads*l0);
double sinm   = sin(rads*pdat.mnanom);
double cos2l0 = cos(2.0 * rads*l0);
double sin4l0 = sin(4.0 * rads*l0);
double sin2m  = sin(2.0 * rads*pdat.mnanom);
double Etime = y * sin2l0 - 2.0 * e * sinm + 4.0 * e * y * sinm * cos2l0
- 0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m;

return degs*Etime*4.0;      // in minutes of time
}

double eqTime = Etime;
double solarTimeFix = eqTime - 4.0 * pdat.longitude;
double trueSolarTime = hh * 60.0 + mm + ss/60.0 + solarTimeFix; // in minutes
while (trueSolarTime > 1440)
{
trueSolarTime -= 1440;
}
HourAngle = trueSolarTime / 4.0 - 180.0;

I am wondering if anybody knows of an algorithm to get the correct zenith and azimuth from the correct hour angle.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
###### Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.