Skip to content
Merged
1 change: 0 additions & 1 deletion doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ Use :func:`pygmt.datasets.load_sample_data` instead.
datasets.load_mars_shape
datasets.load_ocean_ridge_points
datasets.load_sample_bathymetry
datasets.load_usgs_quakes

.. automodule:: pygmt.exceptions

Expand Down
1 change: 0 additions & 1 deletion pygmt/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@
load_ocean_ridge_points,
load_sample_bathymetry,
load_sample_data,
load_usgs_quakes,
)
24 changes: 3 additions & 21 deletions pygmt/datasets/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def load_sample_data(name):
"japan_quakes": load_japan_quakes,
"mars_shape": load_mars_shape,
"ocean_ridge_points": load_ocean_ridge_points,
Comment thread
willschlitzer marked this conversation as resolved.
Outdated
"usgs_quakes": load_usgs_quakes,
}

# Dictionary of private load functions
Expand All @@ -85,6 +84,7 @@ def load_sample_data(name):
"earth_relief_holes": _load_earth_relief_holes,
"maunaloa_co2": _load_maunaloa_co2,
"notre_dame_topography": _load_notre_dame_topography,
"usgs_quakes": _load_usgs_quakes,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove "usgs_quakes": load_usgs_quakes at line 75.

}

if name in load_func_old:
Expand Down Expand Up @@ -215,36 +215,18 @@ def load_sample_bathymetry(**kwargs):
return data


def load_usgs_quakes(**kwargs):
def _load_usgs_quakes():
"""
(Deprecated) Load a table of global earthquakes from the USGS as a
pandas.DataFrame.

.. warning:: Deprecated since v0.6.0. This function has been replaced with
``load_sample_data(name="usgs_quakes")`` and will be removed in
v0.9.0.
Load a table of global earthquakes from the USGS as a pandas.DataFrame.

This is the ``@usgs_quakes_22.txt`` dataset used in the GMT tutorials.
Comment thread
willschlitzer marked this conversation as resolved.
Outdated

The data are downloaded to a cache directory (usually ``~/.gmt/cache``) the
first time you invoke this function. Afterwards, it will load the data from
the cache. So you'll need an internet connection the first time around.

Returns
-------
data : pandas.DataFrame
The data table. Use ``print(data.describe())`` to see the available
columns.
"""

if "suppress_warning" not in kwargs:
warnings.warn(
"This function has been deprecated since v0.6.0 and will be "
"removed in v0.9.0. Please use "
"load_sample_data(name='usgs_quakes') instead.",
category=FutureWarning,
stacklevel=2,
)
fname = which("@usgs_quakes_22.txt", download="c")
data = pd.read_csv(fname)
return data
Comment thread
willschlitzer marked this conversation as resolved.
Outdated
Expand Down
53 changes: 49 additions & 4 deletions pygmt/tests/test_datasets_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
load_ocean_ridge_points,
load_sample_bathymetry,
load_sample_data,
load_usgs_quakes,
)
from pygmt.exceptions import GMTInvalidInput

Expand Down Expand Up @@ -89,10 +88,56 @@ def test_usgs_quakes():
"""
Check that the dataset loads without errors.
Comment thread
willschlitzer marked this conversation as resolved.
Outdated
"""
with pytest.warns(expected_warning=FutureWarning) as record:
data = load_usgs_quakes()
assert len(record) == 1
data = load_sample_data(name="usgs_quakes")
assert data.shape == (1197, 22)
assert list(data.columns) == [
"time",
"latitude",
"longitude",
"depth",
"mag",
"magType",
"nst",
"gap",
"dmin",
"rms",
"net",
"id",
"updated",
"place",
"type",
"horizontalError",
"depthError",
"magError",
"magNst",
"status",
"locationSource",
"magSource",
]
npt.assert_allclose(data["latitude"].min(), -60.6819)
npt.assert_allclose(data["latitude"].max(), 72.6309)
npt.assert_allclose(data["longitude"].min(), -179.9953)
npt.assert_allclose(data["longitude"].max(), 179.9129)
npt.assert_allclose(data["depth"].min(), -0.21)
npt.assert_allclose(data["depth"].max(), 640.49)
npt.assert_allclose(data["mag"].min(), 3)
npt.assert_allclose(data["mag"].max(), 8.1)
npt.assert_allclose(data["nst"].min(), 3)
npt.assert_allclose(data["nst"].max(), 167)
npt.assert_allclose(data["gap"].min(), 10.0)
npt.assert_allclose(data["gap"].max(), 353.0)
npt.assert_allclose(data["dmin"].min(), 0.006421)
npt.assert_allclose(data["dmin"].max(), 39.455)
npt.assert_allclose(data["rms"].min(), 0.02)
npt.assert_allclose(data["rms"].max(), 1.76)
npt.assert_allclose(data["horizontalError"].min(), 0.09)
npt.assert_allclose(data["horizontalError"].max(), 36.8)
npt.assert_allclose(data["depthError"].min(), 0)
npt.assert_allclose(data["depthError"].max(), 65.06)
npt.assert_allclose(data["magError"].min(), 0.02)
npt.assert_allclose(data["magError"].max(), 0.524)
npt.assert_allclose(data["magNst"].min(), 1)
npt.assert_allclose(data["magNst"].max(), 944)


def test_fractures_compilation():
Expand Down