From b91b2fb1fd260fdeaf4bc9c6df5947d9300ac0ec Mon Sep 17 00:00:00 2001 From: Liam Keegan Date: Fri, 1 Dec 2023 08:37:55 +0100 Subject: [PATCH] partial fixes for 3d toy model notebook --- 3d-toy-model.ipynb | 41 +++++++---------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/3d-toy-model.ipynb b/3d-toy-model.ipynb index 3c0c063..5b12a75 100644 --- a/3d-toy-model.ipynb +++ b/3d-toy-model.ipynb @@ -368,7 +368,7 @@ { "cell_type": "code", "execution_count": null, - "id": "08075d98-5e68-4b7b-b7f9-f6588e36f547", + "id": "0b6c6c02-075d-47c9-b48b-bb352443f3d7", "metadata": { "slideshow": { "slide_type": "fragment" @@ -390,23 +390,7 @@ "tags": [] }, "source": [ - "### Create animation of simulation results" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "717a1b1e-6f3f-455a-a919-ff9f87d90823", - "metadata": { - "slideshow": { - "slide_type": "fragment" - }, - "tags": [] - }, - "outputs": [], - "source": [ - "def plot_to_ax(ax, data):\n", - " " + "### Simulation results" ] }, { @@ -421,17 +405,15 @@ }, "outputs": [], "source": [ - "fig = plt.figure()\n", - "#fig, ax = plt.subplots(constrained_layout=True)\n", - "ax = fig.add_subplot(111, projection='3d')\n", - "ax.set_title(f\"Concentration\")\n", + "fig, ax = plt.subplots(constrained_layout=True)\n", + "ax.set_title(f\"Concentration (z=20 slice)\")\n", "norm = plt.Normalize(vmin=0, vmax=1)\n", - "#im = ax.imshow(np.zeros((1, 1)), norm=norm)\n", + "im = ax.imshow(np.zeros((1, 1)), norm=norm)\n", "fig.colorbar(im, ax=ax)\n", "artists = [\n", " [\n", " ax.imshow(\n", - " sum(simulation_result.species_concentration.values())[0, :],\n", + " sum(simulation_result.species_concentration.values())[19, :],\n", " animated=True,\n", " interpolation=None,\n", " norm=norm,\n", @@ -440,16 +422,7 @@ " for simulation_result in simulation_results\n", "]\n", "anim = animation.ArtistAnimation(fig, artists, interval=200, blit=True, repeat=False)\n", - "plt.close()\n", - "\n", - "\n", - " depth, rows, cols, nc = img.shape\n", - " x = np.arange(rows)\n", - " y = np.arange(cols)\n", - " x, y = np.meshgrid(x, y)\n", - "\n", - " for i in range(depth):\n", - " ax.plot_surface(x, y, i * np.ones((cols,rows)), facecolors=img[i], rstride=1, cstride=1, alpha=0.5, shade=False, linewidth=0)" + "plt.close()" ] }, {