Skip to content

Commit

Permalink
Add a sample dataset notre_dame_topography (#1920)
Browse files Browse the repository at this point in the history
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
  • Loading branch information
willschlitzer and seisman committed May 30, 2022
1 parent 427fbdc commit 32ca712
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pygmt/datasets/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def list_sample_data():
"mars_shape": "Table of topographic signature of the hemispheric dichotomy of "
" Mars from Smith and Zuber (1996)",
"ocean_ridge_points": "Table of ocean ridge points for the entire world",
"notre_dame_topography": "Table 5.11 in Davis: Statistics and Data Analysis in Geology",
"usgs_quakes": "Table of global earthquakes from the USGS",
}
return names
Expand Down Expand Up @@ -73,6 +74,7 @@ def load_sample_data(name):
"japan_quakes": load_japan_quakes,
"mars_shape": load_mars_shape,
"ocean_ridge_points": load_ocean_ridge_points,
"notre_dame_topography": _load_notre_dame_topography,
"usgs_quakes": load_usgs_quakes,
}

Expand Down Expand Up @@ -348,6 +350,19 @@ def load_mars_shape(**kwargs):
return data


def _load_notre_dame_topography(**kwargs): # pylint: disable=unused-argument
"""
Load Table 5.11 in Davis: Statistics and Data Analysis in Geology.
Returns
-------
data : pandas.DataFrame
The data table with columns "x", "y", and "z".
"""
fname = which("@Table_5_11.txt", download="c")
return pd.read_csv(fname, sep=r"\s+", header=None, names=["x", "y", "z"])


def _load_earth_relief_holes(**kwargs): # pylint: disable=unused-argument
"""
Loads the remote file @earth_relief_20m_holes.grd.
Expand Down
15 changes: 15 additions & 0 deletions pygmt/tests/test_datasets_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ def test_hotspots():
assert isinstance(data, pd.DataFrame)


def test_load_notre_dame_topography():
"""
Check that the @Table_5_11.txt dataset loads without errors.
"""
data = load_sample_data(name="notre_dame_topography")
assert data.shape == (52, 3)
summary = data.describe()
assert summary.loc["min", "x"] == 0.2
assert summary.loc["max", "x"] == 6.3
assert summary.loc["min", "y"] == 0
assert summary.loc["max", "y"] == 6.2
assert summary.loc["min", "z"] == 690
assert summary.loc["max", "z"] == 960


def test_earth_relief_holes():
"""
Check that the @earth_relief_20m_holes.grd dataset loads without errors.
Expand Down

0 comments on commit 32ca712

Please sign in to comment.