Skip to content

Commit

Permalink
Add load_static_earth_relief function for internal testing (GenericMa…
Browse files Browse the repository at this point in the history
…ppingTools#1727)

Co-authored-by: Meghan Jones <[email protected]>
  • Loading branch information
2 people authored and Josh Sixsmith committed Dec 21, 2022
1 parent 155b14e commit 91a1b95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pygmt/helpers/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -178,10 +179,24 @@ 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",
"@tut_ship.xyz",
"@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)
15 changes: 15 additions & 0 deletions pygmt/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import numpy as np
import pytest
import xarray as xr
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import (
GMTTempFile,
Expand All @@ -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(
Expand Down

0 comments on commit 91a1b95

Please sign in to comment.