Skip to content

Commit

Permalink
Merge pull request #135 from mcflugen/mcflugen/add-answer-cells
Browse files Browse the repository at this point in the history
Add answer cells in landlab notebooks
  • Loading branch information
mcflugen authored Jan 25, 2024
2 parents 7fb82a9 + 6ffdabc commit 72132f1
Show file tree
Hide file tree
Showing 8 changed files with 567 additions and 59 deletions.
50 changes: 46 additions & 4 deletions lessons/landlab/landlab/01-intro.a.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,21 @@
"Now see if you can do something similar with a `HexModelGrid`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# Create a hex grid that has 5 rows and 4 colums of nodes."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -224,7 +239,6 @@
},
"outputs": [],
"source": [
"# Create a hex grid that has 5 rows and 4 colums of nodes.\n",
"grid = HexModelGrid((5, 4))\n",
"plot_graph(grid, at=\"node\")"
]
Expand All @@ -237,6 +251,21 @@
"the correct signature to use."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# create a radial grid instance"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -247,7 +276,6 @@
},
"outputs": [],
"source": [
"# create a radial grid instance\n",
"grid = RadialModelGrid(5, 4)\n",
"plot_graph(grid, at=\"node\")"
]
Expand All @@ -260,6 +288,21 @@
"interior *nodes* have been offset be a random amount."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# Create a framed voronoi grid with 4 rows and 5 columns of nodes."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -270,7 +313,6 @@
},
"outputs": [],
"source": [
"# Create a framed voronoi grid with 4 rows and 5 columns of nodes.\n",
"grid = FramedVoronoiGrid((4, 5))\n",
"plot_graph(grid, at=\"node\")"
]
Expand Down Expand Up @@ -304,7 +346,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
50 changes: 46 additions & 4 deletions lessons/landlab/landlab/01-intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,21 @@
"Now see if you can do something similar with a `HexModelGrid`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# Create a hex grid that has 5 rows and 4 colums of nodes."
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -226,7 +241,6 @@
" <summary>👉 <b>click to see solution</b></summary>\n",
"\n",
"```python\n",
"# Create a hex grid that has 5 rows and 4 colums of nodes.\n",
"grid = HexModelGrid((5, 4))\n",
"plot_graph(grid, at=\"node\")\n",
"```\n",
Expand All @@ -241,6 +255,21 @@
"the correct signature to use."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# create a radial grid instance"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -253,7 +282,6 @@
" <summary>👉 <b>click to see solution</b></summary>\n",
"\n",
"```python\n",
"# create a radial grid instance\n",
"grid = RadialModelGrid(5, 4)\n",
"plot_graph(grid, at=\"node\")\n",
"```\n",
Expand All @@ -268,6 +296,21 @@
"interior *nodes* have been offset be a random amount."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# Create a framed voronoi grid with 4 rows and 5 columns of nodes."
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -280,7 +323,6 @@
" <summary>👉 <b>click to see solution</b></summary>\n",
"\n",
"```python\n",
"# Create a framed voronoi grid with 4 rows and 5 columns of nodes.\n",
"grid = FramedVoronoiGrid((4, 5))\n",
"plot_graph(grid, at=\"node\")\n",
"```\n",
Expand Down Expand Up @@ -316,7 +358,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
85 changes: 79 additions & 6 deletions lessons/landlab/landlab/02-data.a.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"<a href=\"http://landlab.github.io\"><img style=\"float: left\" src=\"https://raw.githubusercontent.com/landlab/tutorials/release/landlab_header.png\"></a>"
]
Expand Down Expand Up @@ -85,13 +91,31 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# Get the values for the field names, \"bar\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"solution"
]
},
"outputs": [],
"source": [
"# Get the values for the field names, \"bar\"\n",
"grid.at_node[\"bar\"]"
]
},
Expand Down Expand Up @@ -146,13 +170,31 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# Write your code here"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"solution"
]
},
"outputs": [],
"source": [
"# Write your code here\n",
"print(f\"Number of points = {grid.number_of_nodes}\")\n",
"print(f\"Number of rows and columns = {grid.shape}\")\n",
"print(f\"Resolution = {grid.spacing}\")\n",
Expand Down Expand Up @@ -345,7 +387,13 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"How do the above two answers change if you select a different DEM type (`\"SRTMGL1\"`, say)?"
]
Expand All @@ -354,6 +402,25 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# Get a DEM of a different type"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"solution"
]
Expand Down Expand Up @@ -436,7 +503,13 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"In this tutorial we looked at how we can add data to *Landlab* grid *nodes*. In the next tutorial we'll have a look at some of the other grid elements (*links* and *cells*).\n",
"\n",
Expand All @@ -462,7 +535,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 72132f1

Please sign in to comment.