ds50 = $jd - 2433281.5 + $UT; return Predict_Math::FMod2p(6.3003880987 * $deep_arg->ds50 + 1.72944494); } /* See the ThetaG doc block above */ public static function ThetaG_JD($jd) { /* Reference: The 1992 Astronomical Almanac, page B6. */ $UT = Predict_Math::Frac($jd + 0.5); $jd = $jd - $UT; $TU = ($jd - 2451545.0) / 36525; $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); return Predict::twopi * $GMST / Predict::secday; } /** * Read the system clock and return the current Julian day. From phpPredict * * @return float */ public static function get_current_daynum() { // Gets the current decimal day number from microtime list($usec, $sec) = explode(' ', microtime()); return self::unix2daynum($sec, $usec); } /** * Converts a standard unix timestamp and optional * milliseconds to a daynum * * @param int $sec Seconds from the unix epoch * @param int $usec Optional milliseconds * * @return float */ public static function unix2daynum($sec, $usec = 0) { $time = ((($sec + $usec) / 86400.0) - 3651.0); return $time + 2444238.5; } /* The function Delta_ET has been added to allow calculations on */ /* the position of the sun. It provides the difference between UT */ /* (approximately the same as UTC) and ET (now referred to as TDT).*/ /* This function is based on a least squares fit of data from 1950 */ /* to 1991 and will need to be updated periodically. */ public static function Delta_ET($year) { /* Values determined using data from 1950-1991 in the 1990 Astronomical Almanac. See DELTA_ET.WQ1 for details. */ $delta_et = 26.465 + 0.747622 * ($year - 1950) + 1.886913 * sin(Predict::twopi * ($year - 1975) / 33); return $delta_et; } /** * Converts a daynum to a unix timestamp. From phpPredict. * * @param float $dn Julian Daynum * * @return float */ public static function daynum2unix($dn) { // Converts a daynum to a UNIX timestamp return (86400.0 * ($dn - 2444238.5 + 3651.0)); } /** * Converts a daynum to a readable time format. * * @param float $dn The julian date * @param string $zone The zone string, defaults to America/Los_Angeles * @param string $format The date() function's format string. Defaults to m-d-Y H:i:s * * @return string */ public static function daynum2readable($dn, $zone = 'America/Los_Angeles', $format = 'm-d-Y H:i:s') { $unix = self::daynum2unix($dn); $date = new DateTime("@" . round($unix)); $dateTimezone = new DateTimezone($zone); $date->setTimezone($dateTimezone); return $date->format($format); } /** * Returns the unix timestamp of a TLE's epoch * * @param Predict_TLE $tle The TLE object * * @return int */ public static function getEpochTimeStamp(Predict_TLE $tle) { $year = $tle->epoch_year; $day = $tle->epoch_day; $sec = round(86400 * $tle->epoch_fod); $zone = new DateTimeZone('GMT'); $date = new DateTime(); $date->setTimezone($zone); $date->setDate($year, 1, 1); $date->setTime(0, 0, 0); return $date->format('U') + (86400 * $day) + $sec - 86400; } }