示例#1
0
        public void PassPrediction()
        {
            List <PassDetails> knownPasses = SetupKnownPasses();
            CoordGeodetic      geo         = new CoordGeodetic(41.760612, -111.819384, 1.394);
            Tle tle = new Tle("ISS (ZARYA)",
                              "1 25544U 98067A   15090.55997958  .00016867  00000-0  24909-3 0  9997",
                              "2 25544  51.6467 111.8303 0006284 156.4629 341.9393 15.55450652935952");
            SGP4 sgp4 = new SGP4(tle);

            /*
             * generate 7 day schedule
             */
            DateTime start_date = new DateTime(2015, 4, 13, 0, 0, 0); //DateTime.Now (true);
            DateTime end_date   = start_date.AddDays(7);              //new DateTime (System.DateTime.Now.AddDays (7));

            List <PassDetails> pass_list = new List <PassDetails>();

            ;

            //Console.WriteLine("Start time: " + start_date.ToString());
            //Console.WriteLine("End time  : " + end_date.ToString());

            /*
             * generate passes
             */
            pass_list = GeneratePassList(geo, sgp4, start_date, end_date, 180);

            Assert.AreEqual(knownPasses.Count, pass_list.Count);
            for (int i = 0; i < pass_list.Count; ++i)
            {
                Assert.AreEqual(knownPasses[i].ToString(), pass_list[i].ToString());
            }
        }
示例#2
0
        private bool IsEqual(CoordGeodetic geo)
        {
            bool equal = false;

            if (latitude == geo.latitude &&
                longitude == geo.longitude &&
                altitude == geo.altitude)
            {
                equal = false;
            }
            return(equal);
        }
示例#3
0
        private void ToEci(DateTime dt, CoordGeodetic geo)
        {
            /*
             * set date
             */
            m_dt = dt;

            const double mfactor = Global.kTWOPI * (Global.kOMEGA_E / Global.kSECONDS_PER_DAY);

            /*
             * Calculate Local Mean Sidereal Time for observers longitude
             */
            double theta = m_dt.ToLocalMeanSiderealTime(geo.longitude);

            /*
             * take into account earth flattening
             */
            double c = 1.0
                       / Math.Sqrt(1.0 + Global.kF * (Global.kF - 2.0) * Math.Pow(Math.Sin(geo.latitude), 2.0));
            double s     = Math.Pow(1.0 - Global.kF, 2.0) * c;
            double achcp = (Global.kXKMPER * c + geo.altitude) * Math.Cos(geo.latitude);

            /*
             * X position in km
             * Y position in km
             * Z position in km
             * W magnitude in km
             */
            m_position.x = achcp * Math.Cos(theta);
            m_position.y = achcp * Math.Sin(theta);
            m_position.z = (Global.kXKMPER * s + geo.altitude) * Math.Sin(geo.latitude);
            m_position.w = m_position.Magnitude();

            /*
             * X velocity in km/s
             * Y velocity in km/s
             * Z velocity in km/s
             * W magnitude in km/s
             */
            m_velocity.x = -mfactor * m_position.y;
            m_velocity.y = mfactor * m_position.x;
            m_velocity.z = 0.0;
            m_velocity.w = m_velocity.Magnitude();
        }
示例#4
0
 /**
  * Update this object with a new date and geodetic position
  * @param dt new date
  * @param geo new geodetic position
  */
 public void Update(DateTime dt, CoordGeodetic geo)
 {
     ToEci(dt, geo);
 }
示例#5
0
 /**
  * @param[in] dt the date to be used for this position
  * @param[in] geo the position
  */
 public Eci(DateTime dt, CoordGeodetic geo)
 {
     ToEci(dt, geo);
 }
示例#6
0
 /**
  * Set the observers location
  * @param[in] geo the observers position
  */
 public void SetLocation(CoordGeodetic geo)
 {
     m_geo = geo;
     m_eci.Update(m_eci.GetDateTime(), m_geo);
 }
示例#7
0
 /**
  * Constructor
  * @param[in] geo the observers position
  */
 public Observer(CoordGeodetic geo)
 {
     m_geo = new CoordGeodetic(geo);
     m_eci = new Eci(new DateTime(), geo);
 }
示例#8
0
 /**
  * ructor
  * @param[in] latitude observers latitude in degrees
  * @param[in] longitude observers longitude in degrees
  * @param[in] altitude observers altitude in kilometers
  */
 public Observer(double latitude, double longitude, double altitude)
 {
     m_geo = new CoordGeodetic(latitude, longitude, altitude);
     m_eci = new Eci(new DateTime(), m_geo);
 }
示例#9
0
        public static DateTime FindCrossingPoint(CoordGeodetic user_geo, SGP4 sgp4, DateTime initial_time1, DateTime initial_time2, bool finding_aos)
        {
            Observer obs = new Observer(user_geo);

            bool running;
            int  cnt;

            DateTime time1       = new DateTime(initial_time1.Ticks());
            DateTime time2       = new DateTime(initial_time2.Ticks());
            DateTime middle_time = null;

            running = true;
            cnt     = 0;
            while (running && cnt++ < 16)
            {
                middle_time = time1.AddSeconds((time2 - time1).TotalSeconds() / 2.0);

                /*
                 * calculate satellite position
                 */
                Eci eci = sgp4.FindPosition(middle_time);
                CoordTopocentric topo = obs.GetLookAngle(eci);

                if (topo.elevation > 0.0)
                {
                    /*
                     * satellite above horizon
                     */
                    if (finding_aos)
                    {
                        time2 = middle_time;
                    }
                    else
                    {
                        time1 = middle_time;
                    }
                }
                else
                {
                    if (finding_aos)
                    {
                        time1 = middle_time;
                    }
                    else
                    {
                        time2 = middle_time;
                    }
                }

                if ((time2 - time1).TotalSeconds() < 1.0)
                {
                    /*
                     * two times are within a second, stop
                     */
                    running = false;

                    /*
                     * remove microseconds
                     */
                    int us = middle_time.Microsecond();
                    middle_time = middle_time.AddMicroseconds(-us);

                    /*
                     * step back into the pass by 1 second
                     */
                    middle_time = middle_time.AddSeconds(finding_aos ? 1 : -1);
                }
            }

            /*
             * go back/forward 1second until below the horizon
             */
            running = true;
            cnt     = 0;
            while (running && cnt++ < 6)
            {
                Eci eci = sgp4.FindPosition(middle_time);
                CoordTopocentric topo = obs.GetLookAngle(eci);
                if (topo.elevation > 0)
                {
                    middle_time = middle_time.AddSeconds(finding_aos ? -1 : 1);
                }
                else
                {
                    running = false;
                }
            }

            return(middle_time);
        }
示例#10
0
        public static double FindMaxElevation(CoordGeodetic user_geo, SGP4 sgp4, DateTime aos, DateTime los)
        {
            Observer obs = new Observer(user_geo);

            bool running;

            double   time_step    = (los - aos).TotalSeconds() / 9.0;
            DateTime current_time = aos; //! current time
            DateTime time1        = aos; //! start time of search period
            DateTime time2        = los; //! end time of search period
            double   max_elevation;      //! max elevation

            running = true;

            do
            {
                running       = true;
                max_elevation = -99999999999999.0;
                while (running && current_time < time2)
                {
                    /*
                     * find position
                     */
                    Eci eci = sgp4.FindPosition(current_time);
                    CoordTopocentric topo = obs.GetLookAngle(eci);

                    if (topo.elevation > max_elevation)
                    {
                        /*
                         * still going up
                         */
                        max_elevation = topo.elevation;

                        /*
                         * move time along
                         */
                        current_time = current_time.AddSeconds(time_step);
                        if (current_time > time2)
                        {
                            /*
                             * dont go past end time
                             */
                            current_time = time2;
                        }
                    }
                    else
                    {
                        /*
                         * stop
                         */
                        running = false;
                    }
                }

                /*
                 * make start time to 2 time steps back
                 */
                time1 = current_time.AddSeconds(-2.0 * time_step);

                /*
                 * make end time to current time
                 */
                time2 = current_time;

                /*
                 * current time to start time
                 */
                current_time = time1;

                /*
                 * recalculate time step
                 */
                time_step = (time2 - time1).TotalSeconds() / 9.0;
            } while (time_step > 1.0);


            return(max_elevation);
        }
示例#11
0
        public static List <PassDetails> GeneratePassList(CoordGeodetic user_geo, SGP4 sgp4, DateTime start_time, DateTime end_time, int time_step)
        {
            List <PassDetails> pass_list = new List <PassDetails>();

            Observer obs = new Observer(user_geo);

            DateTime aos_time = null;
            DateTime los_time = null;

            bool found_aos = false;

            DateTime previous_time = new DateTime(start_time.Ticks());
            DateTime current_time  = new DateTime(start_time.Ticks());

            while (current_time < end_time)
            {
                bool end_of_pass = false;

                /*
                 * calculate satellite position
                 */
                Eci eci = sgp4.FindPosition(current_time);

                CoordTopocentric topo = obs.GetLookAngle(eci);

                if (!found_aos && topo.elevation > 0.0)
                {
                    /*
                     * aos hasnt occured yet, but the satellite is now above horizon
                     * this must have occured within the last time_step
                     */
                    if (start_time == current_time)
                    {
                        /*
                         * satellite was already above the horizon at the start,
                         * so use the start time
                         */
                        aos_time = start_time;
                    }
                    else
                    {
                        /*
                         * find the point at which the satellite crossed the horizon
                         */
                        aos_time = FindCrossingPoint(
                            user_geo,
                            sgp4,
                            previous_time,
                            current_time,
                            true);
                    }
                    found_aos = true;
                }
                else if (found_aos && topo.elevation < 0.0)
                {
                    found_aos = false;

                    /*
                     * end of pass, so move along more than time_step
                     */
                    end_of_pass = true;

                    /*
                     * already have the aos, but now the satellite is below the horizon,
                     * so find the los
                     */
                    los_time = FindCrossingPoint(user_geo, sgp4, previous_time, current_time, false);

                    PassDetails pd = new PassDetails();
                    pd.aos           = aos_time;
                    pd.los           = los_time;
                    pd.max_elevation = FindMaxElevation(user_geo, sgp4, aos_time, los_time);

                    pass_list.Add(pd);
                }

                /*
                 * save current time
                 */
                previous_time = current_time;

                if (end_of_pass)
                {
                    /*
                     * at the end of the pass move the time along by 30mins
                     */
                    current_time = current_time.AddMinutes(30);
                }
                else
                {
                    /*
                     * move the time along by the time step value
                     */
                    current_time = current_time.AddSeconds(180);
                }

                if (current_time > end_time)
                {
                    /*
                     * dont go past end time
                     */
                    current_time = end_time;
                }
            }
            ;

            if (found_aos)
            {
                /*
                 * satellite still above horizon at end of search period, so use end
                 * time as los
                 */
                PassDetails pd = new PassDetails();
                pd.aos           = aos_time;
                pd.los           = end_time;
                pd.max_elevation = FindMaxElevation(user_geo, sgp4, aos_time, end_time);

                pass_list.Add(pd);
            }

            return(pass_list);
        }
示例#12
0
 /**
  * Copy constructor
  * @param[in] geo object to copy from
  */
 public CoordGeodetic(CoordGeodetic geo)
 {
     latitude  = geo.latitude;
     longitude = geo.longitude;
     altitude  = geo.altitude;
 }