Skip to content

Commit

Permalink
Fixes headwind formula
Browse files Browse the repository at this point in the history
  • Loading branch information
trdean1 committed Oct 23, 2024
1 parent a1c42c4 commit f8adb65
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions pycontrails/models/ps_model/ps_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,14 +621,7 @@ def ps_nominal_optimize_mach(
if sin_a is None or cos_a is None:
msg = "Segment angles must be provide if wind data is specified"
raise ValueError(msg)
headwind = np.sqrt((northward_wind * cos_a) ** 2 + (eastward_wind * sin_a) ** 2)
# There's probably a better way to do this?
# Compute angle between wind and segment angle and set to (-pi, pi]
dth = np.arctan2(cos_a, sin_a) - np.arctan2(eastward_wind, northward_wind)
dth = ((dth + np.pi) % (2 * np.pi)) - np.pi
# Flip sign of wind if more than pi/2 part
sign = 2 * (np.abs(dth) > np.pi / 2) - 1
headwind *= sign
headwind = -(northward_wind * cos_a + eastward_wind * sin_a)
else:
headwind = 0.0 # type: ignore

Expand Down

0 comments on commit f8adb65

Please sign in to comment.