araujolma / SOAR

7 stars 5 forks source link

Weird integration error with topocentric coordinate #88

Open araujolma opened 5 years ago

araujolma commented 5 years ago

While trying new stuff in the naive module, I found out there was a huge error integrating the Z coordinate (topocentric), around 50% the value obtained by decomposing altitude with range angle. It turned out to be a rather serious error setting dt variable wrong. After fixing this, the error became much smaller, but still large enough to be uncomfortable.

I made many tests of the integration methods, the unpacking methods, even tried messing with the N variable to check the effects of time grid refinement, but the error persists (~3%), and does not seem to change with N. For some reason, though, the X coordinate, which is integrated just as Z, with the same methods and the same refinement, has a much, much smaller error (~0.005%).

Finally, I gave up and replaced the X and Y integrations, which took place after the range angle (sigma) integration, for simple geometrical decompositions involving the radial distance and Earth radius: X = (R+h) sin(sigma) Z = (R+h) cos(sigma) - R

This is actually much more efficient than doing the integration, but I am seriously worried that this persistent error is actually a side effect of a bigger problem, possibly a coding or math mistake. Please help me figure this out!