Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ Use :func:`pygmt.datasets.load_sample_data` instead.
.. autosummary::
:toctree: generated

datasets.load_hotspots
datasets.load_mars_shape
datasets.load_usgs_quakes

Expand Down
1 change: 0 additions & 1 deletion pygmt/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
)
from pygmt.datasets.samples import (
list_sample_data,
load_hotspots,
load_mars_shape,
load_sample_data,
load_usgs_quakes,
Expand Down
44 changes: 15 additions & 29 deletions pygmt/datasets/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def load_sample_data(name):

# Dictionary of public load functions for backwards compatibility
load_func_old = {
"hotspots": load_hotspots,
"mars_shape": load_mars_shape,
"usgs_quakes": load_usgs_quakes,
}
Expand All @@ -80,6 +79,7 @@ def load_sample_data(name):
"bathymetry": _load_baja_california_bathymetry,
"earth_relief_holes": _load_earth_relief_holes,
"fractures": _load_fractures_compilation,
"hotspots": _load_hotspots,
"japan_quakes": _load_japan_quakes,
"maunaloa_co2": _load_maunaloa_co2,
"notre_dame_topography": _load_notre_dame_topography,
Expand Down Expand Up @@ -217,43 +217,29 @@ def _load_fractures_compilation():
return data[["length", "azimuth"]]


def load_hotspots(**kwargs):
def _load_hotspots():
"""
(Deprecated) Load a table with the locations, names, and suggested symbol
sizes of hotspots.
Load a table with the locations, names, and suggested symbol sizes of
hotspots as a pandas.DataFrame.

.. warning:: Deprecated since v0.6.0. This function has been replaced with
``load_sample_data(name="hotspots")`` and will be removed in
v0.9.0.

This is the ``@hotspots.txt`` dataset used in the GMT tutorials, with data
from Mueller, Royer, and Lawver, 1993, Geology, vol. 21, pp. 275-278. The
main 5 hotspots used by Doubrovine et al. [2012] have symbol sizes twice
the size of all other hotspots.

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.
The data are from Mueller, Royer, and Lawver, 1993, Geology, vol. 21,
pp. 275-278. The main 5 hotspots used by Doubrovine et al. [2012]
have symbol sizes twice the size of all other hotspots.

Returns
-------
data : pandas.DataFrame
The data table with columns "longitude", "latitude", "symbol_size", and
"placename".
The data table. The column names are "longitude", "latitude",
"symbol_size", and "place_name".
"""

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='hotspots') instead.",
category=FutureWarning,
stacklevel=2,
)
fname = which("@hotspots.txt", download="c")
columns = ["longitude", "latitude", "symbol_size", "place_name"]
data = pd.read_table(filepath_or_buffer=fname, sep="\t", skiprows=3, names=columns)
return data
return pd.read_csv(
fname,
sep="\t",
skiprows=3,
names=["longitude", "latitude", "symbol_size", "place_name"],
)


def load_mars_shape(**kwargs):
Expand Down
17 changes: 8 additions & 9 deletions pygmt/tests/test_datasets_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
import numpy.testing as npt
import pandas as pd
import pytest
from pygmt.datasets import (
load_hotspots,
load_mars_shape,
load_sample_data,
load_usgs_quakes,
)
from pygmt.datasets import load_mars_shape, load_sample_data, load_usgs_quakes
from pygmt.exceptions import GMTInvalidInput


Expand Down Expand Up @@ -103,9 +98,7 @@ def test_hotspots():
"""
Check that the @hotspots.txt dataset loads without errors.
"""
with pytest.warns(expected_warning=FutureWarning) as record:
data = load_hotspots()
assert len(record) == 1
data = load_sample_data(name="hotspots")
assert data.shape == (55, 4)
assert list(data.columns) == [
"longitude",
Expand All @@ -114,6 +107,12 @@ def test_hotspots():
"place_name",
]
assert isinstance(data, pd.DataFrame)
assert data["longitude"].min() == -169.6
assert data["longitude"].max() == 167
assert data["latitude"].min() == -78
assert data["latitude"].max() == 64
assert data["symbol_size"].min() == 0.25
assert data["symbol_size"].max() == 0.5


def test_load_notre_dame_topography():
Expand Down