Skip to content

Commit

Permalink
load_earth_relief: Add the support of data source 'GEBCOSI' (GenericM…
Browse files Browse the repository at this point in the history
…appingTools#2192)

Co-authored-by: Dongdong Tian <[email protected]>
  • Loading branch information
2 people authored and Josh Sixsmith committed Dec 21, 2022
1 parent e630810 commit 14caffd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
10 changes: 9 additions & 1 deletion pygmt/datasets/earth_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,17 @@ def load_earth_relief(
- **igpp** : IGPP Global Earth Relief [Default option]. See
:gmt-datasets:`earth-relief.html`.
- **synbath** : IGPP Global Earth Relief dataset that uses
stastical properties of young seafloor to provide more realistic
relief of young areas with small seamounts.
- **gebco** : GEBCO Global Earth Relief with only observed relief and
inferred relief via altimetric gravity. See
:gmt-datasets:`earth-gebco.html`.
- **gebcosi** : GEBCO Global Earth Relief that gives sub-ice (si)
elevations.
Returns
-------
grid : :class:`xarray.DataArray`
Expand Down Expand Up @@ -144,12 +151,13 @@ def load_earth_relief(
earth_relief_sources = {
"igpp": "earth_relief_",
"gebco": "earth_gebco_",
"gebcosi": "earth_gebcosi_",
"synbath": "earth_synbath_",
}
if data_source not in earth_relief_sources:
raise GMTInvalidInput(
f"Invalid earth relief 'data_source' {data_source}, "
"valid values are 'igpp', 'gebco', and 'synbath'."
"valid values are 'igpp', 'gebco', 'gebcosi' and 'synbath'."
)
if data_source != "igpp":
with Session() as lib:
Expand Down
2 changes: 2 additions & 0 deletions pygmt/helpers/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def download_test_data():
datasets = [
# Earth relief grids
"@earth_gebco_01d_g",
"@earth_gebcosi_01d_g",
"@earth_gebcosi_15m_p",
"@earth_relief_01d_p",
"@earth_relief_01d_g",
"@earth_relief_30m_p",
Expand Down
27 changes: 23 additions & 4 deletions pygmt/tests/test_datasets_earth_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pygmt.exceptions import GMTInvalidInput


@pytest.mark.parametrize("data_source", ["igpp", "gebco", "synbath"])
@pytest.mark.parametrize("data_source", ["igpp", "gebco", "gebcosi", "synbath"])
def test_earth_relief_fails(data_source):
"""
Make sure earth relief fails for invalid resolutions.
Expand Down Expand Up @@ -37,12 +37,14 @@ def test_earth_relief_01d_igpp_synbath(data_source):
npt.assert_allclose(data.max(), 5559.0)


def test_earth_relief_01d_gebco():
@pytest.mark.parametrize("data_source", ["gebco", "gebcosi"])
def test_earth_relief_01d_gebco(data_source):
"""
Test some properties of the earth relief 01d data with GEBCO data.
Test some properties of the earth relief 01d data with GEBCO and GEBOCSI
data.
"""
data = load_earth_relief(
resolution="01d", registration="gridline", data_source="gebco"
resolution="01d", registration="gridline", data_source=data_source
)
assert data.shape == (181, 361)
npt.assert_allclose(data.lat, np.arange(-90, 91, 1))
Expand Down Expand Up @@ -114,6 +116,23 @@ def test_earth_relief_05m_with_region():
assert data.sizes["lon"] == 481


def test_earth_gebcosi_15m_with_region():
"""
Test loading a subregion of 15 arc-minute resolution earth_gebcosi grid.
"""
data = load_earth_relief(
resolution="15m",
region=[85, 87, -88, -84],
registration="pixel",
data_source="gebcosi",
)
assert data.shape == (16, 8)
npt.assert_allclose(data.lat, np.arange(-87.875, -84, 0.25))
npt.assert_allclose(data.lon, np.arange(85.125, 87, 0.25))
npt.assert_allclose(data.min(), -531)
npt.assert_allclose(data.max(), 474)


def test_earth_relief_30s_synbath():
"""
Test some properties of the earth relief 30s data with SYNBATH data.
Expand Down

0 comments on commit 14caffd

Please sign in to comment.