Skip to content

Commit 1860e80

Browse files
reint-fischerreint-fischer
authored andcommitted
fix writing suggestions
1 parent 991d0e9 commit 1860e80

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

docs/user_guide/examples/explanation_interpolation.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,23 @@ we _evaluate_ the `parcels.Field` at the particles real position in time and spa
1212
In Parcels we can do this using square brackets:
1313

1414
```
15-
particles.temperature = fieldset.temperature[particles.time, particles.z, particles.lat, particles.lon]
15+
particles.temperature = fieldset.temperature[particles]
1616
```
1717

18+
````{note}
19+
The statement above is shorthand for
20+
```python
21+
particles.temperature = fieldset.temperature[particles.time, particles.z, particles.lat, particles.lon, particles]
22+
```
23+
where the `particles` argument at the end provides the grid search algorithm with a first guess for the element indices to interpolate on.
24+
25+
If you want to sample at a different location, or time, that is not necessarily close to the particles location, you can use
26+
```python
27+
particles.temperature = fieldset.temperature[time, depth, lat, lon]
28+
```
29+
but this could be slower for curvilinear and unstructured because the entire grid needs to be searched.
30+
````
31+
1832
The values of the `temperature` field at the particles' positions are determined using an interpolation
1933
method. This interpolation method defines how the discretized values of the `parcels.Field` should
2034
relate to the value at any point within a grid cell.

docs/user_guide/examples/tutorial_interpolation.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"metadata": {},
77
"source": [
88
"# Using `parcels.interpolators`\n",
9-
"Parcels comes with a number of different interpolation methods for tracer fields, such as temperature. Here, we will look at a few common `parcels.interpolators` for structured (`X`) grids, and how to configure them in an idealised example. For more guidance on the sampling of such fields, check out the [sampling guide](./tutorial_sampling).\n",
9+
"Parcels comes with a number of different interpolation methods for tracer fields, such as temperature. Here, we will look at a few common `parcels.interpolators` for structured (`X`) grids, 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).\n",
1010
"\n",
1111
"We first import the relevant modules"
1212
]
@@ -29,7 +29,7 @@
2929
"cell_type": "markdown",
3030
"metadata": {},
3131
"source": [
32-
"We create a small 2D structured grid where `P` is a tracer that we want to interpolate. In each grid cell, `P` has a random value between 0.1 and 1.1. We then set `P[1,1]` to `0`, which for Parcels specifies that this is a land cell\n"
32+
"We create a small 2D structured grid, where `P` is a tracer that we want to interpolate. In each grid cell, `P` has a random value between 0.1 and 1.1. We then set `P[1,1]` to `0`, which for Parcels specifies that this is a land cell\n"
3333
]
3434
},
3535
{
@@ -256,7 +256,7 @@
256256
"metadata": {},
257257
"source": [
258258
"## Interpolation at boundaries\n",
259-
"In some cases we need to implement specific boundary conditions, for example to prevent particles from \n",
259+
"In some cases, we need to implement specific boundary conditions, for example to prevent particles from \n",
260260
"getting \"stuck\" near land. [This guide](../examples_v3/documentation_unstuck_Agrid.ipynb) describes \n",
261261
"how to implement this in parcels using `parcels.interpolators.XFreeslip` and `parcels.interpolators.XPartialslip`."
262262
]
@@ -266,7 +266,7 @@
266266
"metadata": {},
267267
"source": [
268268
"## Write your own interpolator\n",
269-
"The interpolators included in Parcels are designed for common interpolation schemes in Parcels simulations. If we want to add a custom interpolation method, we can write our own interpolator function (e.g. spline) using the [interpolator API](./explanation_interpolation.md#interpolator-api)."
269+
"The interpolators included in Parcels are designed for common interpolation schemes in Parcels simulations. If we want to add a custom interpolation method, we can write a custom function (e.g. spline) using the [interpolator API](./explanation_interpolation.md#interpolator-api)."
270270
]
271271
}
272272
],

0 commit comments

Comments
 (0)