From c4f81a6b08bcc8e1150d9646d8bb596ef8a85bed Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Thu, 16 Jul 2026 15:23:04 +0200 Subject: [PATCH 1/3] Simplify title of interpolation tutorial --- docs/user_guide/examples/tutorial_interpolation.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user_guide/examples/tutorial_interpolation.ipynb b/docs/user_guide/examples/tutorial_interpolation.ipynb index 713274252..c5e76825c 100644 --- a/docs/user_guide/examples/tutorial_interpolation.ipynb +++ b/docs/user_guide/examples/tutorial_interpolation.ipynb @@ -5,7 +5,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 🖥️ Using the built-in `parcels.interpolators`\n", + "# 🖥️ Using the built-in Interpolators\n", "Parcels comes with a number of different interpolation methods for fields on structured (`X`) and unstructured (`Ux`) grids. Here, we will look at a few common {py:obj}`parcels.interpolators` for tracer fields, and how to configure them in an idealised example. For more guidance on the sampling of such fields, check out the [sampling tutorial](./tutorial_sampling)." ] }, From 1e2bff8a2c7f3fdfb8293de192ec6d58a08819db Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Fri, 17 Jul 2026 11:18:26 +0200 Subject: [PATCH 2/3] Update Nemo tutorial periodic boundaries --- docs/user_guide/examples/tutorial_nemo.ipynb | 25 ++++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/docs/user_guide/examples/tutorial_nemo.ipynb b/docs/user_guide/examples/tutorial_nemo.ipynb index 2bf094c10..a4279a479 100644 --- a/docs/user_guide/examples/tutorial_nemo.ipynb +++ b/docs/user_guide/examples/tutorial_nemo.ipynb @@ -155,7 +155,7 @@ ")\n", "\n", "pset.execute(\n", - " [parcels.kernels.AdvectionEE],\n", + " parcels.kernels.AdvectionRK2,\n", " runtime=runtime,\n", " dt=np.timedelta64(1, \"D\"),\n", " output_file=pfile,\n", @@ -203,7 +203,7 @@ "metadata": {}, "outputs": [], "source": [ - "# post processing\n", + "# handling periodic boundary conditions in post processing\n", "df = df.with_columns((pl.col(\"x\") % 360).alias(\"x\"))\n", "df = df.with_columns(\n", " pl.when(pl.col(\"x\") <= 180)\n", @@ -223,8 +223,23 @@ }, "outputs": [], "source": [ - "# with a Kernel\n", - "def periodicBC(particles, fieldset): # pragma: no cover\n", + "# with a custom Kernel\n", + "def AdvectionRK2_periodicBC(particles, fieldset): # pragma: no cover\n", + " \"\"\"Advection of particles using second-order Runge-Kutta integration,\n", + " keeping particles between -180 and 180 degrees longitude.\n", + " \"\"\"\n", + " (u1, v1) = fieldset.UV[particles]\n", + " x1 = particles.x + u1 * 0.5 * particles.dt\n", + " y1 = particles.y + v1 * 0.5 * particles.dt\n", + " x1 = np.where(x1 > 180, x1 - 360, x1) # keep particles within [-180, 180]\n", + "\n", + " (u2, v2) = fieldset.UV[\n", + " particles.t + 0.5 * particles.dt, particles.z, y1, x1, particles\n", + " ]\n", + " particles.dx += u2 * particles.dt\n", + " particles.dy += v2 * particles.dt\n", + "\n", + " # update particles.dx to stay within [-180, 180]\n", " particles.dx = np.where(\n", " particles.x + particles.dx > 180, particles.dx - 360, particles.dx\n", " )\n", @@ -236,7 +251,7 @@ ")\n", "\n", "pset.execute(\n", - " [parcels.kernels.AdvectionEE, periodicBC],\n", + " AdvectionRK2_periodicBC,\n", " runtime=runtime,\n", " dt=np.timedelta64(1, \"D\"),\n", " output_file=pfile,\n", From 641bfe767fca799c1ed56627f505d22f383bf7b2 Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Fri, 17 Jul 2026 14:44:55 +0200 Subject: [PATCH 3/3] Using modulo for PeriodicBC --- docs/user_guide/examples/tutorial_nemo.ipynb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/user_guide/examples/tutorial_nemo.ipynb b/docs/user_guide/examples/tutorial_nemo.ipynb index a4279a479..3620de50e 100644 --- a/docs/user_guide/examples/tutorial_nemo.ipynb +++ b/docs/user_guide/examples/tutorial_nemo.ipynb @@ -231,7 +231,7 @@ " (u1, v1) = fieldset.UV[particles]\n", " x1 = particles.x + u1 * 0.5 * particles.dt\n", " y1 = particles.y + v1 * 0.5 * particles.dt\n", - " x1 = np.where(x1 > 180, x1 - 360, x1) # keep particles within [-180, 180]\n", + " x1 = ((x1 + 180) % 360) - 180 # keep x1 within [-180, 180]\n", "\n", " (u2, v2) = fieldset.UV[\n", " particles.t + 0.5 * particles.dt, particles.z, y1, x1, particles\n", @@ -239,10 +239,8 @@ " particles.dx += u2 * particles.dt\n", " particles.dy += v2 * particles.dt\n", "\n", - " # update particles.dx to stay within [-180, 180]\n", - " particles.dx = np.where(\n", - " particles.x + particles.dx > 180, particles.dx - 360, particles.dx\n", - " )\n", + " # update particles.dx so particles.x + particles.dx stays within [-180, 180]\n", + " particles.dx = ((particles.x + particles.dx + 180) % 360) - 180 - particles.x\n", "\n", "\n", "pset = parcels.ParticleSet(fieldset, x=lonp, y=latp)\n",