Skip to content

Commit 04e1b36

Browse files
[#2260] Make k and ti broadcastable
This resolves the bug. Thanks to @willirath for the python syntax help
1 parent 2e5badb commit 04e1b36

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

parcels/interpolators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,12 @@ def UXPiecewiseLinearNode(
653653
"""
654654
k, fi = position["Z"][0], position["FACE"][0]
655655
bcoords = position["FACE"][1]
656-
node_ids = field.grid.uxgrid.face_node_connectivity[fi, :]
656+
node_ids = field.grid.uxgrid.face_node_connectivity[fi, :].values
657657
# The zi refers to the vertical layer index. The field in this routine are assumed to be defined at the vertical interface levels.
658658
# For interface zi, the interface indices are [zi, zi+1], so we need to use the values at zi and zi+1.
659659
# First, do barycentric interpolation in the lateral direction for each interface level
660-
fzk = np.sum(field.data.values[ti, k, node_ids] * bcoords, axis=-1)
661-
fzkp1 = np.sum(field.data.values[ti, k + 1, node_ids] * bcoords, axis=-1)
660+
fzk = np.sum(field.data.values[ti[:, None], k[:, None], node_ids] * bcoords, axis=-1)
661+
fzkp1 = np.sum(field.data.values[ti[:, None], k[:, None] + 1, node_ids] * bcoords, axis=-1)
662662

663663
# Then, do piecewise linear interpolation in the vertical direction
664664
zk = field.grid.z.values[k]

0 commit comments

Comments
 (0)