New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cython 7 dec 15 vallado #38
Cython 7 dec 15 vallado #38
Conversation
io.py 1. Rename afspc_mode to opsmode, take a/i as input instead of True/False 2. Clarify which mean anomaly (no) is used, satrec.no variable renamed to satrec.no_kozai, internal updates to support name change 3. Make more internal variables available available to satrec propagation.py 1. Rename afspc_mode to opsmode, take a/i as input instead of True/False 2. Initialize whichconst variables internally once, make values accessible in satrec 3. delete unused variables in initl test.py 1. Replace deprecated assertRaisesRegexp with assertRaisesRegex Notes: - Confirmed SGP4-VER.TLE is still current - Confirmed unit tests pass with python -m unittest discover sgp4
Why return an array rather than a tuple? This now means that the cython and python version do not produce exactly the same output, nor does the cython version return data as specified in documentation. I don't have any strong feelings about the tuples vs arrays here but I do want the back ends to be consistent. |
Clear out numba and other unnecessary code.
An array lends itself to immediate usability in vector math operations (dot products, cross products, etc) which are more likely to be next steps than Python tuple-oriented operations. |
Updated test.py to handle deprecated assertRaisesRegexp for Python 2.6/2.7 |
I know that we have been carrying on conversations about this PR elsewhere, but to keep my thoughts straight I should also duplicate them here on the PR itself!
Maybe, contrary to my first instinct, we should indeed add a compiled version here with magic invisible fallback, but then provide a call from Python that would tell the user which version they were using, so they could check? In the meantime, I'll go look for all other issues and PRs touching this effort, to try to make sure I'm up to date on where they all stand, and to try to assure that I'm telling a consistent story in each one. |
@interplanetarychris — After reading through this PR, it looks to my eyes like the crucial updates to restore full compatibility with upstream Vallado SGP4 that are part of this pull request all landed as part of 55db21e, so I am going to close this PR for now on the assumption that the Cython code, while instructive while we contemplated approaches, is not the direction the project will be taking right now. If instead there are a few changes in this PR that you think should still be merged, please just comment so that I can re-read and look for them. Thanks again for pushing me to look at ways to get this library faster! |
Agreed - the direct call to the original CPP methods are better than the Cython approximations (without replicating all the code). There still may be reason to use Cython with the SGP4.CPP implementation, but I can build those off the main branch. |
I've made the changes for the updated 2015 Vallado version in PR #35 with Cython modifications introduced in PR #36
It is currently failing one unittest, but this is due to my choice to keep the change in spg4 which returns r,v as arrays instead of tuples. The numbers are correct, it's just a difference in ellipses vs brackets.
For my application (a call to sgp4init followed by 3-10 calls to sgp4) it results in about a 2x speedup on my platform (iMac running Mac OS X 10.4.6, with Python 3.7)
I invested a full day in trying to improve the Numba performance, including full declaration of all the variables in all the functions, and jitclass declaration for all the variables in the Satellite() class - however, I wasn't able to prevent it from falling back to object mode at compile time.