/** Initialise satellite data. * @param sat The satellite to initialise. * @param qth Optional QTH info, use (0,0) if NULL. * * This function calculates the satellite data at t = 0, ie. epoch time * The function is called automatically by gtk_sat_data_read_sat. */ public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null) { $obs_geodetic = new Predict_Geodetic(); $obs_set = new Predict_ObsSet(); $sat_geodetic = new Predict_Geodetic(); /* double jul_utc, age; */ $jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0 $sat->jul_epoch = $jul_utc; /* initialise observer location */ if ($qth != null) { $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; } else { $obs_geodetic->lon = 0.0; $obs_geodetic->lat = 0.0; $obs_geodetic->alt = 0.0; $obs_geodetic->theta = 0; } /* execute computations */ $sdpsgp = Predict_SGPSDP::getInstance($sat); if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { $sdpsgp->SDP4($sat, 0.0); } else { $sdpsgp->SGP4($sat, 0.0); } /* scale position and velocity to km and km/sec */ 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($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic); while ($sat_geodetic->lon < -Predict::pi) { $sat_geodetic->lon += Predict::twopi; } while ($sat_geodetic->lon > Predict::pi) { $sat_geodetic->lon -= Predict::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->footprint = 2.0 * Predict::xkmper * acos(Predict::xkmper / $sat->pos->w); $age = 0.0; $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi + $age * $sat->tle->bstar * Predict::ae) * $age + $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1; /* orbit type */ $sat->otype = $sat->get_orbit_type($sat); }