Skip to content

Commit 242f92b

Browse files
load_earth_relief: Add the support of data source 'synbath' (#2162)
* Add synbath option to earth_relief.py * Add tests for Earth relief with the synbath dataset * Update cache for synbath grids Co-authored-by: Dongdong Tian <[email protected]>
1 parent d8c816a commit 242f92b

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

pygmt/datasets/earth_relief.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,15 @@ def load_earth_relief(
141141
f"{registration}-registered Earth relief data for "
142142
f"resolution '{resolution}' is not supported."
143143
)
144-
earth_relief_sources = {"igpp": "earth_relief_", "gebco": "earth_gebco_"}
144+
earth_relief_sources = {
145+
"igpp": "earth_relief_",
146+
"gebco": "earth_gebco_",
147+
"synbath": "earth_synbath_",
148+
}
145149
if data_source not in earth_relief_sources:
146150
raise GMTInvalidInput(
147151
f"Invalid earth relief 'data_source' {data_source}, "
148-
"valid values are 'igpp' and 'gebco'."
152+
"valid values are 'igpp', 'gebco', and 'synbath'."
149153
)
150154
if data_source != "igpp":
151155
with Session() as lib:

pygmt/helpers/testing.py

+3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def download_test_data():
164164
"@earth_relief_10m_g",
165165
"@earth_relief_05m_p",
166166
"@earth_relief_05m_g",
167+
"@earth_synbath_01d_g",
167168
# List of tiles of 03s srtm data.
168169
# Names like @N35E135.earth_relief_03s_g.nc is for internal use only.
169170
# The naming scheme may change. DO NOT USE IT IN YOUR SCRIPTS.
@@ -172,6 +173,8 @@ def download_test_data():
172173
"@N37W120.earth_relief_03s_g.nc",
173174
"@N00W090.earth_relief_03m_p.nc",
174175
"@N00E135.earth_relief_30s_g.nc",
176+
# Earth synbath relief grids
177+
"@S15W105.earth_synbath_30s_p.nc",
175178
# Earth seafloor age grids
176179
"@earth_age_01d_g",
177180
"@S90W180.earth_age_05m_g.nc", # Specific grid for 05m test

pygmt/tests/test_datasets_earth_relief.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from pygmt.exceptions import GMTInvalidInput
99

1010

11-
@pytest.mark.parametrize("data_source", ["igpp", "gebco"])
11+
@pytest.mark.parametrize("data_source", ["igpp", "gebco", "synbath"])
1212
def test_earth_relief_fails(data_source):
1313
"""
1414
Make sure earth relief fails for invalid resolutions.
@@ -21,12 +21,14 @@ def test_earth_relief_fails(data_source):
2121

2222

2323
# Only test 01d and 30m to avoid downloading large datasets in CI
24-
def test_earth_relief_01d_igpp():
24+
@pytest.mark.parametrize("data_source", ["igpp", "synbath"])
25+
def test_earth_relief_01d_igpp_synbath(data_source):
2526
"""
26-
Test some properties of the earth relief 01d data with IGPP data.
27+
Test some properties of the earth relief 01d data with IGPP and SYNBATH
28+
data.
2729
"""
2830
data = load_earth_relief(
29-
resolution="01d", registration="gridline", data_source="igpp"
31+
resolution="01d", registration="gridline", data_source=data_source
3032
)
3133
assert data.shape == (181, 361)
3234
npt.assert_allclose(data.lat, np.arange(-90, 91, 1))
@@ -112,6 +114,21 @@ def test_earth_relief_05m_with_region():
112114
assert data.sizes["lon"] == 481
113115

114116

117+
def test_earth_relief_30s_synbath():
118+
"""
119+
Test some properties of the earth relief 30s data with SYNBATH data.
120+
"""
121+
data = load_earth_relief(
122+
region=[-95, -94, -1.5, -1],
123+
resolution="30s",
124+
registration="pixel",
125+
data_source="synbath",
126+
)
127+
assert data.shape == (60, 120)
128+
npt.assert_allclose(data.min(), -3552.5)
129+
npt.assert_allclose(data.max(), -2154)
130+
131+
115132
def test_earth_relief_05m_without_region():
116133
"""
117134
Test loading high-resolution earth relief without passing 'region'.

0 commit comments

Comments
 (0)