Skip to content

Commit 013ba25

Browse files
Add depth property in uxgrid
This provides consistency with the XGrid class. Additionally, this property is needed for determining min/max depth bounds in particleset.__init__ . With consistency between XGrid and UXGrid, this getting depth ranges with either grid type can be accomplished with the same code in particleset.__init__
1 parent 83fc666 commit 013ba25

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

parcels/uxgrid.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ def __init__(self, grid: ux.grid.Grid, z: ux.UxDataArray) -> UxGrid:
3535
raise ValueError("z must be a 1D array of vertical coordinates")
3636
self.z = z
3737

38+
@property
39+
def depth(self):
40+
"""
41+
Note
42+
----
43+
Included for compatibility with v3 codebase. May be removed in future.
44+
TODO v4: Evaluate
45+
"""
46+
try:
47+
_ = self.z.values
48+
except KeyError:
49+
return np.zeros(1)
50+
return self.z.values
51+
3852
def search(
3953
self, z: float, y: float, x: float, ei: int | None = None, search2D: bool = False
4054
) -> tuple[np.ndarray, int]:

0 commit comments

Comments
 (0)