Skip to content

Commit 39e6027

Browse files
committed
Merge branch 'main' into refactor/check_kind
2 parents 71204d1 + 6d5857a commit 39e6027

File tree

108 files changed

+431
-329
lines changed

Some content is hidden

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

108 files changed

+431
-329
lines changed

.github/workflows/check-links.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040

4141
- name: Link Checker
4242
id: lychee
43-
uses: lycheeverse/[email protected].0
43+
uses: lycheeverse/[email protected].1
4444
with:
4545
fail: false # Don't fail action on broken links
4646
output: /tmp/lychee-out.md
@@ -63,9 +63,11 @@ jobs:
6363
--exclude "^https://test.pypi.org/simple/"
6464
--exclude "^https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf"
6565
--exclude "^https://www.generic-mapping-tools.org/remote-datasets/%s$"
66+
--exclude "^https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html"
6667
--exclude "^https://www.pygmt.org/%7B%7Bpath%7D%7D"
6768
--exclude "^https://www.researchgate.net/"
6869
--exclude "^https://zenodo.org/badge/DOI/"
70+
--exclude "^https://stackoverflow.com/a/69170441"
6971
--verbose
7072
"repository/*.md"
7173
"repository/**/*.py"

.github/workflows/ci_tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
GH_TOKEN: ${{ github.token }}
152152

153153
- name: Install uv
154-
uses: astral-sh/setup-uv@v6.0.1
154+
uses: astral-sh/setup-uv@v6.1.0
155155
with:
156156
activate-environment: true
157157
python-version: ${{ matrix.python-version }}
@@ -183,7 +183,7 @@ jobs:
183183

184184
# Upload coverage to Codecov
185185
- name: Upload coverage to Codecov
186-
uses: codecov/[email protected].2
186+
uses: codecov/[email protected].3
187187
if: success() || failure()
188188
with:
189189
use_oidc: true

pygmt/datasets/load_remote_dataset.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
from typing import Any, Literal, NamedTuple
88

99
import xarray as xr
10-
from pygmt.clib import Session
1110
from pygmt.exceptions import GMTInvalidInput
12-
from pygmt.helpers import build_arg_list, kwargs_to_strings
13-
from pygmt.src import which
1411

1512
with contextlib.suppress(ImportError):
1613
# rioxarray is needed to register the rio accessor
@@ -502,7 +499,6 @@ class GMTRemoteDataset(NamedTuple):
502499
}
503500

504501

505-
@kwargs_to_strings(region="sequence")
506502
def _load_remote_dataset(
507503
name: str,
508504
prefix: str,
@@ -581,22 +577,9 @@ def _load_remote_dataset(
581577
raise GMTInvalidInput(msg)
582578

583579
fname = f"@{prefix}_{resolution}_{reg}"
584-
kwdict = {"R": region, "T": {"grid": "g", "image": "i"}[dataset.kind]}
585-
with Session() as lib:
586-
with lib.virtualfile_out(kind=dataset.kind) as voutgrd:
587-
lib.call_module(
588-
module="read",
589-
args=[fname, voutgrd, *build_arg_list(kwdict)],
590-
)
591-
grid = lib.virtualfile_to_raster(
592-
kind=dataset.kind, outgrid=None, vfname=voutgrd
593-
)
594-
595-
# Full path to the grid if not tiled grids.
596-
source = which(fname, download="a") if not resinfo.tiled else None
597-
# Manually add source to xarray.DataArray encoding to make the GMT accessors work.
598-
if source:
599-
grid.encoding["source"] = source
580+
grid = xr.load_dataarray(
581+
fname, engine="gmt", raster_kind=dataset.kind, region=region
582+
)
600583

601584
# Add some metadata to the grid
602585
grid.attrs["description"] = dataset.description

pygmt/figure.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import base64
66
import os
7+
import warnings
78
from pathlib import Path
89
from tempfile import TemporaryDirectory
910
from typing import Literal, overload
@@ -119,12 +120,19 @@ def _activate_figure(self) -> None:
119120
with Session() as lib:
120121
lib.call_module(module="figure", args=[self._name, fmt])
121122

123+
# TODO(PyGMT>=v0.18.0): Remove the _preprocess method.
122124
def _preprocess(self, **kwargs):
123125
"""
124126
Call the ``figure`` module before each plotting command to ensure we're plotting
125127
to this particular figure.
126128
"""
127129
self._activate_figure()
130+
warnings.warn(
131+
"The Figure._preprocess() method is deprecated since v0.16.0 and will be "
132+
"removed in v0.18.0. Use Figure._activate_figure() instead.",
133+
FutureWarning,
134+
stacklevel=2,
135+
)
128136
return kwargs
129137

130138
@property

pygmt/helpers/caching.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,76 @@ def cache_data() -> None:
1313
datasets = [
1414
# List of GMT remote datasets.
1515
"@earth_age_01d_g",
16-
"@earth_day_01d",
17-
"@earth_dist_01d",
18-
"@earth_edefl_01d",
16+
"@earth_age_30m_g",
17+
"@earth_day_01d_p",
18+
"@earth_dist_01d_g",
19+
"@earth_dist_30m_g",
20+
"@earth_edefl_01d_g",
21+
"@earth_edefl_30m_g",
1922
"@earth_faa_01d_g",
23+
"@earth_faa_30m_g",
2024
"@earth_faaerror_01d_g",
2125
"@earth_gebco_01d_g",
2226
"@earth_gebcosi_01d_g",
2327
"@earth_gebcosi_15m_p",
2428
"@earth_geoid_01d_g",
29+
"@earth_geoid_30m_g",
2530
"@earth_mag_01d_g",
31+
"@earth_mag_30m_g",
2632
"@earth_mag4km_01d_g",
33+
"@earth_mag4km_20m_g",
2734
"@earth_mask_01d_g",
2835
"@earth_mdt_01d_g",
36+
"@earth_mdt_30m_g",
2937
"@earth_mdt_07m_g",
3038
"@earth_mss_01d_g",
31-
"@earth_ndefl_01d",
32-
"@earth_night_01d",
39+
"@earth_mss_30m_g",
40+
"@earth_ndefl_01d_g",
41+
"@earth_night_01d_p",
3342
"@earth_relief_01d_g",
3443
"@earth_relief_01d_p",
44+
"@earth_relief_05m_g",
45+
"@earth_relief_05m_p",
3546
"@earth_relief_10m_g",
3647
"@earth_relief_10m_p",
3748
"@earth_relief_30m_g",
3849
"@earth_relief_30m_p",
39-
"@earth_relief_05m_g",
40-
"@earth_relief_05m_p",
4150
"@earth_synbath_01d_g",
4251
"@earth_vgg_01d_g",
52+
"@earth_vgg_30m_g",
4353
"@earth_wdmam_01d_g",
54+
"@earth_wdmam_20m_g",
4455
"@mars_relief_01d_g",
56+
"@mars_relief_30m_g",
4557
"@mercury_relief_01d_g",
58+
"@mercury_relief_30m_g",
4659
"@moon_relief_01d_g",
60+
"@moon_relief_30m_g",
4761
"@pluto_relief_01d_g",
62+
"@pluto_relief_30m_g",
4863
"@venus_relief_01d_g",
64+
"@venus_relief_30m_g",
4965
# List of tiled remote datasets.
5066
# Names like @N35E135.earth_relief_03s_g.nc are for internal use only.
5167
# The naming scheme may change. DO NOT USE IT IN YOUR SCRIPTS.
5268
"@N00W030.earth_age_01m_g.nc",
5369
"@N30E060.earth_age_01m_g.nc",
5470
"@N30E090.earth_age_01m_g.nc",
71+
"@S90E000.earth_age_05m_g.nc",
5572
"@N00W030.earth_dist_01m_g.nc",
73+
"@S90E000.earth_dist_05m_g.nc",
5674
"@N00W030.earth_edefl_01m_p.nc",
75+
"@S90E000.earth_edefl_05m_g.nc",
5776
"@N00W030.earth_faa_01m_p.nc",
77+
"@S90E000.earth_faa_05m_g.nc",
5878
"@N00W030.earth_faaerror_01m_p.nc",
5979
"@N00W030.earth_geoid_01m_g.nc",
80+
"@S90E000.earth_geoid_05m_g.nc",
6081
"@S30W060.earth_mag_02m_p.nc",
82+
"@S90E000.earth_mag_05m_g.nc",
6183
"@S30W120.earth_mag4km_02m_p.nc",
6284
"@N30E090.earth_mss_01m_g.nc",
85+
"@S90E000.earth_mss_05m_g.nc",
6386
"@N30E090.earth_ndefl_01m_p.nc",
6487
"@N00W090.earth_relief_03m_p.nc",
6588
"@N00E135.earth_relief_30s_g.nc",
@@ -70,12 +93,18 @@ def cache_data() -> None:
7093
"@N37W120.earth_relief_03s_g.nc",
7194
"@S15W105.earth_synbath_30s_p.nc",
7295
"@N00W030.earth_vgg_01m_p.nc",
96+
"@S90E000.earth_vgg_05m_g.nc",
7397
"@S90E000.earth_wdmam_03m_g.nc",
7498
"@N00W030.mars_relief_01m_g.nc",
99+
"@S90E000.mars_relief_05m_g.nc",
75100
"@N00W030.mercury_relief_01m_g.nc",
101+
"@S90E000.mercury_relief_05m_g.nc",
76102
"@N00W030.moon_relief_01m_g.nc",
103+
"@S90E000.moon_relief_05m_g.nc",
77104
"@N00W030.pluto_relief_01m_g.nc",
105+
"@S90E000.pluto_relief_05m_g.nc",
78106
"@N00W030.venus_relief_01m_g.nc",
107+
"@S90E000.venus_relief_05m_g.nc",
79108
# List of cache files.
80109
"@EGM96_to_36.txt",
81110
"@MaunaLoa_CO2.txt",

pygmt/helpers/testing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import xarray as xr
1111
from pygmt.exceptions import GMTImageComparisonFailure
12-
from pygmt.src import which
1312

1413

1514
def check_figures_equal(*, extensions=("png",), tol=0.0, result_dir="result_images"):
@@ -144,17 +143,18 @@ def wrapper(*args, ext="png", request=None, **kwargs):
144143
return decorator
145144

146145

147-
def load_static_earth_relief():
146+
def load_static_earth_relief() -> xr.DataArray:
148147
"""
149-
Load the static_earth_relief file for internal testing.
148+
Load the static_earth_relief.nc file for internal testing.
150149
151150
Returns
152151
-------
153-
data : xarray.DataArray
152+
data
154153
A grid of Earth relief for internal tests.
155154
"""
156-
fname = which("@static_earth_relief.nc", download="c")
157-
return xr.load_dataarray(fname, engine="gmt", raster_kind="grid")
155+
return xr.load_dataarray(
156+
"@static_earth_relief.nc", engine="gmt", raster_kind="grid"
157+
)
158158

159159

160160
def skip_if_no(package):

pygmt/src/basemap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def basemap(self, **kwargs):
3636
At least one of the parameters ``frame``, ``map_scale``, ``rose``, or
3737
``compass`` must be specified if not in subplot mode.
3838
39-
Full option list at :gmt-docs:`basemap.html`
39+
Full GMT docs at :gmt-docs:`basemap.html`.
4040
4141
{aliases}
4242
@@ -82,6 +82,6 @@ def basemap(self, **kwargs):
8282
{perspective}
8383
{transparency}
8484
"""
85-
kwargs = self._preprocess(**kwargs)
85+
self._activate_figure()
8686
with Session() as lib:
8787
lib.call_module(module="basemap", args=build_arg_list(kwargs))

pygmt/src/binstats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def binstats(
3939
presented as is or may be normalized by the circle area to
4040
perhaps give density estimates.
4141
42-
Full option list at :gmt-docs:`gmtbinstats.html`
42+
Full GMT docs at :gmt-docs:`gmtbinstats.html`.
4343
4444
{aliases}
4545

pygmt/src/blockm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def blockmean(
108108
109109
Must provide either ``data`` or ``x``, ``y``, and ``z``.
110110
111-
Full option list at :gmt-docs:`blockmean.html`
111+
Full GMT docs at :gmt-docs:`blockmean.html`.
112112
113113
{aliases}
114114
@@ -212,7 +212,7 @@ def blockmedian(
212212
213213
Must provide either ``data`` or ``x``, ``y``, and ``z``.
214214
215-
Full option list at :gmt-docs:`blockmedian.html`
215+
Full GMT docs at :gmt-docs:`blockmedian.html`.
216216
217217
{aliases}
218218
@@ -310,7 +310,7 @@ def blockmode(
310310
311311
Must provide either ``data`` or ``x``, ``y``, and ``z``.
312312
313-
Full option list at :gmt-docs:`blockmode.html`
313+
Full GMT docs at :gmt-docs:`blockmode.html`.
314314
315315
{aliases}
316316

pygmt/src/coast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def coast(self, **kwargs):
5555
5656
A map projection must be supplied.
5757
58-
Full option list at :gmt-docs:`coast.html`
58+
Full GMT docs at :gmt-docs:`coast.html`.
5959
6060
{aliases}
6161
@@ -193,7 +193,7 @@ def coast(self, **kwargs):
193193
>>> # Show the plot
194194
>>> fig.show()
195195
"""
196-
kwargs = self._preprocess(**kwargs)
196+
self._activate_figure()
197197
if not args_in_kwargs(args=["C", "G", "S", "I", "N", "E", "Q", "W"], kwargs=kwargs):
198198
msg = (
199199
"At least one of the following parameters must be specified: "

0 commit comments

Comments
 (0)