File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
2
Load sample data included with GMT (downloaded from the GMT cache server).
3
3
"""
4
- from .tutorial import load_japan_quakes
4
+ from .tutorial import load_japan_quakes , load_usgs_quakes
5
5
from .earth_relief import load_earth_relief
Original file line number Diff line number Diff line change @@ -36,3 +36,24 @@ def load_japan_quakes():
36
36
"magnitude" ,
37
37
]
38
38
return data
39
+
40
+
41
+ def load_usgs_quakes ():
42
+ """
43
+ Load a table of global earthquakes form the USGS as a pandas.Dataframe.
44
+
45
+ This is the ``@usgs_quakes_22.txt`` dataset used in the GMT tutorials.
46
+
47
+ The data are downloaded to a cache directory (usually ``~/.gmt/cache``) the
48
+ first time you invoke this function. Afterwards, it will load the data from
49
+ the cache. So you'll need an internet connection the first time around.
50
+
51
+ Returns
52
+ -------
53
+ data : pandas.Dataframe
54
+ The data table. Use ``print(data.describe())`` to see the available columns.
55
+
56
+ """
57
+ fname = which ("@usgs_quakes_22.txt" , download = "c" )
58
+ data = pd .read_csv (fname )
59
+ return data
Original file line number Diff line number Diff line change 5
5
import numpy as np
6
6
import numpy .testing as npt
7
7
8
- from ..datasets import load_japan_quakes , load_earth_relief
8
+ from ..datasets import load_japan_quakes , load_earth_relief , load_usgs_quakes
9
9
from ..exceptions import GMTInvalidInput
10
10
11
11
@@ -22,6 +22,12 @@ def test_japan_quakes():
22
22
assert summary .loc ["max" , "day" ] == 31
23
23
24
24
25
+ def test_usgs_quakes ():
26
+ "Check that the dataset loads without errors"
27
+ data = load_usgs_quakes ()
28
+ assert data .shape == (1197 , 22 )
29
+
30
+
25
31
def test_earth_relief_fails ():
26
32
"Make sure earth relief fails for invalid resolutions"
27
33
resolutions = "1m 1d bla 60d 01s 03s 001m 03" .split ()
You can’t perform that action at this time.
0 commit comments