Skip to content

Commit c430817

Browse files
reint-fischerreint-fischer
authored andcommitted
hard wrap prose in quickstart tutorial
1 parent 7479b30 commit c430817

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

docs/getting_started/tutorial_quickstart.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ kernelspec:
66

77
# Quickstart tutorial
88

9-
Welcome to the **Parcels** quickstart tutorial, in which we will go through all the necessary steps to run a simulation. The code in this notebook can be used as a starting point to run Parcels in your own environment. Along the way we will familiarize ourselves with some specific classes and methods. If you are ever confused about one of these and want to read more, we have a [concepts overview](concepts_overview.md) discussing them in more detail. Let's dive in!
9+
Welcome to the **Parcels** quickstart tutorial, in which we will go through all the necessary steps to run a simulation.
10+
The code in this notebook can be used as a starting point to run Parcels in your own environment. Along the way we will
11+
familiarize ourselves with some specific classes and methods. If you are ever confused about one of these and want to
12+
read more, we have a [concepts overview](concepts_overview.md) discussing them in more detail. Let's dive in!
1013

1114
## Imports
1215

13-
Parcels depends on `xarray`, expecting inputs in the form of [`xarray.Dataset`](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html) and writing output files that can be read with xarray.
16+
Parcels depends on `xarray`, expecting inputs in the form of [`xarray.Dataset`](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html)
17+
and writing output files that can be read with xarray.
1418

1519
```{code-cell}
1620
import numpy as np
@@ -20,7 +24,9 @@ import parcels
2024

2125
## Input flow fields: `FieldSet`
2226

23-
A Parcels simulation of Lagrangian trajectories of virtual particles requires two inputs; the first is a set of hydrodynamics fields in which the particles are tracked. Here we provide an example using a subset of the [Global Ocean Physics Reanalysis](https://doi.org/10.48670/moi-00021) from the Copernicus Marine Service.
27+
A Parcels simulation of Lagrangian trajectories of virtual particles requires two inputs; the first is a set of
28+
hydrodynamics fields in which the particles are tracked. Here we provide an example using a subset of the
29+
[Global Ocean Physics Reanalysis](https://doi.org/10.48670/moi-00021) from the Copernicus Marine Service.
2430

2531
```{code-cell}
2632
example_dataset_folder = parcels.download_example_dataset(
@@ -32,9 +38,12 @@ ds_fields.load() # load the dataset into memory
3238
ds_fields
3339
```
3440

35-
As we can see, the reanalysis dataset contains eastward velocity `uo`, northward velocity `vo`, potential temperature (`thetao`) and salinity (`so`) fields.
41+
As we can see, the reanalysis dataset contains eastward velocity `uo`, northward velocity `vo`, potential temperature
42+
(`thetao`) and salinity (`so`) fields.
3643

37-
These hydrodynamic fields need to be stored in a `parcels.FieldSet` object. Parcels provides tooling to parse many types of models or observations into such a `parcels.FieldSet` object. Here, we use `FieldSet.from_copernicusmarine()`, which recognizes the standard names of a velocity field:
44+
These hydrodynamic fields need to be stored in a `parcels.FieldSet` object. Parcels provides tooling to parse many types
45+
of models or observations into such a `parcels.FieldSet` object. Here, we use `FieldSet.from_copernicusmarine()`, which
46+
recognizes the standard names of a velocity field:
3847

3948
```{code-cell}
4049
fieldset = parcels.FieldSet.from_copernicusmarine(ds_fields)
@@ -49,9 +58,13 @@ velocity = ds_fields.isel(time=0, depth=0).plot.quiver(x="longitude", y="latitud
4958

5059
## Input virtual particles: `ParticleSet`
5160

52-
Now that we have created a `parcels.FieldSet` object from the hydrodynamic data, we need to provide our second input: the virtual particles for which we will calculate the trajectories.
61+
Now that we have created a `parcels.FieldSet` object from the hydrodynamic data, we need to provide our second input:
62+
the virtual particles for which we will calculate the trajectories.
5363

54-
We need to create a `parcels.ParticleSet` object with the particles' initial time and position. The `parcels.ParticleSet` object also needs to know about the `FieldSet` in which the particles "live". Finally, we need to specify the type of `parcels.Particle` we want to use. The default particles have `time`, `z`, `lat`, and `lon`, but you can easily add other `Variables` such as size, temperature, or age to create your own particles to mimic plastic or an [ARGO float](../user_guide/examples/tutorial_Argofloats.ipynb).
64+
We need to create a `parcels.ParticleSet` object with the particles' initial time and position. The `parcels.ParticleSet`
65+
object also needs to know about the `FieldSet` in which the particles "live". Finally, we need to specify the type of
66+
`parcels.Particle` we want to use. The default particles have `time`, `z`, `lat`, and `lon`, but you can easily add
67+
other `Variables` such as size, temperature, or age to create your own particles to mimic plastic or an [ARGO float](../user_guide/examples/tutorial_Argofloats.ipynb).
5568

5669
```{code-cell}
5770
# Particle locations and initial time
@@ -76,7 +89,10 @@ ax.scatter(lon,lat,s=40,c='w',edgecolors='r');
7689

7790
## Compute: `Kernel`
7891

79-
After setting up the input data and particle start locations and times, we need to specify what calculations to do with the particles. These calculations, or numerical integrations, will be performed by what we call a `Kernel`, operating on all particles in the `ParticleSet`. The most common calculation is the advection of particles through the velocity field. Parcels comes with a number of standard kernels, from which we will use the Runge-Kutta advection kernel `AdvectionRK2`:
92+
After setting up the input data and particle start locations and times, we need to specify what calculations to do with
93+
the particles. These calculations, or numerical integrations, will be performed by what we call a `Kernel`, operating on
94+
all particles in the `ParticleSet`. The most common calculation is the advection of particles through the velocity field.
95+
Parcels comes with a number of standard kernels, from which we will use the Runge-Kutta advection kernel `AdvectionRK2`:
8096

8197
```{note}
8298
TODO: link to a list of included kernels
@@ -88,20 +104,26 @@ kernels = [parcels.kernels.AdvectionEE]
88104

89105
## Prepare output: `ParticleFile`
90106

91-
Before starting the simulation, we must define where and how frequent we want to write the output of our simulation. We can define this in a `ParticleFile` object:
107+
Before starting the simulation, we must define where and how frequent we want to write the output of our simulation.
108+
We can define this in a `ParticleFile` object:
92109

93110
```{code-cell}
94111
output_file = parcels.ParticleFile("output-quickstart.zarr", outputdt=np.timedelta64(1, "h"))
95112
```
96113

97-
The output files are in `.zarr` [format](https://zarr.readthedocs.io/en/stable/), which can be read by `xarray`. See the [Parcels output tutorial](./tutorial_output.ipynb) for more information on the zarr format. We want to choose the `outputdt` argument so that it captures the smallest timescales of our interest.
114+
The output files are in `.zarr` [format](https://zarr.readthedocs.io/en/stable/), which can be read by `xarray`.
115+
See the [Parcels output tutorial](./tutorial_output.ipynb) for more information on the zarr format. We want to choose
116+
the `outputdt` argument so that it captures the smallest timescales of our interest.
98117

99118
## Run Simulation: `ParticleSet.execute()`
100119

101-
Finally, we can run the simulation by _executing_ the `ParticleSet` using the specified list of `kernels`. Additionally, we need to specify:
120+
Finally, we can run the simulation by _executing_ the `ParticleSet` using the specified list of `kernels`.
121+
Additionally, we need to specify:
102122

103123
- the `runtime`: for how long we want to simulate particles.
104-
- the `dt`: the timestep with which to perform the numerical integration in the `kernels`. Depending on the numerical integration scheme, the accuracy of our simulation will depend on `dt`. Read [this notebook](https://github.com/Parcels-code/10year-anniversary-session2/blob/8931ef69577dbf00273a5ab4b7cf522667e146c5/advection_and_windage.ipynb) to learn more about numerical accuracy.
124+
- the `dt`: the timestep with which to perform the numerical integration in the `kernels`. Depending on the numerical
125+
integration scheme, the accuracy of our simulation will depend on `dt`. Read [this notebook](https://github.com/Parcels-code/10year-anniversary-session2/blob/8931ef69577dbf00273a5ab4b7cf522667e146c5/advection_and_windage.ipynb)
126+
to learn more about numerical accuracy.
105127

106128
```{note}
107129
TODO: add Michaels 10-years Parcels notebook to the user guide
@@ -126,7 +148,9 @@ ds_particles = xr.open_zarr("output-quickstart.zarr")
126148
ds_particles
127149
```
128150

129-
The 10 particle trajectories are stored along the `trajectory` dimension, and each trajectory contains 25 observations (initial values + 24 hourly timesteps) along the `obs` dimension. The [working with Parcels output tutorial](./tutorial_output.ipynb) provides more detail about the dataset and how to analyse it.
151+
The 10 particle trajectories are stored along the `trajectory` dimension, and each trajectory contains 25 observations
152+
(initial values + 24 hourly timesteps) along the `obs` dimension. The [working with Parcels output tutorial](./tutorial_output.ipynb)
153+
provides more detail about the dataset and how to analyse it.
130154

131155
Let's verify that Parcels has computed the advection of the virtual particles!
132156

@@ -143,14 +167,18 @@ plt.colorbar(scatter, label="Observation number")
143167
plt.show()
144168
```
145169

146-
That looks good! The virtual particles released in a line along the 32nd meridian (dark blue) have been advected by the flow field.
170+
That looks good! The virtual particles released in a line along the 32nd meridian (dark blue) have been advected by the
171+
flow field.
147172

148173
## Running a simulation backwards in time
149174

150-
Now that we know how to run a simulation, we can easily run another and change one of the settings. We can trace back the particles from their current to their original position by running the simulation backwards in time. To do so, we can simply make `dt` < 0.
175+
Now that we know how to run a simulation, we can easily run another and change one of the settings. We can trace back
176+
the particles from their current to their original position by running the simulation backwards in time. To do so, we
177+
can simply make `dt` < 0.
151178

152179
```{note}
153-
We have not edited the `ParticleSet`, which means that the new simulation will start with the particles at their current location!
180+
We have not edited the `ParticleSet`, which means that the new simulation will start with the particles at their current
181+
location!
154182
```
155183

156184
```{code-cell}

0 commit comments

Comments
 (0)