Skip to content

Commit 25c5e7e

Browse files
Map query point to cartesian x,y,z when mesh type is spherical
1 parent 9df2804 commit 25c5e7e

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

parcels/_index_search.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ def uxgrid_point_in_cell(grid, y: np.ndarray, x: np.ndarray, yi: np.ndarray, xi:
154154
Barycentric coordinates of the points within their respective cells.
155155
"""
156156
if grid._mesh == "spherical":
157-
# lon_rad = np.deg2rad(grid.lon.values)
158-
# lat_rad = np.deg2rad(grid.lat.values)
159-
# x_cart, y_cart, z_cart = _latlon_rad_to_xyz(lat_rad, lon_rad)
160-
# points = np.column_stack((x_cart.flatten(), y_cart.flatten(), z_cart.flatten()))
157+
lon_rad = np.deg2rad(x)
158+
lat_rad = np.deg2rad(y)
159+
x_cart, y_cart, z_cart = _latlon_rad_to_xyz(lat_rad, lon_rad)
160+
points = np.column_stack((x_cart.flatten(), y_cart.flatten(), z_cart.flatten()))
161161

162162
# Get the vertex indices for each face
163163
nids = grid.uxgrid.face_node_connectivity[yi].values
@@ -178,7 +178,7 @@ def uxgrid_point_in_cell(grid, y: np.ndarray, x: np.ndarray, yi: np.ndarray, xi:
178178
),
179179
axis=-1,
180180
)
181-
points = np.stack((x, y))
181+
points = np.stack((x, y))
182182

183183
M = len(points)
184184

tests/v4/test_particleset_execute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ def test_uxstommelgyre_pset_execute():
400400
dt=np.timedelta64(60, "s"),
401401
pyfunc=AdvectionEE,
402402
)
403-
assert utils.round_and_hash_float_array([p.lon for p in pset]) == 1165397121
404-
assert utils.round_and_hash_float_array([p.lat for p in pset]) == 1142123780
403+
assert utils.round_and_hash_float_array([p.lon for p in pset]) == 1165396086
404+
assert utils.round_and_hash_float_array([p.lat for p in pset]) == 1142124776
405405

406406

407407
@pytest.mark.xfail(reason="Output file not implemented yet")

0 commit comments

Comments
 (0)