Skip to content

Commit 3e33467

Browse files
load_earth_relief: Add the support of data source 'GEBCOSI' (#2192)
Co-authored-by: Dongdong Tian <[email protected]>
1 parent 178f95a commit 3e33467

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

pygmt/datasets/earth_relief.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,17 @@ def load_earth_relief(
7676
- **igpp** : IGPP Global Earth Relief [Default option]. See
7777
:gmt-datasets:`earth-relief.html`.
7878
79+
- **synbath** : IGPP Global Earth Relief dataset that uses
80+
stastical properties of young seafloor to provide more realistic
81+
relief of young areas with small seamounts.
82+
7983
- **gebco** : GEBCO Global Earth Relief with only observed relief and
8084
inferred relief via altimetric gravity. See
8185
:gmt-datasets:`earth-gebco.html`.
8286
87+
- **gebcosi** : GEBCO Global Earth Relief that gives sub-ice (si)
88+
elevations.
89+
8390
Returns
8491
-------
8592
grid : :class:`xarray.DataArray`
@@ -144,12 +151,13 @@ def load_earth_relief(
144151
earth_relief_sources = {
145152
"igpp": "earth_relief_",
146153
"gebco": "earth_gebco_",
154+
"gebcosi": "earth_gebcosi_",
147155
"synbath": "earth_synbath_",
148156
}
149157
if data_source not in earth_relief_sources:
150158
raise GMTInvalidInput(
151159
f"Invalid earth relief 'data_source' {data_source}, "
152-
"valid values are 'igpp', 'gebco', and 'synbath'."
160+
"valid values are 'igpp', 'gebco', 'gebcosi' and 'synbath'."
153161
)
154162
if data_source != "igpp":
155163
with Session() as lib:

pygmt/helpers/testing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ def download_test_data():
156156
datasets = [
157157
# Earth relief grids
158158
"@earth_gebco_01d_g",
159+
"@earth_gebcosi_01d_g",
160+
"@earth_gebcosi_15m_p",
159161
"@earth_relief_01d_p",
160162
"@earth_relief_01d_g",
161163
"@earth_relief_30m_p",

pygmt/tests/test_datasets_earth_relief.py

Lines changed: 23 additions & 4 deletions
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", "synbath"])
11+
@pytest.mark.parametrize("data_source", ["igpp", "gebco", "gebcosi", "synbath"])
1212
def test_earth_relief_fails(data_source):
1313
"""
1414
Make sure earth relief fails for invalid resolutions.
@@ -37,12 +37,14 @@ def test_earth_relief_01d_igpp_synbath(data_source):
3737
npt.assert_allclose(data.max(), 5559.0)
3838

3939

40-
def test_earth_relief_01d_gebco():
40+
@pytest.mark.parametrize("data_source", ["gebco", "gebcosi"])
41+
def test_earth_relief_01d_gebco(data_source):
4142
"""
42-
Test some properties of the earth relief 01d data with GEBCO data.
43+
Test some properties of the earth relief 01d data with GEBCO and GEBOCSI
44+
data.
4345
"""
4446
data = load_earth_relief(
45-
resolution="01d", registration="gridline", data_source="gebco"
47+
resolution="01d", registration="gridline", data_source=data_source
4648
)
4749
assert data.shape == (181, 361)
4850
npt.assert_allclose(data.lat, np.arange(-90, 91, 1))
@@ -114,6 +116,23 @@ def test_earth_relief_05m_with_region():
114116
assert data.sizes["lon"] == 481
115117

116118

119+
def test_earth_gebcosi_15m_with_region():
120+
"""
121+
Test loading a subregion of 15 arc-minute resolution earth_gebcosi grid.
122+
"""
123+
data = load_earth_relief(
124+
resolution="15m",
125+
region=[85, 87, -88, -84],
126+
registration="pixel",
127+
data_source="gebcosi",
128+
)
129+
assert data.shape == (16, 8)
130+
npt.assert_allclose(data.lat, np.arange(-87.875, -84, 0.25))
131+
npt.assert_allclose(data.lon, np.arange(85.125, 87, 0.25))
132+
npt.assert_allclose(data.min(), -531)
133+
npt.assert_allclose(data.max(), 474)
134+
135+
117136
def test_earth_relief_30s_synbath():
118137
"""
119138
Test some properties of the earth relief 30s data with SYNBATH data.

0 commit comments

Comments
 (0)