Skip to content

Commit 33bdc8f

Browse files
Merge branch 'main' into pythonic-arguments/colorbar-frame
2 parents fd1e863 + 3022282 commit 33bdc8f

Some content is hidden

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

53 files changed

+575
-402
lines changed

.github/workflows/ci_docs.yml

+1-1
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.24.3
83+
uses: dawidd6/action-download-artifact@v2.25.0
8484
with:
8585
workflow: cache_data.yaml
8686
workflow_conclusion: success

.github/workflows/ci_tests.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
mamba install gmt=6.4.0 numpy=${{ matrix.numpy-version }} \
9494
pandas xarray netCDF4 packaging \
9595
${{ matrix.optional-packages }} \
96-
build dvc fsspec==2022.11.0 make 'pytest>=6.0' \
96+
build dvc make 'pytest>=6.0' \
9797
pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery
9898
9999
# Show installed pkg information for postmortem diagnostic
@@ -102,7 +102,7 @@ jobs:
102102

103103
# Download cached remote files (artifacts) from GitHub
104104
- name: Download remote data from GitHub
105-
uses: dawidd6/action-download-artifact@v2.24.3
105+
uses: dawidd6/action-download-artifact@v2.25.0
106106
with:
107107
workflow: cache_data.yaml
108108
workflow_conclusion: success

.github/workflows/ci_tests_dev.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
fetch-depth: 0
7272

7373
- name: Show job URL
74-
uses: peter-evans/[email protected].0
74+
uses: peter-evans/[email protected].1
7575
if: github.event_name == 'repository_dispatch' && (matrix.os == 'ubuntu-latest')
7676
with:
7777
token: ${{ steps.generate-token.outputs.token }}
@@ -101,7 +101,7 @@ jobs:
101101
geopandas ghostscript libnetcdf hdf5 zlib curl pcre make
102102
pip install --pre --prefer-binary \
103103
numpy pandas xarray netCDF4 packaging \
104-
build dvc fsspec==2022.11.0 ipython 'pytest>=6.0' pytest-cov \
104+
build dvc ipython 'pytest>=6.0' pytest-cov \
105105
pytest-doctestplus pytest-mpl sphinx-gallery
106106
107107
# Pull baseline image data from dvc remote (DAGsHub)
@@ -132,7 +132,7 @@ jobs:
132132

133133
# Download cached remote files (artifacts) from GitHub
134134
- name: Download remote data from GitHub
135-
uses: dawidd6/action-download-artifact@v2.24.3
135+
uses: dawidd6/action-download-artifact@v2.25.0
136136
with:
137137
workflow: cache_data.yaml
138138
workflow_conclusion: success

.github/workflows/ci_tests_legacy.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
mamba install gmt=${{ matrix.gmt_version }} numpy \
6868
pandas xarray netCDF4 packaging \
6969
geopandas ipython \
70-
build dvc fsspec==2022.11.0 make 'pytest>=6.0' \
70+
build dvc make 'pytest>=6.0' \
7171
pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery
7272
7373
# Show installed pkg information for postmortem diagnostic
@@ -76,7 +76,7 @@ jobs:
7676

7777
# Download cached remote files (artifacts) from GitHub
7878
- name: Download remote data from GitHub
79-
uses: dawidd6/action-download-artifact@v2.24.3
79+
uses: dawidd6/action-download-artifact@v2.25.0
8080
with:
8181
workflow: cache_data.yaml
8282
workflow_conclusion: success

.github/workflows/dvc-diff.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,13 @@ jobs:
8787
# Mention git commit SHA in the report
8888
echo -e "Report last updated at commit ${{ github.event.pull_request.head.sha }}" >> report.md
8989
90-
# Format report to escape newlines before publishing as GitHub comment
91-
report=$(cat report.md)
92-
report="${report//'%'/'%25'}"
93-
report="${report//$'\n'/'%0A'}"
94-
report="${report//$'\r'/'%0D'}"
95-
echo "report=$report" >> $GITHUB_OUTPUT
90+
# Save the report content to the output parameter 'report'
91+
echo 'report<<EOF' >> $GITHUB_OUTPUT
92+
cat report.md >> $GITHUB_OUTPUT
93+
echo 'EOF' >> $GITHUB_OUTPUT
9694
9795
- name: Find comment with image diff report
98-
uses: peter-evans/[email protected].0
96+
uses: peter-evans/[email protected].1
9997
id: fc
10098
with:
10199
issue-number: ${{ github.event.pull_request.number }}
@@ -104,14 +102,14 @@ jobs:
104102

105103
- name: Create comment with image diff report
106104
if: steps.fc.outputs.comment-id == ''
107-
uses: peter-evans/[email protected].0
105+
uses: peter-evans/[email protected].1
108106
with:
109107
issue-number: ${{ github.event.pull_request.number }}
110108
body: ${{ steps.image-diff.outputs.report }}
111109

112110
- name: Update comment with new image diff report
113111
if: steps.fc.outputs.comment-id != ''
114-
uses: peter-evans/[email protected].0
112+
uses: peter-evans/[email protected].1
115113
with:
116114
comment-id: ${{ steps.fc.outputs.comment-id }}
117115
body: ${{ steps.image-diff.outputs.report }}

.github/workflows/format-command.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
fi
4646
4747
- name: Add reaction
48-
uses: peter-evans/[email protected].0
48+
uses: peter-evans/[email protected].1
4949
with:
5050
token: ${{ steps.generate-token.outputs.token }}
5151
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}

AUTHORS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The following people have contributed code and/or documentation to the project
2020
* [Max Jones](https://github.com/maxrjones) | [0000-0003-0180-8928](https://orcid.org/0000-0003-0180-8928) | University of Hawai'i at Mānoa, USA
2121
* [Michael Grund](https://github.com/michaelgrund) | [0000-0001-8759-2018](https://orcid.org/0000-0001-8759-2018) | Innoplexia GmbH, Germany
2222
* [Tyler Newton](http://www.tnewton.com/) | [0000-0002-1560-6553](https://orcid.org/0000-0002-1560-6553) | University of Oregon, USA
23-
* [Wei Ji Leong](https://github.com/weiji14) | [0000-0003-2354-1988](https://orcid.org/0000-0003-2354-1988) | The Ohio State University, USA
23+
* [Wei Ji Leong](https://github.com/weiji14) | [0000-0003-2354-1988](https://orcid.org/0000-0003-2354-1988) | Development Seed, USA
2424
* [William Schlitzer](https://github.com/willschlitzer) | [0000-0002-5843-2282](https://orcid.org/0000-0002-5843-2282) | Unaffiliated
2525
* [Yohai Magen](https://github.com/yohaimagen) | [0000-0002-4892-4013](https://orcid.org/0000-0002-4892-4013) | Tel Aviv University, Israel
2626
* [Yvonne Fröhlich](https://github.com/yvonnefroehlich) | [0000-0002-8566-0619](https://orcid.org/0000-0002-8566-0619) | Karlsruhe Institute of Technology, Germany

CITATION.cff

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ authors:
1414
orcid: https://orcid.org/0000-0001-7967-1197
1515
- given-names: Wei Ji
1616
family-names: Leong
17-
affiliation: The Ohio State University, USA
17+
affiliation: Development Seed, USA
1818
orcid: https://orcid.org/0000-0003-2354-1988
1919
- given-names: Max
2020
family-names: Jones

doc/api/index.rst

-7
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,6 @@ and store them in GMT's user data directory.
227227
datasets.load_earth_vertical_gravity_gradient
228228
datasets.load_sample_data
229229

230-
The following functions are deprecated since v0.6.0 and will be removed in v0.9.0.
231-
Use :func:`pygmt.datasets.load_sample_data` instead.
232-
233-
.. autosummary::
234-
:toctree: generated
235-
236-
datasets.load_mars_shape
237230

238231
.. currentmodule:: pygmt
239232

examples/gallery/symbols/bars.py

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
sharex=True,
3434
margins=["0.5c", "0.75c"],
3535
):
36-
3736
pen = "1.5p"
3837
with fig.set_panel(panel=0):
3938
fill = "skyblue"

pygmt/datasets/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
from pygmt.datasets.earth_vertical_gravity_gradient import (
1414
load_earth_vertical_gravity_gradient,
1515
)
16-
from pygmt.datasets.samples import list_sample_data, load_mars_shape, load_sample_data
16+
from pygmt.datasets.samples import list_sample_data, load_sample_data

pygmt/datasets/earth_magnetic_anomaly.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ def load_earth_magnetic_anomaly(
115115
}
116116
if data_source not in magnetic_anomaly_sources:
117117
raise GMTInvalidInput(
118-
f"Invalid earth magnetic anomaly 'data_source' {data_source}, "
119-
"valid values are 'emag2', 'emag2_4km', and 'wdmam'."
118+
f"Invalid earth magnetic anomaly data source '{data_source}'. "
119+
"Valid values are 'emag2', 'emag2_4km', and 'wdmam'."
120120
)
121121
dataset_prefix = magnetic_anomaly_sources[data_source]
122122
if data_source == "wdmam":

pygmt/datasets/earth_mask.py

+13
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ def load_earth_mask(resolution="01d", region=None, registration=None):
5757
- 3: Islands in lakes in the land areas
5858
- 4: Smaller lakes in islands that are found within lakes
5959
inside the land area
60+
61+
Examples
62+
--------
63+
64+
>>> from pygmt.datasets import load_earth_mask
65+
>>> # load the default grid (gridline-registered 1 arc-degree grid)
66+
>>> grid = load_earth_mask()
67+
>>> # location (120°E, 50°N) is in land area (1)
68+
>>> grid.sel(lon=120, lat=50).values
69+
array(1, dtype=int8)
70+
>>> # location (170°E, 50°N) is in oceanic area (0)
71+
>>> grid.sel(lon=170, lat=50).values
72+
array(0, dtype=int8)
6073
"""
6174
grid = _load_remote_dataset(
6275
dataset_name="earth_mask",

pygmt/datasets/earth_relief.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ def load_earth_relief(
129129
}
130130
if data_source not in earth_relief_sources:
131131
raise GMTInvalidInput(
132-
f"Invalid earth relief 'data_source' {data_source}, "
133-
"valid values are 'igpp', 'gebco', 'gebcosi' and 'synbath'."
132+
f"Invalid earth relief data source '{data_source}'. "
133+
"Valid values are 'igpp', 'gebco', 'gebcosi' and 'synbath'."
134134
)
135135
# Choose earth relief data prefix
136136
if use_srtm and resolution in land_only_srtm_resolutions:
137137
if data_source == "igpp":
138138
dataset_prefix = "srtm_relief_"
139139
else:
140140
raise GMTInvalidInput(
141-
f"The {data_source} option is not available if 'use_srtm=True'."
142-
" Set data_source to 'igpp'."
141+
f"Option 'use_srtm=True' doesn't work with data source '{data_source}'."
142+
" Please set 'data_source' to 'igpp'."
143143
)
144144
else:
145145
dataset_prefix = earth_relief_sources[data_source]

pygmt/datasets/earth_vertical_gravity_gradient.py

+17
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ def load_earth_vertical_gravity_gradient(
5959
The :class:`xarray.DataArray` grid doesn't support slice operation, for
6060
Earth vertical gravity gradient grids with resolutions of 5 arc-minutes or
6161
higher, which are stored as smaller tiles.
62+
63+
Examples
64+
--------
65+
66+
>>> from pygmt.datasets import load_earth_vertical_gravity_gradient
67+
>>> # load the default grid (gridline-registered 1 arc-degree grid)
68+
>>> grid = load_earth_vertical_gravity_gradient()
69+
>>> # load the 30 arc-minutes grid with "gridline" registration
70+
>>> grid = load_earth_vertical_gravity_gradient(
71+
... resolution="30m", registration="gridline"
72+
... )
73+
>>> # load high-resolution (5 arc-minutes) grid for a specific region
74+
>>> grid = load_earth_vertical_gravity_gradient(
75+
... resolution="05m",
76+
... region=[120, 160, 30, 60],
77+
... registration="gridline",
78+
... )
6279
"""
6380
grid = _load_remote_dataset(
6481
dataset_name="earth_vgg",

pygmt/datasets/load_remote_dataset.py

+18-21
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Resolution(NamedTuple):
2222
2323
tiled : bool
2424
States if the given resolution is tiled, which requires an
25-
argument for ``region``."
25+
argument for ``region``.
2626
"""
2727

2828
registrations: list
@@ -270,45 +270,42 @@ def _load_remote_dataset(
270270
The returned :class:`xarray.DataArray` doesn't support slice operation for
271271
tiled grids.
272272
"""
273-
# pylint: disable=too-many-branches
274273
dataset = datasets[dataset_name]
274+
275+
# check resolution
275276
if resolution not in dataset.resolutions.keys():
276277
raise GMTInvalidInput(f"Invalid resolution '{resolution}'.")
278+
279+
# check registration
277280
if registration is None:
278-
# Check if "gridline" is an available registration for the resolution
279-
if "gridline" in dataset.resolutions[resolution].registrations:
280-
# Use default of gridline registration if available
281-
registration = "gridline"
282-
else:
281+
# use gridline registration unless only pixel registration is available
282+
registration = "gridline"
283+
if "gridline" not in dataset.resolutions[resolution].registrations:
283284
registration = "pixel"
284-
if registration in ("pixel", "gridline"):
285-
reg = f"_{registration[0]}"
285+
elif registration in ("pixel", "gridline"):
286+
if registration not in dataset.resolutions[resolution].registrations:
287+
raise GMTInvalidInput(
288+
f"{registration} registration is not available for the "
289+
f"{resolution} {dataset.title} dataset. Only "
290+
f"{dataset.resolutions[resolution].registrations[0]}"
291+
" registration is available."
292+
)
286293
else:
287294
raise GMTInvalidInput(
288295
f"Invalid grid registration: '{registration}', should be either "
289296
"'pixel', 'gridline' or None. Default is None, where a "
290297
"gridline-registered grid is returned unless only the "
291298
"pixel-registered grid is available."
292299
)
293-
294-
if registration and (
295-
registration not in dataset.resolutions[resolution].registrations
296-
):
297-
raise GMTInvalidInput(
298-
f"{registration} registration is not available for the "
299-
f"{resolution} {dataset.title} dataset. Only "
300-
f"{dataset.resolutions[resolution].registrations[0]}"
301-
" registration is available."
302-
)
300+
reg = f"_{registration[0]}"
303301

304302
# different ways to load tiled and non-tiled grids.
305303
# Known issue: tiled grids don't support slice operation
306304
# See https://github.com/GenericMappingTools/pygmt/issues/524
307305
if region is None:
308306
if dataset.resolutions[resolution].tiled:
309307
raise GMTInvalidInput(
310-
f"'region' is required for {dataset.title}"
311-
f"resolution '{resolution}'."
308+
f"'region' is required for {dataset.title} resolution '{resolution}'."
312309
)
313310
fname = which(f"@{dataset_prefix}{resolution}{reg}", download="a")
314311
grid = load_dataarray(fname, engine="netcdf4")

0 commit comments

Comments
 (0)