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 'synbath' #2162

Merged
merged 15 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pygmt/datasets/earth_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ def load_earth_relief(
f"{registration}-registered Earth relief data for "
f"resolution '{resolution}' is not supported."
)
earth_relief_sources = {"igpp": "earth_relief_", "gebco": "earth_gebco_"}
earth_relief_sources = {
"igpp": "earth_relief_",
"gebco": "earth_gebco_",
"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' and 'gebco'."
"valid values are 'igpp', 'gebco', and 'synbath'."
)
if data_source != "igpp":
with Session() as lib:
Expand Down
3 changes: 3 additions & 0 deletions pygmt/helpers/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def download_test_data():
"@earth_relief_10m_g",
"@earth_relief_05m_p",
"@earth_relief_05m_g",
"@earth_synbath_01d_g",
# List of tiles of 03s srtm data.
# Names like @N35E135.earth_relief_03s_g.nc is for internal use only.
# The naming scheme may change. DO NOT USE IT IN YOUR SCRIPTS.
Expand All @@ -172,6 +173,8 @@ def download_test_data():
"@N37W120.earth_relief_03s_g.nc",
"@N00W090.earth_relief_03m_p.nc",
"@N00E135.earth_relief_30s_g.nc",
# Earth synbath relief grids
"@S15W105.earth_synbath_30s_p.nc",
# Earth seafloor age grids
"@earth_age_01d_g",
"@S90W180.earth_age_05m_g.nc", # Specific grid for 05m test
Expand Down
25 changes: 21 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"])
@pytest.mark.parametrize("data_source", ["igpp", "gebco", "synbath"])
def test_earth_relief_fails(data_source):
"""
Make sure earth relief fails for invalid resolutions.
Expand All @@ -21,12 +21,14 @@ def test_earth_relief_fails(data_source):


# Only test 01d and 30m to avoid downloading large datasets in CI
def test_earth_relief_01d_igpp():
@pytest.mark.parametrize("data_source", ["igpp", "synbath"])
def test_earth_relief_01d_igpp_synbath(data_source):
"""
Test some properties of the earth relief 01d data with IGPP data.
Test some properties of the earth relief 01d data with IGPP and SYNBATH
data.
"""
data = load_earth_relief(
resolution="01d", registration="gridline", data_source="igpp"
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 @@ -112,6 +114,21 @@ def test_earth_relief_05m_with_region():
assert data.sizes["lon"] == 481


def test_earth_relief_30s_synbath():
"""
Test some properties of the earth relief 30s data with SYNBATH data.
"""
data = load_earth_relief(
region=[-95, -94, -1.5, -1],
resolution="30s",
registration="pixel",
data_source="synbath",
)
assert data.shape == (60, 120)
npt.assert_allclose(data.min(), -3552.5)
npt.assert_allclose(data.max(), -2154)


def test_earth_relief_05m_without_region():
"""
Test loading high-resolution earth relief without passing 'region'.
Expand Down