Skip to content

Commit

Permalink
partial fixes for 3d toy model notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
lkeegan committed Dec 1, 2023
1 parent 57bb3d5 commit b91b2fb
Showing 1 changed file with 7 additions and 34 deletions.
41 changes: 7 additions & 34 deletions 3d-toy-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
]
},
{
Expand All @@ -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",
Expand All @@ -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()"
]
},
{
Expand Down

0 comments on commit b91b2fb

Please sign in to comment.