Linear interpolation is theoretically wrong for directions in time series output
Summary
For TIME SERIES OUTPUT, linear interpolation is used to determine the values at the output locations. However linear interpolation is not theoretically valid for directional values (the most important ones I can think of are mean and peak wave direction in TOMAWAC). I guess the same may happen in case you export flow direction in TELEMAC-2D and TELEMAC-3D. @chi-tuan.pham , are there more variables where this issue might occur?. The correct way of interpolating this is: -separately interpolate SIN and COS of the direction -recalculate the direction using ATAN2 function
This bug may lead to wrong directions (180 degree off in case you interpolate between 359 and 1 degree directions), but I have not yet encountered the issue in practice.
Note that for T2D, T3D, the corrcet
Environment
- Operating System: Windows/Linux/MacOS
- TELEMAC version: V8P5R0
Steps to reproduce
N/A
N/A
...
What is the current bug behaviour?
See above, there is theoretical possibility that directions are worng.
What is the expected correct behaviour?
Relevant logs and/or screenshots
...
Possible fixes
Add a separate interpolation for directional variables. Add an Boolean array, which specifies whether it is a direction or not for each output variable. An issue to check is whether different conventions (cartesian vs nautical, degrees vs radians) have to be taken into account. In that case, an extra input parameters is needed specifying the convention(s).