|
244 | 244 | "metadata": {}, |
245 | 245 | "source": [ |
246 | 246 | "## Interpolation on unstructured grids\n", |
247 | | - "```{note}\n", |
248 | | - "TODO: add example on simple unstructured fieldset\n", |
249 | | - "```\n", |
250 | | - "- UXPiecewiseConstantFace\n", |
251 | | - "- UXPiecewiseLinearNode" |
| 247 | + "Parcels v4 supports the use of general circulation model output that is defined on unstructured grids. We include basic interpolators to help you get started, including\n", |
| 248 | + "- `UXPiecewiseConstantFace` - this interpolator implements piecewise constant interpolation and is appropriate for data that is registered to the face centers of the unstructured grid\n", |
| 249 | + "- `UXPiecewiseLinearNode` - this interpolator implements barycentric interpolation and is appropriate for data that is registered to the corner vertices of the unstructured grid faces\n", |
| 250 | + "\n", |
| 251 | + "To get started, we use a very simple generated `UxArray.UxDataset` that is included with Parcels." |
252 | 252 | ] |
253 | 253 | }, |
254 | 254 | { |
|
263 | 263 | "ds" |
264 | 264 | ] |
265 | 265 | }, |
| 266 | + { |
| 267 | + "cell_type": "markdown", |
| 268 | + "metadata": {}, |
| 269 | + "source": [ |
| 270 | + "Next, we create the `Field` and `Fieldset` objects that will be used later in advancing particles. When creating a `Field` or `VectorField` object for unstructured grid data, we attach a `parcels.UxGrid` object and attach an `interp_method` to each object. For data that is defined on face centers, we use the `UXPiecewiseConstantFace` interpolator and for data that is defined on the face vertices, we use the `UXPiecewiseLinearNode` interpolator. In this example, we will look specifically at interpolating a tracer field that is defined by the same underlying analytical function, but is defined on both faces and vertices as separate fields." |
| 271 | + ] |
| 272 | + }, |
266 | 273 | { |
267 | 274 | "cell_type": "code", |
268 | 275 | "execution_count": null, |
|
272 | 279 | "import parcels\n", |
273 | 280 | "\n", |
274 | 281 | "grid = parcels.UxGrid(ds.uxgrid, ds.nz, mesh=\"flat\")\n", |
275 | | - "U = parcels.Field(\n", |
276 | | - " \"U\", ds[\"U\"], grid, interp_method=parcels.interpolators.UXPiecewiseConstantFace\n", |
277 | | - ")\n", |
278 | | - "V = parcels.Field(\n", |
279 | | - " \"V\", ds[\"V\"], grid, interp_method=parcels.interpolators.UXPiecewiseConstantFace\n", |
280 | | - ")\n", |
281 | | - "UV = parcels.VectorField(\"UV\", U, V)\n", |
| 282 | + "\n", |
282 | 283 | "Tnode = parcels.Field(\n", |
283 | 284 | " \"T_node\",\n", |
284 | 285 | " ds[\"T_node\"],\n", |
|
291 | 292 | " grid,\n", |
292 | 293 | " interp_method=parcels.interpolators.UXPiecewiseConstantFace,\n", |
293 | 294 | ")\n", |
294 | | - "fieldset = parcels.FieldSet([U, V, UV, Tnode, Tface])" |
| 295 | + "fieldset = parcels.FieldSet([Tnode, Tface])" |
295 | 296 | ] |
296 | 297 | }, |
297 | 298 | { |
|
323 | 324 | { |
324 | 325 | "cell_type": "markdown", |
325 | 326 | "metadata": {}, |
326 | | - "source": [] |
327 | | - }, |
328 | | - { |
329 | | - "cell_type": "code", |
330 | | - "execution_count": null, |
331 | | - "metadata": {}, |
332 | | - "outputs": [], |
333 | 327 | "source": [ |
334 | | - "print(fieldset.fields)" |
| 328 | + "Now, we can create a `ParticleSet` for each interpolation experiment. In one of the `ParticleSet` objects we use the `SampleTracer_Node` kernel to showcase interpolating with the `UXPiecewiseLinearNode` interpolator for node-registered data. In the other, we use the `SampleTracer_Face` to showcase interpolating with the `UxPiecewiseConstantFace` interpolator for face-registered data." |
335 | 329 | ] |
336 | 330 | }, |
337 | 331 | { |
|
358 | 352 | ")" |
359 | 353 | ] |
360 | 354 | }, |
| 355 | + { |
| 356 | + "cell_type": "markdown", |
| 357 | + "metadata": {}, |
| 358 | + "source": [ |
| 359 | + "Now, we can plot the node-registered (`T_node`) and face-registered (`T_face`) fields with the values interpolated onto the particles for each field. " |
| 360 | + ] |
| 361 | + }, |
361 | 362 | { |
362 | 363 | "cell_type": "code", |
363 | 364 | "execution_count": null, |
|
453 | 454 | "ax[1].set_title(\"Face Registered Data\")" |
454 | 455 | ] |
455 | 456 | }, |
| 457 | + { |
| 458 | + "cell_type": "markdown", |
| 459 | + "metadata": {}, |
| 460 | + "source": [ |
| 461 | + "In both plots the black lines show the edges that define the boundaries between the faces in the unstructured grid. For the node registered field, the background coloring is done using smooth shading based on the value of `T_node` at the corner nodes. For the face registered fields, each face is colored according to the value of `T_face` at the face center. The color of the particles is the value of the function that the particles take on via the corresponding interpolation method." |
| 462 | + ] |
| 463 | + }, |
456 | 464 | { |
457 | 465 | "cell_type": "markdown", |
458 | 466 | "metadata": {}, |
|
0 commit comments