Skip to content

Commit c5cb140

Browse files
Adding unit test for vertical 1D field
Note that this unit test currently breaks
1 parent bba37f4 commit c5cb140

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_xgrid.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
import numpy as np
55
import pytest
66
import xarray as xr
7+
import xgcm
78
from numpy.testing import assert_allclose
89

10+
from parcels import Field
911
from parcels._core.index_search import (
1012
LEFT_OUT_OF_BOUNDS,
1113
RIGHT_OUT_OF_BOUNDS,
1214
_search_1d_array,
1315
)
1416
from parcels._core.xgrid import (
17+
_DEFAULT_XGCM_KWARGS,
1518
XGrid,
1619
_transpose_xfield_data_to_tzyx,
1720
)
@@ -134,6 +137,15 @@ def test_invalid_depth():
134137
XGrid.from_dataset(ds)
135138

136139

140+
def test_vertical1D_field():
141+
nz = 11
142+
ds = xr.Dataset({"z1d": (["depth"], np.linspace(0, 10, nz))}, coords={"depth": np.linspace(0, 1, nz)})
143+
grid = XGrid(xgcm.Grid(ds, **_DEFAULT_XGCM_KWARGS))
144+
field = Field("z1d", ds["z1d"], grid)
145+
146+
assert field.eval(np.timedelta64(0, "s"), 0.45, 0, 0) == 4.5
147+
148+
137149
@pytest.mark.parametrize(
138150
"ds",
139151
[

0 commit comments

Comments
 (0)