var sinm = Math.sin(degToRad(m)); var cos2l0 = Math.cos(2.0 * degToRad(l0)); var sin4l0 = Math.sin(4.0 * degToRad(l0)); var sin2m = Math.sin(2.0 * degToRad(m)); var Etime = y * sin2l0 - 2.0 * e * sinm + 4.0 * e * y * sinm * cos2l0 - 0.5 * y * y * sin4l0 - 1.25 * e * e * sin2m; return radToDeg(Etime)*4.0; // in minutes of time }//***********************************************************************///* Name: calcHourAngleSunrise *///* Type: Function *///* Purpose: calculate the hour angle of the sun at sunrise for the *///* latitude *///* Arguments: *///* lat : latitude of observer in degrees *///* solarDec : declination angle of sun in degrees *///* Return value: *///* hour angle of sunrise in radians *///***********************************************************************/ function calcHourAngleSunrise(lat, solarDec) { var latRad = degToRad(lat); var sdRad = degToRad(solarDec) var HAarg = (Math.cos(degToRad(90.833))/(Math.cos(latRad)*Math.cos(sdRad))-Math.tan(latRad) * Math.tan(sdRad)); var HA = (Math.acos(Math.cos(degToRad(90.833))/(Math.cos(latRad)*Math.cos(sdRad))-Math.tan(latRad) * Math.tan(sdRad))); return HA; // in radians }//***********************************************************************///* Name: calcHourAngleSunset *///* Type: Function *///* Purpose: calculate the hour angle of the sun at sunset for the *///* latitude *///* Arguments: *///* lat : latitude of observer in degrees *///* solarDec : declination angle of sun in degrees *///* Return value: *///* hour angle of sunset in radians *///***********************************************************************/ function calcHourAngleSunset(lat, solarDec) { var latRad = degToRad(lat); var sdRad = degToRad(solarDec) var HAarg = (Math.cos(degToRad(90.833))/(Math.cos(latRad)*Math.cos(sdRad))-Math.tan(latRad) * Math.tan(sdRad)); var HA = (Math.acos(Math.cos(degToRad(90.833))/(Math.cos(latRad)*Math.cos(sdRad))-Math.tan(latRad) * Math.tan(sdRad))); return -HA; // in radians }//***********************************************************************///* Name: calcSunriseUTC *///* Type: Function *///* Purpose: calculate the Universal Coordinated Time (UTC) of sunrise *///* for the given day at the given location on earth *///* Arguments: *///* JD : julian day *///* latitude : latitude of observer in degrees *///* longitude : longitude of observer in degrees *///* Return value: *///* time in minutes from zero Z *///***********************************************************************/ function calcSunriseUTC(JD, latitude, longitude) { var t = calcTimeJulianCent(JD); // *** First pass to approximate sunrise var eqTime = calcEquationOfTime(t); var solarDec = calcSunDeclination(t); var hourAngle = calcHourAngleSunrise(latitude, solarDec); var delta = longitude - radToDeg(hourAngle); var timeDiff = 4 * delta; // in minutes of time var timeUTC = 720 + timeDiff - eqTime; // in minutes // alert("eqTime = " + eqTime + "\nsolarDec = " + solarDec + "\ntimeUTC = " + timeUTC); // *** Second pass includes fractional jday in gamma calc var newt = calcTimeJulianCent(calcJDFromJulianCent(t) + timeUTC/1440.0); eqTime = calcEquationOfTime(newt); solarDec = calcSunDeclination(newt); hourAngle = calcHourAngleSunrise(latitude, solarDec); delta = longitude - radToDeg(hourAngle); timeDiff = 4 * delta; timeUTC = 720 + timeDiff - eqTime; // in minutes // alert("eqTime = " + eqTime + "\nsolarDec = " + solarDec + "\ntimeUTC = " + timeUTC); return timeUTC; }//***********************************************************************///* Name: calcSolNoonUTC *///* Type: Function *///* Purpose: calculate the Universal Coordinated Time (UTC) of solar *///* noon for the given day at the given location on earth *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* longitude : longitude of observer in degrees *///* Return value: *///* time in minutes from zero Z *///***********************************************************************/ function calcSolNoonUTC(t, longitude) { var newt = calcTimeJulianCent(calcJDFromJulianCent(t) + 0.5 + longitude/360.0); var eqTime = calcEquationOfTime(newt); var solarNoonDec = calcSunDeclination(newt); var solNoonUTC = 720 +