Skip to content

Commit 5836af2

Browse files
load_earth_relief: Clarify that 03s/01s resolutions are available for iggp source only (#4192)
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
1 parent b50b4eb commit 5836af2

File tree

2 files changed

+46
-36
lines changed

2 files changed

+46
-36
lines changed

pygmt/datasets/earth_relief.py

Lines changed: 35 additions & 36 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 the 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 set to ``True``, only the
108+
original land-only SRTM tiles are loaded without filling in the ocean values.
109+
Only available for ``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,10 +141,18 @@ def load_earth_relief(
143141
... use_srtm=True,
144142
... )
145143
"""
146-
# resolutions of original land-only SRTM tiles from NASA
147-
land_only_srtm_resolutions = ["03s", "01s"]
144+
# Resolutions of original land-only SRTM tiles from NASA.
145+
srtm_resolutions = ("03s", "01s")
148146

149-
# Map data source to prefix
147+
# 03s and 01s resolutions are only available for data source "igpp".
148+
if resolution in srtm_resolutions and data_source != "igpp":
149+
raise GMTValueError(
150+
data_source,
151+
description="data source",
152+
reason=f"Resolution {resolution!r} is only available for data source 'igpp'.",
153+
)
154+
155+
# Determine the dataset prefix.
150156
prefix = {
151157
"igpp": "earth_relief",
152158
"gebco": "earth_gebco",
@@ -159,24 +165,17 @@ def load_earth_relief(
159165
description="earth relief data source",
160166
choices=["igpp", "gebco", "gebcosi", "synbath"],
161167
)
162-
# Use SRTM or not.
163-
if use_srtm and resolution in land_only_srtm_resolutions:
164-
if data_source != "igpp":
165-
raise GMTValueError(
166-
data_source,
167-
description="data source",
168-
reason=(
169-
"Option 'use_srtm=True' doesn't work with data source "
170-
f"{data_source!r}. Please set 'data_source' to 'igpp'."
171-
),
172-
)
168+
# Use original land-only SRTM tiles.
169+
if use_srtm and resolution in srtm_resolutions:
173170
prefix = "srtm_relief"
174-
# Choose earth relief dataset
171+
172+
# Choose earth relief dataset name.
175173
match data_source:
176174
case "igpp" | "synbath":
177175
name = "earth_igpp"
178176
case "gebco" | "gebcosi":
179177
name = "earth_gebco"
178+
180179
grid = _load_remote_dataset(
181180
name=name,
182181
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)