Skip to content

Commit f17ddb3

Browse files
willschlitzerMeghan Jones
and
Meghan Jones
authored
Add load_static_earth_relief function for internal testing (#1727)
Co-authored-by: Meghan Jones <[email protected]>
1 parent ca15b80 commit f17ddb3

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

pygmt/helpers/testing.py

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from matplotlib.testing.compare import compare_images
99
from pygmt.exceptions import GMTImageComparisonFailure
10+
from pygmt.io import load_dataarray
1011
from pygmt.src import which
1112

1213

@@ -178,10 +179,24 @@ def download_test_data():
178179
"@ridge.txt",
179180
"@mars370d.txt",
180181
"@srtm_tiles.nc", # needed for 03s and 01s relief data
182+
"@static_earth_relief.nc",
181183
"@test.dat.nc",
182184
"@tut_bathy.nc",
183185
"@tut_quakes.ngdc",
184186
"@tut_ship.xyz",
185187
"@usgs_quakes_22.txt",
186188
]
187189
which(fname=datasets, download="a")
190+
191+
192+
def load_static_earth_relief():
193+
"""
194+
Load the static_earth_relief file for internal testing.
195+
196+
Returns
197+
-------
198+
data : xarray.DataArray
199+
A grid of Earth relief for internal tests.
200+
"""
201+
fname = which("@static_earth_relief.nc", download="c")
202+
return load_dataarray(fname)

pygmt/tests/test_helpers.py

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import numpy as np
77
import pytest
8+
import xarray as xr
89
from pygmt.exceptions import GMTInvalidInput
910
from pygmt.helpers import (
1011
GMTTempFile,
@@ -13,6 +14,20 @@
1314
kwargs_to_strings,
1415
unique_name,
1516
)
17+
from pygmt.helpers.testing import load_static_earth_relief
18+
19+
20+
def test_load_static_earth_relief():
21+
"""
22+
Check that @static_earth_relief.nc loads without errors.
23+
"""
24+
data = load_static_earth_relief()
25+
assert data.dims == ("lat", "lon")
26+
assert data.shape == (14, 8)
27+
assert data.min() == 190
28+
assert data.max() == 981
29+
assert data.median() == 467
30+
assert isinstance(data, xr.DataArray)
1631

1732

1833
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)