Skip to content

Commit dc614e9

Browse files
committed
Update UxGrid axis to "FACE" instead of "CELL"
1 parent a792863 commit dc614e9

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

parcels/application_kernels/interpolation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def UXPiecewiseConstantFace(
3232
This interpolation method is appropriate for fields that are
3333
face registered, such as u,v in FESOM.
3434
"""
35-
return field.data.values[ti, position["Z"][0], position["CELL"][0]]
35+
return field.data.values[ti, position["Z"][0], position["FACE"][0]]
3636

3737

3838
def UXPiecewiseLinearNode(
@@ -51,8 +51,8 @@ def UXPiecewiseLinearNode(
5151
velocity W in FESOM2. Effectively, it applies barycentric interpolation in the lateral direction
5252
and piecewise linear interpolation in the vertical direction.
5353
"""
54-
k, fi = position["Z"][0], position["CELL"][0]
55-
bcoords = position["CELL"][1]
54+
k, fi = position["Z"][0], position["FACE"][0]
55+
bcoords = position["FACE"][1]
5656
node_ids = field.grid.uxgrid.face_node_connectivity[fi, :]
5757
# The zi refers to the vertical layer index. The field in this routine are assumed to be defined at the vertical interface levels.
5858
# For interface zi, the interface indices are [zi, zi+1], so we need to use the values at zi and zi+1.

parcels/uxgrid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from .basegrid import BaseGrid
1313

14-
_UXGRID_AXES = Literal["Z", "CELL"]
14+
_UXGRID_AXES = Literal["Z", "FACE"]
1515

1616

1717
class UxGrid(BaseGrid):
@@ -83,7 +83,7 @@ def try_face(fid):
8383
if fi == -1:
8484
raise FieldOutOfBoundError(z, y, x)
8585

86-
return {"Z": (zi, zeta), "CELL": (fi, bcoords[0])}
86+
return {"Z": (zi, zeta), "FACE": (fi, bcoords[0])}
8787

8888
def _get_barycentric_coordinates(self, y, x, fi):
8989
"""Checks if a point is inside a given face id on a UxGrid."""
@@ -103,9 +103,9 @@ def _get_barycentric_coordinates(self, y, x, fi):
103103
return bcoord, err
104104

105105
def ravel_index(self, axis_indices: dict[_UXGRID_AXES, int]):
106-
return axis_indices["CELL"] + self.uxgrid.n_face * axis_indices["Z"]
106+
return axis_indices["FACE"] + self.uxgrid.n_face * axis_indices["Z"]
107107

108108
def unravel_index(self, ei) -> dict[_UXGRID_AXES, int]:
109109
zi = ei // self.uxgrid.n_face
110110
fi = ei % self.uxgrid.n_face
111-
return {"Z": zi, "CELL": fi}
111+
return {"Z": zi, "FACE": fi}

0 commit comments

Comments
 (0)