Closed Bernmeister closed 2 years ago
Searching for the words "Near-parabolic" in this repository will get you close—to within a page or two of the error message. But to search for the error message itself, ask GitHub for the phrase nNear-parabolic
and it will jump right to it:
Alas, I guess that GitHub search doesn't understand that \n
isn't part of the words that follow!
It is indeed a bit awkward that the underlying C code is talking directly to the user rather than raising the issue where Python can see it. Let's trace: after printing the message, vrc()
returns -1
, which is detected in the caller obj_elliptical()
and triggers a single line of code:
It looks like it's setting a flag I've never heard of. Let's look for its definition. Here it is:
/* mark an object as circum calculation failed */
#define NOCIRCUM FUSER7
Well, then. I wonder if PyEphem should be checking that flag every time it calls obj_cir()
? I guess I'll go add a check for it, and see if the tests still pass!
@Bernmeister — As you'll see in the commit shown just above, I have removed the old printed warning from the underlying C library, and have instead added detection of the error flag and raised an exception for this circumstance. If you get the chance to try it out with a local install of the development version, I'll be interested to hear whether the change fixes things on your end too!
To install the development version of this project, run:
pip install -U https://github.com/brandon-rhodes/pyephem/archive/master.zip
Ran the test script and got:
Traceback (most recent call last):
File "test.py", line 18, in <module>
print( "All", body.name, str( body.az ), str( body.alt ), str( body.ra ), str( body.dec ), str( body.mag ) )
RuntimeError: cannot compute the body's position at 2022/7/16 03:36:45 with any accuracy because its orbit is nearly parabolic and it is very far from the Sun
Winner winner, chicken dinner!
Thank you @brandon-rhodes
One point: Running sudo pip3 install -U https://github.com/brandon-rhodes/pyephem/archive/master.zip
and then running the test script and gave the old/original error. It seems (and I'm guessing here) the ephem
version I had installed of 4.1.3
and the version I just tested against are the same and so pip
didn't actually overwrite despite downloading. So I did sudo pip3 uninstall ephem
and then did the install and bingo.
When running this test code:
I get the following warning:
I searched for the warning text on both the
PyEphem
andXEphem
sites but no such luck (I also added searching.h
files to no avail.In the data line,
e = 0.999725
, the eccentricity, is very close to1.0
. From the conversion tool, line83
, the eccentricity should bep
for parabolic, note
for elliptical, but that's a data issue, which is ultimately and, correctly I presume, tripping the warning.Now that I know the warning exists, I can preemptively do something like:
Is it possible to catch this warning?