diff --git a/Makefile b/Makefile deleted file mode 100644 index e0306501..00000000 --- a/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -.PHONY: build serve watch - -build: - jupyter-book build book - -watch: - nodemon -w './**' -e yml,md,ipynb --exec jupyter-book build book - -serve: - cd _build/html; python -m http.server 9000 diff --git a/README.md b/README.md index 0f59e7de..83704269 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,7 @@ Use this to facilitate creating a [Jupyter-book](https://jupyterbook.org/) hoste From the root level of the repository ``` -make build -make serve +jb build book ``` ## GitHub Deployment diff --git a/book/_config.yml b/book/_config.yml index bb2f237b..ef5598bd 100644 --- a/book/_config.yml +++ b/book/_config.yml @@ -20,10 +20,19 @@ latex: latex_documents: targetname: book.tex +# Configure your Binder links, such as the URL of the BinderHub. +launch_buttons: + notebook_interface: jupyterlab + #binderhub_url: https://gke.mybinder.org + # NOTE: Want to use nbgitpuller with binderhub, not sure this will work currently... + binderhub_url: https://aws-uswest2-binder.pangeo.io/v2/gh/pangeo-data/notebook-binder/2021.02.02?git-pull?repo=https://github.com/uwhackweek/jupyterbook-template + jupyterhub_url: https://aws-uswest2.pangeo.io + colab_url: "" #empty string disables button + # Information about where the book exists on the web repository: url: https://github.com/uwhackweek/jupyterbook-template # Online location of your book - path_to_book: docs # Optional path to your book, relative to the repository root + path_to_book: book # Optional path to your book, relative to the repository root branch: main # Which branch of the repository should be used when creating links (optional) # Add GitHub buttons to your book diff --git a/book/_toc.yml b/book/_toc.yml index 7bc31231..0740f9a7 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -10,15 +10,17 @@ - file: norms/CoC - file: norms/community - file: projects/index - sections: + sections: - file: projects/project_initialization - file: projects/project_roles - file: projects/example_workflow - file: preliminary/index - sections: + sections: - file: preliminary/conda - file: preliminary/github - file: preliminary/jupyterhub - file: preliminary/jupyterhub_fork_clone - file: preliminary/earthdata - \ No newline at end of file +- file: tutorials/index + sections: + - file: tutorials/raster/intro-ipyleaflet diff --git a/book/tutorials/index.md b/book/tutorials/index.md new file mode 100644 index 00000000..dab183fe --- /dev/null +++ b/book/tutorials/index.md @@ -0,0 +1,20 @@ +# Tutorials + +This section contains everything you need to know about hackweek tutorials: + +* What are the [roles and responsibilities](tutorial_roles.md) of hackweek tutorial lead? +* How to create an interactive jupyter notebook tutorial + +## Organization + +Each tutorial is a collection of jupyterbooks and files in a its own subfolder under tutorials. For example in this template we have the `tutorials/raster/into-ipyleaflet.ipynb`. New tutorials need to be listed explicitly in the `_toc.yml` file to show up in the rendered documentation. + +```{attention} +When adding new notebooks be sure to "Clear all Outputs" before saving. This keeps the book source code small, but outputs are still built for the HTML webpage by Jupyter Book! +``` + +## Suggestions + +Use small example datasets, or have notebooks start by loading source data from the data provider. For example, instead of downloading a large number of datasets from NASA's [NSIDC DAAC](https://nsidc.org/daac) and having your tutorial start by opening local files, your notebook should start with code to retrieve your necessary datasets from NSIDC servers. This captures the full workflow from data acquisition to final analysis. + +Increasingly there are ways to access data remotely in a streaming fashion so that you don't have to download lots of files as a first step in your analysis. This is a good option as well to facilitate data management and portability of your tutorial to run on different machines (hackweek jupyterhub, your personal computer, the computers of collaborators, some temporary server on the Cloud like mybinder.org, etc...) diff --git a/book/tutorials/raster/intro-ipyleaflet.ipynb b/book/tutorials/raster/intro-ipyleaflet.ipynb new file mode 100644 index 00000000..8503df89 --- /dev/null +++ b/book/tutorials/raster/intro-ipyleaflet.ipynb @@ -0,0 +1,128 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "controlling-birth", + "metadata": {}, + "source": [ + "# An introduction to rasters\n", + "\n", + "We will examine raster images from the [MODIS instrument](https://modis.gsfc.nasa.gov/data/). \"MODIS\" stands for \"MODerate Resolution SpectroRadiometer\". Moderate resolution refers to the fact that MODIS data has at best a 250 meter pixel posting, but single images cover hundreds of kilometers and with two sensors currently in orbit, we currently get [daily views of the entire globe](https://worldview.earthdata.nasa.gov/)!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "pleased-humanity", + "metadata": {}, + "outputs": [], + "source": [ + "import ipyleaflet\n", + "from ipyleaflet import Map, Rectangle, basemaps, basemap_to_tiles, TileLayer, SplitMapControl, Polygon\n", + "\n", + "import ipywidgets\n", + "import datetime\n", + "import re" + ] + }, + { + "cell_type": "markdown", + "id": "different-bible", + "metadata": {}, + "source": [ + "Specify a bounding box covering Grand Mesa, Colorado" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "brutal-drama", + "metadata": {}, + "outputs": [], + "source": [ + "bbox = [-108.3, 39.2, -107.8, 38.8]\n", + "west, north, east, south = bbox\n", + "bbox_ctr = [0.5*(north+south), 0.5*(west+east)]" + ] + }, + { + "cell_type": "markdown", + "id": "informative-jewelry", + "metadata": {}, + "source": [ + "Display the bounding box on an interactive basemap for context. All the available basemaps can be found in the [ipyleaflet documentation](https://ipyleaflet.readthedocs.io/en/latest/api_reference/basemaps.html)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "neural-entertainment", + "metadata": {}, + "outputs": [], + "source": [ + "m = Map(center=bbox_ctr, zoom=10)\n", + "rectangle = Rectangle(bounds=((south, west), (north, east))) #SW and NE corners of the rectangle (lat, lon)\n", + "m.add_layer(rectangle)\n", + "m" + ] + }, + { + "cell_type": "markdown", + "id": "noble-initial", + "metadata": {}, + "source": [ + "### NASA GIBS\n", + "\n", + "NASA's [Global Imagery Browse Services (GIBS)](https://earthdata.nasa.gov/eosdis/science-system-description/eosdis-components/gibs) is a great Web Map Tile Service (WMTS) to visualize NASA data as pre-rendered tiled raster images. The NASA [Worldview](https://worldview.earthdata.nasa.gov) web application is a way to explore all GIBS datasets. We can also use ipyleaflet to explore GIBS datasets, like MODIS truecolor images, within a Jupyter Notebook. Use the slider in the image below to reveal the image from 2019-04-25:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "isolated-kennedy", + "metadata": {}, + "outputs": [], + "source": [ + "m = Map(center=bbox_ctr, zoom=6)\n", + "\n", + "right_layer = basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, \"2019-04-25\")\n", + "left_layer = TileLayer()\n", + "control = SplitMapControl(left_layer=left_layer, right_layer=right_layer)\n", + "m.add_control(control)\n", + "\n", + "m.add_layer(rectangle)\n", + "\n", + "m" + ] + }, + { + "cell_type": "markdown", + "id": "official-thong", + "metadata": {}, + "source": [ + "*Thats all for now, stay tuned for more!*" + ] + } + ], + "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.8.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}