From e475966719c8e0ac677fed158e35bb6cb4351a98 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 20 Sep 2022 10:19:56 -0400 Subject: [PATCH 01/16] create first section of contour map tutorial --- examples/get-started/contour-map.py | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 examples/get-started/contour-map.py diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py new file mode 100644 index 00000000000..f344770127f --- /dev/null +++ b/examples/get-started/contour-map.py @@ -0,0 +1,50 @@ +""" +2. Create a contour map +======================= + +This tutorial page covers the basics of creating a figure of Earth relief, +using a remote dataset hosted by GMT, using the method +:meth:`pygmt.datasets.load_earth_relief`. It will use +:meth:`pygmt.Figure.grdimage`, :meth:`pygmt.Figure.grdcontour`, +and :meth:`pygmt.Figure.coast` methods for plotting. +""" + +# sphinx_gallery_thumbnail_number = 1 +import pygmt + +############################################################################### +# Loading the Earth relief dataset +# -------------------------------- +# +# The first step is to import :meth:`pygmt.datasets.load_earth_relief`. +# The ``resolution`` parameter sets the resolution of the remote grid file, +# which will affect the resolution of the plot made later in the tutorial. +# The ``registration`` parameter determines the grid registration. +# +# This grid region covers the islands of Guam and Rota in western Pacific +# Ocean. + +grid = pygmt.datasets.load_earth_relief( + resolution="30s", region=[144.5, 145.5, 13, 14.5], registration="gridline" +) + +############################################################################### +# Plotting Earth relief +# --------------------- +# +# To plot Earth relief data, the method :meth:`pygmt.Figure.grdimage` can be +# used to plot a color-coded figure to display the topography and bathymetry +# in the grid file. The ``grid`` parameter accepts the input grid, which in +# this case is the remote file downloaded in the previous section. If the +# ``region`` parameter is not set, the region boundaries of the input grid are +# used. +# +# The ``cmap`` parameter sets the color palette table (CPT) used for +# portraying Earth relief. The :meth:`pygmt.Figure.grdimage` method used the +# input grid to apply Earth relief values to a specific color within the CPT. +# In this case, the CPT used is "haxby"; a full list of CPTs can be found +# at :gmt-docs:`cookbook/cpts.html`. + +fig = pygmt.Figure() +fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") +fig.show() From dd2641b23b2768411d85b2901821a8b9860f9d01 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 20 Sep 2022 10:37:48 -0400 Subject: [PATCH 02/16] add planned future sections --- examples/get-started/contour-map.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index f344770127f..e15f2898c0f 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -48,3 +48,19 @@ fig = pygmt.Figure() fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") fig.show() + +############################################################################### +# Adding a colorbar +# ----------------- + +############################################################################### +# Adding contour lines +# -------------------- + +############################################################################### +# Color in land +# ------------- + +############################################################################### +# Additional exercises +# -------------------- From 6087e93be056bae8a06987e01e907879130a7ff5 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 21 Sep 2022 08:56:04 -0400 Subject: [PATCH 03/16] add colorbar tutorial --- examples/get-started/contour-map.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index e15f2898c0f..07a9873ab03 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -52,6 +52,23 @@ ############################################################################### # Adding a colorbar # ----------------- +# +# To show how the plotted colors relate to the Earth relief, a colorbar can be +# added using the :meth:`pygmt.Figure.colorbar` method. +# +# To control the labels on the colorbar, a list is passed to the ``frame`` +# parameter. The value beginning with "a" sets the interval for annotation on +# the colorbar, in this case every 1,000 meters. To set the label for an axis +# on the colorbar, the value begins with either "x+l" (x-axis) or "y+l" +# (y-axis), followed by the intended label. +# +# By default, the CPT for the colorbar is the same as the one set +# in :meth:`pygmt.Figure.grdimage`. + +fig = pygmt.Figure() +fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") +fig.colorbar(frame=["a1000", "x+lElevation", "y+lm"]) +fig.show() ############################################################################### # Adding contour lines From bb282476bf9669ad78b945305c65ed389c330b80 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 22 Sep 2022 17:24:31 -0400 Subject: [PATCH 04/16] add grdcontour example --- examples/get-started/contour-map.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index 07a9873ab03..7515d7def15 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -6,7 +6,8 @@ using a remote dataset hosted by GMT, using the method :meth:`pygmt.datasets.load_earth_relief`. It will use :meth:`pygmt.Figure.grdimage`, :meth:`pygmt.Figure.grdcontour`, -and :meth:`pygmt.Figure.coast` methods for plotting. +:meth:`pygmt.Figure.colorbar`, and :meth:`pygmt.Figure.coast` methods for +plotting. """ # sphinx_gallery_thumbnail_number = 1 @@ -73,6 +74,21 @@ ############################################################################### # Adding contour lines # -------------------- +# +# To add contour lines to the color coded figured, the +# :meth:`pygmt.Figure.grdcontour` method is used. The ``frame`` and +# ``projection`` are already set using :meth:`pygmt.Figure.grdimage` and are +# not needed again. However, the same input for ``grid`` (in this case, the +# variable named "grid") must be input again. The ``interval`` parameter sets +# the spacing between lines (in this case, 500 meters), and the ``annotation`` +# parameter sets the spacing between darker lines that have the value on +# written on them (in this case, every 1,000 meters). + +fig = pygmt.Figure() +fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") +fig.grdcontour(grid=grid, interval=500, annotation=1000) +fig.colorbar(frame=["a1000", "x+lElevation (m)"]) +fig.show() ############################################################################### # Color in land From 4af17a96b1522d2101f3b58b64220678d09d06e1 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 23 Sep 2022 06:00:19 -0400 Subject: [PATCH 05/16] add coast example --- examples/get-started/contour-map.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index 7515d7def15..ca9b96e9fb4 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -93,6 +93,18 @@ ############################################################################### # Color in land # ------------- +# +# To make it clear where the islands are located, the +# :meth:`pygmt.Figure.coast` method can be used to color in the land. The +# ``land`` is colored in as "lightgray", and the ``shorelines`` parameters +# draws a border around the islands. + +fig = pygmt.Figure() +fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") +fig.grdcontour(grid=grid, interval=500, annotation=1000) +fig.coast(shorelines="2p", land="lightgray") +fig.colorbar(frame=["a1000", "x+lElevation (m)"]) +fig.show() ############################################################################### # Additional exercises From e47099aebef09d434ece563f3875a2fd07cefa2d Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 23 Sep 2022 06:21:03 -0400 Subject: [PATCH 06/16] add additional exercises --- examples/get-started/contour-map.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index ca9b96e9fb4..ac34b10b126 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -109,3 +109,22 @@ ############################################################################### # Additional exercises # -------------------- +# +# This is the end of the second tutorial. Here are some additional exercises +# for the concepts that were discussed: +# +# 1. Change the resolution of the grid file to either "01m" (lower resolution) +# or "15s" (higher resolution). Note that higher resolution grids will have +# larger file sizes. +# +# 2. Create a contour map of the area around Mt. Rainier. A suggestion for the +# ``region`` would be ``[-122, -121, 46.5, 47.5]``. Adjust the +# :meth:`pygmt.Figure.grdcontour` and :meth:`pygmt.Figure.colorbar` +# settings as needed to make the figure look good. +# +# 3. Create a contour map of São Miguel Island in the Azores; a suggested +# ``region`` is ``[-26, -25, 37.5, 38]``. Instead of coloring in ``land``, +# set ``water`` to "lightblue" to only display Earth relief information for +# the land. +# +# 4. Try other CPTs, such as "jet" and "geo". From da7306673d710deb47a17a6615c8d3e23171305d Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 23 Sep 2022 07:35:52 -0400 Subject: [PATCH 07/16] change Sphinx thumbnail --- examples/get-started/contour-map.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index ac34b10b126..c2efec2f778 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -10,7 +10,7 @@ plotting. """ -# sphinx_gallery_thumbnail_number = 1 +# sphinx_gallery_thumbnail_number = 4 import pygmt ############################################################################### @@ -22,7 +22,7 @@ # which will affect the resolution of the plot made later in the tutorial. # The ``registration`` parameter determines the grid registration. # -# This grid region covers the islands of Guam and Rota in western Pacific +# This grid region covers the islands of Guam and Rota in the western Pacific # Ocean. grid = pygmt.datasets.load_earth_relief( From 9b53fca0530712c56bab5db7936a3b6df5537b78 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Sep 2022 07:33:31 -0400 Subject: [PATCH 08/16] wording fix --- examples/get-started/contour-map.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index c2efec2f778..7e2345baa4a 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -81,8 +81,8 @@ # not needed again. However, the same input for ``grid`` (in this case, the # variable named "grid") must be input again. The ``interval`` parameter sets # the spacing between lines (in this case, 500 meters), and the ``annotation`` -# parameter sets the spacing between darker lines that have the value on -# written on them (in this case, every 1,000 meters). +# parameter draws darker lines that are annotated with the elevation or +# bathymetry. fig = pygmt.Figure() fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") From 32d55bc539ec0de7ac6f3b2ea2de912fafc64b28 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Sep 2022 07:33:45 -0400 Subject: [PATCH 09/16] Update examples/get-started/contour-map.py Co-authored-by: Dongdong Tian --- examples/get-started/contour-map.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index 7e2345baa4a..df7bd1364c2 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -36,7 +36,7 @@ # To plot Earth relief data, the method :meth:`pygmt.Figure.grdimage` can be # used to plot a color-coded figure to display the topography and bathymetry # in the grid file. The ``grid`` parameter accepts the input grid, which in -# this case is the remote file downloaded in the previous section. If the +# this case is the remote file downloaded in the previous step. If the # ``region`` parameter is not set, the region boundaries of the input grid are # used. # From d342fbfc3da7ba6b2410b322b57d1fd58a05519c Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 17 Oct 2022 08:09:17 -0400 Subject: [PATCH 10/16] add N00E135.earth_relief_30s_g.nc to cache in testing.py --- pygmt/helpers/testing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index cb39484900d..b49d16e0c87 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -168,6 +168,7 @@ def download_test_data(): "@N35E135.earth_relief_03s_g.nc", "@N37W120.earth_relief_03s_g.nc", "@N00W090.earth_relief_03m_p.nc", + "@N00E135.earth_relief_30s_g.nc", # Earth seafloor age grids "@earth_age_01d_g", "@S90W180.earth_age_05m_g.nc", # Specific grid for 05m test From c7bc845be20f0f7b5b82bf50cfe56e2443cbfa51 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 17 Oct 2022 08:09:55 -0400 Subject: [PATCH 11/16] uncomment pull_request in cache_data.yaml --- .github/workflows/cache_data.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cache_data.yaml b/.github/workflows/cache_data.yaml index d0359833e96..37286bd8b2e 100644 --- a/.github/workflows/cache_data.yaml +++ b/.github/workflows/cache_data.yaml @@ -3,7 +3,7 @@ name: Cache data on: # Uncomment the 'pull_request' line below to manually re-cache data artifacts - # pull_request: + pull_request: # Schedule runs on 12 noon every Sunday schedule: - cron: '0 12 * * 0' From 36bf020c78d7d2c7c7cee3c26bfed8dee5b5952b Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 20 Oct 2022 08:15:53 -0400 Subject: [PATCH 12/16] Update examples/get-started/contour-map.py Co-authored-by: Dongdong Tian --- examples/get-started/contour-map.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index df7bd1364c2..8786e7e48dc 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -41,7 +41,7 @@ # used. # # The ``cmap`` parameter sets the color palette table (CPT) used for -# portraying Earth relief. The :meth:`pygmt.Figure.grdimage` method used the +# portraying Earth relief. The :meth:`pygmt.Figure.grdimage` method uses the # input grid to apply Earth relief values to a specific color within the CPT. # In this case, the CPT used is "haxby"; a full list of CPTs can be found # at :gmt-docs:`cookbook/cpts.html`. From c992f1b679cd24c75aa6e06784d5b7ad447c99d7 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 30 Oct 2022 09:43:41 -0400 Subject: [PATCH 13/16] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/get-started/contour-map.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index 8786e7e48dc..0c0345d74ef 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -17,7 +17,7 @@ # Loading the Earth relief dataset # -------------------------------- # -# The first step is to import :meth:`pygmt.datasets.load_earth_relief`. +# The first step is to use :meth:`pygmt.datasets.load_earth_relief`. # The ``resolution`` parameter sets the resolution of the remote grid file, # which will affect the resolution of the plot made later in the tutorial. # The ``registration`` parameter determines the grid registration. @@ -127,4 +127,4 @@ # set ``water`` to "lightblue" to only display Earth relief information for # the land. # -# 4. Try other CPTs, such as "jet" and "geo". +# 4. Try other CPTs, such as "SCM/fes" or "geo". From c531c1e9a2060cd9e97a584d751168fd2fdfdbca Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 30 Oct 2022 10:01:47 -0400 Subject: [PATCH 14/16] add link for available resolutions --- examples/get-started/contour-map.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index 0c0345d74ef..c27bd678821 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -113,9 +113,12 @@ # This is the end of the second tutorial. Here are some additional exercises # for the concepts that were discussed: # -# 1. Change the resolution of the grid file to either "01m" (lower resolution) -# or "15s" (higher resolution). Note that higher resolution grids will have -# larger file sizes. +# 1. Change the resolution of the grid file to either "01m" (1 arc-minute, a +# lower resolution) or "15s" (15 arc-seconds, a higher resolution). Note +# that higher resolution grids will have larger file sizes. Available +# resolutions can be found `here +# `_. # # 2. Create a contour map of the area around Mt. Rainier. A suggestion for the # ``region`` would be ``[-122, -121, 46.5, 47.5]``. Adjust the From 5e22a4fea9195fade9cab79bdabedec777aa0e0b Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 30 Oct 2022 10:13:04 -0400 Subject: [PATCH 15/16] change from haxby to oleron --- examples/get-started/contour-map.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/get-started/contour-map.py b/examples/get-started/contour-map.py index c27bd678821..bf10056b1fe 100644 --- a/examples/get-started/contour-map.py +++ b/examples/get-started/contour-map.py @@ -43,11 +43,11 @@ # The ``cmap`` parameter sets the color palette table (CPT) used for # portraying Earth relief. The :meth:`pygmt.Figure.grdimage` method uses the # input grid to apply Earth relief values to a specific color within the CPT. -# In this case, the CPT used is "haxby"; a full list of CPTs can be found +# In this case, the CPT used is "oleron"; a full list of CPTs can be found # at :gmt-docs:`cookbook/cpts.html`. fig = pygmt.Figure() -fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") +fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron") fig.show() ############################################################################### @@ -67,7 +67,7 @@ # in :meth:`pygmt.Figure.grdimage`. fig = pygmt.Figure() -fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") +fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron") fig.colorbar(frame=["a1000", "x+lElevation", "y+lm"]) fig.show() @@ -85,7 +85,7 @@ # bathymetry. fig = pygmt.Figure() -fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") +fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron") fig.grdcontour(grid=grid, interval=500, annotation=1000) fig.colorbar(frame=["a1000", "x+lElevation (m)"]) fig.show() @@ -100,7 +100,7 @@ # draws a border around the islands. fig = pygmt.Figure() -fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="haxby") +fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron") fig.grdcontour(grid=grid, interval=500, annotation=1000) fig.coast(shorelines="2p", land="lightgray") fig.colorbar(frame=["a1000", "x+lElevation (m)"]) From 9b45d7193bd81192b034b9eb62d7ebbcc3709b91 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 31 Oct 2022 15:20:01 +0800 Subject: [PATCH 16/16] Update .github/workflows/cache_data.yaml --- .github/workflows/cache_data.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cache_data.yaml b/.github/workflows/cache_data.yaml index bf8a06c22a0..43caaa67a2c 100644 --- a/.github/workflows/cache_data.yaml +++ b/.github/workflows/cache_data.yaml @@ -3,7 +3,7 @@ name: Cache data on: # Uncomment the 'pull_request' line below to manually re-cache data artifacts - pull_request: + # pull_request: # Schedule runs on 12 noon every Sunday schedule: - cron: '0 12 * * 0'