示例#1
0
<?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));
示例#2
0
文件: Solar.php 项目: stml/auspex
 /**
  * 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;
 }
示例#3
0
文件: Predict.php 项目: stml/auspex
 /** 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;
 }
示例#4
0
文件: Sat.php 项目: stml/auspex
 /**
  * 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;
 }