Skip to content

Commit 106e926

Browse files
Add text to swash notebook
1 parent 3328238 commit 106e926

1 file changed

Lines changed: 42 additions & 13 deletions

File tree

docs/user_guide/examples/tutorial_swash.ipynb

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88
"# 🖥️ SWASH tutorial"
99
]
1010
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "1",
14+
"metadata": {},
15+
"source": [
16+
"This tutorial shows how to load in native Matlab files from the SWASH model and convert them to a Parcels-compatible `FieldSet`. The tutorial also shows how to run a simple particle tracking simulation using the SWASH data."
17+
]
18+
},
1119
{
1220
"cell_type": "code",
1321
"execution_count": null,
14-
"id": "1",
22+
"id": "2",
1523
"metadata": {},
1624
"outputs": [],
1725
"source": [
@@ -25,31 +33,50 @@
2533
{
2634
"cell_type": "code",
2735
"execution_count": null,
28-
"id": "2",
36+
"id": "3",
2937
"metadata": {},
3038
"outputs": [],
3139
"source": [
32-
"swash_files = parcels.tutorial.open_dataset(\"SWASH_data/data\", download_only=True)"
40+
"data_file, coord_file = parcels.tutorial.open_dataset(\n",
41+
" \"SWASH_data/data\", download_only=True\n",
42+
")\n",
43+
"print(data_file, coord_file)"
44+
]
45+
},
46+
{
47+
"cell_type": "markdown",
48+
"id": "4",
49+
"metadata": {},
50+
"source": [
51+
"Unlike the other tutorials, this tutorial uses the original SWASH output files in Matlab format. If you want to use your own SWASH output files, you should use the `GRD.mat` and `ALL.mat` files in the `parcels.convert.swash_to_sgrid()` function below."
3352
]
3453
},
3554
{
3655
"cell_type": "code",
3756
"execution_count": null,
38-
"id": "3",
57+
"id": "5",
3958
"metadata": {},
4059
"outputs": [],
4160
"source": [
4261
"ds = parcels.convert.swash_to_sgrid(\n",
43-
" data_file=swash_files[0], coord_file=swash_files[1], total_depth=8.0\n",
62+
" data_file=data_file, coord_file=coord_file, total_depth=8.0\n",
4463
")\n",
4564
"fieldset = parcels.FieldSet.from_sgrid_conventions(ds)\n",
4665
"fieldset.describe()"
4766
]
4867
},
68+
{
69+
"cell_type": "markdown",
70+
"id": "6",
71+
"metadata": {},
72+
"source": [
73+
"Now, we can use this `FieldSet` to run a simulation (note it's very short because the dataset provided in this tutorial is only 20 seconds long)."
74+
]
75+
},
4976
{
5077
"cell_type": "code",
5178
"execution_count": null,
52-
"id": "4",
79+
"id": "7",
5380
"metadata": {},
5481
"outputs": [],
5582
"source": [
@@ -73,10 +100,18 @@
73100
")"
74101
]
75102
},
103+
{
104+
"cell_type": "markdown",
105+
"id": "8",
106+
"metadata": {},
107+
"source": [
108+
"And then plot the results of the simulation, along with the water level at a given time step. The starting positions of the particles are also shown in white."
109+
]
110+
},
76111
{
77112
"cell_type": "code",
78113
"execution_count": null,
79-
"id": "5",
114+
"id": "9",
80115
"metadata": {},
81116
"outputs": [],
82117
"source": [
@@ -90,12 +125,6 @@
90125
"ax.set_xlim([14, 16])\n",
91126
"plt.show()"
92127
]
93-
},
94-
{
95-
"cell_type": "markdown",
96-
"id": "6",
97-
"metadata": {},
98-
"source": []
99128
}
100129
],
101130
"metadata": {

0 commit comments

Comments
 (0)