|
24 | 24 | "metadata": {}, |
25 | 25 | "outputs": [], |
26 | 26 | "source": [ |
27 | | - "from datetime import timedelta\n", |
28 | | - "\n", |
29 | 27 | "import matplotlib.pyplot as plt\n", |
30 | 28 | "import numpy as np\n", |
31 | 29 | "import xarray as xr\n", |
32 | | - "from IPython.display import HTML\n", |
33 | 30 | "from matplotlib.animation import FuncAnimation\n", |
34 | 31 | "\n", |
35 | | - "import parcels" |
| 32 | + "import parcels\n", |
| 33 | + "\n", |
| 34 | + "# for interactive display of animations\n", |
| 35 | + "plt.rcParams[\"animation.html\"] = \"jshtml\"" |
36 | 36 | ] |
37 | 37 | }, |
38 | 38 | { |
|
138 | 138 | "metadata": {}, |
139 | 139 | "outputs": [], |
140 | 140 | "source": [ |
141 | | - "%%capture\n", |
142 | | - "\n", |
143 | 141 | "ds_particles = xr.open_zarr(\"delayparticle_time.zarr\")\n", |
144 | 142 | "\n", |
145 | 143 | "fig = plt.figure(figsize=(7, 5), constrained_layout=True)\n", |
|
173 | 171 | " )\n", |
174 | 172 | "\n", |
175 | 173 | "\n", |
176 | | - "anim = FuncAnimation(fig, animate, frames=len(timerange), interval=100)" |
177 | | - ] |
178 | | - }, |
179 | | - { |
180 | | - "cell_type": "code", |
181 | | - "execution_count": null, |
182 | | - "metadata": {}, |
183 | | - "outputs": [], |
184 | | - "source": [ |
185 | | - "HTML(anim.to_jshtml())" |
| 174 | + "anim = FuncAnimation(fig, animate, frames=len(timerange), interval=100)\n", |
| 175 | + "plt.close()\n", |
| 176 | + "anim" |
186 | 177 | ] |
187 | 178 | }, |
188 | 179 | { |
|
261 | 252 | "outputs": [], |
262 | 253 | "source": [ |
263 | 254 | "output_file = parcels.ParticleFile(\n", |
264 | | - " \"delayparticle_releasedt.zarr\", outputdt=timedelta(hours=1)\n", |
| 255 | + " \"delayparticle_releasedt.zarr\", outputdt=np.timedelta64(1, \"h\")\n", |
265 | 256 | ")\n", |
266 | 257 | "\n", |
267 | 258 | "pset.execute(\n", |
268 | 259 | " parcels.kernels.AdvectionRK4,\n", |
269 | | - " runtime=timedelta(hours=24),\n", |
270 | | - " dt=timedelta(minutes=5),\n", |
| 260 | + " runtime=np.timedelta64(24, \"h\"),\n", |
| 261 | + " dt=np.timedelta64(5, \"h\"),\n", |
271 | 262 | " output_file=output_file,\n", |
272 | 263 | ")" |
273 | 264 | ] |
|
286 | 277 | "metadata": {}, |
287 | 278 | "outputs": [], |
288 | 279 | "source": [ |
289 | | - "%%capture\n", |
290 | | - "\n", |
291 | 280 | "ds_particles = xr.open_zarr(\"delayparticle_releasedt.zarr\")\n", |
292 | 281 | "\n", |
293 | 282 | "fig = plt.figure(figsize=(7, 5), constrained_layout=True)\n", |
|
321 | 310 | " )\n", |
322 | 311 | "\n", |
323 | 312 | "\n", |
324 | | - "anim = FuncAnimation(fig, animate, frames=len(timerange), interval=100)" |
325 | | - ] |
326 | | - }, |
327 | | - { |
328 | | - "cell_type": "code", |
329 | | - "execution_count": null, |
330 | | - "metadata": {}, |
331 | | - "outputs": [], |
332 | | - "source": [ |
333 | | - "HTML(anim.to_jshtml())" |
| 313 | + "anim = FuncAnimation(fig, animate, frames=len(timerange), interval=100)\n", |
| 314 | + "plt.close(fig)\n", |
| 315 | + "anim" |
334 | 316 | ] |
335 | 317 | }, |
336 | 318 | { |
|
0 commit comments