= 1620) && ($year <= 2000)) { $i = floor(($year - 1620) / 2); $f = (($year - 1620) / 2) - $i; /* Fractional part of year */ $dt = $deltaTtab[$i] + ( ($deltaTtab[$i + 1] - $deltaTtab[$i]) * $f ); } else { $t = ($year - 2000) / 100; if ($year < 948) { $dt = 2177 + (497 * $t) + (44.1 * $t * $t); } else { $dt = 102 + (102 * $t) + (25.3 * $t * $t); if (($year > 2000) && ($year < 2100)) { $dt += 0.37 * ($year - 2100); } } } return $dt; } /* EQUINOX -- Determine the Julian Ephemeris Day of an equinox or solstice. The "which" argument selects the item to be computed: 0 March equinox 1 June solstice 2 September equinox 3 December solstice */ // Periodic terms to obtain true time $EquinoxpTerms = array( 485, 324.96, 1934.136, 203, 337.23, 32964.467, 199, 342.08, 20.186, 182, 27.85, 445267.112, 156, 73.14, 45036.886, 136, 171.52, 22518.443, 77, 222.54, 65928.934, 74, 296.72, 3034.906, 70, 243.58, 9037.513, 58, 119.81, 33718.147, 52, 297.17, 150.678, 50, 21.02, 2281.226, 45, 247.54, 29929.562, 44, 325.15, 31555.956, 29, 60.93, 4443.417, 18, 155.12, 67555.328, 17, 288.79, 4562.452, 16, 198.04, 62894.029, 14, 199.76, 31436.921, 12, 95.39, 14577.848, 12, 287.11, 31931.756, 12, 320.81, 34777.259, 9, 227.73, 1222.114, 8, 15.45, 16859.074 ); $JDE0tab1000 = array( array(1721139.29189, 365242.13740, 0.06134, 0.00111, -0.00071), array(1721233.25401, 365241.72562, -0.05323, 0.00907, 0.00025), array(1721325.70455, 365242.49558, -0.11677, -0.00297, 0.00074), array(1721414.39987, 365242.88257, -0.00769, -0.00933, -0.00006) ); $JDE0tab2000 = array( array(2451623.80984, 365242.37404, 0.05169, -0.00411, -0.00057), array(2451716.56767, 365241.62603, 0.00325, 0.00888, -0.00030), array(2451810.21715, 365242.01767, -0.11575, 0.00337, 0.00078), array(2451900.05952, 365242.74049, -0.06223, -0.00823, 0.00032) ); function equinox($year, $which) { //var deltaL, i, j, JDE0, JDE, JDE0tab, S, T, W, Y; /* Initialise terms for mean equinox and solstices. We have two sets: one for years prior to 1000 and a second for subsequent years. */ global $EquinoxpTerms, $JDE0tab1000, $JDE0tab2000; if ($year < 1000) { $JDE0tab = $JDE0tab1000; $Y = $year / 1000; } else { $JDE0tab = $JDE0tab2000; $Y = ($year - 2000) / 1000; } $JDE0 = $JDE0tab[$which][0] + ($JDE0tab[$which][1] * $Y) + ($JDE0tab[$which][2] * $Y * $Y) + ($JDE0tab[$which][3] * $Y * $Y * $Y) + ($JDE0tab[$which][4] * $Y * $Y * $Y * $Y); //document.debug.log.value += "JDE0 = " + JDE0 + "\n"; $T = ($JDE0 - 2451545.0) / 36525; //document.debug.log.value += "T = " + T + "\n"; $W = (35999.373 * $T) - 2.47; //document.debug.log.value += "W = " + W + "\n"; $deltaL = 1 + (0.0334 * dcos($W)) + (0.0007 * dcos(2 * $W)); //document.debug.log.value += "deltaL = " + deltaL + "\n"; // Sum the periodic terms for time T $S = 0; for ($i = $j = 0; $i < 24; $i++) { $S += $EquinoxpTerms[$j] * dcos($EquinoxpTerms[$j + 1] + ($EquinoxpTerms[$j + 2] * $T)); $j += 3; } //document.debug.log.value += "S = " + S + "\n"; //document.debug.log.value += "Corr = " + ((S * 0.00001) / deltaL) + "\n"; $JDE = $JDE0 + (($S * 0.00001) / $deltaL); return $JDE; } /* SUNPOS -- Position of the Sun. Please see the comments on the return statement at the end of this function which describe the array it returns. We return intermediate values because they are useful in a variety of other contexts. */ function sunpos($jd) { //var T, T2, L0, M, e, C, sunLong, sunAnomaly, sunR, // Omega, Lambda, epsilon, epsilon0, Alpha, Delta, // AlphaApp, DeltaApp; global $JulianCentury, $J2000; $T = ($jd - $J2000) / $JulianCentury; //document.debug.log.value += "Sunpos. T = " + T + "\n"; $T2 = $T * $T; $L0 = 280.46646 + (36000.76983 * $T) + (0.0003032 * $T2); //document.debug.log.value += "L0 = " + L0 + "\n"; $L0 = fixangle($L0); //document.debug.log.value += "L0 = " + L0 + "\n"; $M = 357.52911 + (35999.05029 * $T) + (-0.0001537 * $T2); //document.debug.log.value += "M = " + M + "\n"; $M = fixangle($M); //document.debug.log.value += "M = " + M + "\n"; $e = 0.016708634 + (-0.000042037 * $T) + (-0.0000001267 * $T2); //document.debug.log.value += "e = " + e + "\n"; $C = ((1.914602 + (-0.004817 * $T) + (-0.000014 * $T2)) * dsin($M)) + ((0.019993 - (0.000101 * $T)) * dsin(2 * $M)) + (0.000289 * dsin(3 * $M)); //document.debug.log.value += "C = " + C + "\n"; $sunLong = $L0 + $C; //document.debug.log.value += "sunLong = " + sunLong + "\n"; $sunAnomaly = $M + $C; //document.debug.log.value += "sunAnomaly = " + sunAnomaly + "\n"; $sunR = (1.000001018 * (1 - ($e * $e))) / (1 + ($e * dcos($sunAnomaly))); //document.debug.log.value += "sunR = " + sunR + "\n"; $Omega = 125.04 - (1934.136 * $T); //document.debug.log.value += "Omega = " + Omega + "\n"; $Lambda = $sunLong + (-0.00569) + (-0.00478 * dsin($Omega)); //document.debug.log.value += "Lambda = " + Lambda + "\n"; $epsilon0 = obliqeq($jd); //document.debug.log.value += "epsilon0 = " + epsilon0 + "\n"; $epsilon = $epsilon0 + (0.00256 * dcos($Omega)); //document.debug.log.value += "epsilon = " + epsilon + "\n"; $Alpha = rtd(atan2(dcos($epsilon0) * dsin($sunLong), dcos($sunLong))); //document.debug.log.value += "Alpha = " + Alpha + "\n"; $Alpha = fixangle($Alpha); ////document.debug.log.value += "Alpha = " + Alpha + "\n"; $Delta = rtd(asin(dsin($epsilon0) * dsin($sunLong))); ////document.debug.log.value += "Delta = " + Delta + "\n"; $AlphaApp = rtd(atan2(dcos($epsilon) * dsin($Lambda), dcos($Lambda))); //document.debug.log.value += "AlphaApp = " + AlphaApp + "\n"; $AlphaApp = fixangle($AlphaApp); //document.debug.log.value += "AlphaApp = " + AlphaApp + "\n"; $DeltaApp = rtd(asin(dsin($epsilon) * dsin($Lambda))); //document.debug.log.value += "DeltaApp = " + DeltaApp + "\n"; return array( // Angular quantities are expressed in decimal degrees $L0, // [0] Geometric mean longitude of the Sun $M, // [1] Mean anomaly of the Sun $e, // [2] Eccentricity of the Earth's orbit $C, // [3] Sun's equation of the Centre $sunLong, // [4] Sun's true longitude $sunAnomaly, // [5] Sun's true anomaly $sunR, // [6] Sun's radius vector in AU $Lambda, // [7] Sun's apparent longitude at true equinox of the date $Alpha, // [8] Sun's true right ascension $Delta, // [9] Sun's true declination $AlphaApp, // [10] Sun's apparent right ascension $DeltaApp // [11] Sun's apparent declination ); } /* EQUATIONOFTIME -- Compute equation of time for a given moment. Returns the equation of time as a fraction of a day. */ function equationOfTime($jd) { //var alpha, deltaPsi, E, epsilon, L0, tau global $JulianMillennium, $J2000; $tau = ($jd - $J2000) / $JulianMillennium; //document.debug.log.value += "equationOfTime. tau = " + tau + "\n"; $L0 = 280.4664567 + (360007.6982779 * $tau) + (0.03032028 * $tau * $tau) + (($tau * $tau * $tau) / 49931) + (-(($tau * $tau * $tau * $tau) / 15300)) + (-(($tau * $tau * $tau * $tau * $tau) / 2000000)); //document.debug.log.value += "L0 = " + L0 + "\n"; $L0 = fixangle($L0); //document.debug.log.value += "L0 = " + L0 + "\n"; $sunpos = sunpos($jd); $alpha = $sunpos[10]; //document.debug.log.value += "alpha = " + alpha + "\n"; $nutation = nutation($jd); $deltaPsi = $nutation[0]; //document.debug.log.value += "deltaPsi = " + deltaPsi + "\n"; $epsilon = obliqeq($jd) + $nutation[1]; //document.debug.log.value += "epsilon = " + epsilon + "\n"; $E = $L0 + (-0.0057183) + (-$alpha) + ($deltaPsi * dcos($epsilon)); //document.debug.log.value += "E = " + E + "\n"; $E = $E - 20.0 * (floor($E / 20.0)); //document.debug.log.value += "Efixed = " + E + "\n"; $E = $E / (24 * 60); //document.debug.log.value += "Eday = " + E + "\n"; return $E; } ?>