-
Notifications
You must be signed in to change notification settings - Fork 112
Bug: arcsin lower bound not clamped in get_apparent_wind(), causes silent NaN #170
Description
THE DESCRIPTION
In direct_power_boat.py , the method get_apparent_wind() (/WeatherRoutingTool/ship/direct_power_boat.py) computes np.arcsin() for apparent_wind_angle[iang] using the arg_arcsine as the argument.
But due to the floating-point rounding , the value of the arg_arcsin can land slightly outside its range --> [-1 ,1].
This can be rectified using clamping the value back into the bounds.
But the issue is that only the upper bound is clamped and not the lower bound.
THE EFFECTS OF THIS ERROR ARE :-
--> np.arcsin() returns NaN with no exception, silently corrupting apparent_wind_angle and all values that depend on it.
--> A single NaN segment can affect any aggregation (sum/average) across the entire route.
-->If NaN is absorbed as 0 in numpy operations, fuel consumption is silently underestimated.
-->Route comparisons built on corrupted estimates can select a worst route as optimal.
-->hard to debug.
-->Exported CSVs or JSON logs containing NaN break downstream data pipelines and monitoring tools.
THE CODE WHICH HAS THE ERROR IS :-
diff_to_one = arg_arcsin - 1 * u.radian
if diff_to_one > 0:
assert diff_to_one < 0.000001 * u.radian
arg_arcsin = 1 * u.radian```