parzivail / SGP.NET

C# SGP4 Satellite Prediction Library. Load satellites from TLEs, convert between coordinate systems and reference frames, observe satellites from ground stations, and more.
MIT License
33 stars 14 forks source link

FindNextAboveToBelowCrossingPoint fails to find the crossing #29

Open VE3NEA opened 4 months ago

VE3NEA commented 4 months ago

Under certain circumstances the elevation angle of a satellite gets stuck at some positive value, and FindNextAboveToBelowCrossingPoint finds the crossing only a few years in the future. This code reproduces the problem:

    public void ReproduceError()
    {
      var myLocation = new GeodeticCoordinate(Angle.FromDegrees(44), Angle.FromDegrees(-79), 270);
      var groundStation = new GroundStation(myLocation);

      string tle0 = "0 GOES 18";
      string tle1 = "1 51850U 22021A   24184.52757794  .00000099  00000-0  00000+0 0  9998";
      string tle2 = "2 51850   0.0386 165.9928 0000260 341.7596 186.2013  1.00270475  8635";

      var satellite = new Satellite(tle0, tle1, tle2);
      var start = DateTime.Parse("2024-07-02 21:57:20Z");
      var end = start.AddMinutes(60);

      var passes = groundStation.Observe(satellite, start, end, TimeSpan.FromSeconds(15));
      if (passes.Count > 0) Debug.WriteLine($"Pass end: {passes[0].End}");
    }

This code runs for about a minute and then prints:

Pass end: 2035-01-12 03:26:30
parzivail commented 4 months ago

Interesting, thanks for reporting it. I'll take a look.