shashwatak / satellite-js

Modular set of functions for SGP4 and SDP4 propagation of TLEs.
MIT License
912 stars 145 forks source link

Efficient way to get passes for a given coordinate on the Earth and a satellite #27

Closed ghost closed 5 years ago

ghost commented 7 years ago

Is there any built in method that will give me pass information, given a point on the Earth and a satellite object? Currently, I'm looping through from now until a week from now, 30 seconds at a time, checking the lookAngle elevation against a minimum angle.

shashwatak commented 7 years ago

I do not have a helper function that does that, but if you would like to make a pull request to include something useful like that (or other useful helper utilities you might have), I'd be happy to look over them and see if I can include them :)

fpfaffendorf commented 6 years ago

@laptopdude90 I'm facing the same challenge. Did you find or develop a better way ?

ghost commented 6 years ago

@fpfaffendorf No, but I came up with an idea in theory:

Get the angle for two times, far apart, but less than an orbit period. I have a feeling they follow a sinusoidal trend (Not tested) so you could use that to narrow it down a lot, and then find the exact values and verify.

fpfaffendorf commented 6 years ago

@laptopdude90 Thanks for your response. That's an interesting idea that might save some CPU. Specially for LEO satellites. I think that most satellite prediction software use different formulas to find the rise, transit and set times of a satellite instead of running the math for each instant. I've done that in the past for solar system objects and again, there were formulas. It wasn't necessary to loop. Best,

christianreyes commented 6 years ago

I use this: https://github.com/nsat/jspredict

thkruz commented 6 years ago

jspredict looks very handy, but it still relies on looping through at a specified interval.

What I have done to increase performance is throw a binary flag each iteration if the object is in view and if it is false, then check if it was true last iteration (determine if the object just left field of view).

If the object has just left field of view, I skip a number of iterations equal to 3/4th the period of the object (no way it is in view on the other side of the earth).

Example:

At 1200z the ISS comes into field of view. I check at 1201z, 1202z, 1203z and 1204z and it is still in view. At 1205z it is out of view, so instead of adding 60s, I add ~67 minutes (75% of its 90 minute orbital period) and then continue iterating at 60s intervals.

Since I often want 1s intervals this can save me hundreds of thousands of iterations.

thkruz commented 5 years ago

This can probably be closed.