Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exercises to tutorial notebooks 1-9 #1223

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"## First Light Example\n",
"### Render a sample dataset using Ascent\n",
"To start, we run a basic “First Light” example to generate an image. This example renders the an example dataset using ray casting to create a pseudocolor plot. The dataset is one of the built-in Conduit Mesh Blueprint examples, in this case an unstructured mesh composed of hexagons."
"To start, we run a basic “First Light” example to generate an image. This example renders the example dataset using ray casting to create a pseudocolor plot. The dataset is one of the built-in Conduit Mesh Blueprint examples, in this case an unstructured mesh composed of hexagons."
]
},
{
Expand Down Expand Up @@ -118,11 +118,47 @@
"# close ascent\n",
"a.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"\n",
"**First**, change the \"field\" name for this dataset from \"braid\" to \"radial\" and re-plot the image.\n",
"\n",
"**Second**, observe how the image generated changes as you decrease the number of points on the mesh. For example, move from a 50x50x50 mesh to a 15x15x15 mesh.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise solution\n",
"Run the cell below once to see solutions and twice to run them."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%load solutions/exercise1.py"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -136,7 +172,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,77 @@
"\n",
"print(n.to_yaml())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"\n",
"**First**, create a tree with the following format:\n",
"\n",
"```\n",
"animals: \n",
" carnivores: \n",
" - \"cat\"\n",
" herbivores: \n",
" - \"koala\"\n",
" - \"sloth\"\n",
" omnivores: \n",
" - \"dog\"\n",
" - \"human\"\n",
"```\n",
"\n",
"Hint: You'll have to use lists.\n",
"\n",
"**Second**\n",
"\n",
"Add \"bear\" to the list of omnivores in `animals` so that the tree looks like\n",
"\n",
"```\n",
"animals: \n",
" carnivores: \n",
" - \"cat\"\n",
" herbivores: \n",
" - \"koala\"\n",
" - \"sloth\"\n",
" omnivores: \n",
" - \"dog\"\n",
" - \"human\"\n",
" - \"bear\"\n",
"```\n",
"\n",
"Here you'll use the `set` method introduced above! See [these docs](https://llnl-conduit.readthedocs.io/en/latest/tutorial_python_basics.html) for help."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise solution\n",
"Run the cell below once to see solutions and twice to run them."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%load solutions/exercise2.py"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -136,9 +202,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,55 @@
"# view our results\n",
"ascent.jupyter.AscentImageSequenceViewer(result_image_files).show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"\n",
"Use/alter the code from Mesh Blueprint Example 1 to create a scene with two plots: two versions of the alternating field on a uniform grid -- one with an origin at (-10,-10,-10) and one with an origin at (0,0,0).\n",
"\n",
"**First**, add a second coordinate set to `mesh` and call it `mycoords`. `mycoords` will have the same properties as `coords` except for the difference in origin.\n",
"\n",
"**Second**, add a second topology to `mesh` and call it `mytopo`. `mytopo` will have the same properties as `topo` except that its coordinate set will be `mycoords` instead of `coords`.\n",
"\n",
"**Third**, add a second field to `mesh` and call it `myalternating`. `myalternating` will have the same properties as `alternating` except that its topology will be `mytopo` instead of `topo`.\n",
"\n",
"**Fourth** add a second plot (`p2`) to the scene `s1`. `p1` will still plot the field `alternating` and `p2` should plot `myalternating`.\n",
"\n",
"Finally, use AscentViewer to plot the result.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise solution\n",
"Run the cell below once to see solutions and twice to run them."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%load solutions/exercise3.py"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -468,9 +512,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,57 @@
"# close ascent\n",
"a.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"\n",
"Use and modify the code from Scene Example 3 (\"Adjusting camera parameters\").\n",
"Change the color scheme to Viridis and rotate the view of the tet example\n",
"360 degrees. \n",
"\n",
"**First**, update the name of the color table as in Example 4.\n",
"\n",
"**Second**, create 37 renders of `s1` with azimuth angles [0, 10, 20, 30, .... 360]\n",
"\n",
"Note: the following Python syntax for string interpolation may be helpful:\n",
"\n",
"```\n",
"a = \"world\"\n",
"print(f\"Hello {a}\")\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise solution\n",
"Run the cell below once to see solutions and twice to run them."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%load solutions/exercise4.py"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -336,9 +382,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,50 @@
"# close ascent\n",
"a.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"\n",
"Use and refactor the code in Pipeline Example 3.\n",
"\n",
"**First** break the second pipeline `pl2` with two filters into two pipelines (`pl2` and `pl3`) -- one with a single filter each. \n",
"\n",
"**Second** create separate plots in `s1` for each of the three pipelines.\n",
"\n",
"You should end with a single scene and three plots that you can toggle between."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise solution\n",
"Run the cell below once to see solutions and twice to run them."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%load solutions/exercise5.py"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -335,9 +374,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Loading
Loading