Skip to content

Commit 1b35b80

Browse files
authored
Fix wind drift (#89)
* added wind_drift parameter this allows for altering wind_drift_factor based on the parameter in the UI * updated whats new
1 parent 529cb33 commit 1b35b80

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

docs/whats_new.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
* Fixed bug so that horizontal diffusivity is now properly applied to model output.
6+
* Added `wind_drift` parameter which when False makes sure that `wind_drift_factor=0` so that wind drift is not on.
67

78
## 2.5.0 (March 9, 2026)
89

particle_tracking_manager/models/opendrift/config_opendrift.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,15 @@ class OceanDriftModelConfig(OpenDriftConfig):
438438
},
439439
)
440440

441+
wind_drift: bool = Field(
442+
default=True,
443+
description="If on, elements at surface are moved with a fraction, the wind draft factor, of the wind speed from the surface down to the wind drift depth.",
444+
title="Wind Drift",
445+
json_schema_extra={
446+
"ptm_level": 1,
447+
},
448+
)
449+
441450
wind_drift_depth: float = Field(
442451
default=0.1,
443452
description="The direct wind drift (windage) is linearly decreasing from the surface value (wind_drift_factor) until 0 at this depth.",
@@ -507,6 +516,14 @@ class OceanDriftModelConfig(OpenDriftConfig):
507516
},
508517
)
509518

519+
@model_validator(mode="after")
520+
def check_wind_drift(self) -> Self:
521+
"""If wind_drift is False, set wind_drift_factor to 0."""
522+
if not self.wind_drift:
523+
self.wind_drift_factor = 0
524+
logger.debug("Setting wind_drift_factor to 0 because wind_drift is False.")
525+
return self
526+
510527

511528
class OpenOilModelConfig(OceanDriftModelConfig):
512529
"""OpenOil model configuration for OpenDrift."""

tests/test_config_opendrift.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ def test_OceanDrift_init():
147147
)
148148

149149

150+
def test_OceanDrift_wind_drift():
151+
m = OceanDriftModelConfig(
152+
drift_model="OceanDrift",
153+
steps=1,
154+
wind_drift=False,
155+
)
156+
157+
assert m.wind_drift_factor == 0
158+
159+
m = OceanDriftModelConfig(
160+
drift_model="OceanDrift",
161+
steps=1,
162+
wind_drift=True,
163+
)
164+
165+
assert m.wind_drift_factor == 0.02
166+
167+
150168
def test_OceanDrift_parameters():
151169
"""Make sure OceanDrift-specific parameters are present."""
152170
m = OceanDriftModelConfig(drift_model="OceanDrift", steps=1)

0 commit comments

Comments
 (0)