Skip to content

Commit

Permalink
new before the demo
Browse files Browse the repository at this point in the history
  • Loading branch information
teuben committed Jul 21, 2016
1 parent 8a52509 commit d76e5a3
Show file tree
Hide file tree
Showing 5 changed files with 714 additions and 0 deletions.
102 changes: 102 additions & 0 deletions yt-demo/example1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"import yt\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>1. Load the `\"virgo_novisc.0054.gdf\"` dataset from the `\"data\"` directory.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>2. Create a sphere object centered on the domain center. Use the shorthand `\"c\"` for the center. Give it a radius of 200 kpc.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>3. Create a second sphere object at the location ``[0.1, -0.2, 0.3]``. Give it a radius of 0.4 Mpc.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>4. Query the sphere object for the density and calculate the mean using `np.mean`.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
103 changes: 103 additions & 0 deletions yt-demo/example2.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"import yt\n",
"import yt.units as u\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>1. Load up the Enzo dataset `\"DD0046/DD0046\"` from the `\"data\"` directory, and create a sphere of 1.0 Mpc centered on the maximum density, using the `\"max\"` shorthand.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>2. Query the `\"velocity_x\"` field from the sphere and convert it to units of miles per hour, `\"mile/hr\"`</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>3. Use the `\"cell_mass\"` and `\"velocity_y\"` fields to generate the kinetic energy of the y-component of velocity assuming $KE_y = \\frac{1}{2}mv_y^2$. Print it in units of `\"erg\"`, `\"J\"`, `\"keV\"`, and `\"ft*lbf\"`.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>4. Use the `weighted_average_quantity` derived quantity to generate a weighted average of the temperature field `\"kT\"` where the weight is the field `\"cell_mass\"`.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
115 changes: 115 additions & 0 deletions yt-demo/example3.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"import yt\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>1. Load the `\"virgo_novisc.0054.gdf\"` dataset from the `\"data\"` directory.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ds = yt.load(\"../data/virgo_novisc.0054.gdf\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>2. Create a `SlicePlot` of temperature along the y-axis, with a width of 0.4 Mpc. Change the colormap to \"algae\". Annotate the magnetic field vectors.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"slc = yt.SlicePlot(ds, \"y\", [\"temperature\"], width=(0.4, \"Mpc\"))\n",
"slc.set_cmap(\"temperature\", \"algae\")\n",
"slc.annotate_magnetic_field()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>3. What happens if you supply a vector, say `[0.1, -0.3, 0.4]`, to the second argument of `SlicePlot`? Try it.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"slc = yt.SlicePlot(ds, [0.1, -0.3, 0.4], [\"temperature\"], width=(0.4, \"Mpc\"))\n",
"slc.set_cmap(\"temperature\", \"algae\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p>4. Now make a `ProjectionPlot` of the `\"velocity_x\"` field, weighted by the `\"density\"` field, along the x-axis. Use the `set_log` method to make the plot have linear scaling, and change the units to km/s.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"prj = yt.ProjectionPlot(ds, 'x', [\"velocity_x\"], weight_field=\"density\", width=(0.4, \"Mpc\"))\n",
"prj.set_log(\"velocity_x\", False)\n",
"prj.set_unit(\"velocity_x\", \"km/s\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading

0 comments on commit d76e5a3

Please sign in to comment.