You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user_guide/examples/explanation_interpolation.md
+18-10Lines changed: 18 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,6 @@
3
3
Interpolation is an important functionality of Parcels. On this page we will discuss the way it is
4
4
implemented in **Parcels** and how to write a custom interpolator function.
5
5
6
-
```{note}
7
-
TODO: expand explanation (similar to Kernel loop explanation)
8
-
```
9
-
10
6
When we want to know the state of particles in an environmental field, such as temperature or velocity,
11
7
we _evaluate_ the `parcels.Field` at the particles real position in time and space (`t`, `z`, `lat`, `lon`).
12
8
In Parcels we can do this using square brackets:
@@ -26,7 +22,7 @@ If you want to sample at a different location, or time, that is not necessarily
26
22
```python
27
23
particles.temperature = fieldset.temperature[time, depth, lat, lon]
28
24
```
29
-
but this could be slower for curvilinear and unstructured because the entire grid needs to be searched.
25
+
but this could be slower for curvilinear and unstructured Grids because the entire grid needs to be searched.
30
26
````
31
27
32
28
The values of the `temperature` field at the particles' positions are determined using an interpolation
@@ -36,15 +32,23 @@ relate to the value at any point within a grid cell.
36
32
Each `parcels.Field` is defined on a (structured) `parcels.XGrid` or (unstructured) `parcels.UXGrid`.
37
33
The interpolation function takes information about the particles position relative to this grid (`grid_positions`),
38
34
as well as the values of the grid points of the `parcels.Field` in time and space, to calculate
39
-
the requested value at the particles location. Note that all grid values are available so that higher-order interpolation is possible.
35
+
the requested value at the particles location.
40
36
41
37
## Interpolator API
42
38
43
-
The interpolators included in Parcels are designed for common interpolation schemes in Parcels simulations.
44
-
If we want to add a custom interpolation method, we need to look at the interpolator API:
39
+
The interpolators included in Parcels are designed for common interpolation schemes in Parcels simulations; see the [Using the built-in interpolators tutorial](./tutorial_interpolation.ipynb).
45
40
46
-
We can write an interpolator function that takes a `parcels.Field` (or `parcels.VectorField`), a dictionary with the `particle_positions`
47
-
in real space and time, and a dictionary with the `grid_positions`.
41
+
If we want to create a custom interpolation method, we need to look at the interpolator API. Each interpolator is a class that inherits from either the `ScalarInterpolator` or `VectorInterpolator` class. The `ScalarInterpolator` class is used for scalar fields, such as temperature or salinity, while the `VectorInterpolator` class is used for vector fields, such as velocity. An interpolator class than has to have a `.interp()` method with the following signature:
The `.interp()` method should return a float (in the case o a `ScalarInterpolator` or a tuple of three floats `(u, v, w)` in the case of a `VectorInterpolator`).
83
+
84
+
Writing custom interpolators is not trivial, so we recommend that you have a look at the built-in interpolators in `parcels.interpolators._xinterpolators` or `parcels.interpolators._uxinterpolators` to see how they are implemented.
0 commit comments