Code Monkey home page Code Monkey logo

one_sgp4's People

Contributors

1manprojects avatar netnspace avatar robertk66 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

one_sgp4's Issues

Issues with spherical coordinates.

Describe the bug
I'm not sure if I'm missing something here but I don't get accurate azimuth/elevation values when comparing to other ISS locators.

Observer Lat/Long/Height is: 45.68338, -73.43246, 0

1.) Comparing ISS data the azimuth and elevation are off by varying amounts. The Lat/Long/Altitude of the satellite are correct.

2.) Pass values are strange both for duration and elevation:

Start Of Contact: 14.08.2019-16:06:16, End of Contact: 14.08.2019-16:14:46, Max Elevation: 153.799149518202
Start Of Contact: 14.08.2019-16:15:01, End of Contact: 14.08.2019-19:38:01, Max Elevation: 4170.55683568467
Start Of Contact: 14.08.2019-19:38:16, End of Contact: 14.08.2019-01:13:31, Max Elevation: 1726.2632728008
Start Of Contact: 14.08.2019-08:58:01, End of Contact: 14.08.2019-12:10:16, Max Elevation: 179.48558251804
Start Of Contact: 14.08.2019-12:10:31, End of Contact: 14.08.2019-15:16:46, Max Elevation: 985.429678273676
Start Of Contact: 14.08.2019-15:17:01, End of Contact: 14.08.2019-15:35:16, Max Elevation: 284.913716508419
Start Of Contact: 14.08.2019-15:35:31, End of Contact: 14.08.2019-23:02:01, Max Elevation: 3840.08671322694

To Reproduce

TLE data used were the most updated from Celestrak.

  1. What function was called:

       //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]);
    

I used spherical.x spherical.y and spherical.z for altitude, azimuth and elevation.

satissue

Again not sure if I'm just missing something here.

Thank you,

wrong value for Coordinate.getHeight() ?

I'm using the library to track the ISS based on TLE elements obtained from https://www.celestrak.com/NORAD/elements/stations.txt
The library gives correct values for longitude/latitude and velocity. However I believe there's a glitch in the Height calculation (Coordinate.getHeight() ). I assume the Height is in Km. the Height value is different from what I can see here: http://www.esa.int/Our_Activities/Human_Spaceflight/International_Space_Station/Where_is_the_International_Space_Station
For instance, when the ESA url shows Altitude of 417 km, getHeight() returns 407 km.

thanks,
Eric

CalculatePasses returns unexpected results

Describe the bug
I'm using CalculatePasses function to get upcoming visible passes (5 days) of the ISS for an observer's location but it returns unexpected results

To Reproduce

I'm using One_Sgp4 v1.0.5 (released December 2, 2018 ).
TLE used :

ISS (ZARYA)
1 25544U 98067A 19013.58677685 .00000299 00000-0 11878-4 0 9995
2 25544 51.6425 50.2106 0002416 284.1251 212.8292 15.53757701151234

Code used:

        //Coordinate of an observer on Ground lat, long, height(in meters)
        One_Sgp4.Coordinate observer = new Coordinate(48.8270 , 2.1887);   // VDA
        
        //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)
        {
            Debug.WriteLine(p.ToString());                                
        }

the above code returns the following results:

Start Of Contact: 13.01.2019-21:22:46, End of Contact: 13.01.2019-22:00:46, Max Elevation: 81.132108075482
Start Of Contact: 13.01.2019-22:57:16, End of Contact: 13.01.2019-23:06:16, Max Elevation: 62.8306591872441
Start Of Contact: 13.01.2019-23:06:31, End of Contact: 13.01.2019-02:55:46, Max Elevation: 3140.63559205821
Start Of Contact: 13.01.2019-03:47:01, End of Contact: 13.01.2019-03:58:01, Max Elevation: 91.4952487663781
Start Of Contact: 13.01.2019-05:23:46, End of Contact: 13.01.2019-05:29:31, Max Elevation: 47.1628122069365
Start Of Contact: 13.01.2019-05:29:46, End of Contact: 13.01.2019-06:34:46, Max Elevation: 462.247040970672
Start Of Contact: 13.01.2019-20:32:16, End of Contact: 13.01.2019-21:53:01, Max Elevation: 122.496672327445
Start Of Contact: 13.01.2019-22:05:31, End of Contact: 13.01.2019-22:15:46, Max Elevation: 56.9892797360133
Start Of Contact: 13.01.2019-23:41:46, End of Contact: 13.01.2019-23:53:31, Max Elevation: 102.970356543472
Start Of Contact: 13.01.2019-01:18:16, End of Contact: 13.01.2019-01:27:31, Max Elevation: 80.4046104725208
Start Of Contact: 13.01.2019-01:27:46, End of Contact: 13.01.2019-05:12:31, Max Elevation: 4318.88294826637
Start Of Contact: 13.01.2019-06:10:46, End of Contact: 13.01.2019-06:12:16, Max Elevation: 8.29590168745457
Start Of Contact: 13.01.2019-06:12:31, End of Contact: 13.01.2019-06:12:46, Max Elevation: 5.64650943360117
Start Of Contact: 13.01.2019-21:14:01, End of Contact: 13.01.2019-21:27:01, Max Elevation: 48.1640876561404
Start Of Contact: 13.01.2019-22:49:31, End of Contact: 13.01.2019-22:57:01, Max Elevation: 59.1346820384278
Start Of Contact: 13.01.2019-22:57:16, End of Contact: 13.01.2019-02:06:46, Max Elevation: 3306.80427917464
Start Of Contact: 13.01.2019-02:07:01, End of Contact: 13.01.2019-03:55:46, Max Elevation: 2122.49435586353
Start Of Contact: 13.01.2019-05:16:46, End of Contact: 13.01.2019-05:21:16, Max Elevation: 37.211836643121
Start Of Contact: 13.01.2019-05:21:31, End of Contact: 13.01.2019-05:54:16, Max Elevation: 222.826964989532
Start Of Contact: 13.01.2019-20:23:01, End of Contact: 13.01.2019-20:55:01, Max Elevation: 59.0198862462301
Start Of Contact: 13.01.2019-21:57:46, End of Contact: 13.01.2019-22:10:46, Max Elevation: 94.0689317392554
Start Of Contact: 13.01.2019-23:34:01, End of Contact: 13.01.2019-23:40:46, Max Elevation: 56.369164202541
Start Of Contact: 13.01.2019-23:41:01, End of Contact: 13.01.2019-02:33:16, Max Elevation: 2816.34693645587
Start Of Contact: 13.01.2019-02:47:16, End of Contact: 13.01.2019-02:56:01, Max Elevation: 71.2467740644317
Start Of Contact: 13.01.2019-02:56:16, End of Contact: 13.01.2019-05:33:01, Max Elevation: 794.524838237632
Start Of Contact: 13.01.2019-19:32:31, End of Contact: 13.01.2019-20:48:31, Max Elevation: 100.488426074259
Start Of Contact: 13.01.2019-21:06:01, End of Contact: 13.01.2019-21:21:01, Max Elevation: 86.8978985296678
Start Of Contact: 13.01.2019-22:42:01, End of Contact: 13.01.2019-22:51:46, Max Elevation: 82.9325140612512
Start Of Contact: 13.01.2019-22:52:01, End of Contact: 13.01.2019-02:57:16, Max Elevation: 3012.18646462304
Start Of Contact: 13.01.2019-03:31:46, End of Contact: 13.01.2019-03:37:46, Max Elevation: 49.7877361843573
Start Of Contact: 13.01.2019-03:38:01, End of Contact: 13.01.2019-05:12:01, Max Elevation: 877.429238102212
Start Of Contact: 13.01.2019-05:12:16, End of Contact: 13.01.2019-05:15:31, Max Elevation: 23.1222498676525

However using https://heavens-above.com for same observer's location returns no visible pass for the coming days.

looking at the results above I'm surprised to see sometimes a significant amount of time between 'Start of Contact' and 'End of Contact' , a few examples:

Start Of Contact: 13.01.2019-03:38:01, End of Contact: 13.01.2019-05:12:01, Max Elevation: 877.429238102212
Start Of Contact: 13.01.2019-22:52:01, End of Contact: 13.01.2019-02:57:16, Max Elevation: 3012.18646462304
Start Of Contact: 13.01.2019-02:07:01, End of Contact: 13.01.2019-03:55:46, Max Elevation: 2122.49435586353

Also Max Elevation is very high as you can see.

Expected behavior
Would expect to see results aligned with heavens-above

Convert ECI to ECEF

Hello,

Is it possible to convert ECI coordinates to ECEF from the DLL?

I made a script in PowerShell, the import of the DLL works, the latitude is OK but the longitude does anything and I have curiously always an error of 20 km for the altitude:

$Block = $false
$Streams = Get-Item -LiteralPath "$PSScriptRoot\sgp4\One_Sgp4.dll" -Stream *
$Streams | ForEach-Object {if ($_.Stream -match "Zone.Identifier") {$Block = $true}}
if ($Block) {
    Unblock-File -LiteralPath "$PSScriptRoot\sgp4\One_Sgp4.dll"
    Write-Host -ForegroundColor Yellow -BackgroundColor Red "Un fichier a du être dévérouillé, veuillez redémarrer PowerShell pour la prise en compte"
    }
Add-Type -LiteralPath "$PSScriptRoot\sgp4\One_Sgp4.dll"

# Création d'un objet Satellite
$tleISS = New-Object One_Sgp4.Tle

#Analyse TLE
$tleISS = [One_Sgp4.ParserTLE]::parseTle("1 25544U 98067A   23021.58893016  .00026763  00000-0  47621-3 0  9995","2 25544  51.6443 334.6786 0004827 262.6903 262.3175 15.49939031379055","ISS (ZARYA)")

Write-host -BackgroundColor Black -ForegroundColor Cyan ("Nom du Satellite :    "+$tleISS.getName())
Write-host -BackgroundColor Black -ForegroundColor Cyan ("Numéro du Satellite : "+$tleISS.getSatNumber())

[double]$PI = [Math]::PI
$RayonTerreMin = 6356.752314
$RayonTerreMax = 6378.137
$Maintenant=(Get-Date).ToUniversalTime()
$MaintenantSGP4=[One_Sgp4.EpochTime]::new($Maintenant.Year,$Maintenant.DayOfYear+($Maintenant.Hour/24)+($Maintenant.Minute/1440)+($Maintenant.Second/86400))
$J2000 = [DateTime]'01/01/2000 11:58:55.816'
$Data = [One_Sgp4.SatFunctions]::getSatPositionAtTime($tleISS,$MaintenantSGP4,1)
$ECI_X= $Data.getX()
$ECI_Y= $Data.getY()
$ECI_Z= $Data.getZ()

$Longitude = 180*([Math]::Atan($ECI_Y/$ECI_X))/$PI
$Longitude = $Longitude + 280.46 + 360.9856123035484*(($Maintenant-$J2000).TotalDays) #Pour passer d'une coordonnée ECI à ECEF, il faut ajouter la rotation du temps sidéral par rapport à Greenwich (approximation)  
$Longitude = $Longitude % 360
if ($Longitude -gt 180) {$Longitude -= 360}

$LatitudeRad = [Math]::Atan($ECI_Z/([Math]::Sqrt(([Math]::Pow($ECI_X,2)+[Math]::Pow($ECI_Y,2)))))
$Latitude = ($LatitudeRad/$PI)*180

$RayonTerreP1 = ([Math]::Pow($RayonTerreMax,2))*([Math]::Pow($RayonTerreMax,2))
$RayonTerreP2 = ([Math]::Pow($RayonTerreMax,2))*([Math]::Pow([Math]::Sin($LatitudeRad),2))
$RayonTerreP3 = ([Math]::Pow($RayonTerreMin,2))*([Math]::Pow([Math]::Cos($LatitudeRad),2))
$RayonTerre = [Math]::Sqrt($RayonTerreP1/($RayonTerreP2+$RayonTerreP3))
$Altitude = [Math]::Sqrt([Math]::Pow($ECI_X,2)+[Math]::Pow($ECI_Y,2)+[Math]::Pow($ECI_Z,2)) - $RayonTerre

Write-host -BackgroundColor DarkGray -ForegroundColor Cyan "$Maintenant Z"
Write-host -BackgroundColor DarkGray -ForegroundColor yellow "ECI_X:$ECI_X km ECI_Y:$ECI_Y km ECI_Z:$ECI_Z km"
"Latitude:$Latitude N/S Longitude:$Longitude E/W Altitude:$Altitude km"

Thanks.

Latitude and longitude is WAY off

Latitude and longitude from calcSpherePoint is way off. Try it on the latest library version. Compared to websites like n2yo and heavens above, its extremely off

Add the brightness (magnitude) to the Pass details

Is your feature request related to a problem? Please describe.
Would it be possible to add the brightness (magnitude) to the Pass details?

Describe the solution you'd like

Below are some passes as found on Heavens-above:

image

for each pass we have the brightness (magnitude) value. It would be great if One_Sgp4 can provide the same information (it seems this info is currently missing).

Thanks!

calculate sun position

It would be great if there would be a function(s) to calculate sun and moon position (geodetic and Azim/Elev)

ArgumentException: Value does not fall within the expected range.

I'm attempting to run the example code in the repo with an updated TLE as seen below

Tle tleISS = ParserTLE.parseTle(
            "1 25544U 98067A   23080.70512120  .00015280  00000+0  28135-3 0  9998",
            "2 25544  51.6417  41.9472 0006129 116.4287 305.1642 15.49355675388224",
            "ISS 1");
EpochTime startTime = new EpochTime(DateTime.UtcNow);
EpochTime stopTime = new EpochTime(DateTime.UtcNow.AddSeconds(10));

I'm presented with the following error.

ArgumentException: Value does not fall within the expected range.
One_Sgp4.EpochTime.op_Subtraction (One_Sgp4.EpochTime e1, One_Sgp4.EpochTime e2) (at  Assets/Scripts/TLEsProcessing/One_Sgp4/time/EpochTime.cs:579)

The difference doesn't seem to make sense as the starting date should be smaller than the end date unless that's not the issue.
Thanks for your help.

One_Sgp4.SatFunctions.calcSatSubPoint possibly returning incorrect Longitude

Function "calcSatSubPoint" returning incorrect latitude in latest version 1.0.9. Workign correctly in earlier version 1.0.8.

To Reproduce

string str1 = "ISS (ZARYA)";
string str2 = "1 25544U 98067A   19355.61517352  .00000218  00000-0  11831-4 0  9992";
string str3 = "2 25544  51.6432 152.1290 0007831  58.9521  16.9775 15.50124818204334";
Tle tleISS = ParserTLE.parseTle(str2, str3, str1);
EpochTime startTime = new EpochTime(DateTime.UtcNow.AddHours(-5));
EpochTime earthStartTime = new EpochTime(DateTime.UtcNow.AddHours(-5));
EpochTime stopTime = new EpochTime(DateTime.UtcNow.AddHours(5));

One_Sgp4.Sgp4 sgp4Propagator = new Sgp4(tleISS, Sgp4.wgsConstant.WGS_84);
sgp4Propagator.runSgp4Cal(startTime, stopTime, 1);
List<One_Sgp4.Sgp4Data> resultDataList = new List<Sgp4Data>();
resultDataList = sgp4Propagator.getRestults();
foreach (var result in resultDataList)
{
One_Sgp4.Coordinate satOnGround = One_Sgp4.SatFunctions.calcSatSubPoint(earthStartTime,result, Sgp4.wgsConstant.WGS_84);
double longitude = satOnGround.getLongitude()
earthStartTime.addMinutes(1);
}

Error in One_Sgp4.ParserTLE.parseTle function

Describe the bug
I was using your library for a long time and it was working like a charm. Today I encounter an error in this function in my program, while I haven't change anything

To Reproduce

ln1="1 40069U 14037A   20316.10616772 -.00000018  00000+0  11185-4 0  9995"
ln2="2 40069  98.4875 347.9908 0005143 206.3045 153.7872 14.20677273329034"
satName="METEOR-M 2"
Dim tleData As Tle = ParserTLE.parseTle(ln1, ln2, satName)

This raise an exception :

System.IO.InvalidDataException
HResult=0x80131501
Message=Data contained parse error(s).
Source=One_Sgp4

StackTrace:
     at One_Sgp4.ParserTLE.parseTle(String tleLine1, String tleLine2, String tleName)
     This exception was originally thrown at this call stack:
     string.Substring(int, int)
     One_Sgp4.ParserTLE.parseTle(string, string, string)
Inner Exception 1:
     ArgumentOutOfRangeException: Length cannot be less than zero.
     Parameter name: length

Version:

  • Device: Desktop
  • OS: Windows 10
  • Version 1.0.12

Additional context
I have downloaded the tle data from here:
https://celestrak.com/NORAD/elements/weather.txt

the issue can also be reproduce with following data:
METEOR-M 2
1 40069U 14037A 20316.66959948 -.00000019 00000+0 10591-4 0 9992
2 40069 98.4874 348.5318 0005172 204.5397 155.5535 14.20677290329111

CalculatePasses result doesn't match Heavens-above.com results

Describe the bug
I'm using One_Sgp4 v1.0.11.
I'm trying to use CalculatePasses method to get sighting predictions for the ISS. I'm comparing the results returned by CalculatePasses with predictions obtained from Heavens-Above.com for the same location, same day, but I observe different results.

To Reproduce

  1. What data was used for the bug (e.g. TLE-Data, Date, Time ..)

TLE obtained from Celestrak for ISS on May 31st (https://celestrak.com/satcat/tle.php?CATNR=25544)

ISS (ZARYA)
1 25544U 98067A 20152.27581124 .00000174 00000-0 11188-4 0 9995
2 25544 51.6441 72.1703 0002261 13.9081 125.7010 15.49399407229398

  1. What function was called

CalculatePasses is called as below:

            var bSuccess = await TryGetTLESets();

            if (!bSuccess)
            {
                // tell user we couldn't fetch TLE or not found in local cache
                throw new FileNotFoundException();
            }

            var tleList = ParserTLE.ParseFile(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,
                                                            "stations.txt"));

            var tleISS = tleList.Find(x => x.getNoradID() == "25544");  // return null if not found, otherwise the TLE for ISS

            //Coordinate of an observer on Ground lat, long, height(in meters)
            One_Sgp4.Coordinate observer = new Coordinate(48.858093, 2.294694, 0);   // 48.858093, 2.294694  => Eiffel Tower

            //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), 10, 2, Sgp4.wgsConstant.WGS_84);

            Debug.WriteLine("START TIME:");

            foreach (var p in passes)
            {
                var pd = p.getPassDetailsAtStart();

                Debug.WriteLine(pd.ToString());
                
                
            }

  1. What was the result and output

Results observed for above code and TLE is:

START TIME:

18:44:36 : Elevation: 0.596397746612726°, Azimuth 286.501538004863°, Range 2299.30172721437km 
20:21:26 : Elevation: 0.581273626386928°, Azimuth 289.589556700608°, Range 2302.70192885187km 
21:58:46 : Elevation: 0.224917594272741°, Azimuth 275.738975381313°, Range 2339.95580465039km 
13:08:26 : Elevation: 0.0444936882516238°, Azimuth 173.462625055011°, Range 2340.306324557km 
14:42:56 : Elevation: 0.426040211060339°, Azimuth 223.5007745911°, Range 2302.44754914584km 
16:19:26 : Elevation: 0.331834095560812°, Azimuth 259.584712050285°, Range 2320.59706403633km 
17:56:26 : Elevation: 0.0955231688512556°, Azimuth 282.432782758386°, Range 2352.72291602485km 
19:33:26 : Elevation: 0.574601663417893°, Azimuth 290.262387553938°, Range 2302.94493966847km 
21:10:26 : Elevation: 0.305351401410957°, Azimuth 282.291634222747°, Range 2331.83059685543km 
12:22:26 : Elevation: 0.24334422268383°, Azimuth 148.617524370182°, Range 2320.39585586617km 
13:55:16 : Elevation: 0.197594926130708°, Azimuth 210.804526904679°, Range 2325.32322597625km 
15:31:26 : Elevation: 0.40181438101692°, Azimuth 250.205784968407°, Range 2310.49065301218km 
17:08:26 : Elevation: 0.313512743787331°, Azimuth 277.314123150284°, Range 2327.03545020543km 
  1. If result was not what you expected with what was is compared to and from where does this information come from

Results from heavens-above for same GPS location are:

image

Expected behavior
I would expect that the results match. However the pass for May 31st returned by heavens-above is not found by CalculatePasses

Version(please complete the following information):

  • Device: Desktop PC
  • OS: Windows 10
  • Version 1909

Question:
Am I using CalculatePasses incorrectly or is there a bug in this method?

thank you!

Doppler shift

First of all thank you for your great job.
would you please add a feature to calculate Doppler shift of satellites?
Meanwhile any suggestion on how can I do this, is appreciated.

Using this library in Unity

Hi! I am interested in using this library in Unity5.5.1, however it gives an issue:

The primary reference "One_Sgp4" could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v3.5,Profile=Unity Subset v3.5".

Just wondering is there anyway to use this library regardless of the difference in versions?

Add more properties to the Pass class

Is your feature request related to a problem? Please describe.
My App actually issues HTTP queries to heavens-above.com to get upcoming pass details. I'd like to use One_Sgp4 library instead to achieve the same goal with same pass details.

Describe the solution you'd like
Would it be possible to augment the Pass class (https://github.com/1manprojects/one_Sgp4/blob/master/One_Sgp4/Pass.cs) with the same details as in screenshot below (which comes from heavens-above.com) ?

image

Thanks!

longitude of SatSubPoint result is wrong compre with PyEphem's sat.sublong

        List<One_Sgp4.Tle> tles =One_Sgp4.ParserTLE.ParseFile("iridium.txt");

        var tle = tles.Where(t => t.getName().Contains("97")).ToArray()[0];
        One_Sgp4.Sgp4 sgp4Propagator = new One_Sgp4.Sgp4(tle, 1); 
        One_Sgp4.EpochTime startTime = new One_Sgp4.EpochTime(0, 0, 0, 2018, 4, 7);
        One_Sgp4.EpochTime stopTime = new One_Sgp4.EpochTime(0, 59, 0, 2018,4, 7);
        sgp4Propagator.runSgp4Cal(startTime, stopTime, 1);
        
        List<One_Sgp4.Sgp4Data> resultDataList = new List<One_Sgp4.Sgp4Data>();
        resultDataList = sgp4Propagator.getRestults();

        for (int i = 0; i < 59; i++)
        {
            One_Sgp4.EpochTime t = new One_Sgp4.EpochTime(0, i, 0, 2018, 4, 7);
            One_Sgp4.Coordinate c= One_Sgp4.SatFunctions.calcSatSubPoint(t, resultDataList[i], 1);
            //System.Diagnostics.Debug.WriteLine(t.toDateTime());
            System.Diagnostics.Debug.WriteLine("lat:{0} ,lon:{1}",c.getLatetude(), c.getLongitude());
        }

EpochTime.toDateTime() raises Exception when seconds round to 60

Using a TLE with a DayOfYear generating a time with 59,6... seconds does not return correct ToDateTime() value.

e.g. using
var x = new EpochTime(2017, 326.59305107);
var d = x.toDateTime();
raises an Exception.

  • Library Version 1.0.7

I already have a fix and will provide a pull request for it. I hope you will also accept my additional changes there ;-) .....

Error "Eccentricity is out of bounds"

Hi, I have tracked 9684 satellites and I got this error on 6 of them :
DateTime : 09/02/2023 14:29:03 (France)
Satellites : LEMUR 2 KOBYSZCZE, AEROCUBE 14A, FLOCK 3P 61, NACHOS-1, AEROCUBE 15A, DANTESAT
TLE-Data : JSON from Space-Track (07/02/2023 16h21 France)
Function : [One_Sgp4.SatFunctions]::getSatPositionAtTime
Error :

Exception lors de l'appel de « getSatPositionAtTime » avec « 3 » argument(s) : « LEMUR 2 KOBYSZCZE -Eccentricity is out of bounds
Nom du paramètre : Sgp4Calculation »
Au caractère D:\Samuel\Bureau\C2 FACTORY\Scripts\Space Vision 2\Space Vision 2.ps1:887 : 9
+         $DataECI = [One_Sgp4.SatFunctions]::getSatPositionAtTime($Par ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

image

  • Device: Desktop
  • OS: Windows 11 (the last build)
  • Language Powershell 5.1 and .NET

Wrong Date is diplayed for EpochTime ToString()

Describe the bug
EpochTime will show the wrong date after calling addDays(2);

To Reproduce
EpochTime startTime = new EpochTime(DateTime.UtcNow);
EpochTime endTime = new EpochTime(startTime);
endTime.addDays(2);

        Console.Out.WriteLine(startTime.getDateToString() + " " + startTime.ToString());
        Console.Out.WriteLine(endTime.getDateToString() + " " + endTime.ToString());

Expected behavior
The Date should be 2 days later for endTime but it shows the same as starttime

Version(please complete the following information):
Version 1.0.11

Duplicate List<> items from ParseFile

Describe the bug
When using ParserTLE.ParseFile the populated list has boat loads of duplicates that was not in the file.

To Reproduce
Please Provide the following information to reproduce the issue you have

  1. What data was used for the bug (e.g. TLE-Data, Date, Time ..)
  2. What function was called
    • ParserTLE.ParseFile
  3. What was the result and output
    • Correct data, but a crap ton and a half in duplicates.
  4. If result was not what you expected with what was is compared to and from where does this information come from
    • Not sure I understand the question.

Expected behavior
A single entry in the file, a single entry in the list. For example:

CALSPHERE 1             
1 00900U 64063C   20220.16857472  .00000188  00000-0  19181-3 0  9994
2 00900  90.1535  29.2002 0025171 263.1154 215.9264 13.73401236777412
CALSPHERE 2             
1 00902U 64063E   20219.90849093  .00000018  00000-0  13404-4 0  9991
2 00902  90.1630  31.8626 0017081 325.6007 199.1918 13.52685390566904

should produce a List<Tle> with two entries: one for NORAD ID 900 and the other for NORAD ID 902. It should not, however have 6 entries for ID 900 and 4 entries for 902.

Screenshots
(Context of the messages are the code below)
Debug Console

Version(please complete the following information):

  • Device: Desktop
  • OS: Window$
  • Version 10

Additional context

        private void StartSatelliteUpdates(object sender, FrameLoadEndEventArgs e)
        {
            browser.FrameLoadEnd -= StartSatelliteUpdates;
            string tmp = Path.GetTempFileName();
            Task tleUpdater = new Task(() => {
                Debug.WriteLine("Parsing...", "TLE DATA");
                List<Tle> parsed = ParserTLE.ParseFile(tmp);
                Debug.WriteLine("Cleaning up...", "TLE DATA");
                File.Delete(tmp);
                Debug.WriteLine("Filtering...", "TLE DATA");
                //this did not work, but it was worth the try :-/
                //List<Tle> tles = parsed.Distinct().ToList();
                while(true)
                {
                    foreach (Tle tle in tles)
                    {
                        foreach (Satellite sat in Constants.SATELLITES)
                        {
                        
                            if (sat.ID == tle.getNoradID())
                            {
                                Debug.WriteLine("Adding [" + tle.getNoradID() + "] " + tle.getName());
                                Satellite s = sat;
                                Sgp4 spg4prop = new Sgp4(tle, Sgp4.wgsConstant.WGS_84);
                                EpochTime now = new EpochTime(DateTime.UtcNow);
                                Sgp4Data data = SatFunctions.getSatPositionAtTime(tle, now, Sgp4.wgsConstant.WGS_84);
                                Coordinate c = SatFunctions.calcSatSubPoint(new EpochTime(DateTime.UtcNow), data, Sgp4.wgsConstant.WGS_84);
                                s.Latitude = (decimal)c.getLatitude();
                                s.Longitude = (decimal)c.getLongitude();
                                UpdateSatellite.Report(s);
                                break;
                            }
                            else Debug.WriteLine("Discarding [" + tle.getNoradID() + "] " + tle.getName());
                        }
                    }
                    Thread.Sleep(1000);
                }
            });
            WebClient cli = new WebClient();
            Debug.WriteLine("Downloading...", "TLE DATA");
            cli.DownloadFileCompleted += (object s, AsyncCompletedEventArgs ae) => { tleUpdater.Start(); };
            cli.DownloadFileAsync(new Uri("https://celestrak.com/NORAD/elements/active.txt"), tmp);
        }

how to get Argument of periapsis and Semi major axis?

Hi,

First thank you for the lib, its very useful!

Im trying to integrate it in my project,

but my simulator uses semi major axis and argument of periapsis to calculate orbits,

how can I get them from your tle object?

Or maybe how can I calculate them?

Thanks!

Inconsistencies with SatFunctions.CalculatePasses()

Describe the bug
Calling CalculatePasses(...) every 10 seconds produces a number of passes that fluctuates by 1 or 2.

To Reproduce
TLE:

NOAA 18
1 28654U 05018A   23120.55018578  .00000249  00000+0  15728-3 0  9996
2 28654  98.9107 195.1690 0014973 151.5076 208.6918 14.12924038924756

Calling it on a 10-second System.Timers.Timer via

var spgTle = ParserTLE.parseTle(tle.Line1, tle.Line2, tle.Name);
var passes = SatFunctions.CalculatePasses(observer, spgTle, new EpochTime(DateTime.Now), 10, 2);

Expected behavior
The number of passes is the same in a given 10-second time span.

Additional context
Observed passes.Count() fluctuate between 19 and 21. Seems like between these inconsistencies, the only thing that changes in the passes themselves is the seconds of the start/maxEl/end times. Confirmed that the only variable factor from the input is DateTime.Now, so seems like it could be some sort of rounding or parsing problems with the EpochTime (?). Tried turning the resolution up to 1 as well, with the same results. Obviously the number of passes in a given time period will fluctuate as the satellite completes orbits and time moves forward, but randomly increasing and decreasing every 10 seconds is a bit too frequent to be a coincidence😁

Unhandled exception error "Eccentricity is out of bounds"

Describe the bug
Crashing while running due to un-handeled exception error "Eccentricity is out of bounds". The TLE database is coming from celestrak.com (stations.txt). I dont expect there to be any issue with the Eccentricity values. Not sure what I'm doing incorrectly?

To Reproduce
Simply compile and run the following code:

`List tempSatList = null;
if (System.IO.File.Exists("stations.txt"))
{
tempSatList = ParserTLE.ParseFile("stations.txt");
}
EpochTime myTime = new EpochTime(DateTime.UtcNow);

foreach (var tleVar in tempSatList)
{
One_Sgp4.Sgp4 sgp4Propagator = new Sgp4(tleVar, Sgp4.wgsConstant.WGS_84);
sgp4Propagator.runSgp4Cal(myTime, myTime, 1);
var result = sgp4Propagator.getRestults()[0];
One_Sgp4.Coordinate satCoordinates = One_Sgp4.SatFunctions.calcSatSubPoint(myTime, result, Sgp4.wgsConstant.WGS_84);
logging.Comment(satCoordinates.getLatetude() + " : " + satCoordinates.getLongitude());
}`

Parameter name
Parameter name: Sgp4Calculation

Database link
http://celestrak.com/NORAD/elements/stations.txt

Expected behavior
The TLE details are correct. I expect the library to accept all stations in the database.

Version:

  • Version: 1.08

Exception Unhandled
System.ArgumentException
HResult=0x80070057
Message=ALTAIR PATHFINDER -Eccentricity is out of bounds
Parameter name: Sgp4Calculation
Source=One_Sgp4
StackTrace:
at One_Sgp4.Sgp4.calcSgp4()
at One_Sgp4.Sgp4.runSgp4Cal(EpochTime starttime, EpochTime stoptime, Double step)
at shr_parser_sharp.Controls.SatelliteControl.SatelliteControl_Load(Object sender, EventArgs e) in

calcSatSubPoint returns inaccurate position

Describe the bug
calcSatSubPoint returns inaccurate position

To Reproduce
I'm getting TLE for ISS (Norad Id 25544) from https://www.celestrak.com/NORAD/elements/stations.txt
I call calcSatSubPoint to get ISS position for a time.
I'm comparing today the ISS position calculated in my App using calcSatSubPoint function with http://www.esa.int/Our_Activities/Human_and_Robotic_Exploration/International_Space_Station/Where_is_the_International_Space_Station and I can see the ISS position differs significantly.

Here's a screenshot of my App (taken today 2/2/18 around 6:17pm French time)

image

Expected behavior
Here's a screenshot taken at same time (just a few seconds later) of the ESA link mentioned above

image

We can see the ISS position between both screenshots differs.

Version(please complete the following information):

  • Device: Desktop
  • OS: Windows 10 version 1809
  • Version 1.0.5 of One_Sgp4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.