Skip to content

Commit 1b612a7

Browse files
Merge branch 'v4-dev' into fixing_default_particle_time
2 parents 0e08a88 + 44928f6 commit 1b612a7

30 files changed

+1118
-1265
lines changed

docs/examples/tutorial_stommel_uxarray.ipynb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"\n",
8989
"A `UXArray.Dataset` consists of multiple `UXArray.UxDataArray`'s and a `UXArray.UxGrid`. Parcels views general circulation model data through the `Field` and `VectorField` classes. A `Field` is defined by its `name`, `data`, `grid`, and `interp_method`. A `VectorField` can be constructed by using 2 or 3 `Field`'s. The `Field.data` attribute can be either an `XArray.DataArray` or `UXArray.UxDataArray` object. The `Field.grid` attribute is of type `Parcels.XGrid` or `Parcels.UXGrid`. Last, the `interp_method` is a dynamic function that can be set at runtime to define the interpolation procedure for the `Field`. This gives you the flexibility to use one of the pre-defined interpolation methods included with Parcels v4, or to create your own interpolator. \n",
9090
"\n",
91-
"The first step to creating a `Field` (or `VectorField`) is to define the Grid. For an unstructured grid, we will create a `Parcels.UXGrid` object, which requires a `UxArray.grid` and the vertical layer interface positions."
91+
"The first step to creating a `Field` (or `VectorField`) is to define the Grid. For an unstructured grid, we will create a `Parcels.UXGrid` object, which requires a `UxArray.grid` and the vertical layer interface positions. Setting the `mesh` to `\"spherical\"` is a legacy feature from Parcels v3 that enables unit conversion from `m/s` to `deg/s`; this is needed in this case since the grid locations are defined in units of degrees."
9292
]
9393
},
9494
{
@@ -99,7 +99,7 @@
9999
"source": [
100100
"from parcels.uxgrid import UxGrid\n",
101101
"\n",
102-
"grid = UxGrid(grid=ds.uxgrid, z=ds.coords[\"nz\"])\n",
102+
"grid = UxGrid(grid=ds.uxgrid, z=ds.coords[\"nz\"], mesh=\"spherical\")\n",
103103
"# You can view the uxgrid object with the following command:\n",
104104
"grid.uxgrid"
105105
]
@@ -112,7 +112,7 @@
112112
"\n",
113113
"In Parcels, grid searching is conducted with respect to the faces. In other words, when a grid index `ei` is provided to an interpolation method, this refers the face index `fi` at vertical layer `zi` (when unraveled). Within the interpolation method, the `field.grid.uxgrid.face_node_connectivity` attribute can be used to obtain the node indices that surround the face. Using these connectivity tables is necessary for properly indexing node registered data.\n",
114114
"\n",
115-
"For the example Stommel gyre dataset in this tutorial, the `u` and `v` velocity components are face registered (similar to FESOM). Parcels includes a nearest neighbor interpolator for face registered unstructured grid data through `Parcels.application_kernels.interpolation.UXPiecewiseConstantFace`. Below, we create the `Field`s `U` and `V` and associate them with the `UxGrid` we created previously and this interpolation method. Setting the `mesh_type` to `\"spherical\"` is a legacy feature from Parcels v3 that enables unit conversion from `m/s` to `deg/s`; this is needed in this case since the grid locations are defined in units of degrees."
115+
"For the example Stommel gyre dataset in this tutorial, the `u` and `v` velocity components are face registered (similar to FESOM). Parcels includes a nearest neighbor interpolator for face registered unstructured grid data through `Parcels.application_kernels.interpolation.UXPiecewiseConstantFace`. Below, we create the `Field`s `U` and `V` and associate them with the `UxGrid` we created previously and this interpolation method."
116116
]
117117
},
118118
{
@@ -128,21 +128,18 @@
128128
" name=\"U\",\n",
129129
" data=ds.U,\n",
130130
" grid=grid,\n",
131-
" mesh_type=\"spherical\",\n",
132131
" interp_method=UXPiecewiseConstantFace,\n",
133132
")\n",
134133
"V = Field(\n",
135134
" name=\"V\",\n",
136135
" data=ds.V,\n",
137136
" grid=grid,\n",
138-
" mesh_type=\"spherical\",\n",
139137
" interp_method=UXPiecewiseConstantFace,\n",
140138
")\n",
141139
"P = Field(\n",
142140
" name=\"P\",\n",
143141
" data=ds.p,\n",
144142
" grid=grid,\n",
145-
" mesh_type=\"spherical\",\n",
146143
" interp_method=UXPiecewiseConstantFace,\n",
147144
")"
148145
]

parcels/_core/utils/time.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def __init__(self, left: T, right: T) -> None:
4848
def __contains__(self, item: T) -> bool:
4949
return self.left <= item <= self.right
5050

51+
def is_all_time_in_interval(self, time):
52+
item = np.atleast_1d(time)
53+
return (self.left <= item).all() and (item <= self.right).all()
54+
5155
def __repr__(self) -> str:
5256
return f"TimeInterval(left={self.left!r}, right={self.right!r})"
5357

parcels/_datasets/structured/generated.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import xarray as xr
55

66

7-
def simple_UV_dataset(dims=(360, 2, 30, 4), maxdepth=1, mesh_type="spherical"):
8-
max_lon = 180.0 if mesh_type == "spherical" else 1e6
7+
def simple_UV_dataset(dims=(360, 2, 30, 4), maxdepth=1, mesh="spherical"):
8+
max_lon = 180.0 if mesh == "spherical" else 1e6
99

1010
return xr.Dataset(
1111
{"U": (["time", "depth", "YG", "XG"], np.zeros(dims)), "V": (["time", "depth", "YG", "XG"], np.zeros(dims))},

0 commit comments

Comments
 (0)