Skip to content

Commit bc30fd0

Browse files
authored
Merge pull request #33 from OceanParcels/update_documentation
Improving the readthedocs documentation
2 parents 7664fd0 + e14fd0a commit bc30fd0

16 files changed

Lines changed: 406 additions & 161 deletions

docs/examples/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Examples
2+
3+
Up-to-date documentation on the `plasticparcels` examples can be found [here](https://plastic.oceanparcels.org/en/latest/examples.html).

docs/examples/example_Croatian_fisheries.ipynb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
"source": [
6363
"# Create the simulation settings\n",
6464
"settings['simulation'] = {\n",
65-
" 'start_date': datetime.strptime('2019-01-01-00:00:00', '%Y-%m-%d-%H:%M:%S'), # Start date of simulation\n",
65+
" 'startdate': datetime.strptime('2019-01-01-00:00:00', '%Y-%m-%d-%H:%M:%S'), # Start date of simulation\n",
6666
" 'runtime': timedelta(days=30), # Runtime of simulation\n",
67-
" 'dt_write': timedelta(hours=12), # Timestep of output\n",
68-
" 'dt_timestep': timedelta(minutes=20), # Timestep of advection\n",
67+
" 'outputdt': timedelta(hours=12), # Timestep of output\n",
68+
" 'dt': timedelta(minutes=20), # Timestep of advection\n",
6969
" }\n",
7070
"\n",
7171
"# Overwrite some settings\n",
@@ -155,8 +155,8 @@
155155
"outputs": [],
156156
"source": [
157157
"runtime = settings['simulation']['runtime']\n",
158-
"dt_timestep = settings['simulation']['dt_timestep']\n",
159-
"dt_write = settings['simulation']['dt_write']"
158+
"dt = settings['simulation']['dt']\n",
159+
"outputdt = settings['simulation']['outputdt']"
160160
]
161161
},
162162
{
@@ -174,7 +174,7 @@
174174
"outputs": [],
175175
"source": [
176176
"# Create the particle file where output will be stored\n",
177-
"pfile = pp.ParticleFile('example_Croatia_fisheries.zarr', pset, settings=settings, outputdt=dt_write)"
177+
"pfile = pp.ParticleFile('example_Croatia_fisheries.zarr', pset, settings=settings, outputdt=outputdt)"
178178
]
179179
},
180180
{
@@ -187,13 +187,13 @@
187187
"output_type": "stream",
188188
"text": [
189189
"INFO: Output files are stored in example_Croatia_fisheries.zarr.\n",
190-
"100%|██████████| 2592000.0/2592000.0 [07:16<00:00, 5938.88it/s] \n"
190+
"100%|██████████| 2592000.0/2592000.0 [07:49<00:00, 5524.98it/s]\n"
191191
]
192192
}
193193
],
194194
"source": [
195195
"# Execute the simulation\n",
196-
"pset.execute(kernels, runtime=runtime, dt=dt_timestep, output_file=pfile)"
196+
"pset.execute(kernels, runtime=runtime, dt=dt, output_file=pfile)"
197197
]
198198
},
199199
{
@@ -284,9 +284,9 @@
284284
"metadata": {},
285285
"outputs": [],
286286
"source": [
287-
"settings['bgc']['constants']['biofilm_density'] = 1400.0 # Biofilm density (kg/m^3)\n",
288-
"settings['bgc']['constants']['collision_probability'] = 0.75 # Probability of collision with ambient algae\n",
289-
"settings['bgc']['constants']['algae_mortality_rate'] = 0.80 # Mortality rate of biofilm"
287+
"settings['bgc']['constants']['biofilm_density'] = 1400.0 # Biofilm density (kg/m^3)\n",
288+
"settings['bgc']['constants']['collision_probability'] = 0.75 # Probability of collision with ambient algae\n",
289+
"settings['bgc']['constants']['algae_mortality_rate'] = 0.80 # Mortality rate of biofilm"
290290
]
291291
},
292292
{
@@ -326,7 +326,7 @@
326326
"outputs": [],
327327
"source": [
328328
"# Create the particle file where output will be stored\n",
329-
"pfile = pp.ParticleFile('example_Croatia_fisheries_sensitivity.zarr', pset, settings=settings, outputdt=dt_write)"
329+
"pfile = pp.ParticleFile('example_Croatia_fisheries_sensitivity.zarr', pset, settings=settings, outputdt=outputdt)"
330330
]
331331
},
332332
{
@@ -339,13 +339,13 @@
339339
"output_type": "stream",
340340
"text": [
341341
"INFO: Output files are stored in example_Croatia_fisheries_sensitivity.zarr.\n",
342-
"100%|██████████| 2592000.0/2592000.0 [12:43<00:00, 3394.83it/s] \n"
342+
"100%|██████████| 2592000.0/2592000.0 [19:57<00:00, 2163.97it/s] \n"
343343
]
344344
}
345345
],
346346
"source": [
347347
"# Execute the simulation\n",
348-
"pset.execute(kernels, runtime=runtime, dt=dt_timestep, output_file=pfile)"
348+
"pset.execute(kernels, runtime=runtime, dt=dt, output_file=pfile)"
349349
]
350350
},
351351
{

docs/examples/example_Greece_coast.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
"source": [
6363
"# Create the simulation settings\n",
6464
"settings['simulation'] = {\n",
65-
" 'start_date': datetime.strptime('2019-06-01-00:00:00', '%Y-%m-%d-%H:%M:%S'), # Start date of simulation\n",
66-
" 'runtime': timedelta(days=30), # Runtime of simulation\n",
67-
" 'dt_write': timedelta(hours=12), # Timestep of output\n",
68-
" 'dt_timestep': timedelta(minutes=20), # Timestep of advection\n",
65+
" 'startdate': datetime.strptime('2019-06-01-00:00:00', '%Y-%m-%d-%H:%M:%S'), # Start date of simulation\n",
66+
" 'runtime': timedelta(days=30), # Runtime of simulation\n",
67+
" 'outputdt': timedelta(hours=12), # Timestep of output\n",
68+
" 'dt': timedelta(minutes=20), # Timestep of advection\n",
6969
" }\n",
7070
"\n",
7171
"# Overwrite some settings\n",
@@ -164,8 +164,8 @@
164164
"outputs": [],
165165
"source": [
166166
"runtime = settings['simulation']['runtime']\n",
167-
"dt_timestep = settings['simulation']['dt_timestep']\n",
168-
"dt_write = settings['simulation']['dt_write']"
167+
"dt = settings['simulation']['dt']\n",
168+
"outputdt = settings['simulation']['outputdt']"
169169
]
170170
},
171171
{
@@ -183,7 +183,7 @@
183183
"outputs": [],
184184
"source": [
185185
"# Create the particle file where output will be stored\n",
186-
"pfile = pp.ParticleFile('example_Greece_coast.zarr', pset, settings=settings, outputdt=dt_write)"
186+
"pfile = pp.ParticleFile('example_Greece_coast.zarr', pset, settings=settings, outputdt=outputdt)"
187187
]
188188
},
189189
{
@@ -196,13 +196,13 @@
196196
"output_type": "stream",
197197
"text": [
198198
"INFO: Output files are stored in example_Greece_coast.zarr.\n",
199-
"100%|██████████| 2592000.0/2592000.0 [00:53<00:00, 48730.82it/s]\n"
199+
"100%|██████████| 2592000.0/2592000.0 [00:59<00:00, 43331.55it/s]\n"
200200
]
201201
}
202202
],
203203
"source": [
204204
"# Execute the simulation\n",
205-
"pset.execute(kernels, runtime=runtime, dt=dt_timestep, output_file=pfile)"
205+
"pset.execute(kernels, runtime=runtime, dt=dt, output_file=pfile)"
206206
]
207207
},
208208
{

docs/examples/example_Italy_coast.ipynb

Lines changed: 58 additions & 19 deletions
Large diffs are not rendered by default.

docs/examples/example_add_your_own_kernel.ipynb

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
5757
"source": [
5858
"# Create the simulation settings\n",
5959
"settings['simulation'] = {\n",
60-
" 'start_date': datetime.strptime('2019-01-01-00:00:00', '%Y-%m-%d-%H:%M:%S'), # Start date of simulation\n",
61-
" 'runtime': timedelta(days=30), # Runtime of simulation, use negative if releasing particles backwards in time\n",
62-
" 'dt_write': timedelta(hours=12), # Timestep of output\n",
63-
" 'dt_timestep': timedelta(minutes=20), # Timestep of advection\n",
60+
" 'startdate': datetime.strptime('2019-01-01-00:00:00', '%Y-%m-%d-%H:%M:%S'), # Start date of simulation\n",
61+
" 'runtime': timedelta(days=30), # Runtime of simulation\n",
62+
" 'outputdt': timedelta(hours=12), # Timestep of output\n",
63+
" 'dt': timedelta(minutes=20), # Timestep of advection\n",
6464
" }\n",
6565
"\n",
6666
"# Subset the ocean data to just include the Mediterranean Sea\n",
@@ -210,15 +210,15 @@
210210
"name": "stdout",
211211
"output_type": "stream",
212212
"text": [
213-
"<function PolyTEOS10_bsq at 0x7f38b955f910>\n",
214-
"<function AdvectionRK4_3D at 0x7f38ba1b2d40>\n",
215-
"<function Biofouling at 0x7f38b955f880>\n",
216-
"<function StokesDrift at 0x7f38b955f6d0>\n",
217-
"<function unbeaching at 0x7f38b955fa30>\n",
218-
"<function checkThroughBathymetry at 0x7f38b955fac0>\n",
219-
"<function checkErrorThroughSurface at 0x7f38b955fbe0>\n",
220-
"<function periodicBC at 0x7f38b955fb50>\n",
221-
"<function deleteParticle at 0x7f38b955fc70>\n"
213+
"<function PolyTEOS10_bsq at 0x7f19fefcb910>\n",
214+
"<function AdvectionRK4_3D at 0x7f19ffd2ad40>\n",
215+
"<function Biofouling at 0x7f19fefcb880>\n",
216+
"<function StokesDrift at 0x7f19fefcb6d0>\n",
217+
"<function unbeaching at 0x7f19fefcba30>\n",
218+
"<function checkThroughBathymetry at 0x7f19fefcbac0>\n",
219+
"<function checkErrorThroughSurface at 0x7f19fefcbbe0>\n",
220+
"<function periodicBC at 0x7f19fefcbb50>\n",
221+
"<function deleteParticle at 0x7f19fefcbc70>\n"
222222
]
223223
}
224224
],
@@ -245,21 +245,21 @@
245245
"output_type": "stream",
246246
"text": [
247247
"INFO: Output files are stored in example_Tunisia_fisheries_prebuilt.zarr.\n",
248-
"100%|██████████| 2592000.0/2592000.0 [14:30<00:00, 2977.08it/s]\n"
248+
"100%|██████████| 2592000.0/2592000.0 [07:48<00:00, 5529.73it/s]\n"
249249
]
250250
}
251251
],
252252
"source": [
253253
"# Define the runtime, the timestepping, and the output frequency of the simulation from the settings\n",
254254
"runtime = settings['simulation']['runtime']\n",
255-
"dt_timestep = settings['simulation']['dt_timestep']\n",
256-
"dt_write = settings['simulation']['dt_write']\n",
255+
"dt = settings['simulation']['dt']\n",
256+
"outputdt = settings['simulation']['outputdt']\n",
257257
"\n",
258258
"# Create the particle file where output will be stored\n",
259-
"pfile = pp.ParticleFile('example_Tunisia_fisheries_prebuilt.zarr', pset, settings=settings, outputdt=dt_write)\n",
259+
"pfile = pp.ParticleFile('example_Tunisia_fisheries_prebuilt.zarr', pset, settings=settings, outputdt=outputdt)\n",
260260
"\n",
261261
"# Execute the simulation\n",
262-
"pset.execute(kernels, runtime=runtime, dt=dt_timestep, output_file=pfile)"
262+
"pset.execute(kernels, runtime=runtime, dt=dt, output_file=pfile)"
263263
]
264264
},
265265
{
@@ -359,15 +359,15 @@
359359
"name": "stdout",
360360
"output_type": "stream",
361361
"text": [
362-
"<function PolyTEOS10_bsq at 0x7f38b955f910>\n",
363-
"<function AdvectionRK4_3D at 0x7f38ba1b2d40>\n",
364-
"<function Biofouling at 0x7f38b955f880>\n",
365-
"<function StokesDrift at 0x7f38b955f6d0>\n",
366-
"<function unbeaching at 0x7f38b955fa30>\n",
367-
"<function checkThroughBathymetry at 0x7f38b955fac0>\n",
368-
"<function checkErrorThroughSurface at 0x7f38b955fbe0>\n",
369-
"<function periodicBC at 0x7f38b955fb50>\n",
370-
"<function deleteParticle at 0x7f38b955fc70>\n"
362+
"<function PolyTEOS10_bsq at 0x7f19fefcb910>\n",
363+
"<function AdvectionRK4_3D at 0x7f19ffd2ad40>\n",
364+
"<function Biofouling at 0x7f19fefcb880>\n",
365+
"<function StokesDrift at 0x7f19fefcb6d0>\n",
366+
"<function unbeaching at 0x7f19fefcba30>\n",
367+
"<function checkThroughBathymetry at 0x7f19fefcbac0>\n",
368+
"<function checkErrorThroughSurface at 0x7f19fefcbbe0>\n",
369+
"<function periodicBC at 0x7f19fefcbb50>\n",
370+
"<function deleteParticle at 0x7f19fefcbc70>\n"
371371
]
372372
}
373373
],
@@ -392,17 +392,17 @@
392392
"name": "stdout",
393393
"output_type": "stream",
394394
"text": [
395-
"<function PolyTEOS10_bsq at 0x7f38b955f910>\n",
396-
"<function AdvectionRK4_3D at 0x7f38ba1b2d40>\n",
397-
"<function Biofouling at 0x7f38b955f880>\n",
398-
"<function StokesDrift at 0x7f38b955f6d0>\n",
399-
"<function NorthwardDrift at 0x7f38889ba440>\n",
400-
"<function EastwardDrift at 0x7f38889ba290>\n",
401-
"<function unbeaching at 0x7f38b955fa30>\n",
402-
"<function checkThroughBathymetry at 0x7f38b955fac0>\n",
403-
"<function checkErrorThroughSurface at 0x7f38b955fbe0>\n",
404-
"<function periodicBC at 0x7f38b955fb50>\n",
405-
"<function deleteParticle at 0x7f38b955fc70>\n"
395+
"<function PolyTEOS10_bsq at 0x7f19fefcb910>\n",
396+
"<function AdvectionRK4_3D at 0x7f19ffd2ad40>\n",
397+
"<function Biofouling at 0x7f19fefcb880>\n",
398+
"<function StokesDrift at 0x7f19fefcb6d0>\n",
399+
"<function NorthwardDrift at 0x7f19d409a4d0>\n",
400+
"<function EastwardDrift at 0x7f19d409a440>\n",
401+
"<function unbeaching at 0x7f19fefcba30>\n",
402+
"<function checkThroughBathymetry at 0x7f19fefcbac0>\n",
403+
"<function checkErrorThroughSurface at 0x7f19fefcbbe0>\n",
404+
"<function periodicBC at 0x7f19fefcbb50>\n",
405+
"<function deleteParticle at 0x7f19fefcbc70>\n"
406406
]
407407
}
408408
],
@@ -432,16 +432,16 @@
432432
"output_type": "stream",
433433
"text": [
434434
"INFO: Output files are stored in example_Tunisia_fisheries_custom.zarr.\n",
435-
"100%|██████████| 2592000.0/2592000.0 [15:12<00:00, 2839.68it/s]\n"
435+
"100%|██████████| 2592000.0/2592000.0 [19:57<00:00, 2164.59it/s] \n"
436436
]
437437
}
438438
],
439439
"source": [
440440
"# Create the particle file where output will be stored\n",
441-
"pfile = pp.ParticleFile('example_Tunisia_fisheries_custom.zarr', pset, settings=settings, outputdt=dt_write)\n",
441+
"pfile = pp.ParticleFile('example_Tunisia_fisheries_custom.zarr', pset, settings=settings, outputdt=outputdt)\n",
442442
"\n",
443443
"# Execute the simulation\n",
444-
"pset.execute(kernels, runtime=runtime, dt=dt_timestep, output_file=pfile)"
444+
"pset.execute(kernels, runtime=runtime, dt=dt, output_file=pfile)"
445445
]
446446
},
447447
{

docs/examples/example_initialisation_maps.ipynb

Lines changed: 133 additions & 9 deletions
Large diffs are not rendered by default.

docs/index.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,25 @@ Installation
2121
conda install conda-forge::plasticparcels
2222
2323
24-
Or downloaded from https://github.com/OceanParcels/PlasticParcels
24+
Or downloaded from https://github.com/OceanParcels/plasticparcels
2525

2626

27+
Required Data
28+
^^^^^^^^^^^^^
29+
30+
``plasticparcels`` has been developed for use with data from the Copernicus Marine Service, and requires the following data to run:
31+
32+
* Hydrodynamic model data: `MOI GLO12 (psy4v3r1) <https://www.mercator-ocean.eu/en/solutions-expertise/accessing-digital-data/product-details/?offer=4217979b-2662-329a-907c-602fdc69c3a3&system=d35404e4-40d3-59d6-3608-581c9495d86a>`_
33+
* Biogeochemical model data: `MOI BIO4 (biomer4v2r1) <https://www.mercator-ocean.eu/en/solutions-expertise/accessing-digital-data/product-details/?offer=8d0c01f3-81c7-0a59-0d06-602fdf63c5b6&system=dc40b324-7de7-0732-880b-5d9dcf7d344a>`_
34+
* Wave data: `ECMWF ERA5 Wave <https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels>`_ (specifically, the variables ``mean_wave_period``, ``peak_wave_period``, ``u_component_stokes_drift``, and ``v_component_stokes_drift``.)
35+
* Wind data: `ECMWF ERA5 Wind <https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels>`_ (specifically, the variables ``10m_u_component_of_wind`` and ``10m_v_component_of_wind``)
36+
37+
For the wind and wave data, we recommend using the `CDS API <https://cds.climate.copernicus.eu/api-how-to>`_.
38+
39+
To run the examples, you will need to update the data directories in settings ``.json`` files.
40+
41+
Just like the ``parcels`` framework, ``plasticparcels`` can be adapted to use other hydrodynamic, biogeochemical, wave, and atmospheric models. If you require assistance, please contact us through the [Discussions page on GitHub](https://github.com/OceanParcels/plasticparcels/discussions).
42+
2743
.. toctree::
2844
:maxdepth: 2
2945
:caption: Contents

docs/initialisationmaps.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Description of algorithms for particle initialisation maps
2-
Included in the `PlasticParcels` package are four particle initialisation maps, along with the algorithms to create them. These maps represent best estimates for plastic pollution emissions along coastlines [@Jambeck2015](http://dx.doi.org/10.1126/science.1260352), from river sources [@Meijer2021](http://dx.doi.org/10.1126/sciadv.aaz5803), in the open-ocean from fishing-related activities [@Kroodsma2018](http://dx.doi.org/10.1126/science.aao5646), as well as a current best estimate of buoyant plastic concentrations globally [@Kaandorp2023](http://dx.doi.org/10.1038/s41561-023-01216-0).
2+
Included in the `plasticparcels` package are four particle initialisation maps, along with the algorithms to create them. These maps represent best estimates for plastic pollution emissions along coastlines [@Jambeck2015](http://dx.doi.org/10.1126/science.1260352), from river sources [@Meijer2021](http://dx.doi.org/10.1126/sciadv.aaz5803), in the open-ocean from fishing-related activities [@Kroodsma2018](http://dx.doi.org/10.1126/science.aao5646), as well as a current best estimate of buoyant plastic concentrations globally [@Kaandorp2023](http://dx.doi.org/10.1038/s41561-023-01216-0).
33
Each initialisation map, however, requires that particles be placed in ocean grid cells, so we also provide algorithms to generate these ocean masks too.
44

55
The code for these algorithims can be found in `plasticparcels/scripts/create_release_maps.py`. Below we describe each of the algorithms.
@@ -20,7 +20,7 @@ To generate a particle initialisation map of plastic pollution that enters the o
2020
4. Create an array with the coastal model grid-cell and its associated area, the country name, continent name, region name, and subregion name from the shapefile, and the identified population density.
2121
5. Combine all entries generated in Step 4.4. into one array.
2222
6. Load the global mismanaged plastic waste data [@Jambeck2015](http://dx.doi.org/10.1126/science.1260352), and join it to the array generated in Step 5, by 'left joining' on country name$^*$. Create an additional column 'MPW_cell', which represents the mismanaged plastic waste across the grid cell, by multiplying the mismanaged plastic waste per kilogram per day with the population density and the grid-cell area.
23-
7. Save the data into a `.csv` file, to be read and processed by `PlasticParcels`.
23+
7. Save the data into a `.csv` file, to be read and processed by `plasticparcels`.
2424

2525

2626
$^*$We pre-process the country names in the [@Jambeck2015](http://dx.doi.org/10.1126/science.1260352) data to account for small differences in the naming conventions of each country. We use $`r=50`$ km, and $`\phi`$ is chosen as the model grid width in degrees. A sample plot of the initialisation map is shown in Figure X **add link**.
@@ -36,7 +36,7 @@ To generate a particle initialisation map of plastic pollution that enters the o
3636
1. Compute the distance from the emission source to the center of every coastal grid cell, and identify the closest coastal grid cell.
3737
2. Compute the distance from the emission source to every country border point, and identify the closest country border point.
3838
3. Create an array with the coastal model grid-cell, the country name, continent name, region name, and subregion name of the closest border point from the Natural Earth shapefile, and the associated emissions amount.
39-
5. Save the data into a `.csv` file, to be read and processed by `PlasticParcels`.
39+
5. Save the data into a `.csv` file, to be read and processed by `plasticparcels`.
4040

4141

4242
## Open-sea fishing-related plastic emissions <a name="fishingrelease"></a>
@@ -51,7 +51,7 @@ To generate a particle initialisation map of plastic pollution emitted into the
5151
6. Load (or generate) the coast mask file from the selected ocean model.
5252
7. Find the closest ocean grid cell for each entry in the aggregated dataset from Step 5. using a KD-Tree approach.
5353
8. Aggregate the data by summing the fishing hours over the following columns: country name, continent name, flag, gear type, date (month and year), ocean grid cell.
54-
9. Save the data into a `.csv` file, to be read and processed by `PlasticParcels`.
54+
9. Save the data into a `.csv` file, to be read and processed by `plasticparcels`.
5555

5656
$^*$We use the `fleet-daily-csvs-100-v2-2020` files, which are for the year 2020 only.
5757

@@ -70,4 +70,4 @@ To generate a particle initialisation map of the current best-estimate of global
7070
8. Interpolate the `concentration_mass_log10` to the ocean-grid cells, using an `RegularGridInterpolator` function from `scipy.interpolate`, with the grid and data being `(lon, lat)` and `concentration_mass_log10` from the `concentration_mass_log10` dataset.
7171
9. For all valid concentrations identified in Step 8., identify the closest country boundary vertex from the Natural Earth shapefile.
7272
10. Create an array with the ocean model cell, the interpolated plastic concentration amount (converting it into a mass insteaf of a `log10` mass), and the continent name, region name, subregion name, country name, and country flag from the Natural Earth shapefile.
73-
11. Combine the arrays generated in Steps 6. and 10., and save the data as a `.csv` file, to be read and processed `PlasticParcels`.
73+
11. Combine the arrays generated in Steps 6. and 10., and save the data as a `.csv` file, to be read and processed `plasticparcels`.

docs/paper/example.png

561 KB
Loading

docs/paper/initialisation_maps.png

1.17 MB
Loading

0 commit comments

Comments
 (0)