Skip to content

Commit 0a9007d

Browse files
committed
Merge branch 'main' into ci/python-3.10
2 parents 69d4e67 + 30e0b09 commit 0a9007d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+357
-161
lines changed

.github/workflows/check-links.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
path: documentation
2727

2828
- name: Link Checker
29-
uses: lycheeverse/lychee-action@v1.0.9
29+
uses: lycheeverse/lychee-action@v1.1.1
3030
with:
3131
# 429: Too many requests
3232
args: >

.github/workflows/ci_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080

8181
# Download cached remote files (artifacts) from GitHub
8282
- name: Download remote data from GitHub
83-
uses: dawidd6/action-download-artifact@v2.15.0
83+
uses: dawidd6/action-download-artifact@v2.16.0
8484
with:
8585
workflow: cache_data.yaml
8686
workflow_conclusion: success

.github/workflows/ci_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105

106106
# Download cached remote files (artifacts) from GitHub
107107
- name: Download remote data from GitHub
108-
uses: dawidd6/action-download-artifact@v2.15.0
108+
uses: dawidd6/action-download-artifact@v2.16.0
109109
with:
110110
workflow: cache_data.yaml
111111
workflow_conclusion: success

.github/workflows/ci_tests_dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109

110110
# Download cached remote files (artifacts) from GitHub
111111
- name: Download remote data from GitHub
112-
uses: dawidd6/action-download-artifact@v2.15.0
112+
uses: dawidd6/action-download-artifact@v2.16.0
113113
with:
114114
workflow: cache_data.yaml
115115
workflow_conclusion: success

.github/workflows/format-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
ref: ${{ github.event.pull_request.head.sha }}
2222

2323
# Setup Python environment
24-
- uses: actions/setup-python@v2.2.2
24+
- uses: actions/setup-python@v2.3.1
2525

2626
# Install formatting tools
2727
- name: Install formatting tools

.github/workflows/publish-to-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
fetch-depth: 0
3030

3131
- name: Set up Python
32-
uses: actions/setup-python@v2.2.2
32+
uses: actions/setup-python@v2.3.1
3333
with:
3434
python-version: '3.10'
3535

.github/workflows/release-baseline-images.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
shasum -a 256 baseline-images.zip
3535
3636
- name: Upload baseline image as a release asset
37-
uses: shogo82148/actions-upload-release-asset@v1.3.2
37+
uses: shogo82148/actions-upload-release-asset@v1.4.0
3838
with:
3939
upload_url: ${{ github.event.release.upload_url }}
4040
asset_path: baseline-images.zip

.github/workflows/style_checks.yaml

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

2121
# Setup Miniconda
2222
- name: Set up Python
23-
uses: actions/setup-python@v2.2.2
23+
uses: actions/setup-python@v2.3.1
2424
with:
2525
python-version: '3.10'
2626

AUTHORS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The following people have contributed code and/or documentation to the project
99
(alphabetical by name) and are considered to be "PyGMT Developers":
1010

1111
* [Abhishek Anant](https://twitter.com/itsabhianant) | [0000-0002-5751-2010](https://orcid.org/0000-0002-5751-2010) | Unaffiliated
12-
* [Dongdong Tian](https://seisman.info/) | [0000-0001-7967-1197](https://orcid.org/0000-0001-7967-1197) | Michigan State University
12+
* [Dongdong Tian](https://seisman.info/) | [0000-0001-7967-1197](https://orcid.org/0000-0001-7967-1197) | China University of Geosciences
1313
* [Jamie Quinn](http://jamiejquinn.com) | [0000-0002-0268-7032](https://orcid.org/0000-0002-0268-7032) | University College London
1414
* [Jiayuan Yao](https://github.com/core-man) | [0000-0001-7036-4238](https://orcid.org/0000-0001-7036-4238) | Nanyang Technological University
1515
* [Kathryn Materna](https://github.com/kmaterna) | [0000-0002-6687-980X](https://orcid.org/0000-0002-6687-980X) | US Geological Survey

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors:
1010
orcid: https://orcid.org/0000-0001-6123-9515
1111
- given-names: Dongdong
1212
family-names: Tian
13-
affiliation: Michigan State University, USA
13+
affiliation: China University of Geosciences, China
1414
orcid: https://orcid.org/0000-0001-7967-1197
1515
- given-names: Wei Ji
1616
family-names: Leong

doc/Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(SPHINXOPTS) .
1313

1414
help:
1515
@echo "Please use 'make <target>' where <target> is one of"
16-
@echo " all build the HTML files from the existing rst sources"
17-
@echo " api generate rst source files of API documentation"
18-
@echo " html build the HTML files from the existing rst sources"
19-
@echo " server make a local HTTP server for previewing the built documentation"
20-
@echo " clean clean up built and generated files"
16+
@echo " all build the HTML files from the existing rst sources"
17+
@echo " api generate rst source files of API documentation"
18+
@echo " html build the HTML files from the existing rst sources"
19+
@echo " html-noplot build the HTML files without running any examples"
20+
@echo " server make a local HTTP server for previewing the built documentation"
21+
@echo " clean clean up built and generated files"
2122

2223
all: html
2324

@@ -36,6 +37,14 @@ html: api
3637
@echo
3738
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
3839

40+
html-noplot: api
41+
@echo
42+
@echo "Building HTML files without example plots."
43+
@echo
44+
$(SPHINXBUILD) -D plot_gallery=0 -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
45+
@echo
46+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
47+
3948
server:
4049
@echo
4150
@echo "Running a server on port 8009."

doc/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
"../examples/projections/misc",
8888
"../examples/projections/nongeo",
8989
"../examples/projections/table",
90+
"../examples/tutorials/basics",
91+
"../examples/tutorials/advanced",
9092
]
9193
),
9294
# Patter to search for example files

doc/contributing.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,27 @@ top of the GitHub repository and click *New Issue*.
5050
* After submitting your bug report, try to answer any follow up questions about the bug
5151
as best as you can.
5252

53+
#### Reporting upstream bugs
54+
55+
If you are aware that a bug is caused by an upstream GMT issue rather than a
56+
PyGMT-specific issue, you can optionally take the following steps to help resolve
57+
the problem:
58+
59+
* Add the line `pygmt.config(GMT_VERBOSE='d')` after your import statements, which
60+
will report the equivalent GMT commands as one of the debug messages.
61+
* Either append all messages from running your script to your GitHub issue, or
62+
filter the messages to include only the GMT-equivalent commands using a command
63+
such as:
64+
65+
python <test>.py 2>&1 | awk -F': ' '$2=="GMT_Call_Command string" {print "gmt", $3}'
66+
67+
where `<test>` is the name of your test script.
68+
* If the bug is produced when passing an in-memory data object (e.g., a
69+
pandas.DataFrame or xarray.DataArray) to a PyGMT function, try writing the
70+
data to a file (e.g., a NetCDF or ASCII txt file) and passing the data file
71+
to the PyGMT function instead. In the GitHub issue, please share the results
72+
for both cases along with your code.
73+
5374
### Submitting a Feature Request
5475

5576
* Find the [*Issues*](https://github.com/GenericMappingTools/pygmt/issues) tab on the
@@ -223,7 +244,7 @@ There are four main components to PyGMT's documentation:
223244
The documentation are written primarily in
224245
[reStructuredText](https://docutils.sourceforge.io/rst.html) and built by
225246
[Sphinx](http://www.sphinx-doc.org/). Please refer to
226-
[reStructuredText Cheatsheet](https://docs.generic-mapping-tools.org/latest/rst-cheatsheet.html)
247+
[reStructuredText Cheatsheet](https://docs.generic-mapping-tools.org/latest/devdocs/rst-cheatsheet.html)
227248
if you are new to reStructuredText. When contributing documentation, be sure to
228249
follow the general guidelines in the [pull request workflow](#pull-request-workflow)
229250
section.
@@ -322,12 +343,9 @@ General guidelines for making a good gallery plot:
322343
The tutorials (the User Guide in the docs) are also built by sphinx-gallery from the
323344
`.py` files in the `examples/tutorials` folder of the repository. To add a new tutorial:
324345

325-
* Include a `.py` file in the `examples/tutorials` folder on the base of the repository.
346+
* Create a `.py` file in the `examples/tutorials/advanced` folder.
326347
* Write the tutorial in "notebook" style with code mixed with paragraphs explaining what
327348
is being done. See the other tutorials for the format.
328-
* Include the tutorial in the table of contents of the documentation (side bar). Do this
329-
by adding a line to the User Guide `toc` directive in `doc/index.rst`. Notice that the
330-
file included is the `.rst` generated by sphinx-gallery.
331349
* Choose the most representative figure as the thumbnail figure by adding a comment line
332350
`# sphinx_gallery_thumbnail_number = <fig_number>` to any place (usually at the top)
333351
in the tutorial. The *fig_number* starts from 1.

doc/index.rst

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,17 @@
2020

2121
overview.rst
2222
install.rst
23-
tutorials/first_figure.rst
24-
25-
.. toctree::
26-
:maxdepth: 2
27-
:hidden:
28-
:caption: Examples
29-
30-
gallery/index.rst
31-
external_resources.md
23+
tutorials/basics/first_figure.rst
3224

3325
.. toctree::
3426
:maxdepth: 2
3527
:hidden:
3628
:caption: User Guide
3729

38-
tutorials/frames.rst
30+
tutorials/index.rst
31+
gallery/index.rst
3932
projections/index.rst
40-
tutorials/coastlines.rst
41-
tutorials/regions.rst
42-
tutorials/plot.rst
43-
tutorials/lines.rst
44-
tutorials/vectors.rst
45-
tutorials/date_time_charts.rst
46-
tutorials/text.rst
47-
tutorials/contour_map.rst
48-
tutorials/earth_relief.rst
49-
tutorials/3d_perspective_image.rst
50-
tutorials/insets.rst
51-
tutorials/subplots.rst
52-
tutorials/configuration.rst
33+
external_resources.md
5334

5435
.. toctree::
5536
:maxdepth: 2

doc/install.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,6 @@
33
Installing
44
==========
55

6-
.. note::
7-
8-
🚨 **This package is in the early stages of design and implementation.** 🚨
9-
10-
We welcome any feedback and ideas!
11-
Let us know by submitting
12-
`issues on GitHub <https://github.com/GenericMappingTools/pygmt/issues>`__
13-
or by posting on our `Discourse forum
14-
<https://forum.generic-mapping-tools.org/c/questions/pygmt-q-a>`__.
15-
16-
176
Quickstart
187
----------
198

doc/overview.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ The development of PyGMT has been supported by NSF grants
2929
`OCE-1558403 <https://www.nsf.gov/awardsearch/showAward?AWD_ID=1558403>`__ and
3030
`EAR-1948603 <https://www.nsf.gov/awardsearch/showAward?AWD_ID=1948602>`__.
3131

32+
We welcome any feedback and ideas! Let us know by submitting
33+
`issues on GitHub <https://github.com/GenericMappingTools/pygmt/issues>`__
34+
or by posting on our `Discourse forum
35+
<https://forum.generic-mapping-tools.org/c/questions/pygmt-q-a>`__.
36+
37+
3238
Presentations
3339
-------------
3440

examples/gallery/histograms/blockm.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""
2+
Blockmean
3+
---------
4+
The :meth:`pygmt.blockmean` method calculates different quantities
5+
inside blocks/bins whose dimensions are defined via the ``spacing`` parameter.
6+
The following examples show how to calculate the averages of the given values
7+
inside each bin and how to report the number of points inside each bin.
8+
"""
9+
10+
import pygmt
11+
12+
# Load sample data
13+
data = pygmt.datasets.load_japan_quakes()
14+
# Select only needed columns
15+
data = data[["longitude", "latitude", "depth_km"]]
16+
17+
# Set the region for the plot
18+
region = [130, 152.5, 32.5, 52.5]
19+
# Define spacing in x and y direction (150 by 150 minute blocks)
20+
spacing = "150m"
21+
22+
fig = pygmt.Figure()
23+
24+
# Calculate mean depth in km from all events within 150x150 minute
25+
# bins using blockmean
26+
df = pygmt.blockmean(data=data, region=region, spacing=spacing)
27+
# convert to grid
28+
grd = pygmt.xyz2grd(data=df, region=region, spacing=spacing)
29+
30+
fig.grdimage(
31+
grid=grd,
32+
region=region,
33+
frame=["af", '+t"Mean earthquake depth inside each block"'],
34+
cmap="batlow",
35+
)
36+
# plot slightly transparent landmasses on top
37+
fig.coast(land="darkgray", transparency=40)
38+
# plot original data points
39+
fig.plot(
40+
x=data.longitude, y=data.latitude, style="c0.3c", color="white", pen="1p,black"
41+
)
42+
fig.colorbar(frame=["x+lkm"])
43+
44+
fig.shift_origin(xshift="w+5c")
45+
46+
# Calculate number of total locations within 150x150 minute bins via
47+
# blockmean's summary parameter
48+
df = pygmt.blockmean(data=data, region=region, spacing=spacing, summary="n")
49+
grd = pygmt.xyz2grd(data=df, region=region, spacing=spacing)
50+
51+
fig.grdimage(
52+
grid=grd,
53+
region=region,
54+
frame=["af", '+t"Number of points inside each block"'],
55+
cmap="batlow",
56+
)
57+
fig.coast(land="darkgray", transparency=40)
58+
fig.plot(
59+
x=data.longitude, y=data.latitude, style="c0.3c", color="white", pen="1p,black"
60+
)
61+
fig.colorbar(frame=["x+lcount"])
62+
63+
fig.show()

examples/tutorials/README.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
.. _tutorials:
2+
13
Tutorials
24
=========
5+
6+
These examples teach us how to complete various tasks using PyGMT!
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Advanced
2+
--------

examples/tutorials/date_time_charts.py renamed to examples/tutorials/advanced/date_time_charts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
The following examples will demonstrate how to create plots
1212
using the different datetime objects.
1313
"""
14-
# sphinx_gallery_thumbnail_number = 0
14+
# sphinx_gallery_thumbnail_number = 8
1515

1616
import datetime
1717

@@ -285,7 +285,7 @@
285285
# Starting off with ``WS``, adding this string means that only
286286
# Western/Left (**W**) and Southern/Bottom (**S**) borders of
287287
# the plot will be shown. For more information on this, please
288-
# refer to :doc:`frame instructions </tutorials/frames>`.
288+
# refer to :doc:`frame instructions </tutorials/basics/frames>`.
289289
#
290290
# The other important item in the ``frame`` list is
291291
# ``"sxa1Of1D"``. This string modifies the secondary
File renamed without changes.

examples/tutorials/basics/README.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Basics
2+
------
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pygmt/figure.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def savefig(
264264
if show:
265265
launch_external_viewer(fname)
266266

267-
def show(self, dpi=300, width=500, method=None):
267+
def show(self, dpi=300, width=500, method=None, waiting=0.5):
268268
"""
269269
Display a preview of the figure.
270270
@@ -284,7 +284,11 @@ def show(self, dpi=300, width=500, method=None):
284284
This is useful when running unit tests and building the documentation
285285
in consoles without a Graphical User Interface.
286286
287-
Note that the external viewer does not block the current process.
287+
Note that the external viewer does not block the current process, thus
288+
it's necessary to suspend the execution of the current process for a
289+
short while after launching the external viewer, so that the preview
290+
image won't be deleted before the external viewer tries to open it. Set
291+
the ``waiting`` parameter to a larger number if your computer is slow.
288292
289293
Parameters
290294
----------
@@ -298,6 +302,10 @@ def show(self, dpi=300, width=500, method=None):
298302
- **external**: PDF preview in an external program [default]
299303
- **notebook**: PNG preview [default in Jupyter notebooks]
300304
- **none**: Disable image preview
305+
waiting : float
306+
Suspend the execution of the current process for a given number of
307+
seconds after launching an external viewer.
308+
Only works if ``method="external"``.
301309
"""
302310
# Module level variable to know which figures had their show method
303311
# called. Needed for the sphinx-gallery scraper.
@@ -329,7 +337,7 @@ def show(self, dpi=300, width=500, method=None):
329337

330338
if method == "external":
331339
pdf = self._preview(fmt="pdf", dpi=dpi, anti_alias=False, as_bytes=False)
332-
launch_external_viewer(pdf)
340+
launch_external_viewer(pdf, waiting=waiting)
333341

334342
def shift_origin(self, xshift=None, yshift=None):
335343
"""

0 commit comments

Comments
 (0)