cosinekitty/astronomy

JS VectorObserver / inverse_terra sometimes fails to converge

Opened this issue · 3 comments

There is a possible heisenbug with VectorObserver().
When running the following loop, I end up with the error Uncaught inverse_terra failed to converge (for the value ts=1717780096005).

const body = Astronomy.Body.Sun
for (let ts = 1717780096000; ts <= 1717780096200; ts++) {
   var date = new Date(ts);
   var vect = Astronomy.GeoVector(body, date, true)
   console.log('ts, date, vector', ts, date.valueOf(), vect)
   var point = Astronomy.VectorObserver(vect)
   console.log('point', point)
   console.log('*')
}

However, when I change the starting point of the loop, say from 1717780096000 to 1717780096001, the program falls in error later in the loop. Is anyone able to reproduce this error ?

Thank you for your bug report! I have confirmed this is a real problem. I am investigating, and will report back here when I have an update.

Here is a stack trace using unminified code:

$ node --trace-uncaught test vecobs

/home/don/github/astronomy/source/js/astronomy.js:1942
                throw `inverse_terra failed to converge.`;
                ^
inverse_terra failed to converge.
Thrown at:
    at inverse_terra (/home/don/github/astronomy/source/js/astronomy.js:1942:17)
    at VectorObserver (/home/don/github/astronomy/source/js/astronomy.js:2700:12)
    at VectorObserverTest (/home/don/github/astronomy/generate/test.js:2857:30)
    at main (/home/don/github/astronomy/generate/test.js:3719:16)
    at /home/don/github/astronomy/generate/test.js:3727:14
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at executeUserEntryPoint (node:internal/modules/run_main:86:12)

Node.js v18.18.0

This commit was not supposed to close the issue. Re-opening now, because there are more changes coming.