Skip to content

Commit 8a8fb33

Browse files
committed
load_earth_relief: Clarify that 03s/01s resolutions are available for igpp data source only
1 parent 5ce1971 commit 8a8fb33

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

pygmt/datasets/earth_relief.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def load_earth_relief(
4747
4848
Earth relief datasets (topography and bathymetry).
4949
50-
5150
This function downloads the dataset from the GMT data server, caches it in a user
5251
data directory (usually ``~/.gmt/server/earth/earth_relief``,
5352
``~/.gmt/server/earth/earth_gebco``, ``~/.gmt/server/earth/earth_gebcosi``,
@@ -58,8 +57,8 @@ def load_earth_relief(
5857
The dataset can also be accessed by specifying a file name in any grid processing
5958
function or plotting method, using the following file name format:
6059
**@**\ *earth_relief_type*\_\ *res*\_\ *reg*. *earth_relief_type* is the GMT name
61-
for the dataset. The available options are **earth_relief**\, **earth_gebco**\,
62-
**earth_gebcosi**\, and **earth_synbath**\. *res* is the grid resolution; *reg* is
60+
for the dataset. The available options are **earth_relief**, **earth_gebco**,
61+
**earth_gebcosi**, and **earth_synbath**. *res* is the grid resolution; *reg* is
6362
the grid registration type (**p** for pixel registration, **g** for gridline
6463
registration). If *reg* is omitted (e.g., ``@earth_relief_01d``), the
6564
gridline-registered grid will be loaded for grid processing functions and the
@@ -88,32 +87,32 @@ def load_earth_relief(
8887
registration
8988
Grid registration type. Either ``"pixel"`` for pixel registration or
9089
``"gridline"`` for gridline registration. Default is ``None``, which means
91-
``"gridline"`` for all resolutions except ``"15s"`` which is ``"pixel"``
92-
only.
90+
``"gridline"`` for all resolutions except ``"15s"`` which is ``"pixel"`` only.
9391
data_source
9492
Select the source for the Earth relief data. Available options are:
9593
96-
- ``"igpp"``: IGPP Earth Relief. See
97-
:gmt-datasets:`earth-relief.html`.
98-
- ``"synbath"``: IGPP Earth Relief dataset that uses stastical
99-
properties of young seafloor to provide a more realistic relief
100-
of young areas with small seamounts.
101-
- ``"gebco"``: GEBCO Earth Relief with only observed relief and
102-
inferred relief via altimetric gravity. See
103-
:gmt-datasets:`earth-gebco.html`.
94+
- ``"igpp"``: IGPP Earth Relief. See :gmt-datasets:`earth-relief.html`.
95+
- ``"synbath"``: IGPP Earth Relief dataset that uses stastical properties of
96+
young seafloor to provide a more realistic relief of young areas with small
97+
seamounts.
98+
- ``"gebco"``: GEBCO Earth Relief with only observed relief and inferred relief
99+
via altimetric gravity. See :gmt-datasets:`earth-gebco.html`.
104100
- ``"gebcosi"``: GEBCO Earth Relief that gives sub-ice (si) elevations.
101+
102+
**Notes**: Only the ``"igpp"`` data source provides the highest resolutions
103+
``"03s"`` and ``"01s"``.
105104
use_srtm
106-
By default, the land-only SRTM tiles from NASA are used to generate the
107-
``"03s"`` and ``"01s"`` grids, and the missing ocean values are filled
108-
by up-sampling the SRTM15 tiles which have a resolution of 15
109-
arc-seconds (i.e., ``"15s"``). If True, will only load the original
110-
land-only SRTM tiles. Only works when ``data_source="igpp"``.
105+
For resolutions ``"03s"`` and ``"01s"``, by default the land-only SRTM tiles
106+
from NASA are used along with up-sampled SRTM15 tiles (with a resolution of 15
107+
arc-seconds) to fill in the missing ocean values. If ``True``, will only load
108+
the original land-only SRTM tiles without filling in the ocean values. Only
109+
works when ``data_source="igpp"``.
111110
112111
Returns
113112
-------
114113
grid
115-
The Earth relief grid. Coordinates are latitude and longitude in
116-
degrees. Relief is in meters.
114+
The Earth relief grid. Coordinates are latitude and longitude in degrees. Relief
115+
is in meters.
117116
118117
Note
119118
----
@@ -123,7 +122,6 @@ def load_earth_relief(
123122
124123
Examples
125124
--------
126-
127125
>>> from pygmt.datasets import load_earth_relief
128126
>>> # Load the default grid (gridline-registered 1 arc-degree grid)
129127
>>> grid = load_earth_relief()
@@ -143,7 +141,7 @@ def load_earth_relief(
143141
... use_srtm=True,
144142
... )
145143
"""
146-
# resolutions of original land-only SRTM tiles from NASA
144+
# Resolutions of original land-only SRTM tiles from NASA
147145
land_only_srtm_resolutions = ["03s", "01s"]
148146

149147
# Map data source to prefix
@@ -159,24 +157,28 @@ def load_earth_relief(
159157
description="earth relief data source",
160158
choices=["igpp", "gebco", "gebcosi", "synbath"],
161159
)
162-
# Use SRTM or not.
163-
if use_srtm and resolution in land_only_srtm_resolutions:
160+
161+
# 03s and 01s resolutions are only available for data source "igpp".
162+
if resolution in land_only_srtm_resolutions:
164163
if data_source != "igpp":
165164
raise GMTValueError(
166165
data_source,
167166
description="data source",
168167
reason=(
169-
"Option 'use_srtm=True' doesn't work with data source "
170-
f"{data_source!r}. Please set 'data_source' to 'igpp'."
168+
f"Resolution {resolution!r} is only available for data source "
169+
"'igpp'. Please set 'data_source' to 'igpp'."
171170
),
172171
)
173-
prefix = "srtm_relief"
172+
if use_srtm: # Use original land-only SRTM tiles.
173+
prefix = "srtm_relief"
174+
174175
# Choose earth relief dataset
175176
match data_source:
176177
case "igpp" | "synbath":
177178
name = "earth_igpp"
178179
case "gebco" | "gebcosi":
179180
name = "earth_gebco"
181+
180182
grid = _load_remote_dataset(
181183
name=name,
182184
prefix=prefix,

pygmt/tests/test_datasets_earth_relief.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ def test_earth_relief_invalid_data_source_with_use_srtm():
177177
)
178178

179179

180+
def test_earth_relief_03s_but_not_igpp():
181+
"""
182+
Test loading earth relief with resolution "03s" but data_source not "igpp".
183+
"""
184+
for data_source in ["gebco", "gebcosi", "synbath"]:
185+
with pytest.raises(GMTValueError):
186+
load_earth_relief(
187+
resolution="03s", region=[135, 136, 35, 36], data_source=data_source
188+
)
189+
190+
180191
def test_earth_relief_15s_default_registration():
181192
"""
182193
Test that the grid returned by default for the 15 arc-second resolution has a

0 commit comments

Comments
 (0)