Skip to content

Commit 38c2ded

Browse files
Return tuple even when there is no time interval
This commit also fixes the unstructured stommel gyre example dataset to be consistent in the variable placement with FESOM2. Specifically, the pressure, U, and V fields are face registered and the vertical velocities are vertex registered.
1 parent ce4024b commit 38c2ded

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

parcels/_datasets/unstructured/generic.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
__all__ = ["Nx", "datasets"]
88

99
T = 13
10-
Nx = 20
10+
Nx = 10
1111
vmax = 1.0
1212
delta = 0.1
1313
TIME = xr.date_range("2000", "2001", T)
@@ -44,12 +44,12 @@ def _stommel_gyre_delaunay():
4444
uxgrid.attrs["Conventions"] = "UGRID-1.0"
4545

4646
# Define arrays U (zonal), V (meridional) and P (sea surface height)
47-
U = np.zeros((1, nz1, lat.size), dtype=np.float64)
48-
V = np.zeros((1, nz1, lat.size), dtype=np.float64)
47+
U = np.zeros((1, nz1, uxgrid.n_face), dtype=np.float64)
48+
V = np.zeros((1, nz1, uxgrid.n_face), dtype=np.float64)
4949
W = np.zeros((1, nz, lat.size), dtype=np.float64)
50-
P = np.zeros((1, nz1, lat.size), dtype=np.float64)
50+
P = np.zeros((1, nz1, uxgrid.n_face), dtype=np.float64)
5151

52-
for i, (x, y) in enumerate(zip(lon_flat, lat_flat, strict=False)):
52+
for i, (x, y) in enumerate(zip(uxgrid.face_lon, uxgrid.face_lat, strict=False)):
5353
xi = x / 60.0
5454
yi = y / 60.0
5555

@@ -61,10 +61,10 @@ def _stommel_gyre_delaunay():
6161
data=U,
6262
name="U",
6363
uxgrid=uxgrid,
64-
dims=["time", "nz1", "n_node"],
64+
dims=["time", "nz1", "n_face"],
6565
coords=dict(
6666
time=(["time"], [TIME[0]]),
67-
nz1=(["nz1"], [0]),
67+
nz1=(["nz1"], zc),
6868
),
6969
attrs=dict(
7070
description="zonal velocity", units="m/s", location="node", mesh="delaunay", Conventions="UGRID-1.0"
@@ -74,7 +74,7 @@ def _stommel_gyre_delaunay():
7474
data=V,
7575
name="V",
7676
uxgrid=uxgrid,
77-
dims=["time", "nz1", "n_node"],
77+
dims=["time", "nz1", "n_face"],
7878
coords=dict(
7979
time=(["time"], [TIME[0]]),
8080
nz1=(["nz1"], zc),
@@ -100,7 +100,7 @@ def _stommel_gyre_delaunay():
100100
data=P,
101101
name="p",
102102
uxgrid=uxgrid,
103-
dims=["time", "nz1", "n_node"],
103+
dims=["time", "nz1", "n_face"],
104104
coords=dict(
105105
time=(["time"], [TIME[0]]),
106106
nz1=(["nz1"], zc),

parcels/_index_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _search_time_index(field: Field, time: datetime):
3838
if the sampled value is outside the time value range.
3939
"""
4040
if field.time_interval is None:
41-
return 0
41+
return 0, 0
4242

4343
if time not in field.time_interval:
4444
_raise_time_extrapolation_error(time, field=None)

0 commit comments

Comments
 (0)