Skip to content

Commit c316e95

Browse files
Update tutorial_interpolation.ipynb
Now that interpolators are functions (since #2646)
1 parent 0943d2e commit c316e95

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

docs/user_guide/examples/tutorial_interpolation.ipynb

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"cell_type": "markdown",
66
"metadata": {},
77
"source": [
8-
"# 🖥️ Using `parcels.interpolators`\n",
9-
"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 fiedls, 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)."
8+
"# 🖥️ Using the built-in `parcels.interpolators`\n",
9+
"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)."
1010
]
1111
},
1212
{
@@ -72,7 +72,7 @@
7272
"source": [
7373
"fieldset = parcels.FieldSet.from_sgrid_conventions(ds, mesh=\"flat\")\n",
7474
"\n",
75-
"assert fieldset.P.interp_method == parcels.interpolators.XLinear"
75+
"assert isinstance(fieldset.P.interp_method, parcels.interpolators.XLinear)"
7676
]
7777
},
7878
{
@@ -124,18 +124,18 @@
124124
" XNearest,\n",
125125
")\n",
126126
"\n",
127-
"interp_methods = [XLinear, XLinearInvdistLandTracer, XNearest, CGrid_Tracer]\n",
127+
"interp_methods = [XLinear(), XLinearInvdistLandTracer(), XNearest(), CGrid_Tracer()]\n",
128128
"for p_interp in interp_methods:\n",
129129
" fieldset.P.interp_method = (\n",
130130
" p_interp # setting the interpolation method for fieldset.P\n",
131131
" )\n",
132132
"\n",
133-
" print(fieldset.P.interp_method.__name__)\n",
133+
" print(fieldset.P.interp_method)\n",
134134
" xv, yv = np.meshgrid(np.linspace(0, 1, 8), np.linspace(0, 1, 8))\n",
135-
" pset[p_interp.__name__] = parcels.ParticleSet(\n",
135+
" pset[p_interp.__class__.__name__] = parcels.ParticleSet(\n",
136136
" fieldset, pclass=SampleParticle, lon=xv.flatten(), lat=yv.flatten()\n",
137137
" )\n",
138-
" pset[p_interp.__name__].execute(\n",
138+
" pset[p_interp.__class__.__name__].execute(\n",
139139
" SampleP,\n",
140140
" runtime=np.timedelta64(1, \"D\"),\n",
141141
" dt=np.timedelta64(1, \"D\"),\n",
@@ -188,10 +188,6 @@
188188
"\n",
189189
"For `interp_method='XNearest'`, the particle values are the same for all particles in a grid cell. They are also the same for `interp_method='CGrid_Tracer'`, but the grid cells have then shifted. That is because in a C-grid, the tracer is defined on the corners of the velocity grid (black dashed lines in right-most panel).\n",
190190
"\n",
191-
"```{note}\n",
192-
"TODO: check C-grid indexing after implementation in v4\n",
193-
"```\n",
194-
"\n",
195191
"For `interp_method='XLinearInvdistLandTracer'`, we see that values are the same as `interp_method='XLinear'` for grid cells that don't border the land point. For grid cells that do border the land cell, the `XLinearInvdistLandTracer` interpolation method gives higher values, as also shown in the difference plot below.\n"
196192
]
197193
},
@@ -462,7 +458,8 @@
462458
"ax[1].set_aspect(\"equal\", \"box\")\n",
463459
"ax[1].set_xlabel(\"x\")\n",
464460
"ax[1].set_ylabel(\"y\")\n",
465-
"ax[1].set_title(\"Face Registered Data\")"
461+
"ax[1].set_title(\"Face Registered Data\")\n",
462+
"plt.show()"
466463
]
467464
},
468465
{
@@ -483,7 +480,7 @@
483480
],
484481
"metadata": {
485482
"kernelspec": {
486-
"display_name": "test-notebooks",
483+
"display_name": "Parcels:docs (3.14.6)",
487484
"language": "python",
488485
"name": "python3"
489486
},
@@ -497,7 +494,7 @@
497494
"name": "python",
498495
"nbconvert_exporter": "python",
499496
"pygments_lexer": "ipython3",
500-
"version": "3.13.9"
497+
"version": "3.14.6"
501498
}
502499
},
503500
"nbformat": 4,

0 commit comments

Comments
 (0)