|
15 | 15 | "cell_type": "markdown", |
16 | 16 | "metadata": {}, |
17 | 17 | "source": [ |
18 | | - "\nGrid advection\n==============\n\nDummy advection which use only static geostrophic current, which didn't solve the complex circulation of the ocean.\n" |
| 18 | + "\n# Grid advection\n\nDummy advection which use only static geostrophic current, which didn't solve the complex circulation of the ocean.\n" |
19 | 19 | ] |
20 | 20 | }, |
21 | 21 | { |
|
98 | 98 | "cell_type": "markdown", |
99 | 99 | "metadata": {}, |
100 | 100 | "source": [ |
101 | | - "Anim\n----\nParticles setup\n\n" |
| 101 | + "## Anim\nParticles setup\n\n" |
102 | 102 | ] |
103 | 103 | }, |
104 | 104 | { |
|
127 | 127 | }, |
128 | 128 | "outputs": [], |
129 | 129 | "source": [ |
130 | | - "kwargs = dict(frames=arange(51), interval=100)\nkw_p = dict(nb_step=2, time_step=21600)\nframe_t = kw_p[\"nb_step\"] * kw_p[\"time_step\"] / 86400.0" |
| 130 | + "kwargs = dict(frames=arange(51), interval=100)\nkw_p = dict(u_name=\"u\", v_name=\"v\", nb_step=2, time_step=21600)\nframe_t = kw_p[\"nb_step\"] * kw_p[\"time_step\"] / 86400.0" |
131 | 131 | ] |
132 | 132 | }, |
133 | 133 | { |
|
152 | 152 | "cell_type": "markdown", |
153 | 153 | "metadata": {}, |
154 | 154 | "source": [ |
155 | | - "Filament forward\n^^^^^^^^^^^^^^^^\nDraw 3 last position in one path for each particles.,\nit could be run backward with `backward=True` option in filament method\n\n" |
| 155 | + "### Filament forward\nDraw 3 last position in one path for each particles.,\nit could be run backward with `backward=True` option in filament method\n\n" |
156 | 156 | ] |
157 | 157 | }, |
158 | 158 | { |
|
163 | 163 | }, |
164 | 164 | "outputs": [], |
165 | 165 | "source": [ |
166 | | - "p = g.filament(x, y, \"u\", \"v\", **kw_p, filament_size=3)\nfig, txt, l, t = anim_ax(lw=0.5)\n_ = VideoAnimation(fig, update, **kwargs, fargs=(frame_t,))" |
| 166 | + "p = g.filament(x, y, **kw_p, filament_size=3)\nfig, txt, l, t = anim_ax(lw=0.5)\n_ = VideoAnimation(fig, update, **kwargs, fargs=(frame_t,))" |
167 | 167 | ] |
168 | 168 | }, |
169 | 169 | { |
170 | 170 | "cell_type": "markdown", |
171 | 171 | "metadata": {}, |
172 | 172 | "source": [ |
173 | | - "Particle forward\n^^^^^^^^^^^^^^^^^\nForward advection of particles\n\n" |
| 173 | + "### Particle forward\nForward advection of particles\n\n" |
174 | 174 | ] |
175 | 175 | }, |
176 | 176 | { |
|
181 | 181 | }, |
182 | 182 | "outputs": [], |
183 | 183 | "source": [ |
184 | | - "p = g.advect(x, y, \"u\", \"v\", **kw_p)\nfig, txt, l, t = anim_ax(ls=\"\", marker=\".\", markersize=1)\n_ = VideoAnimation(fig, update, **kwargs, fargs=(frame_t,))" |
| 184 | + "p = g.advect(x, y, **kw_p)\nfig, txt, l, t = anim_ax(ls=\"\", marker=\".\", markersize=1)\n_ = VideoAnimation(fig, update, **kwargs, fargs=(frame_t,))" |
185 | 185 | ] |
186 | 186 | }, |
187 | 187 | { |
|
199 | 199 | }, |
200 | 200 | "outputs": [], |
201 | 201 | "source": [ |
202 | | - "p = g.advect(x, y, \"u\", \"v\", **kw_p, backward=True)\nfig, txt, l, _ = anim_ax(ls=\"\", marker=\".\", markersize=1)\n_ = VideoAnimation(fig, update, **kwargs, fargs=(-frame_t,))" |
| 202 | + "p = g.advect(x, y, **kw_p, backward=True)\nfig, txt, l, _ = anim_ax(ls=\"\", marker=\".\", markersize=1)\n_ = VideoAnimation(fig, update, **kwargs, fargs=(-frame_t,))" |
203 | 203 | ] |
204 | 204 | }, |
205 | 205 | { |
206 | 206 | "cell_type": "markdown", |
207 | 207 | "metadata": {}, |
208 | 208 | "source": [ |
209 | | - "Particles stat\n--------------\n\n" |
| 209 | + "## Particles stat\n\n" |
210 | 210 | ] |
211 | 211 | }, |
212 | 212 | { |
213 | 213 | "cell_type": "markdown", |
214 | 214 | "metadata": {}, |
215 | 215 | "source": [ |
216 | | - "Time_step settings\n^^^^^^^^^^^^^^^^^^\nDummy experiment to test advection precision, we run particles 50 days forward and backward with different time step\nand we measure distance between new positions and original positions.\n\n" |
| 216 | + "### Time_step settings\nDummy experiment to test advection precision, we run particles 50 days forward and backward with different time step\nand we measure distance between new positions and original positions.\n\n" |
217 | 217 | ] |
218 | 218 | }, |
219 | 219 | { |
|
224 | 224 | }, |
225 | 225 | "outputs": [], |
226 | 226 | "source": [ |
227 | | - "fig = plt.figure()\nax = fig.add_subplot(111)\nkw = dict(\n bins=arange(0, 50, 0.001),\n cumulative=True,\n weights=ones(x0.shape) / x0.shape[0] * 100.0,\n histtype=\"step\",\n)\nfor time_step in (10800, 21600, 43200, 86400):\n x, y = x0.copy(), y0.copy()\n kw_advect = dict(nb_step=int(50 * 86400 / time_step), time_step=time_step)\n g.advect(x, y, \"u\", \"v\", **kw_advect).__next__()\n g.advect(x, y, \"u\", \"v\", **kw_advect, backward=True).__next__()\n d = ((x - x0) ** 2 + (y - y0) ** 2) ** 0.5\n ax.hist(d, **kw, label=f\"{86400. / time_step:.0f} time step by day\")\nax.set_xlim(0, 0.25), ax.set_ylim(0, 100), ax.legend(loc=\"lower right\"), ax.grid()\nax.set_title(\"Distance after 50 days forward and 50 days backward\")\nax.set_xlabel(\"Distance between original position and final position (in degrees)\")\n_ = ax.set_ylabel(\"Percent of particles with distance lesser than\")" |
| 227 | + "fig = plt.figure()\nax = fig.add_subplot(111)\nkw = dict(\n bins=arange(0, 50, 0.001),\n cumulative=True,\n weights=ones(x0.shape) / x0.shape[0] * 100.0,\n histtype=\"step\",\n)\nfor time_step in (10800, 21600, 43200, 86400):\n x, y = x0.copy(), y0.copy()\n kw_advect = dict(nb_step=int(50 * 86400 / time_step), time_step=time_step, u_name=\"u\", v_name=\"v\")\n g.advect(x, y, **kw_advect).__next__()\n g.advect(x, y, **kw_advect, backward=True).__next__()\n d = ((x - x0) ** 2 + (y - y0) ** 2) ** 0.5\n ax.hist(d, **kw, label=f\"{86400. / time_step:.0f} time step by day\")\nax.set_xlim(0, 0.25), ax.set_ylim(0, 100), ax.legend(loc=\"lower right\"), ax.grid()\nax.set_title(\"Distance after 50 days forward and 50 days backward\")\nax.set_xlabel(\"Distance between original position and final position (in degrees)\")\n_ = ax.set_ylabel(\"Percent of particles with distance lesser than\")" |
228 | 228 | ] |
229 | 229 | }, |
230 | 230 | { |
231 | 231 | "cell_type": "markdown", |
232 | 232 | "metadata": {}, |
233 | 233 | "source": [ |
234 | | - "Time duration\n^^^^^^^^^^^^^\nWe keep same time_step but change time duration\n\n" |
| 234 | + "### Time duration\nWe keep same time_step but change time duration\n\n" |
235 | 235 | ] |
236 | 236 | }, |
237 | 237 | { |
|
242 | 242 | }, |
243 | 243 | "outputs": [], |
244 | 244 | "source": [ |
245 | | - "fig = plt.figure()\nax = fig.add_subplot(111)\ntime_step = 10800\nfor duration in (5, 50, 100):\n x, y = x0.copy(), y0.copy()\n kw_advect = dict(nb_step=int(duration * 86400 / time_step), time_step=time_step)\n g.advect(x, y, \"u\", \"v\", **kw_advect).__next__()\n g.advect(x, y, \"u\", \"v\", **kw_advect, backward=True).__next__()\n d = ((x - x0) ** 2 + (y - y0) ** 2) ** 0.5\n ax.hist(d, **kw, label=f\"Time duration {duration} days\")\nax.set_xlim(0, 0.25), ax.set_ylim(0, 100), ax.legend(loc=\"lower right\"), ax.grid()\nax.set_title(\n \"Distance after N days forward and N days backward\\nwith a time step of 1/8 days\"\n)\nax.set_xlabel(\"Distance between original position and final position (in degrees)\")\n_ = ax.set_ylabel(\"Percent of particles with distance lesser than \")" |
| 245 | + "fig = plt.figure()\nax = fig.add_subplot(111)\ntime_step = 10800\nfor duration in (5, 50, 100):\n x, y = x0.copy(), y0.copy()\n kw_advect = dict(nb_step=int(duration * 86400 / time_step), time_step=time_step, u_name=\"u\", v_name=\"v\")\n g.advect(x, y, **kw_advect).__next__()\n g.advect(x, y, **kw_advect, backward=True).__next__()\n d = ((x - x0) ** 2 + (y - y0) ** 2) ** 0.5\n ax.hist(d, **kw, label=f\"Time duration {duration} days\")\nax.set_xlim(0, 0.25), ax.set_ylim(0, 100), ax.legend(loc=\"lower right\"), ax.grid()\nax.set_title(\n \"Distance after N days forward and N days backward\\nwith a time step of 1/8 days\"\n)\nax.set_xlabel(\"Distance between original position and final position (in degrees)\")\n_ = ax.set_ylabel(\"Percent of particles with distance lesser than \")" |
246 | 246 | ] |
247 | 247 | } |
248 | 248 | ], |
|
262 | 262 | "name": "python", |
263 | 263 | "nbconvert_exporter": "python", |
264 | 264 | "pygments_lexer": "ipython3", |
265 | | - "version": "3.7.7" |
| 265 | + "version": "3.10.6" |
266 | 266 | } |
267 | 267 | }, |
268 | 268 | "nbformat": 4, |
|
0 commit comments