<?php /** * An example of looking up the lat/lon of the sun for putting on a map. * "dark" lat/lon is the anti-solar point, useful for drawing a * "solar terminator" */ // No autoloading here, require needed files require_once 'Predict/Solar.php'; require_once 'Predict/SGPObs.php'; require_once 'Predict/Math.php'; require_once 'Predict/Time.php'; // Set up data constructs $solar_vector = new Predict_Vector(); $solar_geodetic = new Predict_Geodetic(); // Use current time in the form of a daynum $time = time(); $daynum = Predict_Time::unix2daynum($time); // Do calculations Predict_Solar::Calculate_Solar_Position($daynum, $solar_vector); Predict_SGPObs::Calculate_LatLonAlt($daynum, $solar_vector, $solar_geodetic); // Format to degrees $solar_lat = Predict_Math::Degrees($solar_geodetic->lat); $solar_lon = Predict_Math::Degrees($solar_geodetic->lon); // Reverse values for night circle center $dark_lat = -$solar_lat; $dark_lon = -$solar_lon; $output = array('solar_lat' => $solar_lat, 'solar_lon' => $solar_lon, 'dark_lat' => $dark_lat, 'dark_lon' => $dark_lon, 'timestamp' => $time); // output results var_dump(json_encode($output));
public function Deep($ientry, Predict_Sat $sat) { switch ($ientry) { case self::dpinit: /* Entrance for deep space initialization */ $sat->dps->thgr = Predict_Time::ThetaG($sat->tle->epoch, $sat->deep_arg); $eq = $sat->tle->eo; $sat->dps->xnq = $sat->deep_arg->xnodp; $aqnv = 1.0 / $sat->deep_arg->aodp; $sat->dps->xqncl = $sat->tle->xincl; $xmao = $sat->tle->xmo; $xpidot = $sat->deep_arg->omgdot + $sat->deep_arg->xnodot; $sinq = sin($sat->tle->xnodeo); $cosq = cos($sat->tle->xnodeo); $sat->dps->omegaq = $sat->tle->omegao; $sat->dps->preep = 0; /* Initialize lunar solar terms */ $day = $sat->deep_arg->ds50 + 18261.5; /* Days since 1900 Jan 0.5 */ if ($day != $sat->dps->preep) { $sat->dps->preep = $day; $xnodce = 4.523602 - 0.00092422029 * $day; $stem = sin($xnodce); $ctem = cos($xnodce); $sat->dps->zcosil = 0.91375164 - 0.03568096 * $ctem; $sat->dps->zsinil = sqrt(1.0 - $sat->dps->zcosil * $sat->dps->zcosil); $sat->dps->zsinhl = 0.08968351099999999 * $stem / $sat->dps->zsinil; $sat->dps->zcoshl = sqrt(1.0 - $sat->dps->zsinhl * $sat->dps->zsinhl); $c = 4.7199672 + 0.2299715 * $day; $gam = 5.8351514 + 0.001944368 * $day; $sat->dps->zmol = Predict_Math::FMod2p($c - $gam); $zx = 0.39785416 * $stem / $sat->dps->zsinil; $zy = $sat->dps->zcoshl * $ctem + 0.91744867 * $sat->dps->zsinhl * $stem; $zx = Predict_Math::AcTan($zx, $zy); $zx = $gam + $zx - $xnodce; $sat->dps->zcosgl = cos($zx); $sat->dps->zsingl = sin($zx); $sat->dps->zmos = 6.2565837 + 0.017201977 * $day; $sat->dps->zmos = Predict_Math::FMod2p($sat->dps->zmos); } /* End if(day != preep) */ /* Do solar terms */ $sat->dps->savtsn = 1.0E+20; $zcosg = Predict::zcosgs; $zsing = Predict::zsings; $zcosi = Predict::zcosis; $zsini = Predict::zsinis; $zcosh = $cosq; $zsinh = $sinq; $cc = Predict::c1ss; $zn = Predict::zns; $ze = Predict::zes; $zmo = $sat->dps->zmos; $xnoi = 1.0 / $sat->dps->xnq; /* Loop breaks when Solar terms are done a second */ /* time, after Lunar terms are initialized */ for (;;) { /* Solar terms done again after Lunar terms are done */ $a1 = $zcosg * $zcosh + $zsing * $zcosi * $zsinh; $a3 = -$zsing * $zcosh + $zcosg * $zcosi * $zsinh; $a7 = -$zcosg * $zsinh + $zsing * $zcosi * $zcosh; $a8 = $zsing * $zsini; $a9 = $zsing * $zsinh + $zcosg * $zcosi * $zcosh; $a10 = $zcosg * $zsini; $a2 = $sat->deep_arg->cosio * $a7 + $sat->deep_arg->sinio * $a8; $a4 = $sat->deep_arg->cosio * $a9 + $sat->deep_arg->sinio * $a10; $a5 = -$sat->deep_arg->sinio * $a7 + $sat->deep_arg->cosio * $a8; $a6 = -$sat->deep_arg->sinio * $a9 + $sat->deep_arg->cosio * $a10; $x1 = $a1 * $sat->deep_arg->cosg + $a2 * $sat->deep_arg->sing; $x2 = $a3 * $sat->deep_arg->cosg + $a4 * $sat->deep_arg->sing; $x3 = -$a1 * $sat->deep_arg->sing + $a2 * $sat->deep_arg->cosg; $x4 = -$a3 * $sat->deep_arg->sing + $a4 * $sat->deep_arg->cosg; $x5 = $a5 * $sat->deep_arg->sing; $x6 = $a6 * $sat->deep_arg->sing; $x7 = $a5 * $sat->deep_arg->cosg; $x8 = $a6 * $sat->deep_arg->cosg; $z31 = 12 * $x1 * $x1 - 3 * $x3 * $x3; $z32 = 24 * $x1 * $x2 - 6 * $x3 * $x4; $z33 = 12 * $x2 * $x2 - 3 * $x4 * $x4; $z1 = 3 * ($a1 * $a1 + $a2 * $a2) + $z31 * $sat->deep_arg->eosq; $z2 = 6 * ($a1 * $a3 + $a2 * $a4) + $z32 * $sat->deep_arg->eosq; $z3 = 3 * ($a3 * $a3 + $a4 * $a4) + $z33 * $sat->deep_arg->eosq; $z11 = -6 * $a1 * $a5 + $sat->deep_arg->eosq * (-24 * $x1 * $x7 - 6 * $x3 * $x5); $z12 = -6 * ($a1 * $a6 + $a3 * $a5) + $sat->deep_arg->eosq * (-24 * ($x2 * $x7 + $x1 * $x8) - 6 * ($x3 * $x6 + $x4 * $x5)); $z13 = -6 * $a3 * $a6 + $sat->deep_arg->eosq * (-24 * $x2 * $x8 - 6 * $x4 * $x6); $z21 = 6 * $a2 * $a5 + $sat->deep_arg->eosq * (24 * $x1 * $x5 - 6 * $x3 * $x7); $z22 = 6 * ($a4 * $a5 + $a2 * $a6) + $sat->deep_arg->eosq * (24 * ($x2 * $x5 + $x1 * $x6) - 6 * ($x4 * $x7 + $x3 * $x8)); $z23 = 6 * $a4 * $a6 + $sat->deep_arg->eosq * (24 * $x2 * $x6 - 6 * $x4 * $x8); $z1 = $z1 + $z1 + $sat->deep_arg->betao2 * $z31; $z2 = $z2 + $z2 + $sat->deep_arg->betao2 * $z32; $z3 = $z3 + $z3 + $sat->deep_arg->betao2 * $z33; $s3 = $cc * $xnoi; $s2 = -0.5 * $s3 / $sat->deep_arg->betao; $s4 = $s3 * $sat->deep_arg->betao; $s1 = -15 * $eq * $s4; $s5 = $x1 * $x3 + $x2 * $x4; $s6 = $x2 * $x3 + $x1 * $x4; $s7 = $x2 * $x4 - $x1 * $x3; $se = $s1 * $zn * $s5; $si = $s2 * $zn * ($z11 + $z13); $sl = -$zn * $s3 * ($z1 + $z3 - 14 - 6 * $sat->deep_arg->eosq); $sgh = $s4 * $zn * ($z31 + $z33 - 6); $sh = -$zn * $s2 * ($z21 + $z23); if ($sat->dps->xqncl < 0.052359877) { $sh = 0; } $sat->dps->ee2 = 2 * $s1 * $s6; $sat->dps->e3 = 2 * $s1 * $s7; $sat->dps->xi2 = 2 * $s2 * $z12; $sat->dps->xi3 = 2 * $s2 * ($z13 - $z11); $sat->dps->xl2 = -2 * $s3 * $z2; $sat->dps->xl3 = -2 * $s3 * ($z3 - $z1); $sat->dps->xl4 = -2 * $s3 * (-21 - 9 * $sat->deep_arg->eosq) * $ze; $sat->dps->xgh2 = 2 * $s4 * $z32; $sat->dps->xgh3 = 2 * $s4 * ($z33 - $z31); $sat->dps->xgh4 = -18 * $s4 * $ze; $sat->dps->xh2 = -2 * $s2 * $z22; $sat->dps->xh3 = -2 * $s2 * ($z23 - $z21); if ($sat->flags & self::LUNAR_TERMS_DONE_FLAG) { break; } /* Do lunar terms */ $sat->dps->sse = $se; $sat->dps->ssi = $si; $sat->dps->ssl = $sl; $sat->dps->ssh = $sh / $sat->deep_arg->sinio; $sat->dps->ssg = $sgh - $sat->deep_arg->cosio * $sat->dps->ssh; $sat->dps->se2 = $sat->dps->ee2; $sat->dps->si2 = $sat->dps->xi2; $sat->dps->sl2 = $sat->dps->xl2; $sat->dps->sgh2 = $sat->dps->xgh2; $sat->dps->sh2 = $sat->dps->xh2; $sat->dps->se3 = $sat->dps->e3; $sat->dps->si3 = $sat->dps->xi3; $sat->dps->sl3 = $sat->dps->xl3; $sat->dps->sgh3 = $sat->dps->xgh3; $sat->dps->sh3 = $sat->dps->xh3; $sat->dps->sl4 = $sat->dps->xl4; $sat->dps->sgh4 = $sat->dps->xgh4; $zcosg = $sat->dps->zcosgl; $zsing = $sat->dps->zsingl; $zcosi = $sat->dps->zcosil; $zsini = $sat->dps->zsinil; $zcosh = $sat->dps->zcoshl * $cosq + $sat->dps->zsinhl * $sinq; $zsinh = $sinq * $sat->dps->zcoshl - $cosq * $sat->dps->zsinhl; $zn = Predict::znl; $cc = Predict::c1l; $ze = Predict::zel; $zmo = $sat->dps->zmol; $sat->flags |= self::LUNAR_TERMS_DONE_FLAG; } /* End of for(;;) */ $sat->dps->sse = $sat->dps->sse + $se; $sat->dps->ssi = $sat->dps->ssi + $si; $sat->dps->ssl = $sat->dps->ssl + $sl; $sat->dps->ssg = $sat->dps->ssg + $sgh - $sat->deep_arg->cosio / $sat->deep_arg->sinio * $sh; $sat->dps->ssh = $sat->dps->ssh + $sh / $sat->deep_arg->sinio; /* Geopotential resonance initialization for 12 hour orbits */ $sat->flags &= ~self::RESONANCE_FLAG; $sat->flags &= ~self::SYNCHRONOUS_FLAG; if (!($sat->dps->xnq < 0.0052359877 && $sat->dps->xnq > 0.0034906585)) { if ($sat->dps->xnq < 0.00826 || $sat->dps->xnq > 0.00924) { return; } if ($eq < 0.5) { return; } $sat->flags |= self::RESONANCE_FLAG; $eoc = $eq * $sat->deep_arg->eosq; $g201 = -0.306 - ($eq - 0.64) * 0.44; if ($eq <= 0.65) { $g211 = 3.616 - 13.247 * $eq + 16.29 * $sat->deep_arg->eosq; $g310 = -19.302 + 117.39 * $eq - 228.419 * $sat->deep_arg->eosq + 156.591 * $eoc; $g322 = -18.9068 + 109.7927 * $eq - 214.6334 * $sat->deep_arg->eosq + 146.5816 * $eoc; $g410 = -41.122 + 242.694 * $eq - 471.094 * $sat->deep_arg->eosq + 313.953 * $eoc; $g422 = -146.407 + 841.88 * $eq - 1629.014 * $sat->deep_arg->eosq + 1083.435 * $eoc; $g520 = -532.114 + 3017.977 * $eq - 5740 * $sat->deep_arg->eosq + 3708.276 * $eoc; } else { $g211 = -72.099 + 331.819 * $eq - 508.738 * $sat->deep_arg->eosq + 266.724 * $eoc; $g310 = -346.844 + 1582.851 * $eq - 2415.925 * $sat->deep_arg->eosq + 1246.113 * $eoc; $g322 = -342.585 + 1554.908 * $eq - 2366.899 * $sat->deep_arg->eosq + 1215.972 * $eoc; $g410 = -1052.797 + 4758.686 * $eq - 7193.992 * $sat->deep_arg->eosq + 3651.957 * $eoc; $g422 = -3581.69 + 16178.11 * $eq - 24462.77 * $sat->deep_arg->eosq + 12422.52 * $eoc; if ($eq <= 0.715) { $g520 = 1464.74 - 4664.75 * $eq + 3763.64 * $sat->deep_arg->eosq; } else { $g520 = -5149.66 + 29936.92 * $eq - 54087.36 * $sat->deep_arg->eosq + 31324.56 * $eoc; } } /* End if (eq <= 0.65) */ if ($eq < 0.7) { $g533 = -919.2277 + 4988.61 * $eq - 9064.77 * $sat->deep_arg->eosq + 5542.21 * $eoc; $g521 = -822.71072 + 4568.6173 * $eq - 8491.4146 * $sat->deep_arg->eosq + 5337.524 * $eoc; $g532 = -853.6660000000001 + 4690.25 * $eq - 8624.77 * $sat->deep_arg->eosq + 5341.4 * $eoc; } else { $g533 = -37995.78 + 161616.52 * $eq - 229838.2 * $sat->deep_arg->eosq + 109377.94 * $eoc; $g521 = -51752.104 + 218913.95 * $eq - 309468.16 * $sat->deep_arg->eosq + 146349.42 * $eoc; $g532 = -40023.88 + 170470.89 * $eq - 242699.48 * $sat->deep_arg->eosq + 115605.82 * $eoc; } /* End if (eq <= 0.7) */ $sini2 = $sat->deep_arg->sinio * $sat->deep_arg->sinio; $f220 = 0.75 * (1 + 2 * $sat->deep_arg->cosio + $sat->deep_arg->theta2); $f221 = 1.5 * $sini2; $f321 = 1.875 * $sat->deep_arg->sinio * (1 - 2 * $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); $f322 = -1.875 * $sat->deep_arg->sinio * (1 + 2 * $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); $f441 = 35 * $sini2 * $f220; $f442 = 39.375 * $sini2 * $sini2; $f522 = 9.84375 * $sat->deep_arg->sinio * ($sini2 * (1 - 2 * $sat->deep_arg->cosio - 5 * $sat->deep_arg->theta2) + 0.33333333 * (-2 + 4 * $sat->deep_arg->cosio + 6 * $sat->deep_arg->theta2)); $f523 = $sat->deep_arg->sinio * (4.92187512 * $sini2 * (-2 - 4 * $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2) + 6.56250012 * (1 + 2 * $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2)); $f542 = 29.53125 * $sat->deep_arg->sinio * (2 - 8 * $sat->deep_arg->cosio + $sat->deep_arg->theta2 * (-12 + 8 * $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2)); $f543 = 29.53125 * $sat->deep_arg->sinio * (-2 - 8 * $sat->deep_arg->cosio + $sat->deep_arg->theta2 * (12 + 8 * $sat->deep_arg->cosio - 10 * $sat->deep_arg->theta2)); $xno2 = $sat->dps->xnq * $sat->dps->xnq; $ainv2 = $aqnv * $aqnv; $temp1 = 3 * $xno2 * $ainv2; $temp = $temp1 * Predict::root22; $sat->dps->d2201 = $temp * $f220 * $g201; $sat->dps->d2211 = $temp * $f221 * $g211; $temp1 = $temp1 * $aqnv; $temp = $temp1 * Predict::root32; $sat->dps->d3210 = $temp * $f321 * $g310; $sat->dps->d3222 = $temp * $f322 * $g322; $temp1 = $temp1 * $aqnv; $temp = 2 * $temp1 * Predict::root44; $sat->dps->d4410 = $temp * $f441 * $g410; $sat->dps->d4422 = $temp * $f442 * $g422; $temp1 = $temp1 * $aqnv; $temp = $temp1 * Predict::root52; $sat->dps->d5220 = $temp * $f522 * $g520; $sat->dps->d5232 = $temp * $f523 * $g532; $temp = 2 * $temp1 * Predict::root54; $sat->dps->d5421 = $temp * $f542 * $g521; $sat->dps->d5433 = $temp * $f543 * $g533; $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->xnodeo - $sat->dps->thgr - $sat->dps->thgr; $bfact = $sat->deep_arg->xmdot + $sat->deep_arg->xnodot + $sat->deep_arg->xnodot - Predict::thdt - Predict::thdt; $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssh + $sat->dps->ssh; } else { $sat->flags |= self::RESONANCE_FLAG; $sat->flags |= self::SYNCHRONOUS_FLAG; /* Synchronous resonance terms initialization */ $g200 = 1 + $sat->deep_arg->eosq * (-2.5 + 0.8125 * $sat->deep_arg->eosq); $g310 = 1 + 2 * $sat->deep_arg->eosq; $g300 = 1 + $sat->deep_arg->eosq * (-6 + 6.60937 * $sat->deep_arg->eosq); $f220 = 0.75 * (1 + $sat->deep_arg->cosio) * (1 + $sat->deep_arg->cosio); $f311 = 0.9375 * $sat->deep_arg->sinio * $sat->deep_arg->sinio * (1 + 3 * $sat->deep_arg->cosio) - 0.75 * (1 + $sat->deep_arg->cosio); $f330 = 1 + $sat->deep_arg->cosio; $f330 = 1.875 * $f330 * $f330 * $f330; $sat->dps->del1 = 3 * $sat->dps->xnq * $sat->dps->xnq * $aqnv * $aqnv; $sat->dps->del2 = 2 * $sat->dps->del1 * $f220 * $g200 * Predict::q22; $sat->dps->del3 = 3 * $sat->dps->del1 * $f330 * $g300 * Predict::q33 * $aqnv; $sat->dps->del1 = $sat->dps->del1 * $f311 * $g310 * Predict::q31 * $aqnv; $sat->dps->fasx2 = 0.13130908; $sat->dps->fasx4 = 2.8843198; $sat->dps->fasx6 = 0.37448087; $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->omegao - $sat->dps->thgr; $bfact = $sat->deep_arg->xmdot + $xpidot - Predict::thdt; $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssg + $sat->dps->ssh; } /* End if( !(xnq < 0.0052359877) && (xnq > 0.0034906585) ) */ $sat->dps->xfact = $bfact - $sat->dps->xnq; /* Initialize integrator */ $sat->dps->xli = $sat->dps->xlamo; $sat->dps->xni = $sat->dps->xnq; $sat->dps->atime = 0; $sat->dps->stepp = 720; $sat->dps->stepn = -720; $sat->dps->step2 = 259200; /* End case self::dpinit: */ return; case self::dpsec: /* Entrance for deep space secular effects */ $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->ssl * $sat->deep_arg->t; $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $sat->dps->ssg * $sat->deep_arg->t; $sat->deep_arg->xnode = $sat->deep_arg->xnode + $sat->dps->ssh * $sat->deep_arg->t; $sat->deep_arg->em = $sat->tle->eo + $sat->dps->sse * $sat->deep_arg->t; $sat->deep_arg->xinc = $sat->tle->xincl + $sat->dps->ssi * $sat->deep_arg->t; if ($sat->deep_arg->xinc < 0) { $sat->deep_arg->xinc = -$sat->deep_arg->xinc; $sat->deep_arg->xnode = $sat->deep_arg->xnode + Predict::pi; $sat->deep_arg->omgadf = $sat->deep_arg->omgadf - Predict::pi; } if (~$sat->flags & self::RESONANCE_FLAG) { return; } do { if ($sat->dps->atime == 0 || $sat->deep_arg->t >= 0 && $sat->dps->atime < 0 || $sat->deep_arg->t < 0 && $sat->dps->atime >= 0) { /* Epoch restart */ if ($sat->deep_arg->t >= 0) { $delt = $sat->dps->stepp; } else { $delt = $sat->dps->stepn; } $sat->dps->atime = 0; $sat->dps->xni = $sat->dps->xnq; $sat->dps->xli = $sat->dps->xlamo; } else { if (abs($sat->deep_arg->t) >= abs($sat->dps->atime)) { if ($sat->deep_arg->t > 0) { $delt = $sat->dps->stepp; } else { $delt = $sat->dps->stepn; } } } do { if (abs($sat->deep_arg->t - $sat->dps->atime) >= $sat->dps->stepp) { $sat->flags |= self::DO_LOOP_FLAG; $sat->flags &= ~self::EPOCH_RESTART_FLAG; } else { $ft = $sat->deep_arg->t - $sat->dps->atime; $sat->flags &= ~self::DO_LOOP_FLAG; } if (abs($sat->deep_arg->t) < abs($sat->dps->atime)) { if ($sat->deep_arg->t >= 0) { $delt = $sat->dps->stepn; } else { $delt = $sat->dps->stepp; } $sat->flags |= self::DO_LOOP_FLAG | self::EPOCH_RESTART_FLAG; } /* Dot terms calculated */ if ($sat->flags & self::SYNCHRONOUS_FLAG) { $xndot = $sat->dps->del1 * sin($sat->dps->xli - $sat->dps->fasx2) + $sat->dps->del2 * sin(2 * ($sat->dps->xli - $sat->dps->fasx4)) + $sat->dps->del3 * sin(3 * ($sat->dps->xli - $sat->dps->fasx6)); $xnddt = $sat->dps->del1 * cos($sat->dps->xli - $sat->dps->fasx2) + 2 * $sat->dps->del2 * cos(2 * ($sat->dps->xli - $sat->dps->fasx4)) + 3 * $sat->dps->del3 * cos(3 * ($sat->dps->xli - $sat->dps->fasx6)); } else { $xomi = $sat->dps->omegaq + $sat->deep_arg->omgdot * $sat->dps->atime; $x2omi = $xomi + $xomi; $x2li = $sat->dps->xli + $sat->dps->xli; $xndot = $sat->dps->d2201 * sin($x2omi + $sat->dps->xli - Predict::g22) + $sat->dps->d2211 * sin($sat->dps->xli - Predict::g22) + $sat->dps->d3210 * sin($xomi + $sat->dps->xli - Predict::g32) + $sat->dps->d3222 * sin(-$xomi + $sat->dps->xli - Predict::g32) + $sat->dps->d4410 * sin($x2omi + $x2li - Predict::g44) + $sat->dps->d4422 * sin($x2li - Predict::g44) + $sat->dps->d5220 * sin($xomi + $sat->dps->xli - Predict::g52) + $sat->dps->d5232 * sin(-$xomi + $sat->dps->xli - Predict::g52) + $sat->dps->d5421 * sin($xomi + $x2li - Predict::g54) + $sat->dps->d5433 * sin(-$xomi + $x2li - Predict::g54); $xnddt = $sat->dps->d2201 * cos($x2omi + $sat->dps->xli - Predict::g22) + $sat->dps->d2211 * cos($sat->dps->xli - Predict::g22) + $sat->dps->d3210 * cos($xomi + $sat->dps->xli - Predict::g32) + $sat->dps->d3222 * cos(-$xomi + $sat->dps->xli - Predict::g32) + $sat->dps->d5220 * cos($xomi + $sat->dps->xli - Predict::g52) + $sat->dps->d5232 * cos(-$xomi + $sat->dps->xli - Predict::g52) + 2 * ($sat->dps->d4410 * cos($x2omi + $x2li - Predict::g44) + $sat->dps->d4422 * cos($x2li - Predict::g44) + $sat->dps->d5421 * cos($xomi + $x2li - Predict::g54) + $sat->dps->d5433 * cos(-$xomi + $x2li - Predict::g54)); } /* End of if (isFlagSet(SYNCHRONOUS_FLAG)) */ $xldot = $sat->dps->xni + $sat->dps->xfact; $xnddt = $xnddt * $xldot; if ($sat->flags & self::DO_LOOP_FLAG) { $sat->dps->xli = $sat->dps->xli + $xldot * $delt + $xndot * $sat->dps->step2; $sat->dps->xni = $sat->dps->xni + $xndot * $delt + $xnddt * $sat->dps->step2; $sat->dps->atime = $sat->dps->atime + $delt; } } while ($sat->flags & self::DO_LOOP_FLAG && ~$sat->flags & self::EPOCH_RESTART_FLAG); } while ($sat->flags & self::DO_LOOP_FLAG && $sat->flags & self::EPOCH_RESTART_FLAG); $sat->deep_arg->xn = $sat->dps->xni + $xndot * $ft + $xnddt * $ft * $ft * 0.5; $xl = $sat->dps->xli + $xldot * $ft + $xndot * $ft * $ft * 0.5; $temp = -$sat->deep_arg->xnode + $sat->dps->thgr + $sat->deep_arg->t * Predict::thdt; if (~$sat->flags & self::SYNCHRONOUS_FLAG) { $sat->deep_arg->xll = $xl + $temp + $temp; } else { $sat->deep_arg->xll = $xl - $sat->deep_arg->omgadf + $temp; } return; /* End case dpsec: */ /* End case dpsec: */ case self::dpper: /* Entrance for lunar-solar periodics */ $sinis = sin($sat->deep_arg->xinc); $cosis = cos($sat->deep_arg->xinc); if (abs($sat->dps->savtsn - $sat->deep_arg->t) >= 30) { $sat->dps->savtsn = $sat->deep_arg->t; $zm = $sat->dps->zmos + Predict::zns * $sat->deep_arg->t; $zf = $zm + 2 * Predict::zes * sin($zm); $sinzf = sin($zf); $f2 = 0.5 * $sinzf * $sinzf - 0.25; $f3 = -0.5 * $sinzf * cos($zf); $ses = $sat->dps->se2 * $f2 + $sat->dps->se3 * $f3; $sis = $sat->dps->si2 * $f2 + $sat->dps->si3 * $f3; $sls = $sat->dps->sl2 * $f2 + $sat->dps->sl3 * $f3 + $sat->dps->sl4 * $sinzf; $sat->dps->sghs = $sat->dps->sgh2 * $f2 + $sat->dps->sgh3 * $f3 + $sat->dps->sgh4 * $sinzf; $sat->dps->shs = $sat->dps->sh2 * $f2 + $sat->dps->sh3 * $f3; $zm = $sat->dps->zmol + Predict::znl * $sat->deep_arg->t; $zf = $zm + 2 * Predict::zel * sin($zm); $sinzf = sin($zf); $f2 = 0.5 * $sinzf * $sinzf - 0.25; $f3 = -0.5 * $sinzf * cos($zf); $sel = $sat->dps->ee2 * $f2 + $sat->dps->e3 * $f3; $sil = $sat->dps->xi2 * $f2 + $sat->dps->xi3 * $f3; $sll = $sat->dps->xl2 * $f2 + $sat->dps->xl3 * $f3 + $sat->dps->xl4 * $sinzf; $sat->dps->sghl = $sat->dps->xgh2 * $f2 + $sat->dps->xgh3 * $f3 + $sat->dps->xgh4 * $sinzf; $sat->dps->sh1 = $sat->dps->xh2 * $f2 + $sat->dps->xh3 * $f3; $sat->dps->pe = $ses + $sel; $sat->dps->pinc = $sis + $sil; $sat->dps->pl = $sls + $sll; } $pgh = $sat->dps->sghs + $sat->dps->sghl; $ph = $sat->dps->shs + $sat->dps->sh1; $sat->deep_arg->xinc = $sat->deep_arg->xinc + $sat->dps->pinc; $sat->deep_arg->em = $sat->deep_arg->em + $sat->dps->pe; if ($sat->dps->xqncl >= 0.2) { /* Apply periodics directly */ $ph = $ph / $sat->deep_arg->sinio; $pgh = $pgh - $sat->deep_arg->cosio * $ph; $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $pgh; $sat->deep_arg->xnode = $sat->deep_arg->xnode + $ph; $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; } else { /* Apply periodics with Lyddane modification */ $sinok = sin($sat->deep_arg->xnode); $cosok = cos($sat->deep_arg->xnode); $alfdp = $sinis * $sinok; $betdp = $sinis * $cosok; $dalf = $ph * $cosok + $sat->dps->pinc * $cosis * $sinok; $dbet = -$ph * $sinok + $sat->dps->pinc * $cosis * $cosok; $alfdp = $alfdp + $dalf; $betdp = $betdp + $dbet; $sat->deep_arg->xnode = Predict_Math::FMod2p($sat->deep_arg->xnode); $xls = $sat->deep_arg->xll + $sat->deep_arg->omgadf + $cosis * $sat->deep_arg->xnode; $dls = $sat->dps->pl + $pgh - $sat->dps->pinc * $sat->deep_arg->xnode * $sinis; $xls = $xls + $dls; $xnoh = $sat->deep_arg->xnode; $sat->deep_arg->xnode = Predict_Math::AcTan($alfdp, $betdp); /* This is a patch to Lyddane modification */ /* suggested by Rob Matson. */ if (abs($xnoh - $sat->deep_arg->xnode) > Predict::pi) { if ($sat->deep_arg->xnode < $xnoh) { $sat->deep_arg->xnode += Predict::twopi; } else { $sat->deep_arg->xnode -= Predict::twopi; } } $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; $sat->deep_arg->omgadf = $xls - $sat->deep_arg->xll - cos($sat->deep_arg->xinc) * $sat->deep_arg->xnode; } /* End case dpper: */ return; } /* End switch(ientry) */ }
/** SGP4SDP4 driver for doing AOS/LOS calculations. * @param Predict_Sat $sat The satellite data. * @param Predict_QTH $qth The QTH observer location data. * @param float $t The time for calculation (Julian Date) * */ public function predict_calc(Predict_Sat $sat, Predict_QTH $qth, $t) { $obs_set = new Predict_ObsSet(); $sat_geodetic = new Predict_Geodetic(); $obs_geodetic = new Predict_Geodetic(); $obs_geodetic->lon = $qth->lon * self::de2ra; $obs_geodetic->lat = $qth->lat * self::de2ra; $obs_geodetic->alt = $qth->alt / 1000.0; $obs_geodetic->theta = 0; $sat->jul_utc = $t; $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda; /* call the norad routines according to the deep-space flag */ $sgpsdp = Predict_SGPSDP::getInstance($sat); if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { $sgpsdp->SDP4($sat, $sat->tsince); } else { $sgpsdp->SGP4($sat, $sat->tsince); } Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); /* get the velocity of the satellite */ $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); $sat->velo = $sat->vel->w; Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic); while ($sat_geodetic->lon < -self::pi) { $sat_geodetic->lon += self::twopi; } while ($sat_geodetic->lon > self::pi) { $sat_geodetic->lon -= self::twopi; } $sat->az = Predict_Math::Degrees($obs_set->az); $sat->el = Predict_Math::Degrees($obs_set->el); $sat->range = $obs_set->range; $sat->range_rate = $obs_set->range_rate; $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); $sat->alt = $sat_geodetic->alt; $sat->ma = Predict_Math::Degrees($sat->phase); $sat->ma *= 256.0 / 360.0; $sat->phase = Predict_Math::Degrees($sat->phase); /* same formulas, but the one from predict is nicer */ //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt)); $age = $sat->jul_utc - $sat->jul_epoch; $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi + $age * $sat->tle->bstar * self::ae) * $age + $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1; }
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.09310400000000001 - $TU * 6.2E-6)); $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); return Predict::twopi * $GMST / Predict::secday; }
/** * Finds the current location of the sun based on the observer location * * @param Predict_QTH $qth The observer location * @param int $daynum The daynum or null to use the current daynum * * @return Predict_ObsSet */ public static function FindSun(Predict_QTH $qth, $daynum = null) { if ($daynum === null) { $daynum = Predict_Time::get_current_daynum(); } $obs_geodetic = new Predict_Geodetic(); $obs_geodetic->lon = $qth->lon * Predict::de2ra; $obs_geodetic->lat = $qth->lat * Predict::de2ra; $obs_geodetic->alt = $qth->alt / 1000.0; $obs_geodetic->theta = 0; $solar_vector = new Predict_Vector(); $zero_vector = new Predict_Vector(); $solar_set = new Predict_ObsSet(); self::Calculate_Solar_Position($daynum, $solar_vector); Predict_SGPObs::Calculate_Obs($daynum, $solar_vector, $zero_vector, $obs_geodetic, $solar_set); $solar_set->az = Predict_Math::Degrees($solar_set->az); $solar_set->el = Predict_Math::Degrees($solar_set->el); return $solar_set; }
public static function Calculate_Obs($_time, Predict_Vector $pos, Predict_Vector $vel, Predict_Geodetic $geodetic, Predict_ObsSet $obs_set) { $obs_pos = new Predict_Vector(); $obs_vel = new Predict_Vector(); $range = new Predict_Vector(); $rgvel = new Predict_Vector(); self::Calculate_User_PosVel($_time, $geodetic, $obs_pos, $obs_vel); $range->x = $pos->x - $obs_pos->x; $range->y = $pos->y - $obs_pos->y; $range->z = $pos->z - $obs_pos->z; $rgvel->x = $vel->x - $obs_vel->x; $rgvel->y = $vel->y - $obs_vel->y; $rgvel->z = $vel->z - $obs_vel->z; $range->w = sqrt($range->x * $range->x + $range->y * $range->y + $range->z * $range->z); $sin_lat = sin($geodetic->lat); $cos_lat = cos($geodetic->lat); $sin_theta = sin($geodetic->theta); $cos_theta = cos($geodetic->theta); $top_s = $sin_lat * $cos_theta * $range->x + $sin_lat * $sin_theta * $range->y - $cos_lat * $range->z; $top_e = -$sin_theta * $range->x + $cos_theta * $range->y; $top_z = $cos_lat * $cos_theta * $range->x + $cos_lat * $sin_theta * $range->y + $sin_lat * $range->z; $azim = atan(-$top_e / $top_s); /*Azimuth*/ if ($top_s > 0) { $azim = $azim + Predict::pi; } if ($azim < 0) { $azim = $azim + Predict::twopi; } $el = Predict_Math::ArcSin($top_z / $range->w); $obs_set->az = $azim; /* Azimuth (radians) */ $obs_set->el = $el; /* Elevation (radians)*/ $obs_set->range = $range->w; /* Range (kilometers) */ /* Range Rate (kilometers/second)*/ $obs_set->range_rate = Predict_Math::Dot($range, $rgvel) / $range->w; /* Corrections for atmospheric refraction */ /* Reference: Astronomical Algorithms by Jean Meeus, pp. 101-104 */ /* Correction is meaningless when apparent elevation is below horizon */ // obs_set->el = obs_set->el + Radians((1.02/tan(Radians(Degrees(el)+ // 10.3/(Degrees(el)+5.11))))/60); if ($obs_set->el < 0) { $obs_set->el = $el; /*Reset to true elevation*/ } }
/** * Experimental attempt at calculating apparent magnitude. Known intrinsic * magnitudes are listed inside the function for now. * * @param float $time The daynum the satellite is calculated for * @param Predict_QTH $qth The observer location * * @return null on failure, float otherwise */ public function calculateApparentMagnitude($time, Predict_QTH $qth) { // Recorded intrinsic magnitudes and their respective // illumination and distance from heavens-above.com static $intrinsicMagnitudes = array('25544' => array('mag' => -1.3, 'illum' => 0.5, 'distance' => 1000)); // Return null if we don't have a record of the intrinsic mag if (!isset($intrinsicMagnitudes[$this->tle->catnr])) { return null; } $imag = $intrinsicMagnitudes[$this->tle->catnr]; // Convert the observer's geodetic info to radians and km so // we can compare vectors $observerGeo = new Predict_Geodetic(); $observerGeo->lat = Predict_Math::Radians($qth->lat); $observerGeo->lon = Predict_Math::Radians($qth->lon); $observerGeo->alt = $qth->alt * 1000; // Now determine the sun and observer positions $observerPos = new Predict_Vector(); $observerVel = new Predict_Vector(); $solarVector = new Predict_Vector(); Predict_Solar::Calculate_Solar_Position($time, $solarVector); Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel); // Determine the solar phase and and thus the percent illumination $observerSatPos = new Predict_Vector(); Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos); $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos)); $illum = $phaseAngle / 180; $illuminationChange = $illum / $imag['illum']; $inverseSquareOfDistanceChange = pow($imag['distance'] / $this->range, 2); $changeInMagnitude = log($illuminationChange * $inverseSquareOfDistanceChange, self::POGSONS_RATIO); return $imag['mag'] - $changeInMagnitude; }