Skip to content

Commit d1dc89f

Browse files
reint-fischerreint-fischer
authored andcommitted
fix and standardize animation output in docs
1 parent 54fbc40 commit d1dc89f

File tree

2 files changed

+14
-38
lines changed

2 files changed

+14
-38
lines changed

docs/getting_started/tutorial_output.ipynb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -540,15 +540,9 @@
540540
"\n",
541541
"# Create animation\n",
542542
"anim = FuncAnimation(fig, animate, frames=nframes, interval=100)\n",
543+
"plt.close(fig)\n",
543544
"anim"
544545
]
545-
},
546-
{
547-
"cell_type": "code",
548-
"execution_count": null,
549-
"metadata": {},
550-
"outputs": [],
551-
"source": []
552546
}
553547
],
554548
"metadata": {

docs/user_guide/examples/tutorial_delaystart.ipynb

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
"metadata": {},
2525
"outputs": [],
2626
"source": [
27-
"from datetime import timedelta\n",
28-
"\n",
2927
"import matplotlib.pyplot as plt\n",
3028
"import numpy as np\n",
3129
"import xarray as xr\n",
32-
"from IPython.display import HTML\n",
3330
"from matplotlib.animation import FuncAnimation\n",
3431
"\n",
35-
"import parcels"
32+
"import parcels\n",
33+
"\n",
34+
"# for interactive display of animations\n",
35+
"plt.rcParams[\"animation.html\"] = \"jshtml\""
3636
]
3737
},
3838
{
@@ -138,8 +138,6 @@
138138
"metadata": {},
139139
"outputs": [],
140140
"source": [
141-
"%%capture\n",
142-
"\n",
143141
"ds_particles = xr.open_zarr(\"delayparticle_time.zarr\")\n",
144142
"\n",
145143
"fig = plt.figure(figsize=(7, 5), constrained_layout=True)\n",
@@ -173,16 +171,9 @@
173171
" )\n",
174172
"\n",
175173
"\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"
186177
]
187178
},
188179
{
@@ -261,13 +252,13 @@
261252
"outputs": [],
262253
"source": [
263254
"output_file = parcels.ParticleFile(\n",
264-
" \"delayparticle_releasedt.zarr\", outputdt=timedelta(hours=1)\n",
255+
" \"delayparticle_releasedt.zarr\", outputdt=np.timedelta64(1, \"h\")\n",
265256
")\n",
266257
"\n",
267258
"pset.execute(\n",
268259
" 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",
271262
" output_file=output_file,\n",
272263
")"
273264
]
@@ -286,8 +277,6 @@
286277
"metadata": {},
287278
"outputs": [],
288279
"source": [
289-
"%%capture\n",
290-
"\n",
291280
"ds_particles = xr.open_zarr(\"delayparticle_releasedt.zarr\")\n",
292281
"\n",
293282
"fig = plt.figure(figsize=(7, 5), constrained_layout=True)\n",
@@ -321,16 +310,9 @@
321310
" )\n",
322311
"\n",
323312
"\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"
334316
]
335317
},
336318
{

0 commit comments

Comments
 (0)