Ejemplo n.º 1
0
        /// <summary>
        ///     Observes a satellite at an instant in time, relative to this GroundStation
        /// </summary>
        /// <param name="satellite">The satellite to observe</param>
        /// <param name="time">The time of observation</param>
        /// <returns>A list of observations where an AOS is seen at or after the start parameter</returns>
        public TopocentricObservation Observe(Satellite satellite, DateTime time)
        {
            var eciLocation = Location.ToEci(time);
            var posEci      = satellite.Predict(time);

            return(eciLocation.Observe(posEci));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Creates a list of all of the predicted observations within the specified time period, such that an AOS for the
        ///     satellite from this ground station is seen at or after the start parameter
        /// </summary>
        /// <param name="satellite">The satellite to observe</param>
        /// <param name="start">The time to start observing</param>
        /// <param name="end">The time to end observing</param>
        /// <param name="deltaTime">The time step for the prediction simulation</param>
        /// <returns>A list of observations where an AOS is seen at or after the start parameter</returns>
        public List <SatelliteVisibilityPeriod> Observe(Satellite satellite, DateTime start, DateTime end,
                                                        TimeSpan deltaTime)
        {
            start = start.Round(deltaTime);

            var obs = new List <SatelliteVisibilityPeriod>();

            var t     = start - deltaTime;
            var state = SatelliteObservationState.Init;

            var startedObserving = start;
            var startAz          = Angle.Zero;
            var maxEl            = Angle.Zero;

            while (t <= end || state == SatelliteObservationState.Observing)
            {
                t += deltaTime;

                var eciLocation = Location.ToEci(t);
                var posEci      = satellite.Predict(t);

                if (IsVisible(posEci, Angle.Zero))
                {
                    if (state == SatelliteObservationState.Init)
                    {
                        continue;
                    }

                    var azEl = eciLocation.Observe(posEci);

                    if (azEl.Elevation > maxEl)
                    {
                        maxEl = azEl.Elevation;
                    }

                    if (state == SatelliteObservationState.NotObserving)
                    {
                        startAz          = azEl.Azimuth;
                        startedObserving = t;
                    }

                    state = SatelliteObservationState.Observing;
                }
                else
                {
                    if (state == SatelliteObservationState.Observing)
                    {
                        var azEl = eciLocation.Observe(posEci);
                        obs.Add(new SatelliteVisibilityPeriod(satellite, startedObserving, t, maxEl,
                                                              startAz, azEl.Azimuth));
                    }

                    maxEl = Angle.Zero;
                    state = SatelliteObservationState.NotObserving;
                }
            }

            return(obs);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Observes a satellite at an instant in time, relative to this GroundStation
        /// </summary>
        /// <param name="satellite">The satellite to observe</param>
        /// <param name="time">The time of observation</param>
        /// <returns>A list of observations where an AOS is seen at or after the start parameter</returns>
        public TopocentricObservation Observe(Satellite satellite, DateTime time)
        {
            time = time.ToStrictUtc();

            var posEci = satellite.Predict(time);

            return(Location.Observe(posEci, time));
        }
Ejemplo n.º 4
0
        // finds the next crossing point in time when the observer's elevation changes from below minElevation to above.
        // if the observer's elevation at the start time is above or equal to minElevation, start is returned.
        private DateTime?FindNextBelowToAboveCrossingPoint(Satellite satellite, DateTime start, DateTime end, TimeSpan deltaTime, Angle minElevation, int resolution)
        {
            var eciLocation = Location.ToEci(start);
            var posEci      = satellite.Predict(start);

            var      t = start - deltaTime;
            DateTime prev;
            Angle    el;

            do
            {
                prev = t;
                var next = t + deltaTime;
                t  = next <= end ? next : end;                // clamp t to end
                el = GetTopo(satellite, t).Elevation;
            } while (el < minElevation && t < end);

            if (prev == start)
            {
                return(t);
            }

            if (el < minElevation)
            {
                return(null);
            }             // if we haven't found a crossing point

            // sort out tStart and tEnd
            DateTime tStart, tEnd;

            if (prev < t)
            {
                tStart = prev;
                tEnd   = t;
            }
            else
            {
                tStart = t;
                tEnd   = prev;
            }

            return(FindCrossingTimeWithinInterval(satellite, tStart, tEnd, minElevation, resolution));
        }
Ejemplo n.º 5
0
        // finds the next crossing point in time when the observer's elevation changes from below minElevation to above.
        // if the observer's elevation at the start time is above or equal to minElevation, start is returned.
        private DateTime FindNextBelowToAboveCrossingPoint(Satellite satellite, DateTime start, DateTime end, TimeSpan deltaTime, Angle minElevation, int resolution)
        {
            var eciLocation = Location.ToEci(start);
            var posEci      = satellite.Predict(start);

            var      t = start - deltaTime;
            DateTime prev;
            Angle    el;

            do
            {
                prev = t;
                t   += deltaTime;
                el   = GetTopo(satellite, t).Elevation;
            } while (el < minElevation && t <= end);

            if (t == start)
            {
                return(t);
            }

            // sort out tStart and tEnd
            DateTime tStart, tEnd;

            if (prev < t)
            {
                tStart = prev;
                tEnd   = t;
            }
            else
            {
                tStart = t;
                tEnd   = prev;
            }
            return(FindCrossingTimeWithinInterval(satellite, tStart, tEnd, minElevation, resolution));
        }
Ejemplo n.º 6
0
        // finds the next crossing point in time when the observer's elevation changes from above minElevation to below.
        // if the observer's elevation at time start is below minElevation, the start time is returned.
        // note that deltaTime may be negative, i.e. this function can walk backwards in time as well as forwards.
        private CrossingPointInfo FindNextAboveToBelowCrossingPoint(Satellite satellite, DateTime start, TimeSpan deltaTime, Angle minElevation, int resolution, DateTime?end = null)
        {
            var eciLocation = Location.ToEci(start);
            var posEci      = satellite.Predict(start);

            var      t = start - deltaTime;
            DateTime prev;
            var      maxEl     = Angle.Zero;
            var      maxElTime = DateTime.MinValue;
            Angle    el;

            // we write two loops to make the check condition a little easier to read (and slightly more efficient)
            if (end.HasValue) // if an definite end time is specified
            {
                do
                {
                    prev = t;
                    t   += deltaTime;
                    el   = GetTopo(satellite, t).Elevation;
                    if (el > maxEl)
                    {
                        maxEl     = el;
                        maxElTime = t;
                    }
                } while (el >= minElevation && t <= end);
            }
            else // if no definite end time is specified
            {
                do
                {
                    prev = t;
                    t   += deltaTime;
                    el   = GetTopo(satellite, t).Elevation;
                    if (el > maxEl)
                    {
                        maxEl     = el;
                        maxElTime = t;
                    }
                } while (el >= minElevation);
            }

            if (t == start)
            {
                return(new CrossingPointInfo(t, maxElTime, maxEl));
            }                                                                      // bail out early if t==start
            DateTime tStart, tEnd;

            // sort out tStart and tEnd
            if (prev < t)
            {
                tStart = prev;
                tEnd   = t;
            }
            else
            {
                tStart = t;
                tEnd   = prev;
            }

            t = FindCrossingTimeWithinInterval(satellite, tStart, tEnd, minElevation, resolution);
            return(new CrossingPointInfo(t, maxElTime, maxEl));
        }
Ejemplo n.º 7
0
        // convenience function to get a topocentric observation for a given satellite and time
        private TopocentricObservation GetTopo(Satellite satellite, DateTime time)
        {
            var posEci = satellite.Predict(time);

            return(Location.ToEci(time).Observe(posEci, posEci.Time));
        }