Skip to content

Commit f7d56bf

Browse files
reint-fischerreint-fischer
authored andcommitted
fix backwards figure and hard wrapping recommendation
1 parent 928e07a commit f7d56bf

File tree

2 files changed

+46
-45
lines changed

2 files changed

+46
-45
lines changed

docs/development/docsguide.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## Vision
44

5-
We believe a clear documentation is important to community building, reproducibility, and transparency in our open-source
6-
project. To make it easier to write our documentation in a consistent way, here we outline a brief vision for our
5+
We believe a clear documentation is important to community building, reproducibility, and transparency in our open-source
6+
project. To make it easier to write our documentation in a consistent way, here we outline a brief vision for our
77
documentation based heavily on a few common resources.
88

99
```{note}
@@ -19,7 +19,7 @@ TODO: outline functions of the documentation based on resources
1919

2020
## Notebook execution
2121

22-
We run the notebooks in our documentation using [MyST-NB](https://myst-nb.readthedocs.io/en/latest/index.html). Here is
22+
We run the notebooks in our documentation using [MyST-NB](https://myst-nb.readthedocs.io/en/latest/index.html). Here is
2323
a table showing the latest notebook execution:
2424

2525
```{nb-exec-table}
@@ -28,17 +28,17 @@ a table showing the latest notebook execution:
2828

2929
## Style guide
3030

31-
- **Write out `parcels.class.method` in tutorials and how-to guides** so that we can see which classes and methods are
32-
part of Parcels. Because in the alternative (using `from parcels import class`) the use of `class` in a cell further
33-
along is not obviously part of `parcels`.
34-
- [**Avoid too much Repitition In Documentation**](https://www.writethedocs.org/guide/writing/docs-principles/#arid):
35-
tutorials and how-to guides notebooks will often have repetition of the general **Parcels** steps, which is fine because
36-
we want readers to see the changes to a specific class or method in the context of the simulation, e.g. `Particle` and
37-
`Kernel` are often customised together, which must be defined before the `ParticleSet.execute()`. We try to limit each
38-
page in the documentation to a small number of examples.
31+
- **Write out `parcels.class.method` in tutorials and how-to guides** so that we can see which classes and methods are
32+
part of Parcels. Because in the alternative (using `from parcels import class`) the use of `class` in a cell further
33+
along is not obviously part of `parcels`.
34+
- [**Avoid too much Repitition In Documentation**](https://www.writethedocs.org/guide/writing/docs-principles/#arid):
35+
tutorials and how-to guides notebooks will often have repetition of the general **Parcels** steps, which is fine because
36+
we want readers to see the changes to a specific class or method in the context of the simulation, e.g. `Particle` and
37+
`Kernel` are often customised together, which must be defined before the `ParticleSet.execute()`. We try to limit each
38+
page in the documentation to a small number of examples.
3939
- **Import packages at the top of the section in which they are first used** to show what they are used for.
40-
- **Write documentation in first person plural ("we").** In our open source code, tutorials and guides can be written
41-
by any developer or user, so the documentation teaches all of us how to do something with Parcels. Sometimes it can be
42-
more natural to take on the tone of a teacher, writing to a student/learner, in which case it is okay to use "you".
43-
Please refrain from using impersonal subjects such as "the user".
40+
- **Write documentation in first person plural ("we").** In our open source code, tutorials and guides can be written
41+
by any developer or user, so the documentation teaches all of us how to do something with Parcels. Sometimes it can be
42+
more natural to take on the tone of a teacher, writing to a student/learner, in which case it is okay to use "you".
43+
Please refrain from using impersonal subjects such as "the user".
4444
- We recommend hard wrapping prose in markdown so that reading it becomes easier in any editor.

docs/getting_started/tutorial_quickstart.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ 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.
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
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
1212
read more, we have a [concepts overview](concepts_overview.md) discussing them in more detail. Let's dive in!
1313

1414
## Imports
1515

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

1919
```{code-cell}
@@ -24,8 +24,8 @@ import parcels
2424

2525
## Input flow fields: `FieldSet`
2626

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
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
2929
[Global Ocean Physics Reanalysis](https://doi.org/10.48670/moi-00021) from the Copernicus Marine Service.
3030

3131
```{code-cell}
@@ -38,11 +38,11 @@ ds_fields.load() # load the dataset into memory
3838
ds_fields
3939
```
4040

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

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
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
4646
recognizes the standard names of a velocity field:
4747

4848
```{code-cell}
@@ -58,12 +58,12 @@ velocity = ds_fields.isel(time=0, depth=0).plot.quiver(x="longitude", y="latitud
5858

5959
## Input virtual particles: `ParticleSet`
6060

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

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
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
6767
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).
6868

6969
```{code-cell}
@@ -89,9 +89,9 @@ ax.scatter(lon,lat,s=40,c='w',edgecolors='r');
8989

9090
## Compute: `Kernel`
9191

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.
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.
9595
Parcels comes with a number of standard kernels, from which we will use the Runge-Kutta advection kernel `AdvectionRK2`:
9696

9797
```{note}
@@ -104,26 +104,26 @@ kernels = [parcels.kernels.AdvectionEE]
104104

105105
## Prepare output: `ParticleFile`
106106

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

110110
```{code-cell}
111111
output_file = parcels.ParticleFile("output-quickstart.zarr", outputdt=np.timedelta64(1, "h"))
112112
```
113113

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
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
116116
the `outputdt` argument so that it captures the smallest timescales of our interest.
117117

118118
## Run Simulation: `ParticleSet.execute()`
119119

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

123123
- the `runtime`: for how long we want to simulate particles.
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.
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.
127127

128128
```{note}
129129
TODO: add Michaels 10-years Parcels notebook to the user guide
@@ -148,8 +148,8 @@ ds_particles = xr.open_zarr("output-quickstart.zarr")
148148
ds_particles
149149
```
150150

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)
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)
153153
provides more detail about the dataset and how to analyse it.
154154

155155
Let's verify that Parcels has computed the advection of the virtual particles!
@@ -159,6 +159,7 @@ import matplotlib.pyplot as plt
159159
160160
# plot positions and color particles by number of observation
161161
scatter = plt.scatter(ds_particles.lon.T, ds_particles.lat.T, c=np.repeat(ds_particles.obs.values,npart))
162+
plt.scatter(ds_particles.lon[:,0],ds_particles.lat[:,0],facecolors="none",edgecolors='r') # starting positions
162163
plt.scatter(lon,lat,facecolors="none",edgecolors='r') # starting positions
163164
plt.xlim(31,33)
164165
plt.ylabel("Latitude [deg N]")
@@ -167,17 +168,17 @@ plt.colorbar(scatter, label="Observation number")
167168
plt.show()
168169
```
169170

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

173174
## Running a simulation backwards in time
174175

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

179180
```{note}
180-
We have not edited the `ParticleSet`, which means that the new simulation will start with the particles at their current
181+
We have not edited the `ParticleSet`, which means that the new simulation will start with the particles at their current
181182
location!
182183
```
183184

@@ -201,7 +202,7 @@ When we check the output, we can see that the particles have returned to their o
201202
ds_particles_back = xr.open_zarr("output-backwards.zarr")
202203
203204
scatter = plt.scatter(ds_particles_back.lon.T, ds_particles_back.lat.T, c=np.repeat(ds_particles_back.obs.values,npart))
204-
plt.scatter(lon,lat,facecolors="none",edgecolors='r') # starting positions
205+
plt.scatter(ds_particles_back.lon[:,0],ds_particles_back.lat[:,0],facecolors="none",edgecolors='r') # starting positions
205206
plt.xlabel("Longitude [deg E]")
206207
plt.xlim(31,33)
207208
plt.ylabel("Latitude [deg N]")

0 commit comments

Comments
 (0)