Skip to content

Commit 0dbb2f8

Browse files
committed
Update the logic of codes to make it more readable
1 parent 8a8fb33 commit 0dbb2f8

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

pygmt/datasets/earth_relief.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,18 @@ def load_earth_relief(
141141
... use_srtm=True,
142142
... )
143143
"""
144-
# Resolutions of original land-only SRTM tiles from NASA
145-
land_only_srtm_resolutions = ["03s", "01s"]
144+
# Resolutions of original land-only SRTM tiles from NASA.
145+
srtm_resolutions = ("03s", "01s")
146146

147-
# 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.
148156
prefix = {
149157
"igpp": "earth_relief",
150158
"gebco": "earth_gebco",
@@ -157,22 +165,12 @@ def load_earth_relief(
157165
description="earth relief data source",
158166
choices=["igpp", "gebco", "gebcosi", "synbath"],
159167
)
168+
if (
169+
use_srtm and resolution in srtm_resolutions
170+
): # Use original land-only SRTM tiles.
171+
prefix = "srtm_relief"
160172

161-
# 03s and 01s resolutions are only available for data source "igpp".
162-
if resolution in land_only_srtm_resolutions:
163-
if data_source != "igpp":
164-
raise GMTValueError(
165-
data_source,
166-
description="data source",
167-
reason=(
168-
f"Resolution {resolution!r} is only available for data source "
169-
"'igpp'. Please set 'data_source' to 'igpp'."
170-
),
171-
)
172-
if use_srtm: # Use original land-only SRTM tiles.
173-
prefix = "srtm_relief"
174-
175-
# Choose earth relief dataset
173+
# Choose earth relief dataset name.
176174
match data_source:
177175
case "igpp" | "synbath":
178176
name = "earth_igpp"

0 commit comments

Comments
 (0)