This program demonstrates a process by which we may compute the equinoxes and solstices. In this case, we will compute the date and time (TT) of March equinox for a random Gregorian year.
To build a program around the equinoxes and solstices module, we simply include the module at the beginning of the program. // Attach the equinoxes and solstices functions module. include("Equinoxes_and_Solstices_Module_v0.php");For the example, we will select a random Gregorian year in the range from 1600 to 2400 AD. In this case, the random year is `1839` .
// Select random Gregorian year for example in range 1800 to 2400. $Y = mt_rand(1800, 2400); // Selected random year = 1839We will construct a table centering on March 20 ^{th} of the example year (`1839` ). To do this, we first compute the JD12 value for March 20^{th} (JD12Central) of the year `1839` .
The JD12 range of the table will span a 7-day period starting on `JD12Start = JD12Central−3` and ending on `JD12End = JD12Central+3`
// Compute the JD12 value for central date, 1839 March 20, at 12:00 TT $JD12Central = Ymd_HMS_To_JD($Y . "0320 12"); // = 2392819Now that we have the `JD12Central` value for our table (`2392819` ), we can construct the 7-day table of geocentric solar declinations vs. JD12 values from 3 days before to 3 days after this `JD12Central` value.
// Create 7-day solar declination vs JD12 table centered on JD12Central $DataTable = ""; for ($JD12 = $JD12Central-3; $JD12 <= $JD12Central+3; $JD12++) { list($RAHrs, $declination) = preg_split("[ ]", Geocentric_Sun ($JD12)); $declination = sprintf("%+1.10f", $declination); $DataTable .= "$declination $JD12\n"; }The above loop generates the following DataTable structure.
$DataTable = " -1.4983858335 2392816 -1.1031057101 2392817 -0.7077919363 2392818 -0.3125533197 2392819 +0.0825030299 2392820 +0.4772725795 2392821 +0.8716538277 2392822 ";Given the above data table, we next call the LaGrange interpolation function to compute the JD value for the moment when the apparent geocentric solar declination equates to zero. // Interpolate JD of event = Moment when solar declination == 0 $JDofEvent = LaGrange_Interpolate($DataTable, 0); // = 2392819.7911101This returns the interpolated JD value for the moment when the solar declination equates to zero. In this example, `JDofEvent = 2392819.7911101`
We can then call the inverse JD number function to compute the corresponding integer-encoded date and time string. $Ymd_HMSTT = JD_To_Ymd_HMS($JDofEvent); // = "18390321 06:59:12"Now we can tidy up the date string by replacing the returned month number sub-string, "03", with "March". // Construct final output date from integer-encoded date/time string. $Y_Mmm_dd_HMS = "$Y March " . substr($Ymd_HMSTT, 6, strlen($Ymd_HMSTT));This finally gives us the date and time (TT) of the March equinox in Gregorian year `1839` .
$Y_Mmm_dd_HMS = "1839 March 21 06:59:12"; |