Skip to content

Commit 947831f

Browse files
committed
Update interpolators
1 parent e37caf3 commit 947831f

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/parcels/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Import helpers for compatability between installations."""
22

33

4-
# for compat with v3 of parcels when users provide `initial=attrgetter("lon")` to a Variable
4+
# for compat with v3 of parcels when users provide `initial=attrgetter("...")` to a Variable
55
# so that particle initial state matches another variable
66
class _AttrgetterHelper:
77
"""

src/parcels/_core/field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def _assert_same_time_interval(fields: Sequence[Field]) -> None:
389389

390390
def _get_positions(field: Field, time, z, y, x, particles, _ei) -> tuple[dict, dict]:
391391
"""Initialize and populate particle_positions and grid_positions dictionaries"""
392-
particle_positions = {"time": time, "z": z, "lat": y, "lon": x}
392+
particle_positions = {"time": time, "z": z, "y": y, "x": x}
393393
grid_positions = {}
394394
grid_positions.update(_search_time_index(field, time))
395395
grid_positions.update(field.grid.search(z, y, x, ei=_ei))

src/parcels/interpolators/_uxinterpolators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def interp(
171171
u = vectorfield.U.interp_method.interp(particle_positions, grid_positions, vectorfield.U)
172172
v = vectorfield.V.interp_method.interp(particle_positions, grid_positions, vectorfield.V)
173173
if vectorfield.grid._mesh == "spherical":
174-
u /= 1852 * 60 * np.cos(np.deg2rad(particle_positions["lat"]))
174+
u /= 1852 * 60 * np.cos(np.deg2rad(particle_positions["y"]))
175175
v /= 1852 * 60
176176

177177
if "3D" in vectorfield.vector_type:

src/parcels/interpolators/_xinterpolators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def interp(
132132
field: Field,
133133
):
134134
"""Returning the single value of a Constant Field (with a size=(1,1,1,1) array)"""
135-
return field.data[0, 0, 0, 0].values * np.ones_like(particle_positions["lon"])
135+
return field.data[0, 0, 0, 0].values * np.ones_like(particle_positions["x"])
136136

137137

138138
class XLinear_Velocity(VectorInterpolator): # noqa: N801
@@ -149,7 +149,7 @@ def interp(
149149
u = _xlinear.interp(particle_positions, grid_positions, vectorfield.U)
150150
v = _xlinear.interp(particle_positions, grid_positions, vectorfield.V)
151151
if vectorfield.grid._mesh == "spherical":
152-
u /= 1852 * 60 * np.cos(np.deg2rad(particle_positions["lat"]))
152+
u /= 1852 * 60 * np.cos(np.deg2rad(particle_positions["y"]))
153153
v /= 1852 * 60
154154

155155
if vectorfield.W:
@@ -304,7 +304,7 @@ def _compute_corner_data(data, selection_dict) -> np.ndarray:
304304
v = v.compute()
305305

306306
if grid._mesh == "spherical":
307-
conversion = 1852 * 60.0 * np.cos(np.deg2rad(particle_positions["lat"]))
307+
conversion = 1852 * 60.0 * np.cos(np.deg2rad(particle_positions["y"]))
308308
u /= conversion
309309
v /= conversion
310310

tests/test_particleset_execute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def test_raise_general_error(): ...
332332
def test_errorinterpolation(fieldset):
333333
class NaNInterpolator(ScalarInterpolator): # pragma: no cover
334334
def interp(self, particle_positions, grid_positions, field):
335-
return np.nan * np.zeros_like(particle_positions["lon"])
335+
return np.nan * np.zeros_like(particle_positions["x"])
336336

337337
def SampleU(particles, fieldset): # pragma: no cover
338338
fieldset.U[particles.time, particles.z, particles.y, particles.x, particles]

0 commit comments

Comments
 (0)