From f8adb6525f700094edc1a2667bfac48f54a488cb Mon Sep 17 00:00:00 2001 From: Tom Dean Date: Wed, 23 Oct 2024 17:59:30 +0200 Subject: [PATCH] Fixes headwind formula --- pycontrails/models/ps_model/ps_grid.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pycontrails/models/ps_model/ps_grid.py b/pycontrails/models/ps_model/ps_grid.py index 1703735c..649e900d 100644 --- a/pycontrails/models/ps_model/ps_grid.py +++ b/pycontrails/models/ps_model/ps_grid.py @@ -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