Skip to content

Commit 592018a

Browse files
committed
Change load_earth_relief()'s default resolution to 01d
In GMT 6.0.0, both `01d` and `60m` are valid resolutions of earth relief data. It was called `60m` at the beginning, and was changed to `01d` when GMT 6.0.0 was officially released. `60m` is still valid for backward compatibility. Run the following commands, and you will have the two data in the current directory. ``` gmt which @earth_relief_60m -Gl gmt which @earth_relief_01d -Gl ``` These two files have different file names but are identical: ``` $ md5sum earth_relief_01d.grd earth_relief_60m.grd 74a884c902015dda516d17605f317efe earth_relief_01d.grd 74a884c902015dda516d17605f317efe earth_relief_60m.grd ``` In the upcoming GMT 6.1.0, the resolution `60m` will be deprecated. That's why we have many ~25 errors when testing PyGMT with the GMT master branch, simply because GMT 6.1.0 can't download the `@earth_relief_60m`. To make the transition to GMT 6.1.0 easier, here I change the default earth relief resolution of `load_earth_relief()` function from `60m` to `01d`. As the two grids are identical, the change in this PR won't break anything. Note that, currently there are ~43 failures due to the recent updates of the GMT data server (#451), and we can't fix these failures easily due to the grid registration issue (#476). Thus, I don't try to fix any failures in this PR. The test log files of the master branch and this branch are the same. Tests that fail in the master brach still fail in the same way in this branch.
1 parent 86c46f0 commit 592018a

10 files changed

+27
-22
lines changed

.azure-pipelines.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
- bash: |
129129
set -x -e
130130
source activate testing
131-
gmt which -Gu @earth_relief_10m @earth_relief_60m @ridge.txt @Table_5_11.txt @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz
131+
gmt which -Gu @earth_relief_10m @earth_relief_01d @ridge.txt @Table_5_11.txt @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz
132132
displayName: Download remote data
133133
condition: ne(variables['CACHE_CACHEDATA_RESTORED'], true)
134134
@@ -224,7 +224,7 @@ jobs:
224224
- bash: |
225225
set -x -e
226226
source activate testing
227-
gmt which -Gu @earth_relief_10m @earth_relief_60m @ridge.txt @Table_5_11.txt @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz
227+
gmt which -Gu @earth_relief_10m @earth_relief_01d @ridge.txt @Table_5_11.txt @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz
228228
displayName: Download remote data
229229
condition: ne(variables['CACHE_CACHEDATA_RESTORED'], true)
230230

pygmt/clib/conversion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def dataarray_to_matrix(grid):
4646
--------
4747
4848
>>> from pygmt.datasets import load_earth_relief
49-
>>> # Use the global Earth relief grid with 1 degree spacing (60')
50-
>>> grid = load_earth_relief(resolution='60m')
49+
>>> # Use the global Earth relief grid with 1 degree spacing
50+
>>> grid = load_earth_relief(resolution='01d')
5151
>>> matrix, region, inc = dataarray_to_matrix(grid)
5252
>>> print(region)
5353
[-180.0, 180.0, -90.0, 90.0]

pygmt/clib/session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ def virtualfile_from_grid(self, grid):
12101210
12111211
>>> from pygmt.datasets import load_earth_relief
12121212
>>> from pygmt.helpers import GMTTempFile
1213-
>>> data = load_earth_relief(resolution='60m')
1213+
>>> data = load_earth_relief(resolution='01d')
12141214
>>> print(data.shape)
12151215
(181, 361)
12161216
>>> print(data.lon.values.min(), data.lon.values.max())

pygmt/datasets/earth_relief.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ..exceptions import GMTInvalidInput
99

1010

11-
def load_earth_relief(resolution="60m"):
11+
def load_earth_relief(resolution="01d"):
1212
"""
1313
Load Earth relief grids (topography and bathymetry) in various resolutions.
1414
@@ -23,9 +23,10 @@ def load_earth_relief(resolution="60m"):
2323
Parameters
2424
----------
2525
resolution : str
26-
The grid resolution. The suffix ``m`` and ``s`` stand for arc-minute
27-
and arc-second. It can be ``'60m'``, ``'30m'``, ``'10m'``, ``'05m'``,
28-
``'02m'``, ``'01m'``, ``'30s'`` or ``'15s'``.
26+
The grid resolution. The suffix ``d``, ``m`` and ``s`` stand for
27+
arc-degree, arc-minute and arc-second. It can be ``'01d'``, ``'60m'``,
28+
``'30m'``, ``'10m'``, ``'05m'``, ``'02m'``, ``'01m'``, ``'30s'``
29+
or ``'15s'``.
2930
3031
Returns
3132
-------
@@ -69,6 +70,7 @@ def _is_valid_resolution(resolution):
6970
Examples
7071
--------
7172
73+
>>> _is_valid_resolution("01d")
7274
>>> _is_valid_resolution("60m")
7375
>>> _is_valid_resolution("5m")
7476
Traceback (most recent call last):
@@ -81,7 +83,8 @@ def _is_valid_resolution(resolution):
8183
pygmt.exceptions.GMTInvalidInput: Invalid Earth relief resolution '01s'.
8284
8385
"""
84-
valid_resolutions = ["{:02d}m".format(res) for res in [60, 30, 10, 5, 2, 1]]
86+
valid_resolutions = ["01d"]
87+
valid_resolutions.extend(["{:02d}m".format(res) for res in [60, 30, 20, 15, 10, 6, 5, 4, 3, 2, 1]])
8588
valid_resolutions.extend(["{:02d}s".format(res) for res in [30, 15]])
8689
if resolution not in valid_resolutions:
8790
raise GMTInvalidInput(
@@ -120,7 +123,9 @@ def _shape_from_resolution(resolution):
120123
"""
121124
_is_valid_resolution(resolution)
122125
unit = resolution[2]
123-
if unit == "m":
126+
if unit == "d":
127+
seconds = int(resolution[:2]) * 60 * 60
128+
elif unit == "m":
124129
seconds = int(resolution[:2]) * 60
125130
elif unit == "s":
126131
seconds = int(resolution[:2])

pygmt/tests/test_datasets.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ def test_earth_relief_fails():
6767
load_earth_relief(resolution=resolution)
6868

6969

70-
# Only test 60m and 30m to avoid downloading large datasets in CI
71-
def test_earth_relief_60():
72-
"Test some properties of the earth relief 60m data"
73-
data = load_earth_relief(resolution="60m")
70+
# Only test 01d and 30m to avoid downloading large datasets in CI
71+
def test_earth_relief_01d():
72+
"Test some properties of the earth relief 01d data"
73+
data = load_earth_relief(resolution="01d")
7474
assert data.shape == (181, 361)
7575
npt.assert_allclose(data.lat, np.arange(-90, 91, 1))
7676
npt.assert_allclose(data.lon, np.arange(-180, 181, 1))
7777
npt.assert_allclose(data.min(), -8592.144531)
7878
npt.assert_allclose(data.max(), 5558.79248)
7979

8080

81-
def test_earth_relief_30():
81+
def test_earth_relief_30m():
8282
"Test some properties of the earth relief 30m data"
8383
data = load_earth_relief(resolution="30m")
8484
assert data.shape == (361, 721)

pygmt/tests/test_grdcontour.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_grdcontour_file():
5858
"Plot a contour image using grid file input"
5959
fig = Figure()
6060
fig.grdcontour(
61-
"@earth_relief_60m",
61+
"@earth_relief_01d",
6262
interval="1000",
6363
limit="0",
6464
pen="0.5p,black",

pygmt/tests/test_grdimage.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_grdimage_file():
3232
"Plot an image using file input"
3333
fig = Figure()
3434
fig.grdimage(
35-
"@earth_relief_60m",
35+
"@earth_relief_01d",
3636
cmap="ocean",
3737
region=[-180, 180, -70, 70],
3838
projection="W0/10i",

pygmt/tests/test_grdinfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_grdinfo():
1818

1919
def test_grdinfo_file():
2020
"Test grdinfo with file input"
21-
result = grdinfo("@earth_relief_60m", L=0, C="n")
21+
result = grdinfo("@earth_relief_01d", L=0, C="n")
2222
assert result.strip() == "-180 180 -90 90 -8592.14465255 5558.79248047 1 1 361 181"
2323

2424

pygmt/tests/test_grdtrack.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_grdtrack_input_dataframe_and_ncfile():
5858
Run grdtrack by passing in a pandas.DataFrame and netcdf file as inputs
5959
"""
6060
dataframe = load_ocean_ridge_points()
61-
ncfile = which("@earth_relief_60m", download="c")
61+
ncfile = which("@earth_relief_01d", download="c")
6262

6363
output = grdtrack(points=dataframe, grid=ncfile, newcolname="bathymetry")
6464
assert isinstance(output, pd.DataFrame)
@@ -73,7 +73,7 @@ def test_grdtrack_input_csvfile_and_ncfile():
7373
Run grdtrack by passing in a csvfile and netcdf file as inputs
7474
"""
7575
csvfile = which("@ridge.txt", download="c")
76-
ncfile = which("@earth_relief_60m", download="c")
76+
ncfile = which("@earth_relief_01d", download="c")
7777

7878
try:
7979
output = grdtrack(points=csvfile, grid=ncfile, outfile=TEMP_TRACK)

pygmt/tests/test_grdview.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_grdview_grid_file_with_region_subset():
3131
"""
3232
Run grdview by passing in a grid filename, and cropping it to a region.
3333
"""
34-
gridfile = which("@earth_relief_60m", download="c")
34+
gridfile = which("@earth_relief_01d", download="c")
3535

3636
fig = Figure()
3737
fig.grdview(grid=gridfile, region=[-116, -109, -47, -44])

0 commit comments

Comments
 (0)