Skip to content

Commit 8414b7e

Browse files
Add Mars dataset (#1420)
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]>
1 parent 5fc9680 commit 8414b7e

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

doc/api/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@ and store them in the GMT cache folder.
167167
:toctree: generated
168168

169169
datasets.load_earth_relief
170+
datasets.load_fractures_compilation
171+
datasets.load_hotspots
170172
datasets.load_japan_quakes
173+
datasets.load_mars_shape
171174
datasets.load_ocean_ridge_points
172175
datasets.load_sample_bathymetry
173176
datasets.load_usgs_quakes
174-
datasets.load_fractures_compilation
175-
datasets.load_hotspots
176177

177178
.. automodule:: pygmt.exceptions
178179

pygmt/datasets/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
load_fractures_compilation,
88
load_hotspots,
99
load_japan_quakes,
10+
load_mars_shape,
1011
load_ocean_ridge_points,
1112
load_sample_bathymetry,
1213
load_usgs_quakes,

pygmt/datasets/samples.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,28 @@ def load_hotspots():
149149
columns = ["longitude", "latitude", "symbol_size", "place_name"]
150150
data = pd.read_table(filepath_or_buffer=fname, sep="\t", skiprows=3, names=columns)
151151
return data
152+
153+
154+
def load_mars_shape():
155+
"""
156+
Load a table of data for the shape of Mars.
157+
158+
This is the ``@mars370d.txt`` dataset used in GMT examples, with data and
159+
information from Smith, D. E., and M. T. Zuber (1996), The shape of Mars
160+
and the topographic signature of the hemispheric dichotomy. Data columns
161+
are "longitude," "latitude", and "radius (meters)."
162+
163+
The data are downloaded to a cache directory (usually ``~/.gmt/cache``) the
164+
first time you invoke this function. Afterwards, it will load the data from
165+
the cache. So you'll need an internet connection the first time around.
166+
167+
Returns
168+
-------
169+
data : pandas.DataFrame
170+
The data table with columns "longitude", "latitude", and "radius(m)".
171+
"""
172+
fname = which("@mars370d.txt", download="c")
173+
data = pd.read_csv(
174+
fname, sep="\t", header=None, names=["longitude", "latitude", "radius(m)"]
175+
)
176+
return data

pygmt/tests/test_datasets_samples.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
load_fractures_compilation,
77
load_hotspots,
88
load_japan_quakes,
9+
load_mars_shape,
910
load_ocean_ridge_points,
1011
load_sample_bathymetry,
1112
load_usgs_quakes,
@@ -76,6 +77,21 @@ def test_fractures_compilation():
7677
assert summary.loc["max", "azimuth"] == 360.0
7778

7879

80+
def test_mars_shape():
81+
"""
82+
Check that the @mars370d.txt dataset loads without errors.
83+
"""
84+
data = load_mars_shape()
85+
assert data.shape == (370, 3)
86+
summary = data.describe()
87+
assert summary.loc["min", "longitude"] == 0.008
88+
assert summary.loc["max", "longitude"] == 359.983
89+
assert summary.loc["min", "latitude"] == -79.715
90+
assert summary.loc["max", "latitude"] == 85.887
91+
assert summary.loc["min", "radius(m)"] == -6930
92+
assert summary.loc["max", "radius(m)"] == 15001
93+
94+
7995
def test_hotspots():
8096
"""
8197
Check that the @hotspots.txt dataset loads without errors.

0 commit comments

Comments
 (0)