var C = Math.floor((B - 122.1)/365.25); var D = Math.floor(365.25 * C); var E = Math.floor((B - D)/30.6001); var day = B - D - Math.floor(30.6001 * E) + f; var month = (E < 14) ? E - 1 : E - 13; var year = (month > 2) ? C - 4716 : C - 4715; return ((day<10 ? "0" : "") + day + monthList[month-1].abbr); }//***********************************************************************///* Name: calcTimeJulianCent *///* Type: Function *///* Purpose: convert Julian Day to centuries since J2000.0. *///* Arguments: *///* jd : the Julian Day to convert *///* Return value: *///* the T value corresponding to the Julian Day *///***********************************************************************/ function calcTimeJulianCent(jd) { var T = (jd - 2451545.0)/36525.0; return T; }//***********************************************************************///* Name: calcJDFromJulianCent *///* Type: Function *///* Purpose: convert centuries since J2000.0 to Julian Day. *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* the Julian Day corresponding to the t value *///***********************************************************************/ function calcJDFromJulianCent(t) { var JD = t * 36525.0 + 2451545.0; return JD; }//***********************************************************************///* Name: calGeomMeanLongSun *///* Type: Function *///* Purpose: calculate the Geometric Mean Longitude of the Sun *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* the Geometric Mean Longitude of the Sun in degrees *///***********************************************************************/ function calcGeomMeanLongSun(t) { var L0 = 280.46646 + t * (36000.76983 + 0.0003032 * t); while(L0 > 360.0) { L0 -= 360.0; } while(L0 < 0.0) { L0 += 360.0; } return L0; // in degrees }//***********************************************************************///* Name: calGeomAnomalySun *///* Type: Function *///* Purpose: calculate the Geometric Mean Anomaly of the Sun *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* the Geometric Mean Anomaly of the Sun in degrees *///***********************************************************************/ function calcGeomMeanAnomalySun(t) { var M = 357.52911 + t * (35999.05029 - 0.0001537 * t); return M; // in degrees }//***********************************************************************///* Name: calcEccentricityEarthOrbit *///* Type: Function *///* Purpose: calculate the eccentricity of earth's orbit *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* the unitless eccentricity *///***********************************************************************/ function calcEccentricityEarthOrbit(t) { var e = 0.016708634 - t * (0.000042037 + 0.0000001267 * t); return e; // unitless }//***********************************************************************///* Name: calcSunEqOfCenter *///* Type: Function *///* Purpose: calculate the equation of center for the sun *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* in degrees *///***********************************************************************/ function calcSunEqOfCenter(t) { var m = calcGeomMeanAnomalySun(t); var mrad = degToRad(m); var sinm = Math.sin(mrad); var sin2m = Math.sin(mrad+mrad); var sin3m = Math.sin(mrad+mrad+mrad); var C = sinm * (1.914602 - t * (0.004817 + 0.000014 * t)) + sin2m * (0.019993 - 0.000101 * t) + sin3m * 0.000289; return C; // in degrees }//***********************************************************************///* Name: calcSunTrueLong *///* Type: Function *///* Purpose: calculate the true longitude of the sun *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* sun's true longitude in degrees *///***********************************************************************/ function calcSunTrueLong(t) { var l0 = calcGeomMeanLongSun(t); var c = calcSunEqOfCenter(t); var O = l0 + c; return O; // in degrees }//***********************************************************************///* Name: calcSunTrueAnomaly *///* Type: Function *///*