Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_earth_relief: Add the support of data source 'GEBCOSI' #2192

Merged
merged 9 commits into from
Nov 25, 2022
3 changes: 2 additions & 1 deletion pygmt/datasets/earth_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ def load_earth_relief(
earth_relief_sources = {
"igpp": "earth_relief_",
"gebco": "earth_gebco_",
"gebcosi": "earth_gebcosi_",
"synbath": "earth_synbath_",
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
}
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",
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
"@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