(longitude * 4) - eqTime; // min return solNoonUTC; }//***********************************************************************///* Name: calcSunsetUTC *///* Type: Function *///* Purpose: calculate the Universal Coordinated Time (UTC) of sunset *///* 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 calcSunsetUTC(JD, latitude, longitude) { var t = calcTimeJulianCent(JD); // First calculates sunrise and approx length of day var eqTime = calcEquationOfTime(t); var solarDec = calcSunDeclination(t); var hourAngle = calcHourAngleSunset(latitude, solarDec); var delta = longitude - radToDeg(hourAngle); var timeDiff = 4 * delta; var timeUTC = 720 + timeDiff - eqTime; // first pass used to include fractional day in gamma calc var newt = calcTimeJulianCent(calcJDFromJulianCent(t) + timeUTC/1440.0); eqTime = calcEquationOfTime(newt); solarDec = calcSunDeclination(newt); hourAngle = calcHourAngleSunset(latitude, solarDec); delta = longitude - radToDeg(hourAngle); timeDiff = 4 * delta; timeUTC = 720 + timeDiff - eqTime; // in minutes return timeUTC; }//*********************************************************************/// Returns the decimal latitude from the degrees, minutes and seconds entered // into the form function getLatitude(latLongForm) { var neg = 0; var degs = parseFloat(latLongForm["latDeg"].value); if (latLongForm["latDeg"].value.charAt(0) == '-') { neg = 1; } if(latLongForm["latMin"].value == "") { latLongForm["latMin"].value = 0; } if(latLongForm["latSec"].value == "") { latLongForm["latSec"].value = 0; } var mins = parseFloat(latLongForm["latMin"].value); var secs = parseFloat(latLongForm["latSec"].value); if(neg != 1) { var decLat = degs + (mins / 60) + (secs / 3600); } else if(neg == 1) { var decLat = degs - (mins / 60) - (secs / 3600); } else { return -9999; } return decLat; } //*********************************************************************/// Returns the decimal longitude from the degrees, minutes and seconds entered // into the form function getLongitude(latLongForm) { var neg = 0; var degs = parseFloat(latLongForm["lonDeg"].value); if (latLongForm["lonDeg"].value.charAt(0) == '-') { neg = 1; } if(latLongForm["lonMin"].value == "") { latLongForm["lonMin"].value = 0; } if(latLongForm["lonSec"].value == "") { latLongForm["lonSec"].value = 0; } var mins = parseFloat(latLongForm["lonMin"].value); var secs = parseFloat(latLongForm["lonSec"].value); var decLon = degs + (mins / 60) + (secs / 3600); if(neg != 1) { var decLon = degs + (mins / 60) + (secs / 3600); } else if(neg == 1) { var decLon = degs - (mins / 60) - (secs / 3600); } else { return -9999; } return decLon; } //***********************************************************************///* Name: findRecentSunrise *///* Type: Function *///* Purpose: calculate the julian day of the most recent sunrise *///* starting from 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: *///* julian day of the most recent sunrise *///***********************************************************************/ function findRecentSunrise(jd, latitude, longitude) { var julianday = jd; var time = calcSunriseUTC(julianday, latitude, longitude); while(!isNumber(time)){ julianday -= 1.0; time = calcSunriseUTC(julianday, latitude, longitude); } return julianday; }//***********************************************************************///* Name: findRecentSunset *///* Type: Function *///* Purpose: calculate the julian day of the most recent sunset *///* starting from the given day at the given location on earth *///* Arguments: *///* JD