Skip to content

Commit

Permalink
Add Mars dataset (GenericMappingTools#1420)
Browse files Browse the repository at this point in the history
Sample data table for the shape of Mars. This is the
`@mars370d.txt` dataset used in GMT examples, with data
and information from Smith, D. E., and M. T. Zuber (1996).
The shape of Mars and the topographic signature of the
hemispheric dichotomy. Data columns are "longitude",
"latitude", and "radius (meters)."

Co-authored-by: Wei Ji <[email protected]>
  • Loading branch information
2 people authored and Josh Sixsmith committed Dec 21, 2022
1 parent 9eb7205 commit f164fb3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ and store them in the GMT cache folder.
:toctree: generated

datasets.load_earth_relief
datasets.load_fractures_compilation
datasets.load_hotspots
datasets.load_japan_quakes
datasets.load_mars_shape
datasets.load_ocean_ridge_points
datasets.load_sample_bathymetry
datasets.load_usgs_quakes
datasets.load_fractures_compilation
datasets.load_hotspots

.. automodule:: pygmt.exceptions

Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
load_fractures_compilation,
load_hotspots,
load_japan_quakes,
load_mars_shape,
load_ocean_ridge_points,
load_sample_bathymetry,
load_usgs_quakes,
Expand Down
25 changes: 25 additions & 0 deletions pygmt/datasets/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,28 @@ def load_hotspots():
columns = ["longitude", "latitude", "symbol_size", "place_name"]
data = pd.read_table(filepath_or_buffer=fname, sep="\t", skiprows=3, names=columns)
return data


def load_mars_shape():
"""
Load a table of data for the shape of Mars.
This is the ``@mars370d.txt`` dataset used in GMT examples, with data and
information from Smith, D. E., and M. T. Zuber (1996), The shape of Mars
and the topographic signature of the hemispheric dichotomy. Data columns
are "longitude," "latitude", and "radius (meters)."
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 with columns "longitude", "latitude", and "radius(m)".
"""
fname = which("@mars370d.txt", download="c")
data = pd.read_csv(
fname, sep="\t", header=None, names=["longitude", "latitude", "radius(m)"]
)
return data
16 changes: 16 additions & 0 deletions pygmt/tests/test_datasets_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
load_fractures_compilation,
load_hotspots,
load_japan_quakes,
load_mars_shape,
load_ocean_ridge_points,
load_sample_bathymetry,
load_usgs_quakes,
Expand Down Expand Up @@ -76,6 +77,21 @@ def test_fractures_compilation():
assert summary.loc["max", "azimuth"] == 360.0


def test_mars_shape():
"""
Check that the @mars370d.txt dataset loads without errors.
"""
data = load_mars_shape()
assert data.shape == (370, 3)
summary = data.describe()
assert summary.loc["min", "longitude"] == 0.008
assert summary.loc["max", "longitude"] == 359.983
assert summary.loc["min", "latitude"] == -79.715
assert summary.loc["max", "latitude"] == 85.887
assert summary.loc["min", "radius(m)"] == -6930
assert summary.loc["max", "radius(m)"] == 15001


def test_hotspots():
"""
Check that the @hotspots.txt dataset loads without errors.
Expand Down

0 comments on commit f164fb3

Please sign in to comment.