Skip to content

Commit 750b166

Browse files
Merge pull request #2110 from OceanParcels/unit_conversion_bug
Fixing bug where conversion was not applied in field.eval
2 parents 8669a13 + 120c449 commit 750b166

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

parcels/field.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,14 @@ def eval(self, time: datetime, z, y, x, particle=None, applyConversion=True):
266266
if np.isnan(value):
267267
# Detect Out-of-bounds sampling and raise exception
268268
_raise_field_out_of_bound_error(z, y, x)
269-
else:
270-
return value
271269

272270
except (FieldSamplingError, FieldOutOfBoundError, FieldOutOfBoundSurfaceError) as e:
273271
e.add_note(f"Error interpolating field '{self.name}'.")
274272
raise e
275273

276274
if applyConversion:
277-
return self.units.to_target(value, z, y, x)
278-
else:
279-
return value
275+
value = self.units.to_target(value, z, y, x)
276+
return value
280277

281278
def __getitem__(self, key):
282279
self._check_velocitysampling()
@@ -359,7 +356,6 @@ def eval(self, time: datetime, z, y, x, particle=None, applyConversion=True):
359356
else:
360357
(u, v, w) = self._vector_interp_method(self, ti, position, time, z, y, x)
361358

362-
# print(u,v)
363359
if applyConversion:
364360
u = self.U.units.to_target(u, z, y, x)
365361
v = self.V.units.to_target(v, z, y, x)

0 commit comments

Comments
 (0)