diff --git a/book/intro.md b/book/intro.md index 1857e15..52b384d 100644 --- a/book/intro.md +++ b/book/intro.md @@ -13,7 +13,7 @@ tutorials for making maps 🗺️ and animations 🎦 ::::{grid} 1 1 1 1 :gutter: 1 -:::{grid-item-card} Tutorial 1 - First figure + Subplots / layout +:::{grid-item-card} Tutorial 1 - First figure 🚀 and Subplots / layout :img-top: _images/fd70248f75b8b37ee54b3135f77705f98c6d8489eb18b6910184b447d0f0638d.png :link: ./tut01_firstfigure.html by [Jing-Hui Tong](https://orcid.org/0009-0002-7195-3071) @@ -28,7 +28,7 @@ by [Jing-Hui Tong](https://orcid.org/0009-0002-7195-3071) {bdg-secondary-line}`earth_age` ::: -:::{grid-item-card} Tutorial 2 - Integration with the scientific Python ecosystem: pandas / GeoPandas +:::{grid-item-card} Tutorial 2 - Integration with the scientific Python ecosystem 🐍: pandas and GeoPandas (tabular data 🗒️) :img-top: _images/7f18327908c8dd210197cc51845e45a933f356b9fd12bd029a4a8cbda080eb2b.png :link: ./tut02_spe_pd_gpd.html by [Yvonne Fröhlich](https://orcid.org/0000-0002-8566-0619) @@ -52,7 +52,7 @@ by [Yvonne Fröhlich](https://orcid.org/0000-0002-8566-0619) ::::{grid} 1 1 1 1 :gutter: 1 -:::{grid-item-card} Tutorial 3 - Integration with the scientific Python ecosystem: Xarray (grids) +:::{grid-item-card} Tutorial 3 - Integration with the scientific Python ecosystem 🐍: Xarray (gridded data 🌐) :img-top: _images/a18fcb026fb0d0c83360f2b8382a360e552dd50db6aa2db5311259bf5223d3a2.png :link: ./tut03_spe_xarray.html by [Max Jones](https://orcid.org/0000-0003-0180-8928) @@ -67,7 +67,7 @@ by [Max Jones](https://orcid.org/0000-0003-0180-8928) {bdg-success-line}`CMIP6` ::: -:::{grid-item-card} Tutorial 4 - Geophysics (Seismology) +:::{grid-item-card} Tutorial 4 - Geophysics (Seismology) 🌎🌏🌍 :img-top: https://github.com/user-attachments/assets/37d94581-b9e9-4dec-a021-07c1b58c132a :link: ./tut04_geophysics.html by [Jing-Hui Tong](https://orcid.org/0009-0002-7195-3071) diff --git a/book/tut01_firstfigure.ipynb b/book/tut01_firstfigure.ipynb index e0a9cd0..f25ebb8 100644 --- a/book/tut01_firstfigure.ipynb +++ b/book/tut01_firstfigure.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "eb4b43cc-dc76-45d1-a370-7266bd943910", + "id": "123cc524-73bd-40e5-b727-ebef5b3b1f0b", "metadata": { "panel-layout": { "height": 218.611, @@ -11,27 +11,49 @@ } }, "source": [ - "# **Tutorial 1** - First figure and subplot \n", - "\n", - "This tutorial will cover the fundamental concepts behind making figures with PyGMT: \n", - "- drawing coastlines\n", - "- drawing a map frame\n", - "- choosing a projection\n", - "- downloading remote dataset\n", - "- imaging Earth's relief\n", - "- creating colorbar\n", - "- subplot in a figure\n", - "\n", - "-----\n", - "This tutorial is part of the AGU2024 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", - "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", - "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", + "# **Tutorial 1** - First figure 🚀 and Subplots / layout \n", + "\n", + "This tutorial will cover the fundamental concepts behind making figures with PyGMT:\n", + "\n", + "- Drawing coastlines\n", + "- Drawing a map frame\n", + "- Choosing a projection\n", + "- Downloading remote dataset\n", + "- Imaging Earth's relief\n", + "- Creating colorbar\n", + "- Subplot in a figure" + ] + }, + { + "cell_type": "markdown", + "id": "dfa0db02-962e-4031-a35c-4eaf4bf7d4f2", + "metadata": { + "panel-layout": { + "height": 218.611, + "visible": true, + "width": 100 + } + }, + "source": [ + ":::{note}\n", + "\n", + "This tutorial is part of the AGU24 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", "- Website: https://www.generic-mapping-tools.org/agu24workshop\n", - "- Recommended version: PyGMT v0.13.0 with GMT 6.5.0\n", - "----\n", - "References:\n", + "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", + "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", + "\n", + "History\n", + "- Author: [Jing-Hui Tong](https://orcid.org/0009-0002-7195-3071)\n", + "- Created: November-December 2024\n", + "- Recommended versions: [PyGMT v0.13.0](https://www.pygmt.org/v0.13.0) with [GMT 6.5.0](https://docs.generic-mapping-tools.org/6.5)\n", + "\n", + "References\n", "- Liam Toney, [2021 IRIS ROSES unit05](https://github.com/roseseismo/roses2021/blob/main/unit05/roses_mapping_lecture.ipynb)\n", - "- Chih-Ming Lin, GMT courses for 2019 NTNUES summer program" + "- Chih-Ming Lin, GMT courses for 2019 NTNUES summer program\n", + "\n", + "Fee free to play around with these code examples 🚀. In case you found any kind of error, just report it by [opening an issue](https://github.com/GenericMappingTools/agu24workshop/issues) or [provide a fix via a pull request](https://github.com/GenericMappingTools/agu24workshop/pulls). Please use the [GMT forum](https://forum.generic-mapping-tools.org/) to ask questions.\n", + "\n", + ":::" ] }, { @@ -66,7 +88,7 @@ } }, "source": [ - "## Importing \n", + "## 0️⃣ Importing \n", "\n", "First thing to do is load PyGMT (`import`) so that we can access its functionality. \n", "\n", @@ -88,8 +110,8 @@ "id": "ce622686-4279-4ab3-b00a-a9f3e7dc8cd4", "metadata": {}, "source": [ - "## Starting your first figure -- [`pygmt.Figure`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.html)\n", - "Every figure must start with the creation of a pygmt.Figure" + "## 1️⃣ Starting your first figure -- [`pygmt.Figure`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.html)\n", + "Every figure must start with the creation of a pygmt.Figure()" ] }, { @@ -115,7 +137,7 @@ "id": "03827f08-f6f5-4056-b73b-2071c90d8f0e", "metadata": {}, "source": [ - "## Drawing coastline -- [`pygmt.Figure.coast`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.coast.html)\n", + "### 1.1 Drawing coastline -- [`pygmt.Figure.coast`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.coast.html)\n", "Before plotting, you need to define \n", "1. `region`: Controlling the geographic or Cartesian extent of the figure. Regions are specified as lists of `[xmin, xmax, ymin, ymax]`. Another shortcut, `region=\"g\"`, which specifies a **global** domain.\n", "2. `projection`: Controlling the map projection. GMT (and therefore PyGMT) supports 31 different map projections, from basic Cartesian axes to [arbitrary vertical perspectives](https://docs.generic-mapping-tools.org/6.5/gallery/ex26.html).\n", @@ -158,7 +180,9 @@ "id": "e28639db-0e21-4c12-91b7-2a96f6158160", "metadata": {}, "source": [ - "::::{seealso} If the image size is too small, the default annotation fonts may appear disproportionately large, impacting the overall visual balance and readability." + "::::{seealso}\n", + "If the image size is too small, the default annotation fonts may appear disproportionately large, impacting the overall visual balance and readability.\n", + "::::" ] }, { @@ -167,7 +191,7 @@ "id": "bc713bc7-6c8b-4709-b683-e7908b4a91ef", "metadata": {}, "source": [ - "#### Coloring and add map element (frame and ticks)\n", + "### 1.2 Coloring and add map element (frame and ticks)\n", "1. axis labels `WSne`: If an upper-case letter (W, S, N, E) is passed, the axis is plotted with tick marks and annotations. The lower-case version (w, s, n, e) plots the axis only with tick marks. To only plot the axis pass (l, b, t, r).\n", "\n", "2. annotations `a`: tick labels\n", @@ -199,7 +223,7 @@ "id": "c9b6acaa-ffea-4c8a-bf2a-91b73070d06c", "metadata": {}, "source": [ - "#### NOTE\n", + "### 1.3 Stacking approach of GMT / PyGMT\n", "1. In GMT/PyGMT, plotting is achieved by layering new elements, meaning that each new element is stacked on top of the previous layers. \n", "Therefore, if you draw a black line in an earlier layer and then add a new layer (such as color filling), these new layers might cover the original black line, making it invisible.\n", "2. In a **same figure**, once you define region/projection before, you don't need to define again. " @@ -211,8 +235,7 @@ "id": "244b61fe-c349-41ce-9dca-6eefb35d9393", "metadata": {}, "source": [ - "## Downloading global dataset -- [`pygmt.datasets`](https://www.pygmt.org/v0.13.0/api/index.html#datasets)\n", - "\n", + "## 2️⃣ Downloading global dataset -- [`pygmt.datasets`](https://www.pygmt.org/v0.13.0/api/index.html#datasets)\n", "\n", "Before you access remote dataset from PyGMT, you need to define \n", "1. `region`: Region of interest, format is [xmin, xmax, ymin, ymax]\n", @@ -261,7 +284,7 @@ "id": "79fb24e7-fefe-45b4-b952-29f60172b76b", "metadata": {}, "source": [ - "## Visualizing grid -- [`pygmt.Figure.grdimage`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdimage.html)\n", + "## 3️⃣ Visualizing grid -- [`pygmt.Figure.grdimage`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdimage.html)\n", "Project and plot grids or images\n", "\n", "Now, we start with a new canvas. So you need to set up region/projection again!\n", @@ -294,7 +317,7 @@ "id": "2a1567c3-5ccd-4c17-bc2f-92fe33d4a398", "metadata": {}, "source": [ - "## Customizing colorbar -- [`pygmt.makecpt`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.makecpt.html)\n", + "### 3.1 Customizing colorbar -- [`pygmt.makecpt`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.makecpt.html)\n", "Making GMT color palette tables (CPT).\n", "\n", "You need to define:\n", @@ -326,7 +349,7 @@ "metadata": {}, "source": [ "Now, re-plot the figure with new colormap and ...\n", - "## Adding [`pygmt.Figure.colorbar`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.colorbar.html)\n", + "### 3.2 Adding [`pygmt.Figure.colorbar`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.colorbar.html)\n", "Plot a gray or color scale-bar on maps.\n", "\n", "You need to define,\n", @@ -381,7 +404,7 @@ "id": "d11eff82-e03c-4a89-9480-2860aa033ff6", "metadata": {}, "source": [ - "## Creating multi-panel figures in a canvas -- [`pygmt.Figure.subplot`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.subplot.html#pygmt.Figure.subplot) and [`pygmt.Figure.set_panel`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.set_panel.html#pygmt.Figure.set_panel)\n", + "## 4️⃣ Creating multi-panel figures in a canvas -- [`pygmt.Figure.subplot`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.subplot.html#pygmt.Figure.subplot) and [`pygmt.Figure.set_panel`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.set_panel.html#pygmt.Figure.set_panel)\n", "\n", "\n", "You need to define the figure layout with figure.subplot:\n", @@ -445,7 +468,7 @@ "id": "25aeb001-48ed-417b-94dc-637c3fad15c1", "metadata": {}, "source": [ - "### Basic projection types: \n", + "## 5️⃣ Basic projection types: \n", "\n", "\"position\"\n", "By default, PyGMT will use an equidistant cylindrical projection if the region seems to be geographic longitude and latitude.\n", @@ -492,7 +515,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.7" }, "panel-cell-order": [ "eb4b43cc-dc76-45d1-a370-7266bd943910", diff --git a/book/tut02_spe_pd_gpd.ipynb b/book/tut02_spe_pd_gpd.ipynb index 1f9141a..0291e71 100755 --- a/book/tut02_spe_pd_gpd.ipynb +++ b/book/tut02_spe_pd_gpd.ipynb @@ -2,23 +2,38 @@ "cells": [ { "cell_type": "markdown", - "id": "315a335b-1325-4319-aa06-cb1b239616b8", + "id": "ef4bd355-d444-4afd-8f27-b0a2f7d97a76", "metadata": {}, "source": [ - "# **Tutorial 2** - scientific Python ecosystem: `pandas` and `GeoPandas`\n", + "# **Tutorial 2** - scientific Python ecosystem 🐍: `pandas` and `GeoPandas` (tabular data 🗒️)\n", "\n", "In this tutorial we will learn using\n", " 1. [**pandas**](https://pandas.pydata.org/docs/): **tabular data** stored in ``pandas.DataFrame``s\n", " 2. [**GeoPandas**](https://geopandas.org/en/stable/docs.html): **spatial data** (points, lines, polygons) stored in ``geopandas.GeoDataFrame``s\n", "\n", - "within [`PyGMT`](https://www.pygmt.org) to create histograms and different maps.\n", + "within [`PyGMT`](https://www.pygmt.org) to create histograms and different maps." + ] + }, + { + "cell_type": "markdown", + "id": "06acf2fb-08b1-48b0-bfc7-5e7c46b27ffa", + "metadata": {}, + "source": [ + ":::{note}\n", "\n", - "-----\n", - "This tutorial is part of the AGU2024 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", - "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", - "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", + "This tutorial is part of the AGU24 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", "- Website: https://www.generic-mapping-tools.org/agu24workshop\n", - "- Recommended version: PyGMT v0.13.0 with GMT 6.5.0" + "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", + "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", + "\n", + "History\n", + "- Author: [Yvonne Fröhlich](https://orcid.org/0000-0002-8566-0619)\n", + "- Created: November-December 2024\n", + "- Recommended versions: [PyGMT v0.13.0](https://www.pygmt.org/v0.13.0) with [GMT 6.5.0](https://docs.generic-mapping-tools.org/6.5)\n", + "\n", + "Fee free to play around with these code examples 🚀. In case you found any kind of error, just report it by [opening an issue](https://github.com/GenericMappingTools/agu24workshop/issues) or [provide a fix via a pull request](https://github.com/GenericMappingTools/agu24workshop/pulls). Please use the [GMT forum](https://forum.generic-mapping-tools.org/) to ask questions.\n", + "\n", + ":::" ] }, { @@ -26,7 +41,7 @@ "id": "f56cbd63-a1bd-4e53-837c-13473e0db0d0", "metadata": {}, "source": [ - "## 0. General stuff" + "## 0️⃣ General stuff" ] }, { @@ -58,7 +73,7 @@ "id": "22e12c23-d01b-4c9f-91ca-0d9d1ed07409", "metadata": {}, "source": [ - "## 1. `pandas`" + "## 1️⃣ `pandas`" ] }, { @@ -204,7 +219,7 @@ "id": "0b238bef-3018-4bdc-92f8-9caa888a2c32", "metadata": {}, "source": [ - "## 2. `GeoPandas`" + "## 2️⃣ `GeoPandas`" ] }, { @@ -224,7 +239,7 @@ "source": [ "#### 2.1.1 Spatial Data - `geopandas.GeoDataFrame` with line geometry\n", "\n", - "First we download some data into in a `geopandas.GeoDataFrame`. This dataset contains European rivers with its length and name." + "First we download some data into in a [`geopandas.GeoDataFrame`](https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.html). This dataset contains European rivers with their lengths and names." ] }, { @@ -378,8 +393,8 @@ "source": [ "#### 2.2.1 Spatial Data - `geopandas.GeoDataFrame` with polygon geometry\n", "\n", - "Again we download some data into in a `geopandas.GeoDataFrame`. This dataset contains information regarding airbnb rentals, socioeconomics, and crime in Chicagos.\n", - "This time we are lucky and the data is directly provided in the geographic coordinate reference system (longitude/latitude) and no further coordinate transformation is needed." + "Again we download some data into in a [`geopandas.GeoDataFrame`](https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.html). This dataset contains information regarding airbnb rentals, socioeconomics, and crime in Chicagos.\n", + "This time we are lucky and the data is directly provided in the geographic coordinate reference system (longitude/latitude) and no coordinate transformation is needed." ] }, { @@ -450,7 +465,7 @@ "id": "03516fe8-5013-4acb-89d1-a1ebdbc1d426", "metadata": {}, "source": [ - "## 3. Additional comments\n", + "## 3️⃣ Additional comments\n", "\n", "Some helpful and interesting aspects:\n", "\n", @@ -466,7 +481,7 @@ "id": "9e7abfa1-13ac-4bed-896d-4e55438f1f94", "metadata": {}, "source": [ - "## 4. Orientation / suggestion for \"2.1.4 Plot the rivers with color-coding for the river length\"\n", + "## 4️⃣ Orientation / suggestion for \"2.1.4 Plot the rivers with color-coding for the river length\"\n", "\n", "Below you find a rough code shipset for plotting the rives with color-coding in section 2.1.4." ] diff --git a/book/tut03_spe_xarray.ipynb b/book/tut03_spe_xarray.ipynb index c614bb1..21c2d33 100644 --- a/book/tut03_spe_xarray.ipynb +++ b/book/tut03_spe_xarray.ipynb @@ -4,23 +4,37 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# **Tutorial 3** - scientific Python ecosystem: `Xarray`\n", + "# **Tutorial 3** - scientific Python ecosystem 🐍: `Xarray` (gridded data 🌐)\n", "\n", - "In this tutorial we will to process and visualize raster data using [`PyGMT`](https://www.pygmt.org)'s integration with [**Xarray**](https://xarray.dev).\n", + "In this tutorial we will to process and visualize raster data using [`PyGMT`](https://www.pygmt.org)'s integration with [**Xarray**](https://xarray.dev)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + ":::{note}\n", "\n", - "-----\n", - "This tutorial is part of the AGU2024 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", - "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", - "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", + "This tutorial is part of the AGU24 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", "- Website: https://www.generic-mapping-tools.org/agu24workshop\n", - "- Recommended version: PyGMT v0.13.0 with GMT 6.5.0" + "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", + "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", + "\n", + "History\n", + "- Author: [Max Jones](https://orcid.org/0000-0003-0180-8928)\n", + "- Created: November-December 2024\n", + "- Recommended versions: [PyGMT v0.13.0](https://www.pygmt.org/v0.13.0) with [GMT 6.5.0](https://docs.generic-mapping-tools.org/6.5)\n", + "\n", + "Fee free to play around with these code examples 🚀. In case you found any kind of error, just report it by [opening an issue](https://github.com/GenericMappingTools/agu24workshop/issues) or [provide a fix via a pull request](https://github.com/GenericMappingTools/agu24workshop/pulls). Please use the [GMT forum](https://forum.generic-mapping-tools.org/) to ask questions.\n", + "\n", + ":::" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## What is Xarray?\n", + "## 0️⃣ What is Xarray?\n", "\n", "[Xarray](https://xarray.dev) is an open source project and Python package for working with n-dimensional data using labeled dimensions and coordinates.\n", "\n", @@ -31,7 +45,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Why use Xarray with PyGMT\n", + "## 1️⃣ Why use Xarray with PyGMT\n", "\n", "Xarray provides a set of [useful features](https://xarray.dev/#features) for working with multi-dimensional data and unlocks even more functionality through its [rich ecosystem](https://xarray.dev/#ecosystem). Some specific benefits of integrating Xarray and PyGMT include:\n", "\n", @@ -46,7 +60,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Getting started\n", + "## 2️⃣ Getting started\n", "\n", "First we'll import all the libraries used throughout the tutorial." ] @@ -66,7 +80,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let's use a PyGMT function to explore an Xarray DataArray. We can use the `load_earth_relief` function to load one of GMT's remote datasets. This will take longer the first time that it's run because GMT downloads the data from the GMT server. We'll specify the server in order to quicken download speeds to Washington, D.C., USA." + "Let's use a PyGMT function to explore an Xarray DataArray. We can use the [`pygmt.datasets.load_earth_relief`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.datasets.load_earth_relief.html) function to load one of GMT's remote datasets. This will take longer the first time that it's run because GMT downloads the data from the GMT server. We'll specify the server in order to quicken download speeds to Washington, D.C., USA." ] }, { @@ -84,9 +98,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Plotting raster data\n", + "## 3️⃣ Plotting raster data\n", "\n", - "We can pass this dataset to `grd_image()` to plot the dataset, specifying a projection and colormap. We use the Winkel Tripel projection (\"R\") with a 12c width to show the whole world." + "We can pass this dataset to [`Figure.grdimage`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdimage.html) to plot the dataset, specifying a projection and colormap. We use the Winkel Tripel projection (\"R\") with a 12c width to show the whole world." ] }, { @@ -104,9 +118,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Processing raster data\n", + "## 4️⃣ Processing raster data\n", "\n", - "All of the PyGMT raster processing functions can accept and return Xarray DataArrays. As one example, we'll use the `grdgradient` function to create a hillshade raster. This will calculate the reflection of a light source projecting from west to east at an altitude of 30 degrees." + "All of the PyGMT raster processing functions can accept and return Xarray DataArrays. As one example, we'll use the [`grdgradient`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.grdgradient.html) function to create a hillshade raster. This will calculate the reflection of a light source projecting from west to east at an altitude of 30 degrees." ] }, { @@ -150,9 +164,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Download data and load with Xarray\n", + "## 5️⃣ Download data and load with Xarray\n", "\n", - "Most times you'll want to use your own data rather than the sample datasets. Here we show how to use the `which` functionality to download a NetCDF file available via https." + "Most times you'll want to use your own data rather than the sample datasets. Here we show how to use the [`which`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.which.html) functionality to download a NetCDF file available via https." ] }, { @@ -184,7 +198,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Open data directly from the cloud\n", + "## 6️⃣ Open data directly from the cloud\n", "\n", "Xarray allows you to open data directly from cloud object storage. This can be useful to avoid downloading the entire dataset, since Xarray can subset to a specific section of interest before loading the data into memory.\n", "\n", @@ -250,18 +264,11 @@ "fig.colorbar()\n", "fig.show()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "agu24workshop", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -279,5 +286,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/book/tut04_geophysics.ipynb b/book/tut04_geophysics.ipynb index 530b3e6..da1c574 100755 --- a/book/tut04_geophysics.ipynb +++ b/book/tut04_geophysics.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "315a335b-1325-4319-aa06-cb1b239616b8", + "id": "0caf70d8-a12d-4d62-ab8f-6d2f682640aa", "metadata": { "editable": true, "slideshow": { @@ -11,20 +11,41 @@ "tags": [] }, "source": [ - "# **Tutorial 4** - Geophysics (Seismology)\n", + "# **Tutorial 4** - Geophysics (Seismology) 🌎🌏🌍\n", "\n", "In this tutorial we will learn how to\n", "\n", " 1. Prepare **gridded data**: [`pygmt.xyz2grd`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.xyz2grd.html)\n", " 2. Create a **contour map**: [`pygmt.Figure.grdcontour`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdcontour.html)\n", - " 3. Create a **profile plot**: [`pygmt.project`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.project.html) and [`pygmt.grdtrack`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.grdtrack.html)\n", + " 3. Create a **profile plot**: [`pygmt.project`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.project.html) and [`pygmt.grdtrack`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.grdtrack.html)" + ] + }, + { + "cell_type": "markdown", + "id": "39eb835c-367d-4d44-8ff9-b55eec2a73bf", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "source": [ + ":::{note}\n", "\n", - "-----\n", - "This tutorial is part of the AGU2024 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", - "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", - "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", + "This tutorial is part of the AGU24 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", "- Website: https://www.generic-mapping-tools.org/agu24workshop\n", - "- Recommended version: PyGMT v0.13.0 with GMT 6.5.0" + "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", + "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", + "\n", + "History\n", + "- Authors: [Jing-Hui Tong](https://orcid.org/0009-0002-7195-3071) and [Yvonne Fröhlich](https://orcid.org/0000-0002-8566-0619)\n", + "- Created: November-December 2024\n", + "- Recommended versions: [PyGMT v0.13.0](https://www.pygmt.org/v0.13.0) with [GMT 6.5.0](https://docs.generic-mapping-tools.org/6.5)\n", + "\n", + "Fee free to play around with these code examples 🚀. In case you found any kind of error, just report it by [opening an issue](https://github.com/GenericMappingTools/agu24workshop/issues) or [provide a fix via a pull request](https://github.com/GenericMappingTools/agu24workshop/pulls). Please use the [GMT forum](https://forum.generic-mapping-tools.org/) to ask questions.\n", + "\n", + ":::" ] }, { @@ -32,7 +53,7 @@ "id": "f56cbd63-a1bd-4e53-837c-13473e0db0d0", "metadata": {}, "source": [ - "## 0. General stuff" + "## 0️⃣ General stuff" ] }, { @@ -63,7 +84,7 @@ "id": "22e12c23-d01b-4c9f-91ca-0d9d1ed07409", "metadata": {}, "source": [ - "## 1. Prepare gridded data: [`pygmt.xyz2grd`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.xyz2grd.html)\n", + "## 1️⃣ Prepare gridded data: [`pygmt.xyz2grd`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.xyz2grd.html)\n", "\n", "Sometimes, spatial (regional or global) data is provided as tabular data (.txt or .csv files) containing x, y, and z columns." ] @@ -135,7 +156,7 @@ "id": "3d08000c-7ac9-4899-bd3f-2006280d02d1", "metadata": {}, "source": [ - "In PyGMT, the grid is stored in an `xarray.DataArray`:" + "In PyGMT, the grid is stored in an [`xarray.DataArray`](https://docs.xarray.dev/en/v2024.09.0/generated/xarray.DataArray.html):" ] }, { @@ -165,10 +186,10 @@ "tags": [] }, "source": [ - "## 2. Create a contour map: [`pygmt.Figure.grdcontour`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdcontour.html)\n", + "## 2️⃣ Create a contour map: [`pygmt.Figure.grdcontour`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdcontour.html)\n", "To plot grids or images as contour lines you can use [`pygmt.Figure.grdcontour`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdcontour.html). You need to define:\n", "\n", - "1. `grid`: Access the remote datasets or provide your dataset as an `xarray.DataArray`.\n", + "1. `grid`: Access the remote datasets or provide your dataset as an [`xarray.DataArray`](https://docs.xarray.dev/en/v2024.09.0/generated/xarray.DataArray.html).\n", "2. `level`: Specify the contour intervals to generate; for example, a value of 1000 means plotting contour lines at every 1000 m.\n", "3. `annotation`: Annotate contour levels.\n", "4. `limit`: Draw contours below low or above high, e.g., [-4000, 0] means drawing contour lines below sea level and above -4000 m.\n", @@ -209,7 +230,7 @@ "id": "6b81c889-71b7-4009-bf93-448c37c188a7", "metadata": {}, "source": [ - "## 3. Create a profile plot: [`pygmt.project`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.project.html) and [`pygmt.grdtrack`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.grdtrack.html) " + "## 3️⃣ Create a profile plot: [`pygmt.project`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.project.html) and [`pygmt.grdtrack`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.grdtrack.html) " ] }, { @@ -417,7 +438,7 @@ "id": "4abb07a2-d9d7-4b8b-abd9-50349b3f9392", "metadata": {}, "source": [ - "## 4. Add additional features\n", + "## 4️⃣ Add additional features\n", "\n", "Finally, you can add additional features on top of the geographic map. Feel free to include your own ideas here! Here are a few ideas what you can try:\n", "\n", @@ -614,7 +635,7 @@ "id": "885ad8a2-b4f2-4b8d-8cc3-13c7116600bf", "metadata": {}, "source": [ - "## 5. Additional comments\n", + "## 5️⃣ Additional comments\n", "\n", "Some helpful and interesting aspects:\n", "\n", @@ -626,7 +647,7 @@ "id": "cd146118-8218-433a-8e5d-b7d6153a37fb", "metadata": {}, "source": [ - "## 6. Orientation / suggestion for \"4.2 Add seismicity\"\n", + "## 6️⃣ Orientation / suggestion for \"4.2 Add seismicity\"\n", "\n", "Below you find a rough code shipset for plotting the subsets of the earthquake dataset in section 4.1. Note the logarithmic scaling of size of the symbols as the size is referring to the magnitude of the earthquakes." ] @@ -686,7 +707,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/book/tut05_topography.ipynb b/book/tut05_topography.ipynb index 7c2ec3b..6f10f5a 100644 --- a/book/tut05_topography.ipynb +++ b/book/tut05_topography.ipynb @@ -2,19 +2,40 @@ "cells": [ { "cell_type": "markdown", - "id": "04aad1c8", + "id": "0a1a49e9-6ce7-4c26-8cce-4e5d7521fda5", "metadata": {}, "source": [ - "# **Tutorial 5** - 3-D Topography 🏔️\n", + "# **Tutorial 5** - 3-D Topography (Planetary / Antarctic maps) 🏔️\n", "\n", "In this tutorial, let's use PyGMT to create 3-D perspective plots of Digital Elevation\n", - "Models (DEM) over Mars (the planet) and Antarctica (the continent)!\n", + "Models (DEM) over Mars (the planet) and Antarctica (the continent)!" + ] + }, + { + "cell_type": "markdown", + "id": "e5180e42-06ee-4375-a034-294f481ca27a", + "metadata": {}, + "source": [ + ":::{note}\n", "\n", - "🔖 References:\n", + "This tutorial is part of the AGU24 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT**\n", + "- Website: https://www.generic-mapping-tools.org/agu24workshop\n", + "- GitHub: https://github.com/GenericMappingTools/agu24workshop\n", + "- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736\n", + "\n", + "History\n", + "- Authors: [Wei Ji Leong](https://orcid.org/0000-0003-2354-1988) and [André Belém](https://orcid.org/0000-0002-8865-6180)\n", + "- Created: November-December 2024\n", + "- Recommended versions: [PyGMT v0.13.0](https://www.pygmt.org/v0.13.0) with [GMT 6.5.0](https://docs.generic-mapping-tools.org/6.5)\n", "\n", + "🔖 References\n", "- https://www.generic-mapping-tools.org/remote-datasets/mars-relief.html\n", "- https://github.com/andrebelem/PlanetaryMaps\n", - "- {cite:t}`NeumannMarsOrbiterLaser2003`" + "- {cite:t}`NeumannMarsOrbiterLaser2003`\n", + "\n", + "Fee free to play around with these code examples 🚀. In case you found any kind of error, just report it by [opening an issue](https://github.com/GenericMappingTools/agu24workshop/issues) or [provide a fix via a pull request](https://github.com/GenericMappingTools/agu24workshop/pulls). Please use the [GMT forum](https://forum.generic-mapping-tools.org/) to ask questions.\n", + "\n", + ":::" ] }, { @@ -34,7 +55,7 @@ "id": "13d1cdfb", "metadata": {}, "source": [ - "# 0️⃣ Mars relief data\n", + "## 0️⃣ Mars relief data\n", "\n", "First, we'll load the Mars Orbiter Laser Altimeter (MOLA) dataset using\n", "[`pygmt.datasets.load_mars_relief`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.datasets.load_mars_relief.html).\n", @@ -59,7 +80,7 @@ "id": "07c66015", "metadata": {}, "source": [ - "## 2-D map view\n", + "### 0.1 2-D map view\n", "\n", "Here we can create a map of the entire Martian surface, using a\n", "[Mollweide projection](https://www.pygmt.org/v0.13.0/projections/misc/misc_mollweide.html).\n", @@ -88,7 +109,7 @@ "id": "c56eed5d", "metadata": {}, "source": [ - "## Zoomed in view\n", + "### 0.2 Zoomed in view\n", "\n", "A very interesting feature is [Olympus Mons](https://en.wikipedia.org/wiki/Olympus_Mons)\n", "centered at approximately 19°N and 133°W, with a height of 22 km (14 miles) and\n", @@ -129,7 +150,7 @@ "id": "cbf0ba14", "metadata": {}, "source": [ - "# 1️⃣ Using `grdview` for 3-D Visualization\n", + "## 1️⃣ Using `grdview` for 3-D Visualization\n", "\n", "The [`grdview`](https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.grdview.html)\n", "method in PyGMT is a powerful tool for creating 3-D perspective views of gridded data.\n", @@ -200,7 +221,7 @@ "reveal the data's structure.\n", "```\n", "\n", - "# 2️⃣ Antarctic Digital Elevation Model\n", + "## 2️⃣ Antarctic Digital Elevation Model\n", "\n", "For the next exercise, we'll pay a visit to the Antarctic continent, specifically,\n", "looking at Ross Island where the McMurdo Station (US) and Scott Base (NZ) is located.\n", @@ -211,7 +232,7 @@ "- https://www.pgc.umn.edu/data/rema/\n", "- {cite:t}`HowatReferenceElevationModel2019`\n", "\n", - "## Getting a DEM mosaic\n", + "### 2.1 Getting a DEM mosaic\n", "\n", "The REMA tiles are distributed as several GeoTIFF files. Our area of interest over Ross\n", "Island spans two tiles, so we'll need to retrieve them both an mosaic them. There are\n", @@ -298,7 +319,7 @@ "id": "d25a5273", "metadata": {}, "source": [ - "## Getting RGB imagery\n", + "### 2.2 Getting RGB imagery\n", "\n", "Next, let's get some Sentinel-2 optical satellite imagery, which we'll use to drape\n", "on top of the DEM later. We'll find some relatively cloud-free imagery that was taken on\n", @@ -356,7 +377,7 @@ "analysis.\n", "```\n", "\n", - "# 3️⃣ Draping RGB image on 3-D topography\n", + "## 3️⃣ Draping RGB image on 3-D topography\n", "\n", "We have our RGB imagery from Sentinel-2, and a DEM from REMA, and now we can learn how\n", "to render the colour image on top of the 3-D topography! Once again, we will be using\n", @@ -427,9 +448,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "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.12.7" } }, "nbformat": 4, diff --git a/book/tut06_animation.rst b/book/tut06_animation.rst index eec40e6..d420d8c 100644 --- a/book/tut06_animation.rst +++ b/book/tut06_animation.rst @@ -1,19 +1,25 @@ -**Tutorial 6** - Animations ---------------------------- - -By F. Esteban (@esteban82) - +**Tutorial 6** - Animations with GMT +------------------------------------ +Content - This tutorial explains the basic aspect of doing animations with GMT. - It serves as a guide to help beginners understand and troubleshoot potential issues. - It explains the basic aspect of the :gmt-module:`movie` and :gmt-module:`events` modules. +.. note:: + This tutorial is part of the AGU24 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT** + + * Website: https://www.generic-mapping-tools.org/agu24workshop + * GitHub: https://github.com/GenericMappingTools/agu24workshop + * Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736 + + History -This tutorial is part of the AGU2024 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT** + * Author: `Federico Esteban `_ + * Created: November-December 2024 + * Recommended version: `GMT 6.5.0 `_ -- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736 -- GitHub: https://github.com/GenericMappingTools/agu24workshop -- Website: https://www.generic-mapping-tools.org/agu24workshop + Fee free to play around with these code examples 🚀. In case you found any kind of error, just report it by `opening an issue `_ or `provide a fix via a pull request `_. Please use the `GMT forum `_ to ask questions. 1. Introduction diff --git a/book/tut06_animation_extended.rst b/book/tut06_animation_extended.rst index 45df146..bde7c85 100644 --- a/book/tut06_animation_extended.rst +++ b/book/tut06_animation_extended.rst @@ -1,12 +1,25 @@ -Making animations (extended) ----------------------------- +**Tutorial 6** - Animations with GMT (extended) +----------------------------------------------- -By F. Esteban (@esteban82) +Content +- Extension of "Tutorial 6 - Animations with GMT" -This tutorial is part of the AGU2024 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT** -- Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736 -- GitHub: https://github.com/GenericMappingTools/agu24workshop -- Website: https://www.generic-mapping-tools.org/agu24workshop +.. note:: + This tutorial is part of the AGU24 annual meeting GMT/PyGMT pre-conference workshop (PREWS9) **Mastering Geospatial Visualizations with GMT/PyGMT** + + * Website: https://www.generic-mapping-tools.org/agu24workshop + * GitHub: https://github.com/GenericMappingTools/agu24workshop + * Conference: https://agu.confex.com/agu/agu24/meetingapp.cgi/Session/226736 + + History + + History + + * Author: `Federico Esteban `_ + * Created: November-December 2024 + * Recommended version: `GMT 6.5.0 `_ + + Fee free to play around with these code examples 🚀. In case you found any kind of error, just report it by `opening an issue `_ or `provide a fix via a pull request `_. Please use the `GMT forum `_ to ask questions. 3. Tutorial 2. Earthquakes ~~~~~~~~~~~~~~~~~~~~~~~~~~