Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/parcels/_core/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,20 +316,18 @@ def eval(self, time: datetime, z, y, x, particles=None, applyConversion=True):
w = self.W._interp_method(self.W, ti, position, tau, time, z, y, x)
else:
w = 0.0

if applyConversion:
u = self.U.units.to_target(u, z, y, x)
v = self.V.units.to_target(v, z, y, x)

else:
(u, v, w) = self._vector_interp_method(self, ti, position, tau, time, z, y, x, applyConversion)
(u, v, w) = self._vector_interp_method(self, ti, position, tau, time, z, y, x)

if applyConversion:
u = self.U.units.to_target(u, z, y, x)
v = self.V.units.to_target(v, z, y, x)
if "3D" in self.vector_type:
w = self.W.units.to_target(w, z, y, x)

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

if applyConversion and ("3D" in self.vector_type):
w = self.W.units.to_target(w, z, y, x) if self.W else 0.0

if "3D" in self.vector_type:
return (u, v, w)
else:
Expand Down
10 changes: 1 addition & 9 deletions src/parcels/interpolators.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def ZeroInterpolator_Vector(
z: np.float32 | np.float64,
y: np.float32 | np.float64,
x: np.float32 | np.float64,
applyConversion: bool,
) -> np.float32 | np.float64:
"""Template function used for the signature check of the interpolation methods for velocity fields."""
return 0.0
Expand Down Expand Up @@ -158,7 +157,6 @@ def CGrid_Velocity(
z: np.float32 | np.float64,
y: np.float32 | np.float64,
x: np.float32 | np.float64,
applyConversion: bool,
):
"""
Interpolation kernel for velocity fields on a C-Grid.
Expand Down Expand Up @@ -276,11 +274,7 @@ def CGrid_Velocity(
U = (1 - xsi) * U0 + xsi * U1
V = (1 - eta) * V0 + eta * V1

deg2m = 1852 * 60.0
if applyConversion:
meshJac = (deg2m * deg2m * np.cos(np.deg2rad(y))) if grid._mesh == "spherical" else 1
else:
meshJac = deg2m if grid._mesh == "spherical" else 1
meshJac = 1852 * 60.0 if grid._mesh == "spherical" else 1

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

Expand Down Expand Up @@ -533,7 +527,6 @@ def XFreeslip(
z: np.float32 | np.float64,
y: np.float32 | np.float64,
x: np.float32 | np.float64,
applyConversion: bool,
):
"""Free-slip boundary condition interpolation for velocity fields."""
return _Spatialslip(vectorfield, ti, position, tau, t, z, y, x, a=1.0, b=0.0)
Expand All @@ -548,7 +541,6 @@ def XPartialslip(
z: np.float32 | np.float64,
y: np.float32 | np.float64,
x: np.float32 | np.float64,
applyConversion: bool,
):
"""Partial-slip boundary condition interpolation for velocity fields."""
return _Spatialslip(vectorfield, ti, position, tau, t, z, y, x, a=0.5, b=0.5)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_advection.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def test_nemo_curvilinear_fieldset():
U = parcels.Field("U", ds["U"], grid)
V = parcels.Field("V", ds["V"], grid)
U.units = parcels.GeographicPolar()
V.units = parcels.Geographic()
V.units = parcels.GeographicPolar() # U and V need GoegraphicPolar for C-Grid interpolation to work correctly
UV = parcels.VectorField("UV", U, V, vector_interp_method=CGrid_Velocity)
fieldset = parcels.FieldSet([U, V, UV])

Expand Down Expand Up @@ -543,7 +543,7 @@ def test_nemo_3D_curvilinear_fieldset(method):
V = parcels.Field("V", ds["V"], grid)
W = parcels.Field("W", ds["W"], grid)
U.units = parcels.GeographicPolar()
V.units = parcels.Geographic()
V.units = parcels.GeographicPolar() # U and V need GoegraphicPolar for C-Grid interpolation to work correctly
UV = parcels.VectorField("UV", U, V, vector_interp_method=CGrid_Velocity)
UVW = parcels.VectorField("UVW", U, V, W, vector_interp_method=CGrid_Velocity)
fieldset = parcels.FieldSet([U, V, W, UV, UVW])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_vectorfield_invalid_interpolator():
ds = datasets_structured["ds_2d_left"]
grid = XGrid.from_dataset(ds)

def invalid_interpolator_wrong_signature(self, ti, position, tau, t, z, y, applyConversion, invalid):
def invalid_interpolator_wrong_signature(self, ti, position, tau, t, z, y, invalid):
return 0.0

# Create component fields
Expand Down