|
32 | 32 | "cell_type": "markdown",
|
33 | 33 | "metadata": {},
|
34 | 34 | "source": [
|
35 |
| - "## 1. A 2D histogram of density vs magnetic field\n", |
| 35 | + "## A 2D histogram of density vs magnetic field\n", |
36 | 36 | "\n",
|
37 | 37 | "By default, the `histogram2d` function will show a binned count of cells"
|
38 | 38 | ]
|
|
71 | 71 | "cell_type": "markdown",
|
72 | 72 | "metadata": {},
|
73 | 73 | "source": [
|
74 |
| - "## 2. Simple cut plane\n", |
| 74 | + "## Simple cut plane\n", |
75 | 75 | "\n",
|
76 | 76 | "Create a 2D gas density slice 2000 au wide through the plane normal to `z`,\n",
|
77 | 77 | "with velocity vectors overlayed as arrows, once agains using `layers`:"
|
|
80 | 80 | {
|
81 | 81 | "cell_type": "code",
|
82 | 82 | "execution_count": null,
|
83 |
| - "metadata": { |
84 |
| - "scrolled": false |
85 |
| - }, |
| 83 | + "metadata": {}, |
86 | 84 | "outputs": [],
|
87 | 85 | "source": [
|
88 | 86 | "osyris.plane({\"data\": data[\"hydro\"][\"density\"], \"norm\": \"log\"}, # layer 1\n",
|
|
96 | 94 | "cell_type": "markdown",
|
97 | 95 | "metadata": {},
|
98 | 96 | "source": [
|
99 |
| - "## 3. Cut plane at an arbitrary angle\n", |
| 97 | + "## Cut plane at an arbitrary angle\n", |
100 | 98 | "\n",
|
101 | 99 | "The `plane` function will also accept a vector to define the normal direction to the plane.\n",
|
102 | 100 | "In this example, we also change the colormap."
|
|
105 | 103 | {
|
106 | 104 | "cell_type": "code",
|
107 | 105 | "execution_count": null,
|
108 |
| - "metadata": { |
109 |
| - "scrolled": false |
110 |
| - }, |
| 106 | + "metadata": {}, |
111 | 107 | "outputs": [],
|
112 | 108 | "source": [
|
113 | 109 | "osyris.plane({\"data\": data[\"hydro\"][\"density\"], \"norm\": \"log\"},\n",
|
|
122 | 118 | "cell_type": "markdown",
|
123 | 119 | "metadata": {},
|
124 | 120 | "source": [
|
125 |
| - "## 4. Automatic “top/side” slice orientation according to angular momentum\n", |
| 121 | + "## Automatic “top/side” slice orientation according to angular momentum\n", |
126 | 122 | "\n",
|
127 | 123 | "Create a 2D slice of the logarithm of density 500 au wide using automatic orientation based on the angular momentum in the data.\n",
|
128 | 124 | "This is useful for looking at disks.\n",
|
|
166 | 162 | "cell_type": "markdown",
|
167 | 163 | "metadata": {},
|
168 | 164 | "source": [
|
169 |
| - "## 5. Embedding plots in existing Matplotlib axes\n", |
| 165 | + "## Coloring vectors and streamlines\n", |
| 166 | + "\n", |
| 167 | + "In this example, we represent the velocity field as vectors (left) and as streamlines (right).\n", |
| 168 | + "The colours represent the magnitude of the velocity." |
| 169 | + ] |
| 170 | + }, |
| 171 | + { |
| 172 | + "cell_type": "code", |
| 173 | + "execution_count": null, |
| 174 | + "metadata": {}, |
| 175 | + "outputs": [], |
| 176 | + "source": [ |
| 177 | + "fig, ax = plt.subplots(1, 2, figsize=(10, 3.5))\n", |
| 178 | + "plt.subplots_adjust(wspace=0.35)\n", |
| 179 | + "\n", |
| 180 | + "dx = 2000.0 * osyris.units(\"au\")\n", |
| 181 | + "\n", |
| 182 | + "osyris.plane({\"data\": data[\"hydro\"][\"density\"], \"norm\": \"log\"},\n", |
| 183 | + " {\"data\": data[\"hydro\"][\"velocity\"], \"mode\": \"vec\",\n", |
| 184 | + " \"color\": data[\"hydro\"][\"velocity\"], \"cmap\": \"spring_r\",\n", |
| 185 | + " \"cbar\": False},\n", |
| 186 | + " dx=dx, origin=center, direction=\"z\", ax=ax[0])\n", |
| 187 | + "osyris.plane({\"data\": data[\"hydro\"][\"density\"], \"norm\": \"log\"},\n", |
| 188 | + " {\"data\": data[\"hydro\"][\"velocity\"], \"mode\": \"stream\",\n", |
| 189 | + " \"color\": data[\"hydro\"][\"velocity\"], \"cmap\": \"jet\",\n", |
| 190 | + " \"cbar\": False},\n", |
| 191 | + " dx=dx, origin=center, direction=\"z\", ax=ax[1])" |
| 192 | + ] |
| 193 | + }, |
| 194 | + { |
| 195 | + "cell_type": "markdown", |
| 196 | + "metadata": {}, |
| 197 | + "source": [ |
| 198 | + "## Embedding plots in existing Matplotlib axes\n", |
170 | 199 | "\n",
|
171 | 200 | "In this example, we create two subplot axes with Matplotlib.\n",
|
172 | 201 | "\n",
|
|
182 | 211 | {
|
183 | 212 | "cell_type": "code",
|
184 | 213 | "execution_count": null,
|
185 |
| - "metadata": { |
186 |
| - "scrolled": false |
187 |
| - }, |
| 214 | + "metadata": {}, |
188 | 215 | "outputs": [],
|
189 | 216 | "source": [
|
190 | 217 | "# Create figure\n",
|
|
224 | 251 | "cell_type": "markdown",
|
225 | 252 | "metadata": {},
|
226 | 253 | "source": [
|
227 |
| - "## 6. Plot only a subset of cells belonging to a disk\n", |
| 254 | + "## Plot only a subset of cells belonging to a disk\n", |
228 | 255 | "\n",
|
229 | 256 | "In this example, we select cells according to their density and plot only those.\n",
|
230 | 257 | "This is done by creating a new field and using Numpy's `masked_where` function.\n",
|
|
271 | 298 | "cell_type": "markdown",
|
272 | 299 | "metadata": {},
|
273 | 300 | "source": [
|
274 |
| - "## 7. Difference between two snapshots\n", |
| 301 | + "## Difference between two snapshots\n", |
275 | 302 | "\n",
|
276 | 303 | "Here, we want to make a map of the difference in density between two snapshots.\n",
|
277 | 304 | "Because we do not necessarily have the same number of cells at the same place,\n",
|
|
330 | 357 | "cell_type": "markdown",
|
331 | 358 | "metadata": {},
|
332 | 359 | "source": [
|
333 |
| - "## 8. Slice above the origin\n", |
| 360 | + "## Slice above the origin\n", |
334 | 361 | "\n",
|
335 | 362 | "We want to plot a slice of density but through a point which is 20 AU above the centre of the domain,\n",
|
336 | 363 | "defined as the cell with the highest density."
|
|
355 | 382 | "cell_type": "markdown",
|
356 | 383 | "metadata": {},
|
357 | 384 | "source": [
|
358 |
| - "## 9. Scatter plot\n", |
| 385 | + "## Scatter plot\n", |
359 | 386 | "\n",
|
360 | 387 | "Make a scatter plot of density vs temperature, with only 1 in 1000 cells.\n",
|
361 | 388 | "Colour the dots according to the magnitude of the gas velocity."
|
|
378 | 405 | "cell_type": "markdown",
|
379 | 406 | "metadata": {},
|
380 | 407 | "source": [
|
381 |
| - "## 10. Sink particles\n", |
| 408 | + "## Sink particles\n", |
382 | 409 | "\n",
|
383 | 410 | "Some star formation simulations contain sink particles,\n",
|
384 | 411 | "and these can be represented as a scatter layer on a plane plot. "
|
|
401 | 428 | "cell_type": "markdown",
|
402 | 429 | "metadata": {},
|
403 | 430 | "source": [
|
404 |
| - "## 11. 2D data\n", |
| 431 | + "## 2D data\n", |
405 | 432 | "\n",
|
406 | 433 | "2D data can be loaded and viewed just like 3D data."
|
407 | 434 | ]
|
|
420 | 447 | "cell_type": "markdown",
|
421 | 448 | "metadata": {},
|
422 | 449 | "source": [
|
423 |
| - "## 12. 1D histograms\n", |
| 450 | + "## 1D histograms\n", |
424 | 451 | "\n",
|
425 | 452 | "The `histogram1d` function provides a simple way to quickly make 1d histogram plots:"
|
426 | 453 | ]
|
|
477 | 504 | "cell_type": "markdown",
|
478 | 505 | "metadata": {},
|
479 | 506 | "source": [
|
480 |
| - "## 13. Line integral convolution vector field visualizations\n", |
| 507 | + "## Line integral convolution vector field visualizations\n", |
481 | 508 | "\n",
|
482 | 509 | "Osyris now supports line integral convolution (LIC) visualizations of vector fields. This visualization method, although computationally intensive, offers an excellent representation of the vector field (especially near discontinuities) provided we have enough resolution.\n",
|
483 | 510 | "\n",
|
|
493 | 520 | "outputs": [],
|
494 | 521 | "source": [
|
495 | 522 | "osyris.plane({\"data\": data[\"hydro\"][\"velocity\"], \"mode\": \"lic\"},\n",
|
496 |
| - " dx=dx * osyris.units(\"au\"),\n", |
| 523 | + " dx=2000 * osyris.units(\"au\"),\n", |
497 | 524 | " origin=center,\n",
|
498 | 525 | " direction=\"z\", resolution=1000)"
|
499 | 526 | ]
|
|
513 | 540 | "source": [
|
514 | 541 | "osyris.plane({\"data\": data[\"hydro\"][\"velocity\"], \"mode\": \"lic\",\n",
|
515 | 542 | " \"color\": data[\"hydro\"][\"density\"], \"norm\": \"log\", \"length\":30},\n",
|
516 |
| - " dx=dx * osyris.units(\"au\"),\n", |
| 543 | + " dx=2000 * osyris.units(\"au\"),\n", |
517 | 544 | " origin=center,\n",
|
518 | 545 | " direction=\"z\", resolution=1000)"
|
519 | 546 | ]
|
|
528 | 555 | ],
|
529 | 556 | "metadata": {
|
530 | 557 | "kernelspec": {
|
531 |
| - "display_name": "Python 3", |
| 558 | + "display_name": "Python 3 (ipykernel)", |
532 | 559 | "language": "python",
|
533 | 560 | "name": "python3"
|
534 | 561 | },
|
|
542 | 569 | "name": "python",
|
543 | 570 | "nbconvert_exporter": "python",
|
544 | 571 | "pygments_lexer": "ipython3",
|
545 |
| - "version": "3.8.8" |
| 572 | + "version": "3.9.5" |
546 | 573 | }
|
547 | 574 | },
|
548 | 575 | "nbformat": 4,
|
549 |
| - "nbformat_minor": 2 |
| 576 | + "nbformat_minor": 4 |
550 | 577 | }
|
0 commit comments