davidcalhoun / tle.js

🛰️ Satellite TLE tools in JavaScript: get lat/lon of satellites, get look angles, plot orbit lines, extract individual TLE elements, etc
MIT License
142 stars 28 forks source link

getGroundTracks returning strange values randomly; sometimes tracks equal each other or are completely wrong #20

Closed JeanneKahn closed 3 years ago

JeanneKahn commented 3 years ago

Say I use the following code to get a ground track and print the result:

const satInfo = await getGroundTracks({
      tle: satTLE,
      stepMS: 10000,
      isLngLatFormat: false
    })
console.log(satInfo[0][550]) // Choosing 550 as the index to be consistent
console.log(satInfo[1][550])
console.log(satInfo[2][550])

Sometimes, the results will make sense in that each array has different values, like this:

image

And the satellite's current position (using getLatLngObj()) on a map will lie on ground track [1].

image

But quite often, for no discernible reason (after refreshing or whatever), some of the arrays will be equal to each other.

image

And the satellite's position will no longer lie on the plotted line for that orbit!

image

And sometimes, the values will be completely off everywhere:

image

Changing the startTimeMS does not fix this; nor does changing the TLE, or changing stepMS. I have a hunch that this may be due to something with inclined orbits (TLEs with higher inclinations having more problems) but I have no real way to confirm this because I can't replicate the conditions that explicitly cause it to happen.

JeanneKahn commented 3 years ago

Again after more investigation I believe this is something to do with inclination in orbits - perhaps some trig or division going wrong?

JeanneKahn commented 3 years ago

More investigation - this error may not be happening when getting a single orbit track from getOrbitTrack(), which suggests a problem perhaps with the antimeridian function or something to do with time in general @davidcalhoun ?

davidcalhoun commented 3 years ago

Thanks for the heads up, I'll take a look when I can. The underlying SGP4 library satellite.js definitely has problems with some types of TLEs.

If possible, could you share the TLE and some input times that reproduce this error?

JeanneKahn commented 3 years ago

@davidcalhoun I got these TLEs via https://tle.ivanstanojevic.me/; I tried a bunch until I saw satellites that presented errors, and from that, satellites that shared almost similar orbits.

AII-BRAVO
1 48270U 21034C 21124.53276317 .00000342 00000-0 45565-4 0 9993 2 48270 97.7860 200.0737 0003406 358.5519 1.5688 14.85661284 809

PROXIMA 2 1 43696U 18088G 21124.58637862 .00001563 00000-0 64741-4 0 9999 2 43696 85.0352 224.3224 0018986 174.8560 185.2882 15.22846619137699

IRIDIUM 100
1 42956U 17061B 21124.43823099 .00000102 00000-0 29484-4 0 9993 2 42956 86.3949 86.5825 0002211 84.7810 275.3638 14.34216227186804

Timestamps (using Date().getTime())

(AII-BRAVO never experienced an error)

davidcalhoun commented 3 years ago

Thank you for the details, this helps a lot! Will investigate when I get a chance.

davidcalhoun commented 3 years ago

Thank you again, the extra info was super helpful to track this down. This is now fixed in 4.2.12