Skip to content

Commit 39e2b1b

Browse files
Testing the removal of applyConversion in VectorField API
1 parent ca4817b commit 39e2b1b

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

parcels/_core/field.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,13 @@ def eval(self, time: datetime, z, y, x, particles=None, applyConversion=True):
318318
v = self.V.units.to_target(v, z, y, x)
319319

320320
else:
321-
(u, v, w) = self._vector_interp_method(self, ti, position, tau, time, z, y, x, applyConversion)
321+
(u, v, w) = self._vector_interp_method(self, ti, position, tau, time, z, y, x)
322+
if applyConversion and self.grid._mesh == "spherical":
323+
deg2m = 1852 * 60.0
324+
meshJac = deg2m * deg2m * np.cos(np.deg2rad(y))
325+
u = u / meshJac
326+
v = v / meshJac
327+
print(u, v)
322328

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

parcels/interpolators.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def ZeroInterpolator_Vector(
5252
z: np.float32 | np.float64,
5353
y: np.float32 | np.float64,
5454
x: np.float32 | np.float64,
55-
applyConversion: bool,
5655
) -> np.float32 | np.float64:
5756
"""Template function used for the signature check of the interpolation methods for velocity fields."""
5857
return 0.0
@@ -158,7 +157,6 @@ def CGrid_Velocity(
158157
z: np.float32 | np.float64,
159158
y: np.float32 | np.float64,
160159
x: np.float32 | np.float64,
161-
applyConversion: bool,
162160
):
163161
"""
164162
Interpolation kernel for velocity fields on a C-Grid.
@@ -277,10 +275,7 @@ def CGrid_Velocity(
277275
V = (1 - eta) * V0 + eta * V1
278276

279277
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
278+
meshJac = deg2m if grid._mesh == "spherical" else 1
284279

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

@@ -533,7 +528,6 @@ def XFreeslip(
533528
z: np.float32 | np.float64,
534529
y: np.float32 | np.float64,
535530
x: np.float32 | np.float64,
536-
applyConversion: bool,
537531
):
538532
"""Free-slip boundary condition interpolation for velocity fields."""
539533
return _Spatialslip(vectorfield, ti, position, tau, t, z, y, x, a=1.0, b=0.0)
@@ -548,7 +542,6 @@ def XPartialslip(
548542
z: np.float32 | np.float64,
549543
y: np.float32 | np.float64,
550544
x: np.float32 | np.float64,
551-
applyConversion: bool,
552545
):
553546
"""Partial-slip boundary condition interpolation for velocity fields."""
554547
return _Spatialslip(vectorfield, ti, position, tau, t, z, y, x, a=0.5, b=0.5)

tests/test_field.py

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

132-
def invalid_interpolator_wrong_signature(self, ti, position, tau, t, z, y, applyConversion, invalid):
132+
def invalid_interpolator_wrong_signature(self, ti, position, tau, t, z, y, invalid):
133133
return 0.0
134134

135135
# Create component fields

0 commit comments

Comments
 (0)