Skip to content

Commit 644788b

Browse files
reint-fischerreint-fischer
authored andcommitted
Revert "Merge remote-tracking branch 'upstream/v4-dev' into delayed-start"
This reverts commit 8110e85, reversing changes made to 6982925.
1 parent 8110e85 commit 644788b

4 files changed

Lines changed: 21 additions & 11 deletions

File tree

src/parcels/_core/field.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,20 @@ def eval(self, time: datetime, z, y, x, particles=None, applyConversion=True):
316316
w = self.W._interp_method(self.W, ti, position, tau, time, z, y, x)
317317
else:
318318
w = 0.0
319-
else:
320-
(u, v, w) = self._vector_interp_method(self, ti, position, tau, time, z, y, x)
321319

322-
if applyConversion:
323-
u = self.U.units.to_target(u, z, y, x)
324-
v = self.V.units.to_target(v, z, y, x)
325-
if "3D" in self.vector_type:
326-
w = self.W.units.to_target(w, z, y, x)
320+
if applyConversion:
321+
u = self.U.units.to_target(u, z, y, x)
322+
v = self.V.units.to_target(v, z, y, x)
323+
324+
else:
325+
(u, v, w) = self._vector_interp_method(self, ti, position, tau, time, z, y, x, applyConversion)
327326

328327
for vel in (u, v, w):
329328
_update_particle_states_interp_value(particles, vel)
330329

330+
if applyConversion and ("3D" in self.vector_type):
331+
w = self.W.units.to_target(w, z, y, x) if self.W else 0.0
332+
331333
if "3D" in self.vector_type:
332334
return (u, v, w)
333335
else:

src/parcels/interpolators.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def ZeroInterpolator_Vector(
5252
z: np.float32 | np.float64,
5353
y: np.float32 | np.float64,
5454
x: np.float32 | np.float64,
55+
applyConversion: bool,
5556
) -> np.float32 | np.float64:
5657
"""Template function used for the signature check of the interpolation methods for velocity fields."""
5758
return 0.0
@@ -157,6 +158,7 @@ def CGrid_Velocity(
157158
z: np.float32 | np.float64,
158159
y: np.float32 | np.float64,
159160
x: np.float32 | np.float64,
161+
applyConversion: bool,
160162
):
161163
"""
162164
Interpolation kernel for velocity fields on a C-Grid.
@@ -274,7 +276,11 @@ def CGrid_Velocity(
274276
U = (1 - xsi) * U0 + xsi * U1
275277
V = (1 - eta) * V0 + eta * V1
276278

277-
meshJac = 1852 * 60.0 if grid._mesh == "spherical" else 1
279+
deg2m = 1852 * 60.0
280+
if applyConversion:
281+
meshJac = (deg2m * deg2m * np.cos(np.deg2rad(y))) if grid._mesh == "spherical" else 1
282+
else:
283+
meshJac = deg2m if grid._mesh == "spherical" else 1
278284

279285
jac = i_u._compute_jacobian_determinant(py, px, eta, xsi) * meshJac
280286

@@ -527,6 +533,7 @@ def XFreeslip(
527533
z: np.float32 | np.float64,
528534
y: np.float32 | np.float64,
529535
x: np.float32 | np.float64,
536+
applyConversion: bool,
530537
):
531538
"""Free-slip boundary condition interpolation for velocity fields."""
532539
return _Spatialslip(vectorfield, ti, position, tau, t, z, y, x, a=1.0, b=0.0)
@@ -541,6 +548,7 @@ def XPartialslip(
541548
z: np.float32 | np.float64,
542549
y: np.float32 | np.float64,
543550
x: np.float32 | np.float64,
551+
applyConversion: bool,
544552
):
545553
"""Partial-slip boundary condition interpolation for velocity fields."""
546554
return _Spatialslip(vectorfield, ti, position, tau, t, z, y, x, a=0.5, b=0.5)

tests/test_advection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def test_nemo_curvilinear_fieldset():
457457
U = parcels.Field("U", ds["U"], grid)
458458
V = parcels.Field("V", ds["V"], grid)
459459
U.units = parcels.GeographicPolar()
460-
V.units = parcels.GeographicPolar() # U and V need GoegraphicPolar for C-Grid interpolation to work correctly
460+
V.units = parcels.Geographic()
461461
UV = parcels.VectorField("UV", U, V, vector_interp_method=CGrid_Velocity)
462462
fieldset = parcels.FieldSet([U, V, UV])
463463

@@ -543,7 +543,7 @@ def test_nemo_3D_curvilinear_fieldset(method):
543543
V = parcels.Field("V", ds["V"], grid)
544544
W = parcels.Field("W", ds["W"], grid)
545545
U.units = parcels.GeographicPolar()
546-
V.units = parcels.GeographicPolar() # U and V need GoegraphicPolar for C-Grid interpolation to work correctly
546+
V.units = parcels.Geographic()
547547
UV = parcels.VectorField("UV", U, V, vector_interp_method=CGrid_Velocity)
548548
UVW = parcels.VectorField("UVW", U, V, W, vector_interp_method=CGrid_Velocity)
549549
fieldset = parcels.FieldSet([U, V, W, UV, UVW])

tests/test_field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def test_vectorfield_invalid_interpolator():
159159
ds = datasets_structured["ds_2d_left"]
160160
grid = XGrid.from_dataset(ds)
161161

162-
def invalid_interpolator_wrong_signature(self, ti, position, tau, t, z, y, invalid):
162+
def invalid_interpolator_wrong_signature(self, ti, position, tau, t, z, y, applyConversion, invalid):
163163
return 0.0
164164

165165
# Create component fields

0 commit comments

Comments
 (0)