From 219e3cc08f0e2622e6ff83c0a7be6609374a878e Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 20 Sep 2024 11:33:29 -0600 Subject: [PATCH 1/5] Linkify the examples listing --- examples/README.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/examples/README.md b/examples/README.md index 7048665..debc9e8 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,14 +1,9 @@ -# Examples +# Examples: bmi-topography Here are a few examples of using the Topography data component, *bmi-topography*. -* `topography.ipynb` and `bmi-topography.ipynb`: These Jupyter Notebooks show - how to call the Topography data component through its API and its BMI, - respectively. -* `bmi-topography_ex.sh`: This shell script demonstrates how to call the - Topography CLI. -* `bmi-topography_ex.py`: An example Python script is used in the main - [README](../README.md). -* `config.yaml`: A configuration file used to pass parameters to the Topography - BMI. +* [topography.ipynb](./topography.ipynb) and [bmi-topography.ipynb](./bmi-topography.ipynb): These Jupyter Notebooks show how to call the Topography data component through its API and its BMI, respectively. +* [bmi-topography_ex.sh](./bmi-topography_ex.sh): This shell script demonstrates how to call the Topography CLI. +* [bmi-topography_ex.py](./bmi-topography_ex.py): An example Python script is used in the main [README](../README.md). +* [config.yaml](./config.yaml): A configuration file used to pass parameters to the Topography BMI. From 74b49f4f1fae7e20a27c7717c3f62f7a5d849855 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 20 Sep 2024 11:38:37 -0600 Subject: [PATCH 2/5] Edit text --- examples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index debc9e8..e555364 100644 --- a/examples/README.md +++ b/examples/README.md @@ -5,5 +5,5 @@ Here are a few examples of using the Topography data component, * [topography.ipynb](./topography.ipynb) and [bmi-topography.ipynb](./bmi-topography.ipynb): These Jupyter Notebooks show how to call the Topography data component through its API and its BMI, respectively. * [bmi-topography_ex.sh](./bmi-topography_ex.sh): This shell script demonstrates how to call the Topography CLI. -* [bmi-topography_ex.py](./bmi-topography_ex.py): An example Python script is used in the main [README](../README.md). +* [bmi-topography_ex.py](./bmi-topography_ex.py): An example Python script that is used in the main [README](../README.md). * [config.yaml](./config.yaml): A configuration file used to pass parameters to the Topography BMI. From d37b02780730e465300fa48d4c88d3411d260046 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 20 Sep 2024 11:39:13 -0600 Subject: [PATCH 3/5] Add a landing page notebook --- examples/README.ipynb | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 examples/README.ipynb diff --git a/examples/README.ipynb b/examples/README.ipynb new file mode 100644 index 0000000..004b940 --- /dev/null +++ b/examples/README.ipynb @@ -0,0 +1,47 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "8e3d936a-be52-413e-b714-8f1eba301d21", + "metadata": {}, + "source": [ + "# Examples: bmi-topography" + ] + }, + { + "cell_type": "markdown", + "id": "0bfc1e88-64f6-46b0-bf7d-ecb2487fae9c", + "metadata": {}, + "source": [ + "Here are a few examples of using the Topography data component,\n", + "*bmi-topography*.\n", + "\n", + "* [topography.ipynb](./topography.ipynb) and [bmi-topography.ipynb](./bmi-topography.ipynb): These Jupyter Notebooks show how to call the Topography data component through its API and its BMI, respectively.\n", + "* [bmi-topography_ex.sh](./bmi-topography_ex.sh): This shell script demonstrates how to call the Topography CLI.\n", + "* [bmi-topography_ex.py](./bmi-topography_ex.py): An example Python script that used in the main [README](../README.md).\n", + "* [config.yaml](./config.yaml): A configuration file used to pass parameters to the Topography BMI." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "CSDMS", + "language": "python", + "name": "csdms" + }, + "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.11.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 282b4d20bc06ef2f64996413bc7bfcb2eba59b25 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 20 Sep 2024 11:46:31 -0600 Subject: [PATCH 4/5] Edit text descriptions in the example notebooks --- examples/bmi-topography.ipynb | 22 +++------------------- examples/topography.ipynb | 30 +++--------------------------- 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/examples/bmi-topography.ipynb b/examples/bmi-topography.ipynb index 1e5f1d5..100696f 100644 --- a/examples/bmi-topography.ipynb +++ b/examples/bmi-topography.ipynb @@ -5,7 +5,7 @@ "id": "0", "metadata": {}, "source": [ - "# Get SRTM data through a BMI" + "# Get SRTM data with the Topography data component BMI" ] }, { @@ -14,7 +14,7 @@ "metadata": {}, "source": [ "This notebook describes how to download Shuttle Radar Topography Mission (SRTM) elevation data\n", - "using a [Basic Model Interface](https://bmi.readthedocs.io/) (BMI) through the `BmiTopography` class included in the `bmi-topography` package." + "using the [Basic Model Interface](https://bmi.readthedocs.io/) (BMI) provided in the Topography data component." ] }, { @@ -25,22 +25,6 @@ "## Setup" ] }, - { - "cell_type": "markdown", - "id": "3", - "metadata": {}, - "source": [ - "To ensure all dependencies are met, set up a conda environment using the environment file found in the root directory of this repository:\n", - "```\n", - "conda env create --file=environment.yml\n", - "```\n", - "\n", - "Then install the `bmi-topography` package:\n", - "```\n", - "make install\n", - "```" - ] - }, { "cell_type": "markdown", "id": "4", @@ -73,7 +57,7 @@ "id": "7", "metadata": {}, "source": [ - "Import the `BmiTopography` class from the newly installed `bmi-topography` package:" + "Import the `BmiTopography` class from the `bmi-topography` package:" ] }, { diff --git a/examples/topography.ipynb b/examples/topography.ipynb index e5a1fe2..1d7b9e8 100644 --- a/examples/topography.ipynb +++ b/examples/topography.ipynb @@ -5,7 +5,7 @@ "id": "0", "metadata": {}, "source": [ - "# Get SRTM data with the Topography class" + "# Get SRTM data with the Topography data component" ] }, { @@ -14,31 +14,7 @@ "metadata": {}, "source": [ "This notebook describes how to download Shuttle Radar Topography Mission (SRTM) elevation data\n", - "using the `Topography` class included in the `bmi-topography` package." - ] - }, - { - "cell_type": "markdown", - "id": "2", - "metadata": {}, - "source": [ - "## Setup" - ] - }, - { - "cell_type": "markdown", - "id": "3", - "metadata": {}, - "source": [ - "To ensure all dependencies are met, set up a conda environment using the environment file found in the root directory of this repository:\n", - "```\n", - "conda env create --file=environment.yml\n", - "```\n", - "\n", - "Then install the `bmi-topography` package:\n", - "```\n", - "make install\n", - "```" + "with the Topography data component." ] }, { @@ -54,7 +30,7 @@ "id": "5", "metadata": {}, "source": [ - "Import the `Topography` class from the newly installed `bmi-topography` package:" + "Import the `Topography` class from the `bmi-topography` package:" ] }, { From 447241c6f85425d12e011eee19f01ec1099fb326 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Fri, 20 Sep 2024 11:54:38 -0600 Subject: [PATCH 5/5] Make pretty --- examples/README.ipynb | 4 +- examples/bmi-topography.ipynb | 98 +++++++++++++++++------------------ examples/topography.ipynb | 30 +++++------ 3 files changed, 66 insertions(+), 66 deletions(-) diff --git a/examples/README.ipynb b/examples/README.ipynb index 004b940..e57da47 100644 --- a/examples/README.ipynb +++ b/examples/README.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "8e3d936a-be52-413e-b714-8f1eba301d21", + "id": "0", "metadata": {}, "source": [ "# Examples: bmi-topography" @@ -10,7 +10,7 @@ }, { "cell_type": "markdown", - "id": "0bfc1e88-64f6-46b0-bf7d-ecb2487fae9c", + "id": "1", "metadata": {}, "source": [ "Here are a few examples of using the Topography data component,\n", diff --git a/examples/bmi-topography.ipynb b/examples/bmi-topography.ipynb index 100696f..982b0ca 100644 --- a/examples/bmi-topography.ipynb +++ b/examples/bmi-topography.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "markdown", - "id": "4", + "id": "3", "metadata": {}, "source": [ "Import a pair of libraries for later use:" @@ -36,7 +36,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -46,7 +46,7 @@ }, { "cell_type": "markdown", - "id": "6", + "id": "5", "metadata": {}, "source": [ "## Fetch and load data" @@ -54,7 +54,7 @@ }, { "cell_type": "markdown", - "id": "7", + "id": "6", "metadata": {}, "source": [ "Import the `BmiTopography` class from the `bmi-topography` package:" @@ -63,7 +63,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -72,7 +72,7 @@ }, { "cell_type": "markdown", - "id": "9", + "id": "8", "metadata": {}, "source": [ "Create an instance of this class." @@ -81,7 +81,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -90,7 +90,7 @@ }, { "cell_type": "markdown", - "id": "11", + "id": "10", "metadata": {}, "source": [ "Calling `help` on the instance displays all the BMI methods that are available." @@ -99,7 +99,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ }, { "cell_type": "markdown", - "id": "13", + "id": "12", "metadata": {}, "source": [ "The first step in using a BMI is calling the `initialize` method.\n", @@ -120,7 +120,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -130,7 +130,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -139,7 +139,7 @@ }, { "cell_type": "markdown", - "id": "16", + "id": "15", "metadata": {}, "source": [ "Call `initialize` with the sample configuration file." @@ -148,7 +148,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -157,7 +157,7 @@ }, { "cell_type": "markdown", - "id": "18", + "id": "17", "metadata": {}, "source": [ "This step may take a moment, as the `Topography` library fetches and downloads the data from the internet.\n", @@ -168,7 +168,7 @@ { "cell_type": "code", "execution_count": null, - "id": "19", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -177,7 +177,7 @@ }, { "cell_type": "markdown", - "id": "20", + "id": "19", "metadata": {}, "source": [ "## Access data through the BMI" @@ -185,7 +185,7 @@ }, { "cell_type": "markdown", - "id": "21", + "id": "20", "metadata": {}, "source": [ "Now that we've fetched the data, let's access it through the BMI.\n", @@ -198,7 +198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -207,7 +207,7 @@ }, { "cell_type": "markdown", - "id": "23", + "id": "22", "metadata": {}, "source": [ "The (long) name for the variable representing elevation is an instance of a [CSDMS Standard Name](https://csdms.colorado.edu/wiki/CSDMS_Standard_Names).\n", @@ -216,7 +216,7 @@ }, { "cell_type": "markdown", - "id": "24", + "id": "23", "metadata": {}, "source": [ "Find the data type of the elevation data." @@ -225,7 +225,7 @@ { "cell_type": "code", "execution_count": null, - "id": "25", + "id": "24", "metadata": {}, "outputs": [], "source": [ @@ -235,7 +235,7 @@ }, { "cell_type": "markdown", - "id": "26", + "id": "25", "metadata": {}, "source": [ "Within the BMI, functions that describe the grids that variables are defined on take an index instead of a variable name.\n", @@ -246,7 +246,7 @@ { "cell_type": "code", "execution_count": null, - "id": "27", + "id": "26", "metadata": {}, "outputs": [], "source": [ @@ -256,7 +256,7 @@ }, { "cell_type": "markdown", - "id": "28", + "id": "27", "metadata": {}, "source": [ "Then find the total size of the elevation data." @@ -265,7 +265,7 @@ { "cell_type": "code", "execution_count": null, - "id": "29", + "id": "28", "metadata": {}, "outputs": [], "source": [ @@ -275,7 +275,7 @@ }, { "cell_type": "markdown", - "id": "30", + "id": "29", "metadata": {}, "source": [ "Next, get the elevation values.\n", @@ -291,7 +291,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31", + "id": "30", "metadata": {}, "outputs": [], "source": [ @@ -301,7 +301,7 @@ }, { "cell_type": "markdown", - "id": "32", + "id": "31", "metadata": {}, "source": [ "Get the elevation data." @@ -310,7 +310,7 @@ { "cell_type": "code", "execution_count": null, - "id": "33", + "id": "32", "metadata": {}, "outputs": [], "source": [ @@ -319,7 +319,7 @@ }, { "cell_type": "markdown", - "id": "34", + "id": "33", "metadata": {}, "source": [ "Note that the elevation array is one-dimensional." @@ -328,7 +328,7 @@ { "cell_type": "code", "execution_count": null, - "id": "35", + "id": "34", "metadata": {}, "outputs": [], "source": [ @@ -337,7 +337,7 @@ }, { "cell_type": "markdown", - "id": "36", + "id": "35", "metadata": {}, "source": [ "### Reshape data" @@ -345,7 +345,7 @@ }, { "cell_type": "markdown", - "id": "37", + "id": "36", "metadata": {}, "source": [ "Like all BMI arrays, the elevations returned from the BMI `get_value` function are flattened.\n", @@ -354,7 +354,7 @@ }, { "cell_type": "markdown", - "id": "38", + "id": "37", "metadata": {}, "source": [ "First, determine the dimensionality of the elevation variable." @@ -363,7 +363,7 @@ { "cell_type": "code", "execution_count": null, - "id": "39", + "id": "38", "metadata": {}, "outputs": [], "source": [ @@ -373,7 +373,7 @@ }, { "cell_type": "markdown", - "id": "40", + "id": "39", "metadata": {}, "source": [ "Get the dimensions of the elevation data, first creating an array to store their values." @@ -382,7 +382,7 @@ { "cell_type": "code", "execution_count": null, - "id": "41", + "id": "40", "metadata": {}, "outputs": [], "source": [ @@ -393,7 +393,7 @@ { "cell_type": "code", "execution_count": null, - "id": "42", + "id": "41", "metadata": {}, "outputs": [], "source": [ @@ -402,7 +402,7 @@ }, { "cell_type": "markdown", - "id": "43", + "id": "42", "metadata": {}, "source": [ "Reshape the elevation data, creating a new array." @@ -411,7 +411,7 @@ { "cell_type": "code", "execution_count": null, - "id": "44", + "id": "43", "metadata": {}, "outputs": [], "source": [ @@ -421,7 +421,7 @@ { "cell_type": "code", "execution_count": null, - "id": "45", + "id": "44", "metadata": {}, "outputs": [], "source": [ @@ -430,7 +430,7 @@ }, { "cell_type": "markdown", - "id": "46", + "id": "45", "metadata": {}, "source": [ "## Visualize" @@ -438,7 +438,7 @@ }, { "cell_type": "markdown", - "id": "47", + "id": "46", "metadata": {}, "source": [ "Let's visualize the elevation data as an image." @@ -447,7 +447,7 @@ { "cell_type": "code", "execution_count": null, - "id": "48", + "id": "47", "metadata": {}, "outputs": [], "source": [ @@ -456,7 +456,7 @@ }, { "cell_type": "markdown", - "id": "49", + "id": "48", "metadata": {}, "source": [ "## Conclusion" @@ -464,7 +464,7 @@ }, { "cell_type": "markdown", - "id": "50", + "id": "49", "metadata": {}, "source": [ "Last, call the BMI `finalize` function." @@ -473,7 +473,7 @@ { "cell_type": "code", "execution_count": null, - "id": "51", + "id": "50", "metadata": {}, "outputs": [], "source": [ @@ -482,7 +482,7 @@ }, { "cell_type": "markdown", - "id": "52", + "id": "51", "metadata": {}, "source": [ "This demonstration of the BMI took a lot of code to reproduce a simple result.\n", diff --git a/examples/topography.ipynb b/examples/topography.ipynb index 1d7b9e8..f69b33a 100644 --- a/examples/topography.ipynb +++ b/examples/topography.ipynb @@ -19,7 +19,7 @@ }, { "cell_type": "markdown", - "id": "4", + "id": "2", "metadata": {}, "source": [ "## Fetch and load data" @@ -27,7 +27,7 @@ }, { "cell_type": "markdown", - "id": "5", + "id": "3", "metadata": {}, "source": [ "Import the `Topography` class from the `bmi-topography` package:" @@ -36,7 +36,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -45,7 +45,7 @@ }, { "cell_type": "markdown", - "id": "7", + "id": "5", "metadata": {}, "source": [ "`Topography` downloads and stores SRTM data through the [OpenTopography](https://opentopography.org/) [REST API](https://portal.opentopography.org/apidocs/#/Public/getGlobalDem). OpenTopography is an NSF-supported project that provides open access to high-resolution topography data and services." @@ -53,7 +53,7 @@ }, { "cell_type": "markdown", - "id": "8", + "id": "6", "metadata": {}, "source": [ "Create an instance of `Topography` using parameters to describe\n", @@ -69,7 +69,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -86,7 +86,7 @@ }, { "cell_type": "markdown", - "id": "10", + "id": "8", "metadata": {}, "source": [ "While this step sets up a call to the OpenTopography API, it doesn't download the data. Download the data by calling the `fetch` method:" @@ -95,7 +95,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -105,7 +105,7 @@ }, { "cell_type": "markdown", - "id": "12", + "id": "10", "metadata": {}, "source": [ "This step may take a few moments to run while the data are fetched from OpenTopography and downloaded." @@ -113,7 +113,7 @@ }, { "cell_type": "markdown", - "id": "13", + "id": "11", "metadata": {}, "source": [ "The `fetch` method only downloads data; it doesn't load it into memory. Call the `load` method to open the downloaded file and load it into an `xarray` DataArray:" @@ -122,7 +122,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -132,7 +132,7 @@ }, { "cell_type": "markdown", - "id": "15", + "id": "13", "metadata": {}, "source": [ "Note that `load` calls `fetch`, so the latter can be omitted if the goal is the get the data into memory." @@ -140,7 +140,7 @@ }, { "cell_type": "markdown", - "id": "16", + "id": "14", "metadata": {}, "source": [ "## Visualize" @@ -148,7 +148,7 @@ }, { "cell_type": "markdown", - "id": "17", + "id": "15", "metadata": {}, "source": [ "Finally, let's visualize the downloaded elevation data." @@ -157,7 +157,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "16", "metadata": {}, "outputs": [], "source": [