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)." ] }, diff --git a/docs/user_guide/examples/tutorial_nemo.ipynb b/docs/user_guide/examples/tutorial_nemo.ipynb index 2bf094c10..3620de50e 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,11 +223,24 @@ }, "outputs": [], "source": [ - "# with a Kernel\n", - "def periodicBC(particles, fieldset): # pragma: no cover\n", - " particles.dx = np.where(\n", - " particles.x + particles.dx > 180, particles.dx - 360, particles.dx\n", - " )\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 = ((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", + " ]\n", + " particles.dx += u2 * particles.dt\n", + " particles.dy += v2 * particles.dt\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", @@ -236,7 +249,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",