-
Notifications
You must be signed in to change notification settings - Fork 156
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
Fix for a corner-case numerical problem and corresponding unit test. #181
base: master
Are you sure you want to change the base?
Fix for a corner-case numerical problem and corresponding unit test. #181
Conversation
tests/test_adsb.py
Outdated
lat_ref = 30.508474576271183 # Close to (360.0/59.0)*5 | ||
lon_ref = 7.2*5.0+3e-15 | ||
pos = adsb.airborne_position_with_ref( | ||
"8D06A15358BF17FF7D4A84", lat_ref, lon_ref |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct message here (with CRC) would be 8d06a15358bf17ff7d4a84b47b95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. I added the CRC to the message.
Thanks for pointing that out! |
You are right, it's the same situation. I just applied the same fix there. In general, given the odd behavior of the % operator, I would replace it everywhere by its definition:
I'd like to know more about how the % operator is implemented in Python to understand where the numerical error is coming from. |
Python's % operator is mostly a call to the
|
Yes nice comment. We should look into more occurrences of calculations of j and m in this file. FYI I did the same in my Rust version following your comment (current version here but opened issue and PR accordingly) and it seems the modulo in Rust behaves differently but has a similar issue. |
Thank you, @EdFuentetaja. Awesome bug fix! we will fix the surface position functions too. |
Thank you for this excellent library.
I noticed this problem decoding some ADS-B messages. The local airborne decoding failed is some particular cases.
There seems to be some oddities with the Python modulus operator. E.g.:
Checking the standard (1090 MOPS, Vol.1 DO-260C), section 1.7.5 in Appendix A, shows an equivalent and simpler expression that doesn't require use of a modulus function. I think this should be the preferred approach since it's more accurate and requires less computations.