Skip to content

Commit 492290f

Browse files
committed
Updating Italy coast example settings to include global concentrations release map, and creating a Greek coastline global concentrations example
1 parent 3fb89a3 commit 492290f

3 files changed

Lines changed: 381 additions & 2 deletions

File tree

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# PlasticParcels Example\n",
8+
"## The pathways and fate of existing plastic pollution along Greek coastlines\n",
9+
"In this example, we will use `plasticparcels` to run a basic simulation of microplastic pollution along the Greek coastline."
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": null,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"# Library imports\n",
19+
"from datetime import datetime, timedelta\n",
20+
"\n",
21+
"# Parcels and PlasticParcels imports\n",
22+
"import os\n",
23+
"os.chdir('../../')\n",
24+
"import plasticparcels as pp\n",
25+
"\n",
26+
"# Plotting imports\n",
27+
"import matplotlib.pyplot as plt\n",
28+
"import cartopy.crs as ccrs\n",
29+
"import xarray as xr"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"# Load the model settings\n",
39+
"settings_file = 'docs/examples/example_Greece_coast_settings.json'\n",
40+
"settings = pp.utils.load_settings(settings_file)"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"# Create the simulation settings\n",
50+
"settings['simulation'] = {\n",
51+
" 'start_date': datetime.strptime('2019-01-10-00:00:00', '%Y-%m-%d-%H:%M:%S'), # Start date of simulation\n",
52+
" 'runtime': timedelta(days=30), # Runtime of simulation, use negative if releasing particles backwards in time\n",
53+
" 'dt_write': timedelta(hours=12), # Timestep of output\n",
54+
" 'dt_timestep': timedelta(minutes=20), # Timestep of advection\n",
55+
" }\n",
56+
"\n",
57+
"# Overwrite some settings\n",
58+
"settings['use_3D'] = False\n",
59+
"settings['use_biofouling'] = False\n",
60+
"settings['use_stokes'] = True\n",
61+
"settings['use_wind'] = True\n"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": null,
67+
"metadata": {},
68+
"outputs": [],
69+
"source": [
70+
"# Create the particle release settings\n",
71+
"settings['release'] = {\n",
72+
" 'initialisation_type': 'global_concentrations',\n",
73+
" 'concentration_type': 'Beach',\n",
74+
" 'country': 'Greece',\n",
75+
"}"
76+
]
77+
},
78+
{
79+
"cell_type": "code",
80+
"execution_count": null,
81+
"metadata": {},
82+
"outputs": [],
83+
"source": [
84+
"# Create the plastic type settings\n",
85+
"settings['plastictype'] = {\n",
86+
" 'wind_coefficient' : 0.01, # Percentage of wind to apply to particles\n",
87+
" 'plastic_diameter' : 0.001, # Plastic particle diameter (m)\n",
88+
" 'plastic_density' : 1030., # Plastic particle density (kg/m^3)\n",
89+
"}"
90+
]
91+
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": null,
95+
"metadata": {},
96+
"outputs": [],
97+
"source": [
98+
"settings['ocean']['indices'] = {'lon':range(3300, 4000), 'lat':range(1850, 2400)}#, 'depth':range(0,2)}"
99+
]
100+
},
101+
{
102+
"cell_type": "code",
103+
"execution_count": null,
104+
"metadata": {},
105+
"outputs": [],
106+
"source": [
107+
"# Download the mask and release data\n",
108+
"#settings = pp.utils.download_plasticparcels_dataset('NEMO0083', settings, 'input_data')"
109+
]
110+
},
111+
{
112+
"cell_type": "code",
113+
"execution_count": null,
114+
"metadata": {},
115+
"outputs": [],
116+
"source": [
117+
"# Create the fieldset\n",
118+
"fieldset = pp.constructors.create_fieldset(settings)"
119+
]
120+
},
121+
{
122+
"cell_type": "code",
123+
"execution_count": null,
124+
"metadata": {},
125+
"outputs": [],
126+
"source": [
127+
"# Create the particleset\n",
128+
"pset = pp.constructors.create_particleset_from_map(fieldset, settings)"
129+
]
130+
},
131+
{
132+
"cell_type": "code",
133+
"execution_count": null,
134+
"metadata": {},
135+
"outputs": [],
136+
"source": [
137+
"# Create the applicable kernels to the plastic particles\n",
138+
"kernels = pp.constructors.create_kernel(fieldset)"
139+
]
140+
},
141+
{
142+
"cell_type": "code",
143+
"execution_count": null,
144+
"metadata": {},
145+
"outputs": [],
146+
"source": [
147+
"# Define the runtime, the timestepping, and the output frequency of the simulation from the settings\n",
148+
"runtime = settings['simulation']['runtime']\n",
149+
"dt_timestep = settings['simulation']['dt_timestep']\n",
150+
"dt_write = settings['simulation']['dt_write']"
151+
]
152+
},
153+
{
154+
"cell_type": "code",
155+
"execution_count": null,
156+
"metadata": {},
157+
"outputs": [],
158+
"source": [
159+
"# Create the particle file where output will be stored\n",
160+
"pfile = pp.ParticleFile('example_Italy_coast.zarr', pset, settings=settings, outputdt=dt_write)"
161+
]
162+
},
163+
{
164+
"cell_type": "code",
165+
"execution_count": null,
166+
"metadata": {},
167+
"outputs": [],
168+
"source": [
169+
"# Execute the simulation\n",
170+
"pset.execute(kernels, runtime=runtime, dt=dt_timestep, output_file=pfile)"
171+
]
172+
},
173+
{
174+
"cell_type": "code",
175+
"execution_count": null,
176+
"metadata": {},
177+
"outputs": [],
178+
"source": [
179+
"# Plot the trajectories\n",
180+
"ds = xr.open_zarr('example_Italy_coast.zarr')\n",
181+
"\n",
182+
"ax = plt.subplot(111, projection=ccrs.PlateCarree())\n",
183+
"ax.coastlines(zorder=20)\n",
184+
"ax.plot(ds['lon'].T, ds['lat'].T, transform=ccrs.PlateCarree())\n",
185+
"\n",
186+
"plt.show()"
187+
]
188+
}
189+
],
190+
"metadata": {
191+
"kernelspec": {
192+
"display_name": "py3_parcels",
193+
"language": "python",
194+
"name": "python3"
195+
},
196+
"language_info": {
197+
"codemirror_mode": {
198+
"name": "ipython",
199+
"version": 3
200+
},
201+
"file_extension": ".py",
202+
"mimetype": "text/x-python",
203+
"name": "python",
204+
"nbconvert_exporter": "python",
205+
"pygments_lexer": "ipython3",
206+
"version": "3.11.4"
207+
}
208+
},
209+
"nbformat": 4,
210+
"nbformat_minor": 2
211+
}
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
{
2+
"use_3D": true,
3+
"allow_time_extrapolation": false,
4+
"verbose_delete": false,
5+
"use_mixing": false,
6+
"use_biofouling": false,
7+
"use_stokes": false,
8+
"use_wind": false,
9+
"ocean": {
10+
"modelname": "NEMO0083",
11+
"directory": "/storage/shared/oceanparcels/input_data/MOi/",
12+
"filename_style": "psy4v3r1/psy4v3r1-daily_",
13+
"ocean_mesh": "domain_ORCA0083-N006/PSY4V3R1_mesh_hgr.nc",
14+
"bathymetry_mesh": "domain_ORCA0083-N006/PSY4V3R1_mesh_zgr.nc",
15+
"variables": {
16+
"U": "vozocrtx",
17+
"V": "vomecrty",
18+
"W": "vovecrtz",
19+
"conservative_temperature": "votemper",
20+
"absolute_salinity": "vosaline"
21+
},
22+
"dimensions": {
23+
"U": {
24+
"lon": "glamf",
25+
"lat": "gphif",
26+
"depth": "depthw",
27+
"time": "time_counter"
28+
},
29+
"V": {
30+
"lon": "glamf",
31+
"lat": "gphif",
32+
"depth": "depthw",
33+
"time": "time_counter"
34+
},
35+
"W": {
36+
"lon": "glamf",
37+
"lat": "gphif",
38+
"depth": "depthw",
39+
"time": "time_counter"
40+
},
41+
"conservative_temperature": {
42+
"lon": "glamf",
43+
"lat": "gphif",
44+
"depth": "depthw",
45+
"time": "time_counter"
46+
},
47+
"absolute_salinity": {
48+
"lon": "glamf",
49+
"lat": "gphif",
50+
"depth": "depthw",
51+
"time": "time_counter"
52+
}
53+
},
54+
"indices": {},
55+
"bathymetry_variables": {
56+
"bathymetry": "mbathy"
57+
},
58+
"bathymetry_dimensions": {
59+
"lon": "nav_lon",
60+
"lat": "nav_lat"
61+
},
62+
"mixing_variables": {
63+
"mixing_kz": "votkeavt"
64+
},
65+
"mixing_dimensions": {
66+
"lon": "glamf",
67+
"lat": "gphif",
68+
"depth": "depthw",
69+
"time": "time_counter"
70+
}
71+
},
72+
"bgc": {
73+
"directory": "/storage/shared/oceanparcels/input_data/MOi/",
74+
"filename_style": "biomer4v2r1/biomer4v2r1-weekly_",
75+
"bgc_mesh": "domain_ORCA025-N006/mesh_hgr_PSY4V3_deg.nc",
76+
"variables": {
77+
"pp_phyto": "nppv",
78+
"bio_nanophy": "phy",
79+
"bio_diatom": "phy2"
80+
},
81+
"dimensions": {
82+
"pp_phyto": {
83+
"lon": "glamf",
84+
"lat": "gphif",
85+
"depth": "depthw",
86+
"time": "time_counter"
87+
},
88+
"bio_nanophy": {
89+
"lon": "glamf",
90+
"lat": "gphif",
91+
"depth": "depthw",
92+
"time": "time_counter"
93+
},
94+
"bio_diatom": {
95+
"lon": "glamf",
96+
"lat": "gphif",
97+
"depth": "depthw",
98+
"time": "time_counter"
99+
}
100+
},
101+
"indices": {},
102+
"constants": {
103+
"biofilm_density": 1388.0,
104+
"algae_cell_volume": 2e-16,
105+
"K": 1.3805834190672156e-23,
106+
"R20": 1.1574074074074074e-06,
107+
"Q10": 2.13,
108+
"Gamma": 2.0,
109+
"carbon_molecular_weight": 12.0,
110+
"collision_probability": 1.0,
111+
"algae_mortality_rate": 1.0,
112+
"algae_respiration_f": 1.0
113+
}
114+
},
115+
"stokes": {
116+
"directory": "/storage/shared/oceanparcels/output_data/data_Michael/ERA5/waves/",
117+
"filename_style": "ERA5_global_waves_monthly_",
118+
"variables": {
119+
"Stokes_U": "ust",
120+
"Stokes_V": "vst",
121+
"wave_Tp": "pp1d"
122+
},
123+
"dimensions": {
124+
"lat": "latitude",
125+
"lon": "longitude",
126+
"time": "time"
127+
},
128+
"indices": {}
129+
},
130+
"wind": {
131+
"directory": "/storage/shared/oceanparcels/output_data/data_Michael/ERA5/wind/",
132+
"filename_style": "ERA5_global_wind_monthly_",
133+
"variables": {
134+
"Wind_U": "u10",
135+
"Wind_V": "v10"
136+
},
137+
"dimensions": {
138+
"lat": "latitude",
139+
"lon": "longitude",
140+
"time": "time"
141+
},
142+
"indices": {}
143+
},
144+
"unbeaching": {
145+
"directory": "input_data/NEMO0083/",
146+
"filename": "land_current_NEMO0083.nc",
147+
"variables": {
148+
"unbeach_U": "land_current_u",
149+
"unbeach_V": "land_current_v"
150+
},
151+
"dimensions": {
152+
"lat": "lat",
153+
"lon": "lon"
154+
}
155+
},
156+
"simulation": {
157+
"start_date": null,
158+
"runtime": null,
159+
"dt_write": null,
160+
"dt_timestep": null
161+
},
162+
"release_maps": {
163+
"coastal": "input_data/NEMO0083/coastal_population_MPW_NEMO0083.csv",
164+
"rivers": "input_data/NEMO0083/river_emissions_NEMO0083.csv",
165+
"fisheries": "input_data/NEMO0083/agg_data_fisheries_info_NEMO0083.csv",
166+
"global_concentrations": "input_data/NEMO0083/global_concentrations_NEMO0083.csv"
167+
}
168+
}

docs/examples/example_Italy_coast_settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"release_maps": {
163163
"coastal": "input_data/NEMO0083/coastal_population_MPW_NEMO0083.csv",
164164
"rivers": "input_data/NEMO0083/river_emissions_NEMO0083.csv",
165-
"fisheries": "input_data/NEMO0083/agg_data_fisheries_info.csv",
166-
"global_concentrations": null
165+
"fisheries": "input_data/NEMO0083/agg_data_fisheries_info_NEMO0083.csv",
166+
"global_concentrations": "input_data/NEMO0083/global_concentrations_NEMO0083.csv"
167167
}
168168
}

0 commit comments

Comments
 (0)