|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "markdown", |
5 | | - "metadata": {}, |
| 5 | + "metadata": { |
| 6 | + "deletable": true, |
| 7 | + "editable": true |
| 8 | + }, |
6 | 9 | "source": [ |
7 | 10 | "## Tutorial showing how to create Parcels in Agulhas animated gif" |
8 | 11 | ] |
9 | 12 | }, |
10 | 13 | { |
11 | 14 | "cell_type": "markdown", |
12 | | - "metadata": {}, |
| 15 | + "metadata": { |
| 16 | + "deletable": true, |
| 17 | + "editable": true |
| 18 | + }, |
13 | 19 | "source": [ |
14 | 20 | "This brief tutorial shows how to recreate the [animated gif](http://oceanparcels.org/animated-gifs/globcurrent_fullyseeded.gif) showing particles in the Agulhas region south of Africa." |
15 | 21 | ] |
16 | 22 | }, |
17 | 23 | { |
18 | 24 | "cell_type": "markdown", |
19 | | - "metadata": {}, |
| 25 | + "metadata": { |
| 26 | + "deletable": true, |
| 27 | + "editable": true |
| 28 | + }, |
20 | 29 | "source": [ |
21 | 30 | "We start with importing the relevant modules" |
22 | 31 | ] |
|
25 | 34 | "cell_type": "code", |
26 | 35 | "execution_count": 1, |
27 | 36 | "metadata": { |
28 | | - "collapsed": true |
| 37 | + "collapsed": true, |
| 38 | + "deletable": true, |
| 39 | + "editable": true |
29 | 40 | }, |
30 | 41 | "outputs": [], |
31 | 42 | "source": [ |
|
36 | 47 | }, |
37 | 48 | { |
38 | 49 | "cell_type": "markdown", |
39 | | - "metadata": {}, |
| 50 | + "metadata": { |
| 51 | + "deletable": true, |
| 52 | + "editable": true |
| 53 | + }, |
40 | 54 | "source": [ |
41 | 55 | "Now load the Globcurrent fields from the `GlobCurrent_example_data` directory" |
42 | 56 | ] |
43 | 57 | }, |
44 | 58 | { |
45 | 59 | "cell_type": "code", |
46 | 60 | "execution_count": 2, |
47 | | - "metadata": {}, |
| 61 | + "metadata": { |
| 62 | + "collapsed": false, |
| 63 | + "deletable": true, |
| 64 | + "editable": true |
| 65 | + }, |
48 | 66 | "outputs": [ |
49 | 67 | { |
50 | 68 | "name": "stderr", |
|
69 | 87 | }, |
70 | 88 | { |
71 | 89 | "cell_type": "markdown", |
72 | | - "metadata": {}, |
| 90 | + "metadata": { |
| 91 | + "deletable": true, |
| 92 | + "editable": true |
| 93 | + }, |
73 | 94 | "source": [ |
74 | 95 | "Now create vectors of Longitude and Latitude starting locations on a regular mesh, and use these to initialise a `ParticleSet` object." |
75 | 96 | ] |
76 | 97 | }, |
77 | 98 | { |
78 | 99 | "cell_type": "code", |
79 | 100 | "execution_count": 3, |
80 | | - "metadata": {}, |
| 101 | + "metadata": { |
| 102 | + "collapsed": true, |
| 103 | + "deletable": true, |
| 104 | + "editable": true |
| 105 | + }, |
81 | 106 | "outputs": [], |
82 | 107 | "source": [ |
83 | 108 | "lons, lats = np.meshgrid(range(15, 35), range(-40, -30))\n", |
|
86 | 111 | }, |
87 | 112 | { |
88 | 113 | "cell_type": "markdown", |
89 | | - "metadata": {}, |
| 114 | + "metadata": { |
| 115 | + "deletable": true, |
| 116 | + "editable": true |
| 117 | + }, |
90 | 118 | "source": [ |
91 | 119 | "Now we want to advect the particles. However, the Globcurrent data that we loaded in is only for a limited, regional domain and particles might be able to leave this domain. We therefore need to tell Parcels that particles that leave the domain need to be deleted. We do that using a `Recovery Kernel`, which will be invoked when a particle encounters an `ErrorOutOfBounds` error:" |
92 | 120 | ] |
|
95 | 123 | "cell_type": "code", |
96 | 124 | "execution_count": 4, |
97 | 125 | "metadata": { |
98 | | - "collapsed": true |
| 126 | + "collapsed": true, |
| 127 | + "deletable": true, |
| 128 | + "editable": true |
99 | 129 | }, |
100 | 130 | "outputs": [], |
101 | 131 | "source": [ |
102 | | - "def DeleteParticle(particle):\n", |
| 132 | + "def DeleteParticle(particle, fieldset, time, dt):\n", |
103 | 133 | " particle.delete()" |
104 | 134 | ] |
105 | 135 | }, |
106 | 136 | { |
107 | 137 | "cell_type": "markdown", |
108 | | - "metadata": {}, |
| 138 | + "metadata": { |
| 139 | + "deletable": true, |
| 140 | + "editable": true |
| 141 | + }, |
109 | 142 | "source": [ |
110 | 143 | "Now we can advect the particles. Note that we do this inside a `for`-loop, so we can save a plot every six hours (which is the value of `runtime`). See the [plotting tutorial](http://nbviewer.jupyter.org/github/OceanParcels/parcels/blob/master/examples/tutorial_plotting.ipynb) for more information on the `pset.show()` method." |
111 | 144 | ] |
112 | 145 | }, |
113 | 146 | { |
114 | 147 | "cell_type": "code", |
115 | 148 | "execution_count": 5, |
116 | | - "metadata": {}, |
| 149 | + "metadata": { |
| 150 | + "collapsed": false, |
| 151 | + "deletable": true, |
| 152 | + "editable": true |
| 153 | + }, |
117 | 154 | "outputs": [ |
118 | 155 | { |
119 | 156 | "name": "stderr", |
120 | 157 | "output_type": "stream", |
121 | 158 | "text": [ |
122 | | - "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py:1767: MatplotlibDeprecationWarning: The get_axis_bgcolor function was deprecated in version 2.0. Use get_facecolor instead.\n", |
123 | | - " axisbgc = ax.get_axis_bgcolor()\n", |
124 | | - "/Users/erik/Codes/PARCELScode/parcels/particleset.py:402: RuntimeWarning: invalid value encountered in divide\n", |
125 | | - " normU = U/speed\n", |
126 | | - "/Users/erik/Codes/PARCELScode/parcels/particleset.py:403: RuntimeWarning: invalid value encountered in divide\n", |
127 | | - " normV = V/speed\n", |
128 | | - "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py:3707: MatplotlibDeprecationWarning: The ishold function was deprecated in version 2.0.\n", |
129 | | - " b = ax.ishold()\n", |
130 | | - "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py:3716: MatplotlibDeprecationWarning: axes.hold is deprecated.\n", |
131 | | - " See the API Changes document (http://matplotlib.org/api/api_changes.html)\n", |
132 | | - " for more details.\n", |
133 | | - " ax.hold(b)\n", |
134 | | - "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py:3222: MatplotlibDeprecationWarning: The ishold function was deprecated in version 2.0.\n", |
135 | | - " b = ax.ishold()\n", |
136 | | - "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py:3231: MatplotlibDeprecationWarning: axes.hold is deprecated.\n", |
137 | | - " See the API Changes document (http://matplotlib.org/api/api_changes.html)\n", |
138 | | - " for more details.\n", |
139 | | - " ax.hold(b)\n", |
140 | 159 | "INFO: Plot saved to particles00.png\n", |
141 | 160 | "INFO: Compiled JITParticleAdvectionRK4 ==> /var/folders/r2/8593q8z93kd7t4j9kbb_f7p00000gr/T/parcels-504/27805ff3aa34ba12ddb373f3f2cb1d1b.so\n", |
142 | 161 | "INFO: Plot saved to particles01.png\n", |
|
159 | 178 | }, |
160 | 179 | { |
161 | 180 | "cell_type": "markdown", |
162 | | - "metadata": {}, |
| 181 | + "metadata": { |
| 182 | + "deletable": true, |
| 183 | + "editable": true |
| 184 | + }, |
163 | 185 | "source": [ |
164 | 186 | "This now has created 3 plots. Note that the original animated gif contained 20 plots, but to keep running of this notebook fast we have reduced the number here. Of course, it is trivial to increase the number of plots by changing the value in the `range()` in the cell above." |
165 | 187 | ] |
166 | 188 | }, |
167 | 189 | { |
168 | 190 | "cell_type": "markdown", |
169 | | - "metadata": {}, |
| 191 | + "metadata": { |
| 192 | + "deletable": true, |
| 193 | + "editable": true |
| 194 | + }, |
170 | 195 | "source": [ |
171 | 196 | "As a final step, you can use [ImageMagick](http://www.imagemagick.org/script/index.php) or an online tool to stitch these individual plots together in an animated gif." |
172 | 197 | ] |
|
0 commit comments