|
8 | 8 | "# 🖥️ SWASH tutorial" |
9 | 9 | ] |
10 | 10 | }, |
| 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 | + }, |
11 | 19 | { |
12 | 20 | "cell_type": "code", |
13 | 21 | "execution_count": null, |
14 | | - "id": "1", |
| 22 | + "id": "2", |
15 | 23 | "metadata": {}, |
16 | 24 | "outputs": [], |
17 | 25 | "source": [ |
|
25 | 33 | { |
26 | 34 | "cell_type": "code", |
27 | 35 | "execution_count": null, |
28 | | - "id": "2", |
| 36 | + "id": "3", |
29 | 37 | "metadata": {}, |
30 | 38 | "outputs": [], |
31 | 39 | "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." |
33 | 52 | ] |
34 | 53 | }, |
35 | 54 | { |
36 | 55 | "cell_type": "code", |
37 | 56 | "execution_count": null, |
38 | | - "id": "3", |
| 57 | + "id": "5", |
39 | 58 | "metadata": {}, |
40 | 59 | "outputs": [], |
41 | 60 | "source": [ |
42 | 61 | "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", |
44 | 63 | ")\n", |
45 | 64 | "fieldset = parcels.FieldSet.from_sgrid_conventions(ds)\n", |
46 | 65 | "fieldset.describe()" |
47 | 66 | ] |
48 | 67 | }, |
| 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 | + }, |
49 | 76 | { |
50 | 77 | "cell_type": "code", |
51 | 78 | "execution_count": null, |
52 | | - "id": "4", |
| 79 | + "id": "7", |
53 | 80 | "metadata": {}, |
54 | 81 | "outputs": [], |
55 | 82 | "source": [ |
|
73 | 100 | ")" |
74 | 101 | ] |
75 | 102 | }, |
| 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 | + }, |
76 | 111 | { |
77 | 112 | "cell_type": "code", |
78 | 113 | "execution_count": null, |
79 | | - "id": "5", |
| 114 | + "id": "9", |
80 | 115 | "metadata": {}, |
81 | 116 | "outputs": [], |
82 | 117 | "source": [ |
|
90 | 125 | "ax.set_xlim([14, 16])\n", |
91 | 126 | "plt.show()" |
92 | 127 | ] |
93 | | - }, |
94 | | - { |
95 | | - "cell_type": "markdown", |
96 | | - "id": "6", |
97 | | - "metadata": {}, |
98 | | - "source": [] |
99 | 128 | } |
100 | 129 | ], |
101 | 130 | "metadata": { |
|
0 commit comments