Skip to content

Fix arcsin domain error in get_apparent_wind by clamping to [-1,1]#176

Open
RitikaSen27 wants to merge 1 commit into52North:mainfrom
RitikaSen27:fix-arcsin-domain
Open

Fix arcsin domain error in get_apparent_wind by clamping to [-1,1]#176
RitikaSen27 wants to merge 1 commit into52North:mainfrom
RitikaSen27:fix-arcsin-domain

Conversation

@RitikaSen27
Copy link
Copy Markdown

@RitikaSen27 RitikaSen27 commented Mar 15, 2026

Summary

Fix numerical domain error in get_apparent_wind() where np.arcsin() could receive values outside the valid range [-1, 1].

Problem

Due to floating-point rounding, arg_arcsin can occasionally exceed the valid domain slightly. The current implementation clamps only the upper bound (>1) but does not handle values below -1.

This can cause np.arcsin() to return NaN, which may propagate into downstream route calculations.

Fix

Clamp the argument of np.arcsin() to the full valid range [-1, 1] while keeping the existing rounding tolerance checks.

Impact

Prevents NaN propagation in apparent wind angle calculations and improves numerical stability.

PR Checklist:

In the context of this PR, I:

Please consider that PRs which do not meet the requirements specified in the checklist will not be evaluated. Also, PRs with no activities will be closed after a reasonable amount of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants