Skip to content

Commit 76db3a2

Browse files
Fixing unit conversion for non-Cgrids
Temporarily, as #2461 will move this unit conversion to the vector-interpolators
1 parent bd2c626 commit 76db3a2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/parcels/_core/field.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,23 @@ def eval(self, time: datetime, z, y, x, particles=None, apply_conversion=True):
330330
if self._vector_interp_method is None:
331331
u = self.U._interp_method(particle_positions, grid_positions, self.U)
332332
v = self.V._interp_method(particle_positions, grid_positions, self.V)
333+
334+
if apply_conversion and self.U.grid._mesh == "spherical":
335+
u /= 1852 * 60.0 * np.cos(np.deg2rad(y))
336+
v /= 1852 * 60.0
337+
333338
if "3D" in self.vector_type:
334339
w = self.W._interp_method(particle_positions, grid_positions, self.W)
335340
else:
336341
w = 0.0
337342
else:
338343
(u, v, w) = self._vector_interp_method(particle_positions, grid_positions, self)
339344

340-
if apply_conversion:
341-
if self.U.grid._mesh == "spherical":
342-
meshJac = 1852 * 60.0 * np.cos(np.deg2rad(y))
343-
u = u / meshJac
344-
v = v / meshJac
345+
if apply_conversion:
346+
if self.U.grid._mesh == "spherical":
347+
meshJac = 1852 * 60.0 * np.cos(np.deg2rad(y))
348+
u = u / meshJac
349+
v = v / meshJac
345350

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

0 commit comments

Comments
 (0)