Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/user_guide/examples/tutorial_interpolation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)."
]
},
Expand Down
25 changes: 20 additions & 5 deletions docs/user_guide/examples/tutorial_nemo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down