Skip to content

Commit 2cbb03f

Browse files
committed
Update Stokes kernel to only sample Stokes_U and Stokes_V if they are going to be applied.
1 parent 0224fa7 commit 2cbb03f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

plasticparcels/kernels.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ def StokesDrift(particle, fieldset, time):
3939
[1] Breivik (2016) - https://doi.org/10.1016/j.ocemod.2016.01.005
4040
4141
"""
42-
# Sample the U / V components of Stokes drift
43-
stokes_U = fieldset.Stokes_U[time, particle.depth, particle.lat, particle.lon]
44-
stokes_V = fieldset.Stokes_V[time, particle.depth, particle.lat, particle.lon]
45-
4642
# Sample the peak wave period
4743
T_p = fieldset.wave_Tp[time, particle.depth, particle.lat, particle.lon]
4844

@@ -51,6 +47,10 @@ def StokesDrift(particle, fieldset, time):
5147

5248
# Only compute displacements if the peak wave period is large enough and the particle is in the water
5349
if T_p > 1E-14 and particle.depth < local_bathymetry:
50+
# Sample the U / V components of Stokes drift
51+
stokes_U = fieldset.Stokes_U[time, particle.depth, particle.lat, particle.lon]
52+
stokes_V = fieldset.Stokes_V[time, particle.depth, particle.lat, particle.lon]
53+
5454
# Peak wave frequency
5555
omega_p = 2. * math.pi / T_p
5656

0 commit comments

Comments
 (0)