diff --git a/WeatherRoutingTool/ship/direct_power_boat.py b/WeatherRoutingTool/ship/direct_power_boat.py index 7a87ac4..668ff8c 100644 --- a/WeatherRoutingTool/ship/direct_power_boat.py +++ b/WeatherRoutingTool/ship/direct_power_boat.py @@ -230,12 +230,15 @@ def get_apparent_wind(self, true_wind_speed, true_wind_angle): arg_arcsin = true_wind_speed[iang] * np.sin(np.radians(true_wind_angle[iang])) / apparent_wind_speed[ iang] * u.radian - # catch it if argument of arcsin is > 1 due to rounding issues but make sure to apply this only for + # catch it if argument of arcsin is > 1 and arcsin is < -1 due to rounding issues but make sure to apply this only for # rounding issues 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 + elif (diff_to_minus_one := arg_arcsin + 1 * u.radian) < 0: + assert abs(diff_to_minus_one) < 0.000001 * u.radian + arg_arcsin = -1 * u.radian if apparent_wind_speed[iang] > 0: apparent_wind_angle[iang] = np.arcsin(arg_arcsin.value) * u.radian