Closed trufanov-nok closed 11 months ago
Or better, keeping in mind that the module has from numpy import ... fmod
to use fmod(-5.0*t, 1.0)
Also the fa %= tau
at https://github.com/skyfielders/python-skyfield/blob/master/skyfield/nutationlib.py#L189 will produce incorrect results. It should be replaced with fa = fmod(fa, tau)
As we discovered in the PR, this doesn't seem to affect Skyfield's results measurably, so for the moment I'm included to leave that code alone. Please do let me know if you find a case in which Skyfield returns an incorrect angle, though!
I was trying to debug my TEME<->ITRF conversion by comparing to skyfield results and found out a point there my results are starting to differ. It's here: https://github.com/skyfielders/python-skyfield/blob/master/skyfield/nutationlib.py#L177
In particular at
-5.0*t % 1.0
.I was surprised that modulo operation with negative value behaves weird in python. For example:
while I would expect
And that's how it would work in C with
fmod(-5.0*0.16322491910627326, 1.0)
.So I tried to find an article or another source for this method. And in SOFA's C codebase (http://iausofa.org/2021_0512_C/sofa_c-20210512.tar.gz) at
nut80.c::224
I found:I assume that C code was a source and then it was ported to python. In this case Skyfield has a bug because C
fmod(-5.0 * t, 1.0)
is not equivalent to python's-5.0*t % 1.0
.I don't know python lang but perhaps it should be?: