Skip to content

Commit 9bfc26d

Browse files
committed
create a mediterannean subset of fisheries data and give logo to workshop tutorial
1 parent 48514f2 commit 9bfc26d

3 files changed

Lines changed: 123 additions & 80 deletions

File tree

src/DRAKKAR workshop code/PlasticParcels_DRAKKAR_tutorial.ipynb

Lines changed: 6 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -55,50 +55,7 @@
5555
"id": "8hmSW7UJUdO8",
5656
"outputId": "5a03f29c-ae96-48f0-a045-0e37e228e7d3"
5757
},
58-
"outputs": [
59-
{
60-
"name": "stdout",
61-
"output_type": "stream",
62-
"text": [
63-
"cgen\n",
64-
"jupyter\n",
65-
"matplotlib-base>=2.0.2\n",
66-
"netcdf4>=1.1.9\n",
67-
"numpy>=1.9.1\n",
68-
"platformdirs\n",
69-
"psutil\n",
70-
"py>=1.4.27\n",
71-
"pymbolic\n",
72-
"scipy\n",
73-
"tqdm\n",
74-
"trajan\n",
75-
"xarray>=0.10.8\n",
76-
"cftime>=1.3.1\n",
77-
"dask>=2.0\n",
78-
"nbval\n",
79-
"scikit-learn\n",
80-
"pykdtree\n",
81-
"zarr>=2.11.0\n",
82-
"black\n",
83-
"isort\n",
84-
"pytest\n",
85-
"pytest-html\n",
86-
"coverage\n",
87-
"flake8>=2.1.0\n",
88-
"pre_commit\n",
89-
"pydocsty;e\n",
90-
"ipython\n",
91-
"numpydoc\n",
92-
"nbsphinx\n",
93-
"sphinx<6\n",
94-
"pandoc>1.12.1,<3\n",
95-
"pydata-sphinx-theme\n",
96-
"sphinx-autobuild\n",
97-
"myst-parser\n",
98-
"parcels\n"
99-
]
100-
}
101-
],
58+
"outputs": [],
10259
"source": [
10360
"packages = ['cgen',\n",
10461
" 'netcdf4>=1.1.9',\n",
@@ -131,25 +88,7 @@
13188
"id": "hoW6ozA04wue",
13289
"outputId": "cdf7ef3d-c0d1-4da1-99b3-73373b1bb0c4"
13390
},
134-
"outputs": [
135-
{
136-
"ename": "FileURLRetrievalError",
137-
"evalue": "Failed to retrieve file url:\n\n\tCannot retrieve the public link of the file. You may need to change\n\tthe permission to 'Anyone with the link', or have had many accesses.\n\nYou may still be able to access the file from the browser:\n\n\thttps://drive.google.com/uc?id=1DMtK76aCZxUOHdJFv1mI_EPTTHz_HIIN\n\nbut Gdown can't. Please check connections and permissions.",
138-
"output_type": "error",
139-
"traceback": [
140-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
141-
"\u001b[0;31mFileURLRetrievalError\u001b[0m Traceback (most recent call last)",
142-
"\u001b[0;32m/usr/local/lib/python3.10/dist-packages/gdown/download.py\u001b[0m in \u001b[0;36mdownload\u001b[0;34m(url, output, quiet, proxy, speed, use_cookies, verify, id, fuzzy, resume, format, user_agent)\u001b[0m\n\u001b[1;32m 231\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 232\u001b[0;31m \u001b[0murl\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_url_from_gdrive_confirmation\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mres\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 233\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mFileURLRetrievalError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
143-
"\u001b[0;32m/usr/local/lib/python3.10/dist-packages/gdown/download.py\u001b[0m in \u001b[0;36mget_url_from_gdrive_confirmation\u001b[0;34m(contents)\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 49\u001b[0;31m raise FileURLRetrievalError(\n\u001b[0m\u001b[1;32m 50\u001b[0m \u001b[0;34m\"Cannot retrieve the public link of the file. \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
144-
"\u001b[0;31mFileURLRetrievalError\u001b[0m: Cannot retrieve the public link of the file. You may need to change the permission to 'Anyone with the link', or have had many accesses.",
145-
"\nDuring handling of the above exception, another exception occurred:\n",
146-
"\u001b[0;31mFileURLRetrievalError\u001b[0m Traceback (most recent call last)",
147-
"\u001b[0;32m<ipython-input-6-ff46f8bfe9e1>\u001b[0m in \u001b[0;36m<cell line: 23>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;31m#except:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0;31m# print(os.system('wget https://drive.google.com/uc?id='+file_id+' -P '+output))\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 30\u001b[0;31m \u001b[0mgdown\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdownload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moutput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mquiet\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
148-
"\u001b[0;32m/usr/local/lib/python3.10/dist-packages/gdown/download.py\u001b[0m in \u001b[0;36mdownload\u001b[0;34m(url, output, quiet, proxy, speed, use_cookies, verify, id, fuzzy, resume, format, user_agent)\u001b[0m\n\u001b[1;32m 241\u001b[0m \u001b[0murl_origin\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 242\u001b[0m )\n\u001b[0;32m--> 243\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mFileURLRetrievalError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 244\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 245\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mgdrive_file_id\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mis_gdrive_download_link\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
149-
"\u001b[0;31mFileURLRetrievalError\u001b[0m: Failed to retrieve file url:\n\n\tCannot retrieve the public link of the file. You may need to change\n\tthe permission to 'Anyone with the link', or have had many accesses.\n\nYou may still be able to access the file from the browser:\n\n\thttps://drive.google.com/uc?id=1DMtK76aCZxUOHdJFv1mI_EPTTHz_HIIN\n\nbut Gdown can't. Please check connections and permissions."
150-
]
151-
}
152-
],
91+
"outputs": [],
15392
"source": [
15493
"## Download required data for the tutorial\n",
15594
"files = [\"coordinates.zip\",\n",
@@ -184,22 +123,7 @@
184123
"id": "l4rWBopK4-33",
185124
"outputId": "ca64b20d-82aa-4a58-d614-7aa0b9f951ed"
186125
},
187-
"outputs": [
188-
{
189-
"name": "stdout",
190-
"output_type": "stream",
191-
"text": [
192-
"daily_V.zip unzipped\n",
193-
"daily_W.zip unzipped\n",
194-
"PlasticParcels.zip unzipped\n",
195-
"ERA5.zip unzipped\n",
196-
"coordinates.zip unzipped\n",
197-
"unbeaching.zip unzipped\n",
198-
"release.zip unzipped\n",
199-
"daily_U.zip unzipped\n"
200-
]
201-
}
202-
],
126+
"outputs": [],
203127
"source": [
204128
"## Unzip data and delete the .zip file\n",
205129
"download_files = os.listdir('./data_download/')\n",
@@ -221,6 +145,9 @@
221145
},
222146
"source": [
223147
"# PlasticParcels DRAKKAR Tutorial\n",
148+
"\n",
149+
"![PlasticParcels](https://github.com/OceanParcels/PlasticParcels/blob/main/logo.png)\n",
150+
"\n",
224151
"In this tutorial we will introduce you to some of the basic Parcels functions, as well as utilise the PlasticParcels tool for simulating microplastic pollution in the Mediterranean sea.\n",
225152
"\n",
226153
"By the end of this tutorial you should be able to create and visual hydrodynamic (and other) fields, create particle sets that represent marine microplastic pollution release locations, and apply physics parameterisations to simulate the dispersal of microplastics in the ocean.\n",
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 4,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import numpy as np\n",
10+
"import xarray as xr\n",
11+
"import pandas as pd\n"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": 5,
17+
"metadata": {},
18+
"outputs": [],
19+
"source": [
20+
"## Create a subset of the fisheries data for the tutorial\n",
21+
"file = '../../data/release/generated_files/agg_data_fisheries_info.csv'\n",
22+
"df = pd.read_csv(file)"
23+
]
24+
},
25+
{
26+
"cell_type": "code",
27+
"execution_count": 6,
28+
"metadata": {},
29+
"outputs": [],
30+
"source": [
31+
"left_lim, right_lim = [-10, 42]\n",
32+
"bottom_lim, top_lim = [30, 48]"
33+
]
34+
},
35+
{
36+
"cell_type": "code",
37+
"execution_count": 12,
38+
"metadata": {},
39+
"outputs": [],
40+
"source": [
41+
"inside_longitudes = np.logical_and((df['Longitude']>= left_lim), (df['Longitude'] <= right_lim))"
42+
]
43+
},
44+
{
45+
"cell_type": "code",
46+
"execution_count": 13,
47+
"metadata": {},
48+
"outputs": [],
49+
"source": [
50+
"inside_latitudes = np.logical_and((df['Latitude']>= bottom_lim), (df['Latitude'] <= top_lim))"
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": 14,
56+
"metadata": {},
57+
"outputs": [],
58+
"source": [
59+
"id_to_keep = np.logical_and(inside_longitudes, inside_latitudes)"
60+
]
61+
},
62+
{
63+
"cell_type": "code",
64+
"execution_count": 16,
65+
"metadata": {},
66+
"outputs": [],
67+
"source": [
68+
"subset = df[id_to_keep]"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": 17,
74+
"metadata": {},
75+
"outputs": [],
76+
"source": [
77+
"# Store datafile\n",
78+
"output_data = '../../data/release/generated_files/'\n",
79+
"subset.to_csv(output_data+'agg_data_fisheries_info_subset.csv')"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": null,
85+
"metadata": {},
86+
"outputs": [],
87+
"source": []
88+
}
89+
],
90+
"metadata": {
91+
"kernelspec": {
92+
"display_name": "py3_parcels",
93+
"language": "python",
94+
"name": "python3"
95+
},
96+
"language_info": {
97+
"codemirror_mode": {
98+
"name": "ipython",
99+
"version": 3
100+
},
101+
"file_extension": ".py",
102+
"mimetype": "text/x-python",
103+
"name": "python",
104+
"nbconvert_exporter": "python",
105+
"pygments_lexer": "ipython3",
106+
"version": "3.11.4"
107+
}
108+
},
109+
"nbformat": 4,
110+
"nbformat_minor": 2
111+
}

src/release/create_fisheries_release.ipynb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"outputs": [],
8888
"source": [
8989
"# Store datafile\n",
90-
"#agg_data_fisheries.to_csv(output_data+'fleet_monthly_aggregated.csv')\n",
90+
"agg_data_fisheries.to_csv(output_data+'fleet_monthly_aggregated.csv')\n",
9191
"## This chops it down from 70gb for one year to 2gb!"
9292
]
9393
},
@@ -320,6 +320,11 @@
320320
"## This chops it down from 70gb for one year to 2gb!"
321321
]
322322
},
323+
{
324+
"cell_type": "markdown",
325+
"metadata": {},
326+
"source": []
327+
},
323328
{
324329
"cell_type": "code",
325330
"execution_count": 12,

0 commit comments

Comments
 (0)