diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index aceb3c2b92e..41560a4baca 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -7,6 +7,7 @@ from matplotlib.testing.compare import compare_images from pygmt.exceptions import GMTImageComparisonFailure +from pygmt.io import load_dataarray from pygmt.src import which @@ -178,6 +179,7 @@ def download_test_data(): "@ridge.txt", "@mars370d.txt", "@srtm_tiles.nc", # needed for 03s and 01s relief data + "@static_earth_relief.nc", "@test.dat.nc", "@tut_bathy.nc", "@tut_quakes.ngdc", @@ -185,3 +187,16 @@ def download_test_data(): "@usgs_quakes_22.txt", ] which(fname=datasets, download="a") + + +def load_static_earth_relief(): + """ + Load the static_earth_relief file for internal testing. + + Returns + ------- + data : xarray.DataArray + A grid of Earth relief for internal tests. + """ + fname = which("@static_earth_relief.nc", download="c") + return load_dataarray(fname) diff --git a/pygmt/tests/test_helpers.py b/pygmt/tests/test_helpers.py index 014f020c135..29bfa1f5750 100644 --- a/pygmt/tests/test_helpers.py +++ b/pygmt/tests/test_helpers.py @@ -5,6 +5,7 @@ import numpy as np import pytest +import xarray as xr from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import ( GMTTempFile, @@ -13,6 +14,20 @@ kwargs_to_strings, unique_name, ) +from pygmt.helpers.testing import load_static_earth_relief + + +def test_load_static_earth_relief(): + """ + Check that @static_earth_relief.nc loads without errors. + """ + data = load_static_earth_relief() + assert data.dims == ("lat", "lon") + assert data.shape == (14, 8) + assert data.min() == 190 + assert data.max() == 981 + assert data.median() == 467 + assert isinstance(data, xr.DataArray) @pytest.mark.parametrize(