skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.43k stars 213 forks source link

Set a deorbit flag? #375

Closed craeftsmith closed 4 years ago

craeftsmith commented 4 years ago

I am not completely sure that I have correctly diagnosed this behavior, but assuming I did...

I am checking to see which satellites are above the horizon at a place. Here is a snippet

object = ephem.readtle(row[0],row[1],row[2]) object.compute(place) if object.neverup == False and object.alt > 0:

Sometimes this crashes with the error: RuntimeError: error computing rise, transit, and set circumstances and it says the error occurs in the if statement. I think that what is happening is that it is trying to propagate an orbit past reentry, i.e., the satellite orbit intersected with the Earth. It would be cool if instead of crashing, a flag gets set instead. Something like: object.deorbit N.B. I don't understand why the crash occurs in the if statement. I would have thought that it would crash in object.compute().
brandon-rhodes commented 4 years ago

First, a quick double-check: is the error coming from Skyfield, or from another library? Could you share the full traceback? Thanks!

craeftsmith commented 4 years ago

Oh shoot... It's in Ephem not Skyfield. Sorry about that. Here is the traceback: Traceback (most recent call last): File "./sat_visible.py", line 56, in if object.neverup == False and object.alt > 0: RuntimeError: error computing rise, transit, and set circumstances

brandon-rhodes commented 4 years ago

My guess is that it would be difficult to improve that situation in PyEphem, because the underlying C library raises an error there and user code by this point probably expects it. I recommend catching the exception.

It's raised in that line because PyEphem tries to be efficient by computing things lazily, only when they're asked for, instead of when compute() is called. It was a pretty poor design, I admit!