Exemplo n.º 1
0
    /*****************************************************************************
    * @function name : calECIDateAndVelocity
    * @author : Kaguya
    * @date : 2020/12/3 12:38
    * @inparam :
    * @outparam :
    * @last change :
    * @usage : 基于one_sgp4项目,计算航天器基于ECI坐标系下的位置和速度
    *****************************************************************************/
    public void calECIDateAndVelocity()
    {
        Tle       tleISS    = ParserTLE.parseTle(first, second, "ISS 1");
        DateTime  t         = new DateTime(data[0], data[1], data[2], data[3], data[4], data[5]);
        EpochTime startTime = new EpochTime(t);
        Sgp4Data  sate      = SatFunctions.getSatPositionAtTime(tleISS, startTime, Sgp4.wgsConstant.WGS_84);

        One_Sgp4.Point3d position = sate.getPositionData();
        ECI    = new double[3];
        ECI[0] = position.x;
        ECI[1] = position.y;
        ECI[2] = position.z;

        velocity    = new double[3];
        velocity[0] = sate.getVelocityData().x;
        velocity[1] = sate.getVelocityData().y;
        velocity[2] = sate.getVelocityData().z;
        velocity    = getECEF(velocity, data);
    }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //Parse three line element
            Tle tleISS = ParserTLE.parseTle(
                "1 25544U 98067A   19132.30925117  .00001081  00000-0  24694-4 0  9993",
                "2 25544  51.6426 179.4820 0001363 344.4861  92.2261 15.52657683169680",
                "ISS 1");

            //Parse tle from file
            if (System.IO.File.Exists("tleData.txt"))
            {
                List <Tle> tleList = ParserTLE.ParseFile("tleData.txt");
            }

            //Get TLE from Space-Track.org
            //list of satellites by their NORAD ID
            string[] noradIDs = { "8709", "43572" };
            try
            {
                One_Sgp4.SpaceTrack.GetSpaceTrack(noradIDs, "USERNAME", "PASSWORD");
            }
            catch { Console.Out.WriteLine("Error could not retrive TLE's from Space-Track, Login credentials might be wrong"); }


            //Create Time points
            EpochTime startTime   = new EpochTime(DateTime.UtcNow);
            EpochTime anotherTime = new EpochTime(2018, 100.5); //(Year 2018, 100 day at 12:00 HH)
            EpochTime stopTime    = new EpochTime(DateTime.UtcNow.AddHours(1));

            //get time difference
            double daysSince = startTime - anotherTime;
            //throws exception if first time > second time
            //double daysSince = anotherTime - startTime;

            //compare Time points
            EpochTime compareTime = new EpochTime(2018, 100.5); //(Year 2018, 100 day at 12:00 HH)
            bool      equals      = anotherTime == compareTime;
            bool      notequals   = startTime != anotherTime;
            bool      greater     = startTime > anotherTime;
            bool      smaler      = anotherTime < startTime;

            //Add 15 Seconds to EpochTime
            anotherTime.addTick(15);
            //Add 20 Min to EpochTime
            anotherTime.addMinutes(15);
            //Add 1 hour to EpochTime
            anotherTime.addHours(1);
            //Add 2 Days to EpochTime
            anotherTime.addDays(2);
            Console.Out.WriteLine(anotherTime.ToString());

            //Calculate Satellite Position and Speed
            One_Sgp4.Sgp4 sgp4Propagator = new Sgp4(tleISS, Sgp4.wgsConstant.WGS_84);
            //set calculation parameters StartTime, EndTime and caclulation steps in minutes
            sgp4Propagator.runSgp4Cal(startTime, stopTime, 1 / 30.0); // 1/60 => caclulate sat points every 2 seconds
            List <One_Sgp4.Sgp4Data> resultDataList = new List <Sgp4Data>();

            //Return Results containing satellite Position x,y,z (ECI-Coordinates in Km) and Velocity x_d, y_d, z_d (ECI-Coordinates km/s)
            resultDataList = sgp4Propagator.getRestults();

            //Coordinate of an observer on Ground lat, long, height(in meters)
            One_Sgp4.Coordinate observer = new Coordinate(35.00, 18.0, 0);
            //Convert to ECI coordinate system
            One_Sgp4.Point3d eci = observer.toECI(startTime.getLocalSiderealTime());
            //Get Local SiderealTime for Observer
            double localSiderealTime = startTime.getLocalSiderealTime(observer.getLongitude());

            //Calculate if Satellite is Visible for a certain Observer on ground at certain timePoint
            bool satelliteIsVisible = One_Sgp4.SatFunctions.isSatVisible(observer, 0.0, startTime, resultDataList[0]);

            //Calculate Sperical Coordinates from an Observer to Satellite
            //returns 3D-Point with range(km), azimuth(radians), elevation(radians) to the Satellite
            One_Sgp4.Point3d spherical = One_Sgp4.SatFunctions.calcSphericalCoordinate(observer, startTime, resultDataList[0]);

            //Calculate the Next 5 Passes over a point
            //for a location, Satellite, StartTime, Accuracy in Seconds = 15sec, MaxNumber of Days = 5 Days, Wgs constant = WGS_84
            //Returns pass with Location, StartTime of Pass, EndTime Of Pass, Max Elevation in Degrees
            List <Pass> passes = One_Sgp4.SatFunctions.CalculatePasses(observer, tleISS, new EpochTime(DateTime.UtcNow), 15, 5, Sgp4.wgsConstant.WGS_84);

            foreach (var p in passes)
            {
                Console.Out.WriteLine(p.ToString());
            }
            Console.Out.WriteLine("Done");
        }
Exemplo n.º 3
0
 //! Clears all Data
 /*!
 */
 public void clear()
 {
     vel = null;
     pos = null;
 }
Exemplo n.º 4
0
        private Point3d vel; /*!< 3D-pointData for velocity Data */

        #endregion Fields

        #region Constructors

        //! SGP4-Data constructor.
        /*!
        \param integer SateliteNumber.
        */
        public Sgp4Data( int satNr = -1)
        {
            satNumber = satNr;
            pos = new Point3d();
            vel = new Point3d();
        }
        public static async Task <Satellite> FindClosestSatellite(double userLat, double userLong, double userHeight)
        {
            List <Tle> tleList = ParserTLE.ParseFile(pathToTLEData);

            Vector3 difference = new Vector3(0, 0, 0);

            Satellite        closest    = new Satellite("Temporary Satellite. If you see this, you done messed up", double.MaxValue);
            List <Satellite> satellites = new List <Satellite>();

            One_Sgp4.Coordinate observer = new Coordinate(userLat, userLong, userHeight);

            for (int i = 0; i < tleList.Count; i++)
            {
                //Create Time points
                EpochTime startTime = new EpochTime(DateTime.UtcNow);
                EpochTime stopTime  = new EpochTime(DateTime.UtcNow.AddHours(1));

                One_Sgp4.Sgp4 sgp4Propagator = new Sgp4(tleList[i], Sgp4.wgsConstant.WGS_84);

                try
                {
                    sgp4Propagator.runSgp4Cal(startTime, stopTime, 0.5);
                }
                catch
                {
                    Console.WriteLine("Something went wrong with " + tleList[i].getName());
                }

                List <One_Sgp4.Sgp4Data> resultDataList = new List <Sgp4Data>();
                //Return Results containing satellite Position x,y,z (ECI-Coordinates in Km) and Velocity x_d, y_d, z_d (ECI-Coordinates km/s)
                resultDataList = sgp4Propagator.getResults();

                try
                {
                    double localSiderealTime = startTime.getLocalSiderealTime(observer.getLongitude());

                    Sgp4Data grrPoint = One_Sgp4.SatFunctions.getSatPositionAtTime(tleList[0], startTime, Sgp4.wgsConstant.WGS_84);

                    One_Sgp4.Point3d sphCoordsSat = One_Sgp4.SatFunctions.calcSphericalCoordinate(observer, startTime, resultDataList[0]);

                    double distance = sphCoordsSat.x;

                    Satellite satellite = new Satellite(tleList[i].getName(), distance);
                    satellites.Add(satellite);

                    if (distance < closest.distance)
                    {
                        closest = satellite;
                    }
                }
                catch
                {
                    //Something went wrong with a satellite, skipped
                }
            }

            closest.distance = Math.Round(closest.distance, 2);

            return(closest);

            //Console.WriteLine("Done: " + satellites.Count + " satellites successfully analyzed from " + tleList.Count + " in the dataset.");
            //Console.WriteLine("The closest active satellite is " + closest.name.Trim() + " which is " + Math.Round(closest.distance, 2).ToString() + " kilometres away from you. Time: " + DateTime.Now.ToString("HH:mm:ss"));
            //Console.WriteLine();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            //Parse three line element
            Tle tleISS = ParserTLE.parseTle(
                "1 25544U 98067A   19097.23063721 -.00000469  00000-0  00000+0 0  9999",
                "2 25544  51.6449 353.9503 0002279 151.1697 290.4275 15.52495932164239",
                "ISS 1");

            //Parse tle from file
            if (System.IO.File.Exists("tleData.txt"))
            {
                List <Tle> tleList = ParserTLE.ParseFile("tleData.txt");
            }

            //Get TLE from Space-Track.org
            //list of satellites by their NORAD ID
            string[] noradIDs = { "8709", "43572" };
            try
            {
                One_Sgp4.SpaceTrack.GetSpaceTrack(noradIDs, "USERNAME", "PASSWORD");
            }
            catch { Console.Out.WriteLine("Error could not retrive TLE's from Space-Track, Login credentials might be wrong"); }


            //Create Time points
            EpochTime startTime   = new EpochTime(DateTime.UtcNow);
            EpochTime anotherTime = new EpochTime(2018, 100.5); //(Year 2017, 100 day at 12:00 HH)
            EpochTime stopTime    = new EpochTime(DateTime.UtcNow.AddHours(1));

            //Add 15 Seconds to EpochTime
            anotherTime.addTick(15);
            //Add 20 Min to EpochTime
            anotherTime.addMinutes(15);
            //Add 1 hour to EpochTime
            anotherTime.addHours(1);
            //Add 2 Days to EpochTime
            anotherTime.addDays(2);
            Console.Out.WriteLine(anotherTime.ToString());


            //Calculate Satellite Position and Speed
            One_Sgp4.Sgp4 sgp4Propagator = new Sgp4(tleISS, Sgp4.wgsConstant.WGS_84);
            //set calculation parameters StartTime, EndTime and caclulation steps in minutes
            sgp4Propagator.runSgp4Cal(startTime, stopTime, 1 / 30.0); // 1/60 => caclulate sat points every 2 seconds
            List <One_Sgp4.Sgp4Data> resultDataList = new List <Sgp4Data>();

            //Return Results containing satellite Position x,y,z (ECI-Coordinates in Km) and Velocity x_d, y_d, z_d (ECI-Coordinates km/s)
            resultDataList = sgp4Propagator.getRestults();

            //Coordinate of an observer on Ground lat, long, height(in meters)
            One_Sgp4.Coordinate observer = new Coordinate(35.554595, 18.888574, 0);
            //Convert to ECI coordinate system
            One_Sgp4.Point3d eci = observer.toECI(startTime.getLocalSiderealTime());
            //Get Local SiderealTime for Observer
            double localSiderealTime = startTime.getLocalSiderealTime(observer.getLongitude());

            //TESTING MIR

            //TEST ECI
            EpochTime T_eciTime = new EpochTime(09, 00, 00, 1995, 10, 1);

            //Test GMST
            if (T_eciTime.getLocalSiderealTime() == 2.524218)
            {
            }
            Coordinate T_eciCoo = new Coordinate(40, -75);
            var        t_eci    = T_eciCoo.toECI(T_eciTime.getLocalSiderealTime());
            //Coordinate equals x' = 1703.295 km, y' = 4586.650 km, z' = 4077.984 km.


            EpochTime  t_time = new EpochTime(12, 46, 0, 1995, 11, 18);
            Coordinate t_cord = new Coordinate(45.0, -93);
            Sgp4Data   mirPos = new Sgp4Data();

            mirPos.setX(-4400.594);
            mirPos.setY(1932.870);
            mirPos.setZ(4760.712);
            var lookAngels = SatFunctions.calcSphericalCoordinate(t_cord, t_time, mirPos);
            var onGround   = SatFunctions.calcSatSubPoint(t_time, mirPos, Sgp4.wgsConstant.WGS_72);
            var r          = t_cord.toECI(t_time.getLocalSiderealTime());


            //Calculate if Satellite is Visible for a certain Observer on ground at certain timePoint
            bool satelliteIsVisible = One_Sgp4.SatFunctions.isSatVisible(observer, 0.0, startTime, resultDataList[0]);

            //Calculate Sperical Coordinates from an Observer to Satellite
            //returns 3D-Point with range(km), azimuth(radians), elevation(radians) to the Satellite
            One_Sgp4.Point3d spherical = One_Sgp4.SatFunctions.calcSphericalCoordinate(observer, startTime, resultDataList[0]);

            //Calculate the Next 5 Passes over a point
            //for a location, Satellite, StartTime, Accuracy in Seconds = 15sec, MaxNumber of Days = 5 Days, Wgs constant = WGS_84
            //Returns pass with Location, StartTime of Pass, EndTime Of Pass, Max Elevation in Degrees
            List <Pass> passes = One_Sgp4.SatFunctions.CalculatePasses(observer, tleISS, new EpochTime(DateTime.UtcNow), 15, 5, Sgp4.wgsConstant.WGS_84);

            foreach (var p in passes)
            {
                Console.Out.WriteLine(p.ToString());
            }
        }
Exemplo n.º 7
0
        //! Calculate visibility of a satellite from a point on Earth
        /*!
            \param Station to calcuate if satellite is in View
            \param TimeDate start time
            \param List<Sgp4Data> satellite position vector
            \param string name of the satellite
            \param double tick in witch time is increased by each step
            \return true if object is visible at given time and current location
        */
        public static bool isSatVisible(Coordinate coordinate, 
            double minElevation, EpochTime time, Sgp4Data satPosData)
        {
            double lsr = time.getLocalSiderealTime(coordinate.getLongitude());
                Point3d groundLocation = coordinate.toECI(lsr);

                Point3d v = new Point3d();
                v.x = satPosData.getX() - groundLocation.x;
                v.y = satPosData.getY() - groundLocation.y;
                v.z = satPosData.getZ() - groundLocation.z;

                double r_lat = coordinate.getLatetude() * toRadians;

                double sin_lat = Math.Sin(r_lat);
                double cos_lat = Math.Cos(r_lat);
                double sin_srt = Math.Sin(lsr);
                double cos_srt = Math.Cos(lsr);

                double rs = sin_lat * cos_srt * v.x
                          + sin_lat * sin_srt * v.y
                          - cos_lat * v.z;
                double re = - sin_srt * v.x
                            + cos_srt * v.y;
                double rz = cos_lat * cos_srt * v.x
                            + cos_lat * sin_srt * v.y + sin_lat * v.z;

                double range = Math.Sqrt(rs * rs + re * re + rz * rz);
                double elevation = Math.Asin(rz / range);
                double azimuth = Math.Atan(-re / rs);

                if (rs > 0.0)
                {
                    azimuth += pi;
                }
                if (azimuth < 0.0)
                {
                    azimuth += twoPi;
                }

                if (elevation >= minElevation)
                {
                    return true;
                }
                else
                {
                    return false;
                }
        }
Exemplo n.º 8
0
        //! Calculate Range, Azimuth and elevation for satellite
        //! for given time point and satellite position
        /*!
            \param Station to calcuate if satellite is in View
            \param TimeDate start time
            \param List<Sgp4Data> satellite position vector
            \return Point3d containing range, azimuth, elevation
        */
        public static Point3d calcSphericalCoordinate(Coordinate coordinate,
            EpochTime time, Sgp4Data satPosData)
        {
            double lsr = time.getLocalSiderealTime(coordinate.getLongitude());
            Point3d groundLocation = coordinate.toECI(lsr);
            Point3d result = new Point3d();

            Point3d v = new Point3d();
            v.x = satPosData.getX() - groundLocation.x;
            v.y = satPosData.getY() - groundLocation.y;
            v.z = satPosData.getZ() - groundLocation.z;

            double r_lat = coordinate.getLatetude() * toRadians;

            double sin_lat = Math.Sin(r_lat);
            double cos_lat = Math.Cos(r_lat);
            double sin_srt = Math.Sin(lsr);
            double cos_srt = Math.Cos(lsr);

            double rs = sin_lat * cos_srt * v.x
                      + sin_lat * sin_srt * v.y
                      - cos_lat * v.z;
            double re = -sin_srt * v.x
                        + cos_srt * v.y;
            double rz = cos_lat * cos_srt * v.x
                        + cos_lat * sin_srt * v.y + sin_lat * v.z;

            result.x = Math.Sqrt(rs * rs + re * re + rz * rz);
            result.y = Math.Atan(-re / rs);
            result.z = Math.Asin(rz / result.x);

            if (rs > 0.0)
            {
                result.y += pi;
            }
            if (result.y < 0.0)
            {
                result.y += twoPi;
            }

            return result;
        }
Exemplo n.º 9
0
        //! Convert to ECI
        /*!
        \param double SidrealTime
        \return point3D ECI-Position vector of the Coordinate
        */
        public Point3d toECI(double siderealTime)
        {
            double srt = siderealTime;
            double lat_rad = toRadians * latetude;
            Point3d eciPos = new Point3d();

            double c = 1.0 / Math.Sqrt(1.0 + f * (f - 2.0) *
                       (Math.Sin(lat_rad) * Math.Sin(lat_rad)));
            double s = (1.0 - f) * (1.0 - f) * c;
            eciPos.x = a_Wgs72 * c * Math.Cos(lat_rad) * Math.Cos(srt);
            eciPos.y = a_Wgs72 * c * Math.Cos(lat_rad) * Math.Sin(srt);
            eciPos.z = a_Wgs72 * s * Math.Sin(lat_rad);

            return eciPos;
        }