Skip to content

Commit 47fbb58

Browse files
Fix indexing of ei/fi/zi in uxgrid search
1 parent 99ff096 commit 47fbb58

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

parcels/uxgrid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,18 @@ def try_face(fid):
8787
zi, zeta = _search_1d_array(self.z.values, z)
8888

8989
if ei is not None:
90-
_, fi = self.unravel_index(ei)
90+
indices = self.unravel_index(ei)
91+
fi = indices["FACE"][0]
9192
bcoords = try_face(fi)
9293
if bcoords is not None:
93-
return bcoords, self.ravel_index(zi, fi)
94+
return {"Z": (zi, zeta), "FACE": (np.asarray([fi]), bcoords)}
9495
# Try neighbors of current face
9596
for neighbor in self.uxgrid.face_face_connectivity[fi, :]:
9697
if neighbor == -1:
9798
continue
9899
bcoords = try_face(neighbor)
99100
if bcoords is not None:
100-
return bcoords, self.ravel_index(zi, neighbor)
101+
return {"Z": (zi, zeta), "FACE": (np.asarray([neighbor]), bcoords)}
101102

102103
# Global fallback as last ditch effort
103104
points = np.column_stack((x, y))
@@ -113,7 +114,6 @@ def try_face(fid):
113114
def _get_barycentric_coordinates_latlon(self, y, x, fi):
114115
"""Checks if a point is inside a given face id on a UxGrid."""
115116
# Check if particle is in the same face, otherwise search again.
116-
117117
n_nodes = self.uxgrid.n_nodes_per_face[fi].to_numpy()
118118
node_ids = self.uxgrid.face_node_connectivity[fi, 0:n_nodes]
119119
nodes = np.column_stack(

0 commit comments

Comments
 (0)