Skip to content

Commit 0772260

Browse files
committed
Merge branch 'main' into ci/python-3.10
2 parents fca7a68 + 1e10b03 commit 0772260

File tree

14 files changed

+195
-120
lines changed

14 files changed

+195
-120
lines changed

.github/workflows/ci_tests.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
python-version: [3.7, 3.9]
33+
python-version: ['3.8', '3.9']
3434
os: [ubuntu-latest, macOS-latest, windows-latest]
3535
# Is it a draft Pull Request (true or false)?
3636
isDraft:
@@ -44,13 +44,13 @@ jobs:
4444
# - os: ubuntu-latest
4545
# python-version: 3.7
4646
# isDraft: true
47-
# Pair Python 3.7 with NumPy 1.18 and Python 3.9 with NumPy 1.21
47+
# Pair Python 3.8 with NumPy 1.19 and Python 3.9 with NumPy 1.21
4848
# Only install optional packages on Python 3.9/NumPy 1.21
4949
include:
50-
- python-version: 3.7
51-
numpy-version: '1.18'
50+
- python-version: '3.8'
51+
numpy-version: '1.19'
5252
optional-packages: ''
53-
- python-version: 3.9
53+
- python-version: '3.9'
5454
numpy-version: '1.21'
5555
optional-packages: 'geopandas ipython'
5656
timeout-minutes: 30

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ doc/_build/
2828
doc/gallery/
2929
doc/projections/
3030
doc/tutorials/
31+
doc/get-started/
3132

3233
# Jupyter Notebook
3334
.ipynb_checkpoints/

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Compatibility with GMT/Python/NumPy versions
219219
- `Dev Documentation <https://www.pygmt.org/dev>`_ (reflects `main branch <https://github.com/GenericMappingTools/pygmt>`_)
220220
- >=6.3.0
221221
- >=3.7
222-
- >=1.18
222+
- >=1.19
223223
* - `v0.5.0 <https://github.com/GenericMappingTools/pygmt/releases/tag/v0.5.0>`_ (latest release)
224224
- `v0.5.0 Documentation <https://www.pygmt.org/v0.5.0>`_
225225
- >=6.2.0

doc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ clean:
5757
rm -rf api/generated
5858
rm -rf gallery
5959
rm -rf tutorials
60+
rm -rf get-started
6061
rm -rf projections

doc/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@
6666
"examples_dirs": [
6767
"../examples/gallery",
6868
"../examples/tutorials",
69+
"../examples/get-started",
6970
"../examples/projections",
7071
],
7172
# path where to save gallery generated examples
72-
"gallery_dirs": ["gallery", "tutorials", "projections"],
73+
"gallery_dirs": ["gallery", "tutorials", "get-started", "projections"],
7374
"subsection_order": ExplicitOrder(
7475
[
7576
"../examples/gallery/maps",
@@ -89,6 +90,7 @@
8990
"../examples/projections/table",
9091
"../examples/tutorials/basics",
9192
"../examples/tutorials/advanced",
93+
"../examples/get-started",
9294
]
9395
),
9496
# Patter to search for example files

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
overview.rst
2222
install.rst
23-
tutorials/basics/first_figure.rst
23+
get-started/index.rst
2424

2525
.. toctree::
2626
:maxdepth: 2

doc/install.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Start by looking at the tutorials on our sidebar, good luck!
3535
Which Python?
3636
-------------
3737

38-
PyGMT is tested to run on **Python 3.7 or greater**.
38+
PyGMT is tested to run on **Python 3.8 or greater**.
3939

4040
We recommend using the `Anaconda <https://www.anaconda.com/distribution>`__
4141
Python distribution to ensure you have all dependencies installed and the
@@ -69,7 +69,7 @@ Dependencies
6969

7070
PyGMT requires the following libraries to be installed:
7171

72-
* `numpy <https://numpy.org>`__ (>= 1.18)
72+
* `numpy <https://numpy.org>`__ (>= 1.19)
7373
* `pandas <https://pandas.pydata.org>`__
7474
* `xarray <https://xarray.pydata.org>`__
7575
* `netCDF4 <https://unidata.github.io/netcdf4-python>`__

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66
# Required dependencies
77
- pip
88
- gmt=6.3.0
9-
- numpy>=1.18
9+
- numpy>=1.19
1010
- pandas
1111
- xarray
1212
- netCDF4

examples/get-started/README.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Intro to PyGMT
2+
==============
3+
4+
Welcome to PyGMT! This tutorial is designed to teach the basic concepts to
5+
make a map in PyGMT.
6+
7+
**About this tutorial**
8+
9+
This tutorial assumes that PyGMT has been successfully
10+
:doc:`installed </install>`. A quick way to test this is to type
11+
``import pygmt`` in a Python IDE or
12+
`Jupyter <https://jupyter.org>`__ Notebook.
13+
14+
This tutorial will progressively cover PyGMT plotting concepts, and later
15+
examples will use concepts explained in previous examples. It will not
16+
cover all PyGMT modules.
17+

examples/get-started/first_figure.py

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
"""
2+
1. Making your first figure
3+
===========================
4+
5+
This tutorial page covers the basics of creating a figure using PyGMT - a
6+
Python wrapper for the Generic Mapping Tools (GMT). It will only use
7+
the ``coast`` module for plotting. Later examples will address other PyGMT
8+
modules.
9+
"""
10+
11+
###############################################################################
12+
# Setting up the development environment
13+
# --------------------------------------
14+
#
15+
# PyGMT can be used in both a Python script and a notebook environment, such
16+
# as Jupyter. The tutorial's recommended method is to use a notebook, and the
17+
# code will be for a notebook environment.
18+
19+
20+
###############################################################################
21+
# Loading the library
22+
# -------------------
23+
#
24+
# The first step is to import ``pygmt``. All modules and figure generation is
25+
# accessible from the :mod:`pygmt` top level package.
26+
27+
# sphinx_gallery_thumbnail_number = 4
28+
import pygmt
29+
30+
###############################################################################
31+
# Creating a figure
32+
# -----------------
33+
#
34+
# All figure generation in PyGMT is handled by the :class:`pygmt.Figure` class.
35+
# Start a new figure by creating an instance of this class:
36+
37+
fig = pygmt.Figure()
38+
39+
###############################################################################
40+
# To add to a plot object (``fig`` in this example), the PyGMT module is used
41+
# as a method on the class. This example will use the module ``coast``, which
42+
# can be used to create a map without any other modules or external data. The
43+
# ``coast`` module plots the coastlines, borders, and bodies of water using a
44+
# database that is included in GMT.
45+
#
46+
# First, a region for the figure must be selected. This example will plot some
47+
# of the coast of Maine in the northeastern US. A Python list can be passed to
48+
# the ``region`` argument with the minimum and maximum X-values (longitude)
49+
# and the minimum and maximum Y-values (latitude). For this example, the
50+
# minimum (bottom left) coordinates are (N43.75, W69) and the maximum (top
51+
# right) coordinates are (N44.75, W68). Negative values can be passed for
52+
# latitudes in the southern hemisphere or longitudes in the western hemisphere.
53+
#
54+
# In addition to the region, an argument needs to be passed to ``coast`` to
55+
# tell it what to plot. In this example, ``coast`` will be told to plot the
56+
# shorelines by passing the Boolean value ``True`` to the ``shorelines``
57+
# parameter. The ``shorelines`` parameter has other options for finer control,
58+
# but setting it to ``True`` uses the default values.
59+
60+
fig.coast(region=[-69, -68, 43.75, 44.75], shorelines=True)
61+
62+
###############################################################################
63+
# To see the figure, call :meth:`pygmt.Figure.show`.
64+
65+
fig.show()
66+
67+
###############################################################################
68+
# Color the land and water
69+
# ------------------------
70+
#
71+
# This figure plots all of the coastlines in the given region, but it does not
72+
# indicate where the land and water are. Color values can be passed to ``land``
73+
# and ``water`` to set the colors on the figure.
74+
#
75+
# When plotting colors in PyGMT, there are multiple
76+
# :gmt-docs:`color codes <gmtcolors.html>`, that can be used. This includes
77+
# standard GMT color names (like ``skyblue``), R/G/B levels (like ``0/0/255``),
78+
# a hex value (like ``#333333``), or a graylevel (like ``50``). For this
79+
# example, GMT color names are used.
80+
81+
fig = pygmt.Figure()
82+
fig.coast(
83+
region=[-69, -68, 43.75, 44.75],
84+
shorelines=True,
85+
land="lightgreen",
86+
water="lightblue",
87+
)
88+
fig.show()
89+
90+
###############################################################################
91+
# Set the projection
92+
# ------------------
93+
#
94+
# This figure now has its colors set, but there is no projection or size
95+
# set for the map. Both of these values are set using the ``projection``
96+
# parameter.
97+
#
98+
# The appropriate projection varies for the type of map. The available
99+
# projections are explained in the :doc:`projection </projections/index>`
100+
# gallery. For this example, the Mercator projection is set using ``"M"``.
101+
# The width of the figure will be 10 centimeters, as set by ``"10c"``. The map
102+
# size can also be set in inches using "i" (e.g. a 5 inch wide Mercator
103+
# projection would use ``"M5i"``).
104+
105+
fig = pygmt.Figure()
106+
fig.coast(
107+
region=[-69, -68, 43.75, 44.75],
108+
shorelines=True,
109+
land="lightgreen",
110+
water="lightblue",
111+
projection="M10c",
112+
)
113+
fig.show()
114+
115+
###############################################################################
116+
# Add a frame
117+
# -----------
118+
#
119+
# While that the map's colors, projection, and size have been set, the region
120+
# that is being displayed is not apparent. A frame can be added to
121+
# annotate the latitude and longitude of the region.
122+
#
123+
# The ``frame`` parameter is used to add a frame to the figure. For now, it
124+
# will be set to ``True`` to use default settings, but later tutorials will
125+
# show how ``frame`` can be used to customize the axes, gridlines, and titles.
126+
127+
fig = pygmt.Figure()
128+
fig.coast(
129+
region=[-69, -68, 43.75, 44.75],
130+
shorelines=True,
131+
land="lightgreen",
132+
water="lightblue",
133+
projection="M10c",
134+
frame=True,
135+
)
136+
fig.show()
137+
138+
###############################################################################
139+
# Additional exercises
140+
# --------------------
141+
#
142+
# This is the end of the first tutorial. Here are some additional exercises
143+
# for the concepts that were discussed:
144+
#
145+
# 1. Make a map of Germany using its ISO country code ("DE"). Pass the ISO
146+
# code as a Python string to the ``region`` parameter.
147+
#
148+
# 2. Change the color of the land to "khaki" and the water to "azure".
149+
#
150+
# 3. Change the color of the lakes (using the ``lakes`` parameter) to "red".
151+
#
152+
# 4. Create a global map. Set the region to "d" to center the map at the Prime
153+
# Meridian or "g" to center the map at the International Date Line. When the
154+
# region is set without using a list full of integers or floating numbers,
155+
# the argument needs to be passed as a Python string. Create a 15 centimeter
156+
# map using the Mollwide ("W") projection.

examples/tutorials/basics/first_figure.py

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)